extracting values from an image with color legend
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
howdy folks,
I want to extract numerical values from this figure. each circle is a fuel rod, that has a "power peaking factor" I would like to obtain a numerical value for that.
0 comentarios
Respuestas (3)
Adam Danz
el 20 de Mayo de 2024
One way to see the color value is to add the color data to the data tip. When you click on or hover over one of the points, you can see the color data in addition to the other data tip information.
Here are three demos where that is implemented.
1 comentario
Adam Danz
el 21 de Mayo de 2024
Based on the other answers, I think I may have misinterpretted the question. My answer offers a solution for MATLAB figures. The other answers, which seem more relevant, offer solution for working with flat images.
DGM
el 20 de Mayo de 2024
% the image
inpict = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1699336/image.png');
% extract the colorbar
CT = imcrop(inpict,[87.51 229.51 41.98 263.98]);
CT = permute(mean(im2double(CT),2),[1 3 2]);
CT = flipud(unique(CT,'rows','stable'));
% these are the extreme colorbar ticks
% i'm assuming everything is linearly spaced
outrange = [0.83 1.19]; % the colorbar scale
% crop out just the area of interest
inpict = imcrop(inpict,[233.51 50.51 631.98 629.98]);
% create a mask which selects the background
[~,S,V] = rgb2hsv(inpict);
bgmask = 1 - (S.*V);
bgmask(11:130,550:end) = 1; % get rid of the remnants of the legend box
% get the distance map
D = -bwdist(bgmask);
% split blobs with watershed segmentation
regionmin = imextendedmin(D,2); % the basin minima (ideally one per cell)
D = imimposemin(D,regionmin);
ridgelines = watershed(D);
mask = ~bgmask;
mask(ridgelines == 0) = false;
imshow(mask)
% estimate zdata from the pseudocolor image
PF = rgb2ind(inpict,CT,'nodither'); % remap to integer indices
inrange = [0 size(CT,1)-1]; % rescale to data units
PF = (outrange(2)-outrange(1))*(double(PF)-inrange(1))/(inrange(2)-inrange(1))+outrange(1);
% get the centroids and mean zdata in each mask blob
% centroids are given [x y]
% mean intensity is the PF as corresponds to the colorbar
% blobs are ordered as the image is scanned from top-bottom, left-right
stats = regionprops(mask,PF,'centroid','meanintensity');
% you can do what you want with that information. I'm just going to dump it into a table.
table(vertcat(stats.Centroid),vertcat(stats.MeanIntensity))
0 comentarios
Image Analyst
el 21 de Mayo de 2024
Editada: Image Analyst
el 21 de Mayo de 2024
See my thermal image demo in my File Exchange. I do essentially this but for a thermal image with a colorbar.
It's a generic, general purpose demo that lets you locate the color bar interactively, then converts the RGB image into an image where the pixel value is the actual underlying pixel value corresponding to the colors.
0 comentarios
Ver también
Categorías
Más información sobre Orange en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!