#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include ;~ Sources: ;~ https://docs.opencv.org/4.5.1/d8/dc8/tutorial_histogram_comparison.html ConsoleWrite("Start" & @CRLF) _OpenCV_DLLOpen("libemgucv-windesktop-4.5.1.4349\libs\x64\cvextern.dll") Local $matEmpty = _cveMatCreate() Local $matSrcBase = _cveImread("Histogram_Comparison_Source_0.jpg") Local $matSrcTest1 = _cveImread("Histogram_Comparison_Source_1.jpg") Local $matSrcTest2 = _cveImread("Histogram_Comparison_Source_2.jpg") Local $matHsvBase = _cveMatCreate() _cveCvtColorMat($matSrcBase, $matHsvBase, $CV_COLOR_BGR2HSV, 0) Local $matHsvTest1 = _cveMatCreate() _cveCvtColorMat($matSrcTest1, $matHsvTest1, $CV_COLOR_BGR2HSV, 0) Local $matHsvTest2 = _cveMatCreate() _cveCvtColorMat($matSrcTest2, $matHsvTest2, $CV_COLOR_BGR2HSV, 0) Local $tHsvBaseSize = _cvSize(0, 0) _cveMatGetSize($matHsvBase, $tHsvBaseSize) Local $iRows = $tHsvBaseSize.height Local $iCols = $tHsvBaseSize.width $tHsvBaseSize = 0 Local $tHalfDownRect = _cvRect(0, $iCols / 2, $iRows, $iCols / 2) Local $matHsvHalfDown = _cveMatCreateFromRect($matHsvBase, $tHalfDownRect) $tHalfDownRect = 0 ; Quantize the hue to 50 levels and the saturation to 60 levels Local $aHistSize[2] = [50, 60] ; hue varies from 0 to 179 and saturation from 0 (black-gray-white) to 255 (pure spectrum color) Local $aRanges[4] = [0.0, 180.0, 0.0, 256.0] ; we compute the histogram from the 0-th and 1-st channels Local $aChannels[2] = [0, 1] Local $matHistBase = _cveMatCreate() Local $aMatHsvBase[1] = [$matHsvBase] _cveCalcHistMat($aMatHsvBase, $aChannels, $matEmpty, $matHistBase, $aHistSize, $aRanges, False) _cveNormalizeMat($matHistBase, $matHistBase, 0, 1, $CV_NORM_MINMAX, -1, $matEmpty) Local $matHistHalfDown = _cveMatCreate() Local $aMatHsvHalfDown[1] = [$matHsvHalfDown] _cveCalcHistMat($aMatHsvHalfDown, $aChannels, $matEmpty, $matHistHalfDown, $aHistSize, $aRanges, False) _cveNormalizeMat($matHistHalfDown, $matHistHalfDown, 0, 1, $CV_NORM_MINMAX, -1, $matEmpty) Local $matHistTest1 = _cveMatCreate() Local $aMatHsvTest1[1] = [$matHsvTest1] _cveCalcHistMat($aMatHsvTest1, $aChannels, $matEmpty, $matHistTest1, $aHistSize, $aRanges, False) _cveNormalizeMat($matHistTest1, $matHistTest1, 0, 1, $CV_NORM_MINMAX, -1, $matEmpty) Local $matHistTest2 = _cveMatCreate() Local $aMatHsvTest2[1] = [$matHsvTest2] _cveCalcHistMat($aMatHsvTest2, $aChannels, $matEmpty, $matHistTest2, $aHistSize, $aRanges, False) _cveNormalizeMat($matHistTest2, $matHistTest2, 0, 1, $CV_NORM_MINMAX, -1, $matEmpty) For $iCompareMethod = 0 To 3 Step 1 Local $dBaseBase = _cveCompareHistMat($matHistBase, $matHistBase, $iCompareMethod) Local $dBaseBalf = _cveCompareHistMat($matHistBase, $matHistHalfDown, $iCompareMethod) Local $dBaseBest1 = _cveCompareHistMat($matHistBase, $matHistTest1, $iCompareMethod) Local $dBaseBest2 = _cveCompareHistMat($matHistBase, $matHistTest2, $iCompareMethod) ConsoleWrite("Method " & $iCompareMethod & " Perfect, Base-Half, Base-Test(1), Base-Test(2) : " & $dBaseBase & " / " & $dBaseBalf & " / " & $dBaseBest1 & " / " & $dBaseBest2 & @CRLF) Next _cveMatRelease($matHistTest2) _cveMatRelease($matHistTest1) _cveMatRelease($matHistHalfDown) _cveMatRelease($matHistBase) _cveMatRelease($matHsvHalfDown) _cveMatRelease($matHsvTest2) _cveMatRelease($matHsvTest1) _cveMatRelease($matHsvBase) _cveMatRelease($matEmpty) _Opencv_DLLClose() ConsoleWrite("Done" & @CRLF)