1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-22 07:31:26 +08:00
Files
opencv_contrib/modules/intensity_transform/samples/intensity_transform.cpp
Lim 9aa74df09e new module: intensity_transform (includes gamma correction, log transfomration, autoscaling, contrast stretching)
build error fix: remove trailing whitespaces, casting types

minor edits based on alalek's feedback

removing trailing whitespace

using std::array for LUT argument
2020-01-27 16:32:38 -05:00

39 lines
1.0 KiB
C++

#include "opencv2/core.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/intensity_transform.hpp"
#include <iostream>
using namespace std;
using namespace cv;
using namespace cv::intensity_transform;
int main(int argc, char **argv)
{
if (argc != 2)
{
cerr << "Must input the path of the input image. Ex: intensity_transform image.jpg" << endl;
return -1;
}
// Read input image
Mat image = imread(argv[1]);
// Apply intensity transformations
Mat imgGamma, imgAutoscaled, imgLog, contrastStretch;
gammaCorrection(image, imgGamma, (float)(0.4));
autoscaling(image, imgAutoscaled);
logTransform(image, imgLog);
contrastStretching(image, contrastStretch, 70, 15, 120, 240);
// Display intensity transformation results
imshow("Original Image", image);
imshow("Autoscale", imgAutoscaled);
imshow("Gamma Correction", imgGamma);
imshow("Log Transformation", imgLog);
imshow("Contrast Stretching", contrastStretch);
waitKey(0);
return 0;
}