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!
