test / samples /java /tutorial_code /Histograms_Matching /histogram_equalization /EqualizeHistDemo.java
Download samples/java/tutorial_code/Histograms_Matching/histogram_equalization/EqualizeHistDemo.java from tgollogly/test: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/tgollogly/test/resolve/main/samples/java/tutorial_code/Histograms_Matching/histogram_equalization/EqualizeHistDemo.java
- Command line
-
hf download hf://tgollogly/test/samples/java/tutorial_code/Histograms_Matching/histogram_equalization/EqualizeHistDemo.java
-
curl -L -o EqualizeHistDemo.java https://huggingface.co/tgollogly/test/resolve/main/samples/java/tutorial_code/Histograms_Matching/histogram_equalization/EqualizeHistDemo.java
1.35 kB
| import org.opencv.core.Core; | |
| import org.opencv.core.Mat; | |
| import org.opencv.highgui.HighGui; | |
| import org.opencv.imgcodecs.Imgcodecs; | |
| import org.opencv.imgproc.Imgproc; | |
| class EqualizeHist { | |
| public void run(String[] args) { | |
| //! [Load image] | |
| String filename = args.length > 0 ? args[0] : "../data/lena.jpg"; | |
| Mat src = Imgcodecs.imread(filename); | |
| if (src.empty()) { | |
| System.err.println("Cannot read image: " + filename); | |
| System.exit(0); | |
| } | |
| //! [Load image] | |
| //! [Convert to grayscale] | |
| Imgproc.cvtColor(src, src, Imgproc.COLOR_BGR2GRAY); | |
| //! [Convert to grayscale] | |
| //! [Apply Histogram Equalization] | |
| Mat dst = new Mat(); | |
| Imgproc.equalizeHist( src, dst ); | |
| //! [Apply Histogram Equalization] | |
| //! [Display results] | |
| HighGui.imshow( "Source image", src ); | |
| HighGui.imshow( "Equalized Image", dst ); | |
| //! [Display results] | |
| //! [Wait until user exits the program] | |
| HighGui.waitKey(0); | |
| //! [Wait until user exits the program] | |
| System.exit(0); | |
| } | |
| } | |
| public class EqualizeHistDemo { | |
| public static void main(String[] args) { | |
| // Load the native OpenCV library | |
| System.loadLibrary(Core.NATIVE_LIBRARY_NAME); | |
| new EqualizeHist().run(args); | |
| } | |
| } | |