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

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

本文整理了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

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

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

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

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

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

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

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

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

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

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

  1. public static ImageCV applyCropMask(Mat source, Rectangle b, double alpha) {
  2. Mat srcImg = Objects.requireNonNull(source);
  3. ImageCV dstImg = new ImageCV();
  4. source.copyTo(dstImg);
  5. if(b.getY() > 0) {
  6. Imgproc.rectangle(dstImg, new Point(0.0, 0.0), new Point(dstImg.width(), b.getMinY() ), new Scalar(0), -1);
  7. }
  8. if(b.getX() > 0) {
  9. Imgproc.rectangle(dstImg, new Point(0.0, b.getMinY()), new Point(b.getMinX(), b.getMaxY() ), new Scalar(0), -1);
  10. }
  11. if(b.getX() < dstImg.width()) {
  12. Imgproc.rectangle(dstImg, new Point(b.getMaxX(), b.getMinY()), new Point(dstImg.width(), b.getMaxY() ), new Scalar(0), -1);
  13. }
  14. if(b.getY() < dstImg.height()) {
  15. Imgproc.rectangle(dstImg, new Point(0.0, b.getMaxY()), new Point(dstImg.width(), dstImg.height() ), new Scalar(0), -1);
  16. }
  17. Core.addWeighted(dstImg, alpha, srcImg, 1- alpha, 0.0, dstImg);
  18. return dstImg;
  19. }

相关文章

Core类方法