直方图的均衡化
来源:互联网 发布:医疗数据分析师 编辑:程序博客网 时间:2024/05/17 09:10
#include <opencv2/opencv.hpp>#include <iostream>using namespace std;using namespace cv;int main(){ //直方图 Mat image = imread("D:/group.jpg", 0); MatND hist; const int channels[] = { 0 }; const int histsize[] = { 256 }; const float range[] = { 0., 255. }; const float *ranges[] = { range }; calcHist(&image, 1, channels, Mat(), hist, 1, histsize, ranges); double min, max; minMaxLoc(hist, &min, &max); double rate = 255. / max; Mat histgram(256, 256, CV_8U, Scalar(255)); //Mat histagram(Size(255, 255), CV_8U, Scalar(255)); for (int i = 0;i < 255; i++) { //line(histagram, Point(i, 255), Point(i, 255 - hist.at<float>(i)*rate), Scalar(0)); line(histgram, Point(i, 255), Point(i, 255 - hist.at<float>(i)*rate), Scalar(0)); } namedWindow("image"); imshow("image", image); namedWindow("histgram"); imshow("histgram", histgram); //直方图均衡化,像素强度更平均 Mat result; equalizeHist(image, result); namedWindow("equalizeHist"); imshow("equalizeHist", result); MatND histo; calcHist(&result, 1, channels, Mat(), histo, 1, histsize, ranges); //该加const一定要加const,否则会报错参数不匹配 minMaxLoc(histo, &min, &max); //参数定义一定要和函数内部数据类型一致,double rate = 255. / max; Mat histogram(256, 256, CV_8U, Scalar(255)); for (int i = 0;i < 255; i++) { line(histogram, Point(i, 255), Point(i, 255 - histo.at<float>(i)*rate), Scalar(0));//用int是不可以的,用float } namedWindow("histogram"); imshow("histogram", histogram); imwrite("D:/picture1/image.png", image); imwrite("D:/picture1/eqiulizeHist.png", result); waitKey(0); return 0;}
阅读全文
0 0
- 直方图的均衡化
- 直方图的均衡化
- 直方图的均衡化
- 直方图的均衡化
- matlab 的直方图均衡化
- 直方图均衡化的理解
- 直方图均衡化的原理
- opencv3的直方图均衡化
- 位图的直方图均衡化和直方图的绘制
- 图像直方图均衡化和直方图匹配的理解
- 直方图均衡化、自适应直方图均衡化
- 图像的灰度化,直方图均衡化
- 彩色图像的直方图均衡化
- 直方图均衡化的matlab实现
- bmp图像的直方图均衡化
- 直方图均衡化的算法和代码
- 直方图均衡化的算法和代码
- java 图像的直方图均衡化
- Linux命令大全网址
- Netty4实战第十一章:WebSockets
- python 数字信号的滤波器设计 signal.buffer
- C#228课的主要内容
- datagrid下fitcolums设置没有铺满100%问题
- 直方图的均衡化
- 水仙花数
- 数据结构复习资料
- QT 程序中对Linux设备内存的监控
- GPA计算
- java三大特性——多态
- oracl数据库(子查询)
- Eclipse 设置编码格式
- SpringMvc-Hibernate校验