How to map the points of the graph from the coordinates on the image to the actual coordinates
2 views (last 30 days)
Show older comments
Trong Link
on 15 Nov 2021
Commented: Image Analyst
on 19 Nov 2021
I am implementing an auto-digitizer to extract (x, y) value pairs of a line graph. I have determined the position of the axes and y-axis on the image by specifying the beginning and the end of each axis on the image. I also found the coordinates of the points on the graph image. Now how can I map those values to real values so that I can plot the graph again with the values I just mapped??
Here is my input image:
I have defined the beginning and the end of the x,y axis (the red points) and know the limit ranges of each axis. I have determined the coordinates on the image of the points of the graph (for example, with the blue point in the image, I have determined the coordinates of its x_coord and its y_coord ). Now I want to convert from the coordinates on the image to the actual coordinates so that I can plot the graph again. What formula can help me do that?
0 Comments
Accepted Answer
Image Analyst
on 15 Nov 2021
You can get formulas from polyfit
y1 = 363;
y2 = 21;
x1 = 47;
x2 = 482;
% Get formulas
xCoefficients = polyfit([x1, x2], [0, 10], 1)
yCoefficients = polyfit([y1, y2], [-1.5, 1.5], 1)
% Get values for a particular point on the image.
x_coord = 117; % Whatever...
y_coord = 79; % Whatever...
x_Value = polyval(xCoefficients, x_coord)
y_Value = polyval(yCoefficients, y_coord)
2 Comments
Image Analyst
on 18 Nov 2021
You'll have to develope a calibration formula so you'll need more than 2 points. Then you can use fitnlm to fit a curve to the log values. I'm attaching a few examples. Modify one of them to use the log formula.
More Answers (1)
yanqi liu
on 18 Nov 2021
Edited: yanqi liu
on 18 Nov 2021
sir, please check the follow demo:
https://mp.weixin.qq.com/s?__biz=MzU5NTAyMTIzOQ==&mid=2247485036&idx=1&sn=6b92275258f1532398eb09602825c5f0&chksm=fe791ab4c90e93a21ee3e235b3a4fab3d13ca6db06cb2fa5ed8c9f799d320232748ed604232d&scene=21#wechat_redirect
it use click to get points
2 Comments
Image Analyst
on 19 Nov 2021
@Tung Vu There are some graph digitizing apps in the File Exchange with source code. Note that this one and probably the others don't handle semi-log data.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!