But processing time is slow.
For using the EMD compare, we should make signature value.
The EMD method compares two signatures value.
Firstly, we prepare histograms of 2 images.
And convert values of histrogram to signature.
A configuration of signature values is very simple.
bins value, x index, y index.
bins value, x index, y index.
bins value, x index, y index.
bins value, x index, y index.
bins value, x index, y index.
....
Of course this type is in case of 2d histogram.
More detail, see the source code.
In here I cannot explain earth mover distance algorithm.
please refer to internet information.
thank you.
origin images
result
...
#include < iostream> #include < vector> #include < stdio.h> #include < opencv2\opencv.hpp> #ifdef _DEBUG #pragma comment(lib, "opencv_core249d.lib") #pragma comment(lib, "opencv_imgproc249d.lib") //MAT processing #pragma comment(lib, "opencv_highgui249d.lib") #else #pragma comment(lib, "opencv_core249.lib") #pragma comment(lib, "opencv_imgproc249.lib") #pragma comment(lib, "opencv_highgui249.lib") #endif using namespace cv; using namespace std; int main() { //read 2 images for histogram comparing /////////////////////////////////////////////////////////////////////////////////////////////////////////////// Mat imgA, imgB; imgA = imread(".\\image1.jpg"); imgB = imread(".\\image2.jpg"); imshow("img1", imgA); imshow("img2", imgB); //variables preparing /////////////////////////////////////////////////////////////////////////////////////////////////////////////// int hbins = 30, sbins = 32; int channels[] = {0, 1}; int histSize[] = {hbins, sbins}; float hranges[] = { 0, 180 }; float sranges[] = { 0, 255 }; const float* ranges[] = { hranges, sranges}; Mat patch_HSV; MatND HistA, HistB; //cal histogram & normalization /////////////////////////////////////////////////////////////////////////////////////////////////////////////// cvtColor(imgA, patch_HSV, CV_BGR2HSV); calcHist( &patch_HSV, 1, channels, Mat(), // do not use mask HistA, 2, histSize, ranges, true, // the histogram is uniform false ); normalize(HistA, HistA, 0, 1, CV_MINMAX); cvtColor(imgB, patch_HSV, CV_BGR2HSV); calcHist( &patch_HSV, 1, channels, Mat(),// do not use mask HistB, 2, histSize, ranges, true, // the histogram is uniform false ); normalize(HistB, HistB, 0, 1, CV_MINMAX); //compare histogram /////////////////////////////////////////////////////////////////////////////////////////////////////////////// int numrows = hbins * sbins; //make signature Mat sig1(numrows, 3, CV_32FC1); Mat sig2(numrows, 3, CV_32FC1); //fill value into signature for(int h=0; h< hbins; h++) { for(int s=0; s< sbins; ++s) { float binval = HistA.at< float>(h,s); sig1.at< float>( h*sbins + s, 0) = binval; sig1.at< float>( h*sbins + s, 1) = h; sig1.at< float>( h*sbins + s, 2) = s; binval = HistB.at< float>(h,s); sig2.at< float>( h*sbins + s, 0) = binval; sig2.at< float>( h*sbins + s, 1) = h; sig2.at< float>( h*sbins + s, 2) = s; } } //compare similarity of 2images using emd. float emd = cv::EMD(sig1, sig2, CV_DIST_L2); //emd 0 is best matching. printf("similarity %5.5f %%\n", (1-emd)*100 ); waitKey(0); return 0; }...
I feel happy to see your webpage and looking forward for more updates.
ReplyDeletePython Training in Chennai
ccna course in Chennai
R Programming Training in Chennai
AWS Training in Chennai
DevOps Training in Chennai
Angularjs Training in Chennai
RPA Training in Chennai
Blue Prism Training in Chennai
Data Science Course in Chennai
This comment has been removed by the author.
ReplyDeletegomovies
ReplyDeletemobile whatsapp groups
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteWow! Such an amazing and helpful post this is. I really really love it. I hope that you continue to do your work like this in the future also.
ReplyDeleteRobotic Process Automation (RPA) Training in Chennai | Robotic Process Automation (RPA) Training in anna nagar | Robotic Process Automation (RPA) Training in omr | Robotic Process Automation (RPA) Training in porur | Robotic Process Automation (RPA) Training in tambaram | Robotic Process Automation (RPA) Training in velachery
For those willing to build a career in the field of Business analysis, it has designed proficient handling programs in IT and Business analysis. The programs have been designed to effectively impart statistics analyzing capability to the learners so that they are confident to work exercising personal productivity tools, creative thinking and other relevant skills. data science course syllabus
ReplyDeleteĐại lý vé máy bay Aivivu, tham khảo:
ReplyDeletevé máy bay đi Mỹ bao nhiêu
vé máy bay từ mỹ về việt nam 2020
lịch bay từ anh về việt nam hôm nay
bay từ pháp về việt nam mấy tiếng