- #include <QCoreApplication>
- #include <QDebug>
- #include "opencv/highgui.h"
- #include "opencv/cvaux.h"
- int main(int argc, char *argv[])
- {
- CvSize sz;
- IplImage* img1 = cvLoadImage("Tulips.jpg");
- sz.height = img1->height;
- sz.width = img1->width;
- IplImage* img2r = cvCreateImage(sz,IPL_DEPTH_8U,1);
- IplImage* img2g = cvCreateImage(sz,IPL_DEPTH_8U,1);
- IplImage* img2b = cvCreateImage(sz,IPL_DEPTH_8U,1);
- cvSplit(img1,img2r,img2g,img2b,NULL);
- cvEqualizeHist(img2r,img2r);
- cvEqualizeHist(img2g,img2g);
- cvEqualizeHist(img2b,img2b);
- IplImage* img3 = cvCloneImage(img1);
- cvMerge(img2r,img2g,img2b,NULL,img3);
- cvNamedWindow("Win1",CV_WINDOW_AUTOSIZE);
- cvNamedWindow("Win2r",CV_WINDOW_AUTOSIZE);
- cvNamedWindow("Win2g",CV_WINDOW_AUTOSIZE);
- cvNamedWindow("Win2b",CV_WINDOW_AUTOSIZE);
- cvNamedWindow("Win3",CV_WINDOW_AUTOSIZE);
- cvShowImage("Win1",img1);
- cvShowImage("Win2r",img2r);
- cvShowImage("Win2g",img2g);
- cvShowImage("Win2b",img2b);
- cvShowImage("Win3",img3);
- cvSaveImage("img3.jpg",img3);
- cvWaitKey(0);
- return 5;
- Q_UNUSED(argc)
- Q_UNUSED(argv)
- }
对一幅整体较暗淡的彩色图像分别抽取RGB三个通道进行直方图均衡化,然后再合并。发现结果图像的色彩在各个基色通道都均衡化后的合并结果,效果在视觉上有所优化,但还存在一些蓝斑,应该是数据信息细节不足导致。
阅读(3555) | 评论(0) | 转发(0) |