diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-02-12 15:55:21 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-02-12 15:55:21 +0800 |
commit | 10eb95869601e145b1d8bc909424777c25752d51 (patch) | |
tree | 49449a4076ded9bd937a51679318edbe2a532cae /works/life/digital-image-process-lab/HistogramEqulization.cpp | |
parent | 29ba3e88b1a7425fe00af0005b8a8228103aa21c (diff) | |
parent | f8c10dd1fc55e60f35286475356e48c4f642eb63 (diff) | |
download | crupest-10eb95869601e145b1d8bc909424777c25752d51.tar.gz crupest-10eb95869601e145b1d8bc909424777c25752d51.tar.bz2 crupest-10eb95869601e145b1d8bc909424777c25752d51.zip |
import(life): IMPORT crupest/life COMPLETE.
Diffstat (limited to 'works/life/digital-image-process-lab/HistogramEqulization.cpp')
-rw-r--r-- | works/life/digital-image-process-lab/HistogramEqulization.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/works/life/digital-image-process-lab/HistogramEqulization.cpp b/works/life/digital-image-process-lab/HistogramEqulization.cpp new file mode 100644 index 0000000..951a966 --- /dev/null +++ b/works/life/digital-image-process-lab/HistogramEqulization.cpp @@ -0,0 +1,34 @@ +#include <iostream> +#include <string> + +#include <opencv2/highgui.hpp> +#include <opencv2/imgcodecs.hpp> +#include <opencv2/imgproc.hpp> + +int main(int argc, char **argv) { + if (argc != 2) { + std::cerr << "Please input an image file path as the only arg." + << std::endl; + return -1; + } + + std::string file_name(argv[1]); + + cv::Mat src, dst; + + src = cv::imread(file_name, cv::IMREAD_COLOR); + if (src.empty()) { + std::cerr << "Failed to load image file: " << file_name << std::endl; + return -2; + } + + cv::cvtColor(src, src, cv::COLOR_BGR2GRAY); + + cv::equalizeHist(src, dst); + + cv::imshow("Source Image", src); + cv::imshow("Equalized Image", dst); + cv::waitKey(); + + return 0; +} |