org.opencv.core.Core.addWeighted()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(309)

本文整理了Java中org.opencv.core.Core.addWeighted()方法的一些代码示例,展示了Core.addWeighted()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Core.addWeighted()方法的具体详情如下:
包路径:org.opencv.core.Core
类名称:Core
方法名:addWeighted

Core.addWeighted介绍

[英]Calculates the weighted sum of two arrays.

The function addWeighted calculates the weighted sum of two arrays as follows:

dst(I)= saturate(src1(I) alpha + src2(I)* beta + gamma)*

where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each channel is processed independently. The function can be replaced with a matrix expression: ``

// C++ code:

dst = src1alpha + src2beta + gamma;

Note: Saturation is not applied when the output array has the depth CV_32S. You may even get result of an incorrect sign in the case of overflow.
[中]计算两个数组的加权和。
函数addWeighted计算两个数组的加权和,如下所示:
dst(I)=饱和(src1(I)α+src2(I)β+γ)
其中I是数组元素的多维索引。对于多通道阵列,每个通道都是独立处理的。该函数可以替换为矩阵表达式:``
//C++代码:
dst=src1
α+src2
β+γ;
注意:当输出数组的深度为CV_32S时,不应用饱和度。在溢出的情况下,您甚至可能会得到错误符号的结果。

代码示例

代码示例来源:origin: nroduit/Weasis

public static ImageCV combineTwoImages(Mat source, Mat imgOverlay, int transparency) {
  Mat srcImg = Objects.requireNonNull(source);
  Mat src2Img = Objects.requireNonNull(imgOverlay);
  ImageCV dstImg = new ImageCV();
  Core.addWeighted(srcImg, 1.0, src2Img, transparency, 0.0, dstImg);
  return dstImg;
}

代码示例来源:origin: nroduit/Weasis

private MediaElement interpolateDosePlanes(int upperBoundaryIndex, int lowerBoundaryIndex, double fractionalDistance) {
  MediaElement dosePlane = null;
  DicomImageElement upperPlane = (DicomImageElement) this.images.get(upperBoundaryIndex);
  DicomImageElement lowerPlane = (DicomImageElement) this.images.get(lowerBoundaryIndex);
  
  // A simple linear interpolation (lerp)
  Mat dosePlaneMat = new Mat();
  addWeighted(lowerPlane.getImage().toMat(), 1.0 - fractionalDistance, upperPlane.getImage().toMat(), fractionalDistance, 0.0, dosePlaneMat);
  //TODO: dosePlaneMat should be an image for new dosePlane MediaElement
  return dosePlane;
}

代码示例来源:origin: hschott/Camdroid

protected void execute() {
  out = this.rgb();
  Imgproc.blur(out, this.mask, new Size(sigma_x, sigma_x));
  Core.addWeighted(out, (double) alpha / 10, this.mask,
      ((double) beta - 10) / 10, 0, out);
}

代码示例来源:origin: us.ihmc/IHMCPerception

Core.addWeighted(thresholdMat, 1.0, mat, 1.0, 0.0, thresholdMat);

代码示例来源:origin: us.ihmc/ihmc-perception

Core.addWeighted(thresholdMat, 1.0, mat, 1.0, 0.0, thresholdMat);

代码示例来源:origin: nroduit/Weasis

public static ImageCV applyCropMask(Mat source, Rectangle b, double alpha) {
  Mat srcImg = Objects.requireNonNull(source);
  ImageCV dstImg = new ImageCV();        
  source.copyTo(dstImg);
  if(b.getY() > 0) {
    Imgproc.rectangle(dstImg, new Point(0.0, 0.0), new Point(dstImg.width(), b.getMinY() ), new Scalar(0), -1);
  }
  if(b.getX() > 0) {
    Imgproc.rectangle(dstImg, new Point(0.0, b.getMinY()), new Point(b.getMinX(), b.getMaxY() ), new Scalar(0), -1);
  }
  if(b.getX() < dstImg.width()) {
    Imgproc.rectangle(dstImg, new Point(b.getMaxX(), b.getMinY()), new Point(dstImg.width(), b.getMaxY() ), new Scalar(0), -1);
  }
  if(b.getY() < dstImg.height()) {
    Imgproc.rectangle(dstImg, new Point(0.0, b.getMaxY()), new Point(dstImg.width(), dstImg.height() ), new Scalar(0), -1);
  }
  Core.addWeighted(dstImg, alpha, srcImg, 1- alpha, 0.0, dstImg);
  return dstImg;
}

相关文章

Core类方法