/
Alx89
/
OpenCV
Обзор
Документация
Войти
/
Alx89
/
OpenCV
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
4.x
samples/java/tutorial_code/Histograms_Matching/histogram_equalization/EqualizeHistDemo.java
49 строк
1 KB
catree
Add Java and Python code for the following imgproc tutorials: Affine Transformations, Histogram Equalization, Histogram Calculation, Histogram Comparison, Back Projection.
24 май 2018, 02:11
24 май 2018, 02:11
4c1c314
Код
Авторство
О чём код?
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); } }