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

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

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

Core.multiply介绍

[英]Calculates the per-element scaled product of two arrays.

The function multiply calculates the per-element product of two arrays:

dst(I)= saturate(scale * src1(I) * src2(I))

There is also a "MatrixExpressions" -friendly variant of the first function. See "Mat.mul".

For a not-per-element matrix product, see "gemm".

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.
[中]计算两个阵列的每元素比例积。
函数multiply计算两个数组的每元素乘积:
dst(I)=饱和(标度src1(I)src2(I))
还有一个“MatrixExpressions”——第一个函数的友好变体。参见“Mat.mul”。
对于非每元素矩阵乘积,请参见“gemm”。
注意:当输出数组的深度为CV_32S时,不应用饱和度。在溢出的情况下,您甚至可能会得到错误符号的结果。

代码示例

代码示例来源:origin: ytai/IOIOPlotter

  1. Core.multiply(procImage_, new Scalar(0.25, 0.25, 0.25), procImage_);
  2. Core.add(procImage_, new Scalar(192, 192, 192), procImage_);

代码示例来源:origin: JavaOpenCVBook/code

  1. protected void processOperation() {
  2. Imgproc.Canny(originalImage, image, 220, 255, 3, false);
  3. Imgproc.threshold(image, image, 100, 255, Imgproc.THRESH_BINARY_INV);
  4. Imgproc.distanceTransform(image, image, Imgproc.CV_DIST_L2, 3);
  5. image.convertTo(image, CvType.CV_8UC1);
  6. Core.multiply(image, new Scalar(20), image);
  7. updateView();
  8. }

代码示例来源:origin: ytai/IOIOPlotter

  1. private void clear() {
  2. // Resize to native resolution divided by blur factor.
  3. float scale = LINE_WIDTH_TO_IMAGE_WIDTH / blur_ / srcImage_.cols();
  4. Imgproc.resize(srcImage_, imageResidue_, new Size(), scale, scale, Imgproc.INTER_AREA);
  5. // Negative.
  6. final Mat scalar = new Mat(1, 1, CvType.CV_64FC1).setTo(new Scalar(255));
  7. Core.subtract(scalar, imageResidue_, imageResidue_);
  8. // Convert to S16.
  9. imageResidue_.convertTo(imageResidue_, CvType.CV_16SC1);
  10. // Full scale is now blur * GRAY_RESOLUTION.
  11. Core.multiply(imageResidue_, new Scalar(blur_ * GRAY_RESOLUTION / 255), imageResidue_);
  12. // Clear map.
  13. curves_.clear();
  14. kernelFactory_.setDimensions(imageResidue_.width(), imageResidue_.height());
  15. }

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

  1. multiply(histogram, scalar, histogram);

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

  1. public Mat getMaskedDosePlaneHist(double slicePosition, Mat mask, int maxDose) {
  2. DicomImageElement dosePlane = (DicomImageElement) this.getDosePlaneBySlice(slicePosition);
  3. int rows = dosePlane.getImage().toMat().rows();
  4. int cols = dosePlane.getImage().toMat().cols();
  5. // Calculate dose matrix for OpenCV
  6. Mat src = new Mat(rows, cols, CvType.CV_32FC1);
  7. dosePlane.getImage().toMat().convertTo(src, CvType.CV_32FC1);
  8. Scalar scalar = new Scalar(this.doseGridScaling * 100);
  9. Mat doseMatrix = new Mat(rows, cols, CvType.CV_32FC1);
  10. multiply(src, scalar, doseMatrix);
  11. List<Mat> doseMatrixVector = new ArrayList<>();
  12. doseMatrixVector.add(doseMatrix);
  13. // Masked dose plan histogram
  14. Mat hist = new Mat();
  15. // Number of histogram bins
  16. MatOfInt histSize = new MatOfInt(maxDose);
  17. // Dose varies from 0 to maxDose
  18. MatOfFloat histRange = new MatOfFloat(0, maxDose);
  19. // Only one 0-th channel
  20. MatOfInt channels = new MatOfInt(0);
  21. // Ned to change the structure dose mask type vor OpenCV histogram calculation
  22. Mat maskSrc = new Mat(mask.rows(), mask.cols(), CvType.CV_8U);
  23. mask.convertTo(maskSrc, CvType.CV_8U);
  24. Imgproc.calcHist(doseMatrixVector, channels, maskSrc, hist, histSize, histRange);
  25. return hist;
  26. }

相关文章

Core类方法