Extract XY data from the image based on the color filter
조회 수: 9 (최근 30일)
이전 댓글 표시
Hi,
How could I extract XY data from the image by selecting points of the same color? For example, in the attached figure, gain is plotted versus frequency for three different temperatures. +85C is red color, +25C is green color and -40C is blue color. I would like to be able to extract XY data but instead of picking up manually point by point on the curve, I would like to pick one point on the red curve which would then select all points with the same color and export them as the XY data scaled based on the some already known XY points presented on the graph.
Thank you,
S.R.

댓글 수: 6
Ameer Hamza
2020년 6월 6일
I think there is no straightforward way to extract the data. You may need to write the code according to your requirement using the image processing tools.
채택된 답변
Image Analyst
2020년 6월 6일
편집: Image Analyst
2020년 6월 6일
Try imsplit
[r,g,b] = imsplit(rgbImage);
% Then scan each column with find() until you find the first row where that color appears.
redImage = r == 255 & g == 0 & b == 0;
greenImage = r == 0 & g == 255 & b == 0;
blueImage = r == 0 & g == 0 & b == 255;
[rows, columns] = size(redImage)
ry = zeros(1, columns)
gy = zeros(1, columns)
by = zeros(1, columns)
for col = 1 : columns
% First the red
thisCol = redImage(:, col);
topRow = find(thisCol);
if ~isempty(topRow)
ry = topRow;
end
% Next the green
thisCol = greenImage(:, col);
topRow = find(thisCol);
if ~isempty(topRow)
gy = topRow;
end
% Next the blue
thisCol = blueImage(:, col);
topRow = find(thisCol);
if ~isempty(topRow)
by = topRow;
end
end
Of course the values will be in units and coordinates of image pixels, so you'll have to calibrate the distances.
댓글 수: 3
Image Analyst
2020년 6월 6일
Are you sure you can't get the figure, or the data used to create the figure. If you have just the PNG image, it's going to be hard to pull out each curve independently since they overlap. You're probably best off using imfreehand to hand trace the curve. I'm attaching a demo.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
