Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract heatmap on top of image

Tags:

I have an image like this one Heatmap with original image as background and the corresponding background image. Original 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 Mask

Looks like a straightforward problem in image processing, but I lack experience. Thanks!

like image 253
Black Arrow Avatar asked Mar 04 '17 14:03

Black Arrow


People also ask

How do you visualize a heatmap?

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.

Is a heatmap a figure or a table?

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.


1 Answers

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:

  1. The heat map itself and
  2. transparency (they are linked but the exact mapping is unknown).

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
enter image description here

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;
like image 192
Richard Avatar answered Sep 25 '22 10:09

Richard