How do I find the X and Y coordinates of image (want to plot this figure)

91 views (last 30 days)
I have this image
As I want to plot it, I need to have the coordinations.
I checked the code here getting coordinates but it does not give me the coordinations.
  1 Comment
Sam Chak
Sam Chak on 19 Mar 2022
Hi @NA
They are stochastic signals. Although the patterns are visible, they are certainly 'noisy', not to mention that the quality of the image is also lossy (mean some pixels on the signals are removed during the scanning process). @Image Analyst is an authority in this field. Perhaps there are ways to restore or sharpen the image using Artificial Intelligence.
With the labels on the x- and y-axes, it is possible to 'estimate' the coordinate of each dot (as well as the restored missing dot) on the signal via some edge detection algorithms. But to identify the governing mathematical function and the noise spectrum with the confidence bounds will be a little challenging.

Sign in to comment.

Answers (2)

DGM
DGM on 20 Mar 2022
Edited: DGM on 20 Mar 2022
To paraphrase prior answers to similar questions:
If you want the original data, you're out of luck. It's gone. Simply put, the image is not the data. All images of plotted data are simplified representations of the underlying data, intended for visualization -- not as a store of data. The size of the image, the width of the lines, and the degree of destructive compression used all create ambiguity that influences the precision of any recovery attempt. Accordingly, the quality of any extracted information will be questionable.
Starting with a poor source of information and expecting to automagically extract the underlying data without human effort is simply an exercise in tedious oversight. In other words, you either have to invest effort in transcribing the data, or you'll have to invest at least as much effort in babysitting a very fragile automation of the same.
You can try to throw a bunch of image processing at it, or you can just manually transcribe the curves and rescale them to the data coordinate space described by the axes labels. The question is whether it's subjectively less of a hassle to spend your time guessing where the missing or malformed line segments go, or whether you prefer to spend your time writing and debugging an elaborate script that does the same amount of guessing without the benefit of conceptual insight.
For something like this, I'd suggest starting by trying to rectify the image. The image appears to be scanned. It is not merely rotated, but also distorted. You'll have to transform it back into a rectangle.
At that point, you can use images.roi.Polyline() and get a point list. Then rescale those image coordinates to data coordinates.
EDIT: here's a start:
A = imread('1.jpg');
A = rgb2gray(A);
imshow(A)
% these are the coordinates of the box corners
boxm = [81 28; % [x y]
84 660;
968 647;
965 19];
% assert that this is where they're supposed to be
boxf = [80 30; % [x y]
80 660;
970 660;
970 30];
% rectify the image
TF = fitgeotrans(boxm,boxf,'projective');
outview = imref2d(size(A));
B = imwarp(A,TF,'fillvalues',255,'outputview',outview);
imshow(B)
% the extent of the data axes
dataaxes = [1 1; % [x y]
286 1.05];
% where did that 286 come from? find the x-location of the 281 tick ...
%(281-1) * range(boxf(:,1))/(955-min(boxf(:,1))) + 1
% UNCOMMENT THIS
% % create a polyline ROI object
% R1 = images.roi.Polyline(gca)
% R1.draw % start manually drawing it
% pause() % wait for the user to finish adjusting the ROI
% % user has to hit enter in the console to continue
% THIS IS JUST PLACEHOLDER DATA TO REPLACE THE COMMENTED CODE ABOVE
% DELETE THIS
R1.Position = [93 134;133 73.4;206 86.8;252 58.9;462 309;478 231;569 284;657 141;672 184;730 166;764 97.2;911 60;940 101;977 61];
% rescale the ROI coordinates to data coordinates
% trace1 is a Mx2 array of points formatted as [x y]
trace1 = (R1.Position - min(boxf,[],1))./range(boxf,1); % normalized coordinates
trace1(:,2) = 1-trace1(:,2); % flip y-data
trace1 = trace1.*range(dataaxes,1) + min(dataaxes,[],1) % scale to data
trace1 = 14×2
5.1629 1.0417 17.9719 1.0466 41.3483 1.0455 56.0787 1.0477 123.3258 1.0279 128.4494 1.0340 157.5899 1.0298 185.7697 1.0412 190.5730 1.0378 209.1461 1.0392
Since interactive things like ROI creation can't be used in the forum editor, I slapped in a crude example curve. You'll have to uncomment the ROI stuff and delete the placeholder. You'll have to do whatever you want to generate all four traces (make a loop or something) and save the resulting data (a .mat file or something).
Returning to the discussion of the limitations, note that even after being rectified, the plot box lines are not all straight. The distortion is more complex than a simple perspective; the page was likely not flat. Consequently, the remaining distortion will simply contribute to the error in any transcribed data.
  1 Comment
Image Analyst
Image Analyst on 20 Mar 2022
Thanks for showing the perspective warp correction code. It could be useful for many situations and people. 🙂🙂🙂

Sign in to comment.


Image Analyst
Image Analyst on 20 Mar 2022
There are several options in the File Exchange you might want to look at.

Community Treasure Hunt

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

Start Hunting!