extracting values from an image with color legend
조회 수: 16 (최근 30일)
이전 댓글 표시
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
답변 (3개)
Adam Danz
2024년 5월 20일
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
Adam Danz
2024년 5월 21일
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
2024년 5월 20일
% 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
Image Analyst
2024년 5월 21일
편집: Image Analyst
2024년 5월 21일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Orange에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!