org.opencv.imgproc.Imgproc.equalizeHist()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(185)

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

Imgproc.equalizeHist介绍

[英]Equalizes the histogram of a grayscale image.

The function equalizes the histogram of the input image using the following algorithm:

  • Calculate the histogram H for src.
  • Normalize the histogram so that the sum of histogram bins is 255.
  • Compute the integral of the histogram:

H'_i = sum(by: 0

Transform the image using H' as a look-up table: dst(x,y) = H'(src(x,y))

The algorithm normalizes the brightness and increases the contrast of the image.
[中]均衡灰度图像的直方图。
该函数使用以下算法均衡输入图像的直方图:
计算src的直方图H*。
*对直方图进行规格化,使直方图单元的总和为255。
计算直方图的积分:
H''i=总和(由:0得出)
使用
H'*作为查找表变换图像:dst(x,y)=H'(src(x,y))
该算法使亮度正常化并增加图像的对比度。

代码示例

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

@Override
  public Result process(CvPipeline pipeline) throws Exception {
    Mat mat = pipeline.getWorkingImage();
    Imgproc.equalizeHist(mat, mat);
    return null;
  }
}

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

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

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

protected void processOperation() {
  Imgproc.cvtColor(originalImage, grayImage, Imgproc.COLOR_RGB2GRAY);
  Imgproc.equalizeHist(grayImage, image);
  updateView();
}

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

protected void execute() {
    out = gray();
    Imgproc.equalizeHist(out, out);
    synchronized (mog) {
      mog.apply(out, this.mask, (double) (-10 + learning_rate) / 10);
    }
    Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_DILATE,
        new Size(3, 3));
    Imgproc.dilate(mask, mask, kernel);
    ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>();
    Imgproc.findContours(this.mask, contours, new Mat(),
        Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
    double maxheight = object_max_size * this.in.height() / 100;
    double minheight = object_min_size * this.in.height() / 100;
    Iterator<MatOfPoint> each = contours.iterator();
    each = contours.iterator();
    while (each.hasNext()) {
      MatOfPoint contour = each.next();
      Rect rect = Imgproc.boundingRect(contour);
      if (rect.height > minheight && rect.height < maxheight) {
        Imgproc.rectangle(out, rect.tl(), rect.br(), new Scalar(255,
            0, 0), 1);
      }
    }
  }
}

代码示例来源: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();
  }
}

相关文章

微信公众号

最新文章

更多

Imgproc类方法