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

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

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

Core.normalize介绍

[英]Normalizes the norm or value range of an array.

The functions normalize scale and shift the input array elements so that

| dst|_(L_p)= alpha

(where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that

min _I dst(I)= alpha, max _I dst(I)= beta

when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or min-max but modify the whole array, you can use "norm" and "Mat.convertTo".

In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this, the range transformation for sparse matrices is not allowed since it can shift the zero level.
[中]规范化数组的范数或值范围。
函数normalize缩放并移动输入数组元素,以便
|dst |(L_p)=α
(其中p=Inf,1或2)分别在normType=NORM_INFNORM_L1NORM_L2时;差不多
最小(I)=α,最大(I)=β
normType=NORM_MINMAX时(仅适用于密集阵列)。可选遮罩指定要规格化的子数组。这意味着在子数组上计算范数或min-n-max,然后将该子数组修改为规格化。如果只想使用遮罩计算范数或最小-最大值,但要修改整个数组,可以使用“范数”和“Mat.convertTo”。
对于稀疏矩阵,只分析和转换非零值。因此,稀疏矩阵的范围变换是不允许的,因为它可以移动零级。

代码示例

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

  1. protected void execute() {
  2. out = gray();
  3. Imgproc.equalizeHist(out, out);
  4. Core.normalize(out, out, min, max, Core.NORM_MINMAX);
  5. }

代码示例来源:origin: openpnp/openpnp

  1. @Override
  2. public Result process(CvPipeline pipeline) throws Exception {
  3. Mat mat = pipeline.getWorkingImage();
  4. if(mat.channels()==1) {
  5. Core.normalize(mat, mat, 0, 255, Core.NORM_MINMAX);
  6. } else {
  7. filter(mat);
  8. }
  9. return new Result(mat);
  10. }
  11. }

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

  1. protected void execute() {
  2. out = gray();
  3. Imgproc.equalizeHist(out, out);
  4. Core.normalize(out, out, min, max, Core.NORM_MINMAX);
  5. Imgproc.adaptiveThreshold(out, out, 255, Imgproc.THRESH_BINARY,
  6. Imgproc.ADAPTIVE_THRESH_MEAN_C, blocksize, reduction);
  7. byte[] data = new byte[(int) out.total()];
  8. out.get(0, 0, data);
  9. this.tessBaseAPI.setImage(data, out.width(), out.height(),
  10. out.channels(), (int) out.step1());
  11. String utf8Text = this.tessBaseAPI.getUTF8Text();
  12. int score = this.tessBaseAPI.meanConfidence();
  13. this.tessBaseAPI.clear();
  14. if (score >= SIMPLETEXT_MIN_SCORE && utf8Text.length() > 0) {
  15. simpleText = utf8Text;
  16. } else {
  17. simpleText = new String();
  18. }
  19. }

代码示例来源:origin: kongqw/OpenCVForAndroid

  1. public Bitmap createTrackedObject(Mat rgba, Rect region) {
  2. hsv = new Mat(rgba.size(), CvType.CV_8UC3);
  3. mask = new Mat(rgba.size(), CvType.CV_8UC1);
  4. hue = new Mat(rgba.size(), CvType.CV_8UC1);
  5. prob = new Mat(rgba.size(), CvType.CV_8UC1);
  6. //将rgb摄像头帧转化成hsv空间的
  7. rgba2Hsv(rgba);
  8. updateHueImage();
  9. Mat tempMask = mask.submat(region);
  10. // MatOfFloat ranges = new MatOfFloat(0f, 256f);
  11. // MatOfInt histSize = new MatOfInt(25);
  12. MatOfInt histSize = new MatOfInt(255);
  13. List<Mat> images = Collections.singletonList(hueList.get(0).submat(region));
  14. Imgproc.calcHist(images, new MatOfInt(0), tempMask, hist, histSize, ranges);
  15. Bitmap bitmap = Bitmap.createBitmap(hue.width(), hue.height(), Bitmap.Config.ARGB_8888);
  16. Utils.matToBitmap(hue, bitmap);
  17. // 将hist矩阵进行数组范围归一化,都归一化到0~255
  18. Core.normalize(hist, hist, 0, 255, Core.NORM_MINMAX);
  19. trackRect = region;
  20. return bitmap;
  21. }

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

  1. Core.normalize(magnitude, magnitude,0,255, Core.NORM_MINMAX, CvType.CV_8UC1);

相关文章

Core类方法