Create HeatMap from blobs of different sizes using C ++

I want to get a heat map from an attached image. Large drops will have darker (red) areas, and then gradually disappear to a lighter blue hue. Smaller drops will have lighter variations. But keep in mind that the center of the larger blob should be the hottest region. I think drops can be more inquisitive using Gaussian blur and threshold value.

I used the opencvs method, for example, using remote conversion, and then applied colormap. But this is similar to his inverted circles, such as skeletons (thinning) of drops. I want a better gradient heatmap.

enter image description here

I want it to be more like enter image description here

not like this from opencv enter image description here

+4
1

, . . . , !

Mat mSource_Gray,mBlobHeatMap,mHeatMap;
mSource_Gray= imread(FileName_S.c_str(),0);

//Just making sure everything is binary
threshold(mSource_Gray,mSource_Gray,254,255,THRESH_BINARY);
imshow("Source Image",mSource_Gray);

enter image description here

//Finding Distance Transform
Mat mDist,mBlobDist;
distanceTransform(mSource_Gray, mDist, CV_DIST_L2, 3);
normalize(mDist, mDist, 0, 1., cv::NORM_MINMAX);
mDist.convertTo(mDist,CV_8UC1,255,0);
imshow("mDist",mDist);

enter image description here

vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
/// Find contours to Mask out the Individual Contours
findContours( mSource_Gray, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0) );
/// Draw contours (Mask)
Mat mBlobMask = Mat::zeros( mSource_Gray.size(), CV_8UC1 );
for( size_t i = 0; i< contours.size(); i++ )
{
    drawContours( mBlobMask, contours, (int)i, Scalar(255), -1);
    mDist.copyTo(mBlobDist,mBlobMask);
    applyColorMap(mBlobDist,mBlobHeatMap,COLORMAP_JET);
    GaussianBlur(mBlobHeatMap,mBlobHeatMap,Size(21,21),0,0);
    mBlobHeatMap.copyTo(mHeatMap,mBlobMask);
}

imshow("mHeatMap",mHeatMap);

enter image description here

+8

Source: https://habr.com/ru/post/1606173/


All Articles