Created
December 29, 2018 14:09
-
-
Save p208p2002/0c9ad3d17fb2d142ffd093501501410a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <iostream> | |
| #include <opencv2/opencv.hpp> | |
| #include <opencv2/highgui/highgui.hpp> | |
| using namespace cv; | |
| using namespace std; | |
| /** @function main */ | |
| Mat equalizeIntensity(const Mat& inputImage) | |
| { | |
| if (inputImage.channels() >= 3) | |
| { | |
| Mat ycrcb; | |
| cvtColor(inputImage, ycrcb, CV_BGR2YCrCb); | |
| vector<Mat> channels; | |
| split(ycrcb, channels); | |
| equalizeHist(channels[0], channels[0]); | |
| Mat result; | |
| merge(channels, ycrcb); | |
| cvtColor(ycrcb, result, CV_YCrCb2BGR); | |
| return result; | |
| } | |
| return Mat(); | |
| } | |
| int main(int argc, char** argv) | |
| { | |
| Mat src, dst; | |
| /// Load image | |
| src = imread("C:/img/Fig0635(bottom_left_stream).tif"); | |
| Mat src2 = src.clone(); | |
| if (!src.data) | |
| { | |
| cout << "Usage: ./Histogram_Demo <path_to_image>" << endl; | |
| return -1; | |
| } | |
| src = equalizeIntensity(src); | |
| imshow("before", src2); | |
| imshow("after", src); | |
| /// Wait until user exits the program | |
| waitKey(0); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment