514KBZIP
matlab have to find the extreme value of the function findpeak can only find a one-dimensional extreme value, and opencv has no corresponding function, the so-called extreme value is larger than the surrounding values, and then see what degree of demand to be the extreme value: for the adhesion of the target, I use this extreme value method to find out the extreme value and then + watershed segmentation, the effect is better than the segmentation methods that I have tried before, but also simple and time-consuming less.
Mat dist_image,eachpeaks,peaksshow.
distanceTransform(bwimg,dist_image, DIST_L2, 3);
vector<Point> peaks.
findPeaks(dist_image,lengthresh,peaks,eachpeaks).
Mat imglabels,segresult.
watershedSegmentProc(bwimg, eachpeaks,peaksshow,imglabels,segresult);
Any center area points found like this are more accurate, and then there is less over-segmentation when the watershed splits.
However, this approach should be optimized a bit more, because the poles found this way are not friendly to a single large objective, which will find several poles. As for the optimized code, I won't post it (for internal company use).
One quibble: when debugging today, how come the watershed results still had unknown areas unassigned:
It's surprising that there are values in the 0-unknown region here, clearly the result after the watershed has already been split:
/* Watershed division processing
* srcmatbw-------- binary map Single channel
* everycenters---- center map of divisible stones with black 0 in the background and white dot 255 in the center
* imglabels------- watershed result background is 100, divider is -1, divisible stones are 1~N (may have 0 already tolerated)
* */
int watershedSegmentProc(Mat &srcmatbw,Mat &everycenters,Mat &imglabels)
{
// int not_zero_count=countNonZero(srcmatbw);
// float white_count_thre=srcmatbw.rows*srcmatbw.cols;
// white_count_thre*=0.8;
// if((not_zero_count(int)white_count_thre))
// {
// return 2;
// }
Mat element = getStructuringElement(MORPH_ELLIPSE, Size(11, 11));
Mat element2 = getStructuringElement(MORPH_ELLIPSE, Size(3, 3));
Mat binary_dilate.//every centers
dilate(everycenters, binary_dilate, element2, Point(-))1, -1), 1);
Mat binary_8UC3.
vector resultmats.
resultmats.push_back(srcmatbw);
resultmats.push_back(srcmatbw); resultmats.push_back(srcmatbw).
resultmats.push_back(srcmatbw); resultmats.push_back(srcmatbw).
merge(resultmats,binary_8UC3).
Mat unknown.//Obtain the unknown area, i.e. the area involved in the demarcation of the dividing line.
bitwise_xor(srcmatbw,binary_dilate,unknown);
//Merge marker images
Mat imgstats, imgcentroid.
connectedComponentsWithStats(binary_dilate, imglabels, imgstats, imgcentroid); //Connected domain tagging
imglabels.convertTo(imglabels, CV_32SC1); // Image type conversion
imglabels = imglabels + 100;//Background area of 100 pixels
for (int i=0;i<unknown.rows;i++)
{
uchar* ptr = unknown.ptr(i);
for (int j=0;j<unknown.cols;j++)
{
if (255==ptr[j])
{
imglabels.at(i, j) = 0; // Unknown area pixels are 0
}
}
}
//Watershed Split
watershed(binary_8UC3, imglabels).
}
What's going on with that 0 I don't know?
/**********************************************************************/
Regarding opencv 4.1 calling tensorflow trained .pb models with DropOut or BatchNorm nodes, a new coworker said that opencv c++ doesn't support it, I checked:
Export tensorflow graph with batchnorm to opencv dnn - OpenCV Q&A Forum
OpenCV: modules/dnn/src/tensorflow/tf_importer.cpp | Fossies
How to load a Keras model build with tensorflow backend in OpenCV - OpenCV Q&A Forum
Tensorflow C++ from Training to Deployment (3): Training and Deploying CNNs with Keras - Tech Liu
C++ and the phase_train node - Issue #357 - davidsandberg/facenet - GitHub
Checked the opencv4.1 source code, see is written fushBatchNorm interface, if not support, that opencv why write this interface, not chicken ribs:
See, it does recognize this node's. I think it just has to be the way opencv c++ specifies before it comes to load the trained model under python.
As for the dropout node, I don't see it in the opencv source code at the moment, but I've seen solutions talked about online:
And another guy even wrote the code to train the model with dropout nodes under python and then opencv c++ calls.
So I don't think these aren't unsupported, opencv c++ is just a bit more stringent than under python, and it will load by its rules, we're just still on our way to figuring them out.
Today, I found some very useful information on image segmentation over the wall, but unfortunately there is no corresponding code, there is a particularly good one that talks about segmenting overlapping irregular targets by shape matching or fitting.
I hope I have time to implement it for another project. Below is the result from the thesis: I feel it works better for high overlapping & out of focus graphs!
Resource Disclaimer (Purchase is deemed to be agreement with this statement): 1. Any operation on the website platform is considered to have read and agreed to the registration agreement and disclaimer at the bottom of the website, this site resources have been ultra-low price, and does not provide technical support 2. Some network users share the net disk address may be invalid, such as the occurrence of failure, please send an e-mail to customer service code711cn#qq.com (# replaced by @) will be made up to send 3. This site provides all downloadable resources (software, etc.) site to ensure that no negative changes; but this site can not guarantee the accuracy, security and integrity of the resources, the user downloads at their own discretion, we communicate to learn for the purpose of not all the source code is not 100% error-free or no bugs; you need to have a certain foundation to be able to read and understand the code, be able to modify the debugging yourself! code and solve the error. At the same time, users of this site must understand that the Source Code Convenience Store does not own any rights to the software provided for download, the copyright belongs to the legal owner of the resource. 4. All resources on this site only for learning and research purposes, please must be deleted within 24 hours of the downloaded resources, do not use for commercial purposes, otherwise the legal disputes arising from the site and the publisher of the collateral liability site and will not be borne! 5. Due to the reproducible nature of the resources, once purchased are non-refundable, the recharge balance is also non-refundable