0
votes

I have to draw a curve captured on a image using screen pixels (mouse clicks) into a coordinate system. E.g.: Pixels on the screen, from left to right (130 px to 970 px) correspond to the x-axis of my coordinate system (1000 to 6000). Pixels from bottom to top (670 to 99) correspond to the y-axis of coordinate system (0 to 1.2). How can this be done? Maybe there's a function in matlab doing something like that?

Some more explanation: I have a jpg image of a curve on a coordinate system. I've got pixel positions (x,y) of several points on that curve. Now I want to plot same curve into a matlab figure with same x and y axis as on the jpg image.

1

1 Answers

0
votes

Not sure if there is a MATLAB function/command to do this, but it may not be too difficult to come up with something.

Suppose that xPixDiff = 970-130 and xAxisDiff = 6000-1000. Then the xPixel value from any (xPixel,yPixel) pair can be translated into an x-axis coordinate via

xAxisCoord = (xPixel-130)*xAxisDiff/xPixDiff + 1000

It is clear from the above that xPixel=130 maps to 1000 and xPixel=970 maps to 6000.

The yAxisCoord calculation is similar but we just have to remember that the "directions" are opposite in the y-axis coordinate system and the y pixel positions.

Let yPixDiff=99-670 and yAxisDiff=1.2-0. Then the yPixel value from any (xPixel,yPixel) pair can be translated into an y-axis coordinate via

yAxisCoord = (yPixel-670)*yAxisDiff/yPixDiff + 0

It is clear from the above that yPixel=670 maps to 0 and yPixel=99 maps to 1.2.

Hope that the above helps!