Is there any way of extracting raw data from scanned plots of charts with X and Y scales defined on graph paper?
6 次查看(过去 30 天)
显示 更早的评论
I want to use scanned image of a chart with plotted data. If I define the X/Y scaling and limits, is there a way to extract plotted data points from the scanned image using MATLAB without having the raw data available?
1 个评论
John BG
2018-5-1
Hi Thomas
Indeed it is (possible).
Can you attach the image to your question so that readers can have a look?
采纳的回答
Walter Roberson
2018-5-1
Have a look at https://www.mathworks.com/matlabcentral/fileexchange/?utf8=%E2%9C%93&term=tag%3Adigitize
I went through and tagged a number of contributions for this purpose last year. There might also have been some newer ones added after I did the sweep.
更多回答(3 个)
James
2023-12-22
I know this is an old question, but for those who don't want to use the WebPlotDigitizer online resource, the following code does the same for a simple 2D X-Y plot (linear scale).
%% Get Image
cd('Path to directory containing the image')
image_data = imread('Path to image of figure');
imshow(image_data);
% Set the scale by selecting two points on the x-axis (small to large)
x_values = [min_x, max_x]; % Replace with the numerical values of the points you will select
disp('Click on point (min_x, 0.00)');
[x_pixel1, ~] = ginput(1); % Click on the pixel position for the minimum x-axis value
disp('Click on point (max_x, 0.00)');
[x_pixel2, ~] = ginput(1); % Click on the pixel position for the maximum x-axis value
% Now select two points on the y-axis (large to small this time)
y_values = [max_y, min_y]; % Replace with the numerical values of the points you will select
disp('Click on point (0.00, max_y)');
[~, y_pixel1] = ginput(1); % Click on the pixel position for the maximum y-axis value
disp('Click on point (0.00, min_y');
[~, y_pixel2] = ginput(1); % Click on the pixel position for the minimum y-axis value
%% Get Data
% Calculate scales for x and y axes
x_axis_scale = diff([x_values(1), x_values(2)]) / diff([x_pixel1, x_pixel2]);
y_axis_scale = diff([y_values(1), y_values(2)]) / diff([y_pixel2, y_pixel1]);
disp('Click on the curve to select points. Press Enter when finished.');
[x, y] = ginput; % Select points using mouse clicks
% Normalize the coordinates using the scale of the axes
x = (x - x_pixel1) * x_axis_scale + x_values(1);
y = (y_pixel1 - y) * y_axis_scale + y_values(1);
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!