Heatmap image convert to data. Percentage of black to white.

7 ビュー (過去 30 日間)
muhammad afiq
muhammad afiq 2020 年 6 月 17 日
コメント済み: Ameer Hamza 2020 年 6 月 17 日
Hi,
Im having some issue to find a tutorial which i can change the heatmap from my analysis to percentage. For the image convertion to black and white image, there a lot of tutorial but to anaylze the heapmap i couldnt find any. Im new to this matlab.
Original image.
Need to convert to black and white image as below
Then calculate the percentage of the ratio between black/white region. This is to analyze to heatmap.
thanks.
  2 件のコメント
Benoit Espinola
Benoit Espinola 2020 年 6 月 17 日
How do you load your image? What is the format in Matlab?
muhammad afiq
muhammad afiq 2020 年 6 月 17 日
Im not load yet to the matlab but my image in .png format

サインインしてコメントする。

回答 (2 件)

Ameer Hamza
Ameer Hamza 2020 年 6 月 17 日
rgb2gray() seems to work
img = im2double(imread('image.png'));
img_gray = rgb2gray(img);
imshow(img_gray)
However, the correct solution depends on the values of color in the heatmap. Do you have such mapping?
  2 件のコメント
muhammad afiq
muhammad afiq 2020 年 6 月 17 日
編集済み: muhammad afiq 2020 年 6 月 17 日
this is the actual value indication.
Ameer Hamza
Ameer Hamza 2020 年 6 月 17 日
Do you only have data as an image, or do you also have data in numeric format?

サインインしてコメントする。


Benoit Espinola
Benoit Espinola 2020 年 6 月 17 日
編集済み: Benoit Espinola 2020 年 6 月 17 日
You can calculate the lightness (=brightness) of each pixel in your image.
Assuming your RGB values are between 0 and 1 (which is the default in Matlab).
you can do:
L = (max(R,G,B)-min(R,G,B))/2;
Then you can use that for your gray.
R = L;
G=L;
B=L;
And finally, you should plot it in your figure.
About the ratio between "black" and "white" regions. Depends on how you define the threashold.
Ratio = sum(L(L>0.5))/numel(L); % gives you the ratio between 0 and 1.
You can change your threashold to something sensible, though 0.5 (= 50% white) seems like a sensible value.

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by