Plot to Image?

Hi, I have a set of XY points that I plotted. Is there a way to convert this to an image? Basically I'm hoping to retain the resolution of the points while doing some image processing on it using the IPT.
Long story short, I have some encoders that have taken motion position numbers, and when I plot the XY encoder values I get the shape I expect, but I want to run it under regionprops and I have no idea how to turn the plot into an image with the same resolution so I can get accurate counts/mm. Currently 1 count = 1 pixel or 1 value on the plot.
Thanks

Answers (2)

Mark Sherstan
Mark Sherstan on 10 Dec 2018
Would the following work for you or at least push you in the right direction?
x = 1:10;
y = x.^2;
xwidth = 300;
ywidth = 200;
figure (1)
h = figure(1);
set(gcf,'PaperPositionMode','auto')
set(h, 'Position', [0 0 xwidth ywidth])
plot(x,y)
saveas(gcf,'someFigure.png')

4 Comments

Elmer Wang
Elmer Wang on 11 Dec 2018
So this doesn't work becuase the image that's saved isn't 300 x 200. I need it to be exactly the same. otherwise the encoder counts are no longer accurate to estimate the lengths. It's close, but it still ends up at like 361x251 pxls. Thanks for your hlep.
Image Analyst
Image Analyst on 11 Dec 2018
Upload screenshots of what you're seeing. Otherwise you're making us guess blind.
Try this (solution was found here):
plot(1:10) % Example graph
set(gcf,'PaperUnits','inches','PaperPosition',[0 0 4 3])
print -djpeg filename.jpg -r100
Otherwise please provide more information such as example plots.
Elmer Wang
Elmer Wang on 11 Dec 2018
I think I've found a workaround that doesn't use the IPT. Thank you for your help. I was trying to use IPT to match a second analysis method so that we had two data sets to compare parity between. But after talking to some of my colleagues, I don't believe that it's completely necessary.
Instead I'm just going to manipulate the data to get the information I need. Thank you again!

Sign in to comment.

Products

Release

R2018b

Asked:

on 10 Dec 2018

Commented:

on 11 Dec 2018

Community Treasure Hunt

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

Start Hunting!