필터 지우기
필터 지우기

How to map the points of the graph from the coordinates on the image to the actual coordinates

조회 수: 3 (최근 30일)
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?

채택된 답변

Image Analyst
Image Analyst 2021년 11월 15일
You can get formulas from polyfit
y1 = 363;
y2 = 21;
x1 = 47;
x2 = 482;
% Get formulas
xCoefficients = polyfit([x1, x2], [0, 10], 1)
xCoefficients = 1×2
0.0230 -1.0805
yCoefficients = polyfit([y1, y2], [-1.5, 1.5], 1)
yCoefficients = 1×2
-0.0088 1.6842
% Get values for a particular point on the image.
x_coord = 117; % Whatever...
y_coord = 79; % Whatever...
x_Value = polyval(xCoefficients, x_coord)
x_Value = 1.6092
y_Value = polyval(yCoefficients, y_coord)
y_Value = 0.9912
  댓글 수: 2
Trong Link
Trong Link 2021년 11월 18일
Thank you for your excellent answer. The formula you gave works fine with linear scale but with logarithmic scale it doesn't seem to work well. So with logarithmic scale, how should I do?
This is my input image:
This is my output:
Is there any difference here?
Image Analyst
Image Analyst 2021년 11월 18일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

yanqi liu
yanqi liu 2021년 11월 18일
편집: yanqi liu 2021년 11월 18일
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
Image Analyst
Image Analyst 2021년 11월 19일
@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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by