Asked by Edvardas
on 10 Apr 2013

Hello.

I am currently trying to reproduce a graph on matlab from a .jpeg file. I've managed to extract the correct shape, however I am at a loss of how to rescale the data, as one of the axis that has to be modified (x axis) is the number of columns of the matrix rather than actual data (It's a [1 341] matrix, where the row contains the data for the y axis).

Basically, the graph was generated from this image:

into this:

So as it can be seen the x axis should be from 0 to 2000, and the zero should be where it's currently 50.

Y axis should run in a similar range, but start at 0, whereas currently it's 40.

So to recap, I am uncertain on how to make the x axis, which is the number of columns, and the y axis into ranges of 0-2000 without creating gaps in the graph, as well as modifying starting positions of the data.

Thank you for your time,

Edvardas.

Answer by Image Analyst
on 10 Apr 2013

Accepted answer

You have to come up with a spatial calibration factor for the x and y directions. I suggest you use imdistline() and then inputdlg() to ask the user to click on known tick marks on the axes and specify what the "real" number is for the tick marks. See example 3 under imdistline().

Edvardas
on 11 Apr 2013

Hello! Thanks for the answer. I think I understand what you mean, however, in this exercise my task is to go from a very similar method to what you described (except there the user would tick the marks on the graph of the image file) to a more of an automated process.

Hence I was wondering whether there is a method to play around with the matrix itself (e.g. increase the size from 1x341 to 1x2000 whilst avoiding gaps in the graph, or changing the matrix into a 2x341, where one row would contain approximated data points between 0 to 2000 on the x axis, and the other row would be scaled appropriately), so that it could be coded to do it automatically without user input?

Again, thank you for your time!

Regards,

Edvardas

Image Analyst
on 11 Apr 2013

Edvardas
on 12 Apr 2013

Awesome. Will try that out. Thank you!

P.S. Got the initial suggestion running as well, used the ginput command to get values which I then used to find the scaling factors and then used that to scale up the axis. I'm not sure whether it's as efficient, just felt more familiar with ginput, but I understand the principle is pretty similar, so thanks again :)

Related Content

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments