mardi 3 mars 2015

Find all maximums for Mat() in OpenCV C++


I want to find all maximums (numbers of non-zero pixels) for my image. I need it to divide my picture such way:


enter image description here


So, i already asked question, how to project all image to one of the axis, and now i need to find all maximums on this one-row image. Here's my part of the code:



void segment_plate (Mat input_image) {
double minVal;
double maxVal;
Point minLoc;
Point maxLoc;
Mat work_image = input_image;
Mat output;
//binarize image
adaptiveThreshold(work_image,work_image, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 15, 10);
//project it to one axis
reduce(work_image,output,0,CV_REDUCE_SUM,CV_32S);

//find minimum and maximum falue for ALL image
minMaxLoc(output, &minVal,&maxVal,&minLoc,&maxLoc);
cout << "min val : " << minVal << endl;
cout << "max val: " << maxVal << endl;


As you can see, i could find one maximum and one minimum for all picture, but i need to find local maximums. Thanks for any help!




Aucun commentaire:

Enregistrer un commentaire