I have an image like this one and the corresponding background image.
I am trying to extract the heatmap of the first image. My first approach was to mask every pixel that was not "equal enough" (thresholding the euclidean distance between every pixel), but the results were not good enough
Looks like a straightforward problem in image processing, but I lack experience. Thanks!
Heatmap is a graphical way to visualize visitor behavior data in the form of hot and cold spots employing a warm-to-cool color scheme. The warm colors indicate sections with the most visitor interaction, red being the area of highest interaction, and the cool colors point to the sections with the lowest interaction.
Heat Map Chart, or Heatmap is a two-dimensional visual representation of data, where values are encoded in colors, delivering a convenient, insightful view of information. Essentially, this chart type is a data table with rows and columns denoting different sets of categories.
Obtaining the exact heat map is a highly non-trivial problem since the heat map was superimposed with varying levels of transparency.
This means that per pixel there are two unknowns:
If a rough segmentation suffices, I suggest a simple thresholding via the color intensities. You can see that the stronger regions of the heatmap are surrounded by a strong, blue color:
I = imread('https://i.stack.imgur.com/7oVZK.png');
% Simple, manual color thresholding
mask1 = I(:,:,3) > 230 & I(:,:,1) < 30 & I(:,:,2) < 10;
Now we dilate the mask to close any holes in the blue heat map boundaries and fill the holes:
% Morphological processing
mask2 = imdilate(mask1, strel('disk',5,0));
mask2 = imfill(mask2, 'holes');
Finally, we can extract the heat map:
% Extract heat map
heat_map = I;
heat_map(~repmat(mask2,[1 1 3])) = 255;
imshow(heat_map)
Here is the Result
Edit: If you have to process many similar images, it might be more robust to perform the segmentation in hsv space:
I_hsv = rgb2hsv(I);
mask1 = I_hsv(:,:,1) > 0.6 & I_hsv(:,:,1) < 0.7 & I_hsv(:,:,2) > 0.95 & I_hsv(:,:,3) > 0.9;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With