0

I have x and y coordinates of a contour. Now they cannot be used as pixel locations since they are not integers. I am unable to find a way to convert them into pixel locations. Floor and round functions do not help as they create blobs. I need a crisp contour similar as in a plot.

1 Answers1

1

You can plot your (x,y) points, remove axis ticks, and grab the axes into image. Try this:

figure;
plot(rand(10,1),rand(10,1));
box on; set(gca,'XTick',[],'YTick',[])
F = getframe(gca);
Image = F.cdata;
figure; imshow( Image );

EDIT: If you need to draw many lines on image you may consider Bresenham's line algorithm to draw lines on image. See, for exmple, question and suggestions there:

Community
  • 1
  • 1
anandr
  • 1,622
  • 1
  • 12
  • 10
  • I am already aware of this technique. However, I do not prefer using this as it will slow down my code a lot further since I am doing all this in a loop. I will have to close the figure each time which will cause flickering. Please suggest a solution to this. Thanks!! – user2396273 May 18 '13 at 17:48