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

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

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

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

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

@Override
  public Result process(CvPipeline pipeline) throws Exception {
    Mat mat = pipeline.getWorkingImage();
  if(mat.channels()==1) {
    Core.normalize(mat, mat, 0, 255, Core.NORM_MINMAX);	
  } else {
    filter(mat);
  }

    return new Result(mat);
  }
}

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

protected void execute() {
  out = gray();
  Imgproc.equalizeHist(out, out);
  Core.normalize(out, out, min, max, Core.NORM_MINMAX);
  Imgproc.adaptiveThreshold(out, out, 255, Imgproc.THRESH_BINARY,
      Imgproc.ADAPTIVE_THRESH_MEAN_C, blocksize, reduction);
  byte[] data = new byte[(int) out.total()];
  out.get(0, 0, data);
  this.tessBaseAPI.setImage(data, out.width(), out.height(),
      out.channels(), (int) out.step1());
  String utf8Text = this.tessBaseAPI.getUTF8Text();
  int score = this.tessBaseAPI.meanConfidence();
  this.tessBaseAPI.clear();
  if (score >= SIMPLETEXT_MIN_SCORE && utf8Text.length() > 0) {
    simpleText = utf8Text;
  } else {
    simpleText = new String();
  }
}

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

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

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

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

相关文章

Core类方法