0

I'm using matlab in order to perform modifications on an image. I have loaded an image on Matlab. (the image may be in different resolutions) Converted the image to gray scale then converted the image's matrix to double.

I have drawn grid lines on the image (I have posted the code how to do that somewhere here on stack over flow).

My problem is that I may have upon the 1000 squares as a result from girding the image on the X axis and the Y axis.

I'd like to numbering the squares in that image.

Is there an option of drawing numbers on Matlab ? I'd be glad to receive any information about that (except from being a clicking monkey and writing 0 till 1000 on paint haha... ).

Cheers S

TripleS
  • 1,216
  • 1
  • 23
  • 39

2 Answers2

7

Here is a code example to put text labels on an image in the middle of grids:

x = imread('cameraman.tif');
image(x)
axis image
grid on
%# grid domains
xg = 0:50:200;
yg = 0:50:200;
%# label coordinates
[xlbl, ylbl] = meshgrid(xg+25, yg+25);
%# create cell arrays of number labels
lbl = strtrim(cellstr(num2str((1:numel(xlbl))')));
text(xlbl(:), ylbl(:), lbl(:),'color','w',...
    'HorizontalAlignment','center','VerticalAlignment','middle');

enter image description here

yuk
  • 19,098
  • 13
  • 68
  • 99
  • If you want to capture the resulting image and store it to disk, you might want to to take a look at [this related question](http://stackoverflow.com/questions/4137628/render-matlab-figure-in-memory). – André Caron Dec 07 '11 at 16:18
3

Use text

text is the low-level function for creating text graphics objects. Use text to place character strings at specified locations.

text(x,y,'string') adds the string in quotes to the location specified by the point (x,y) x and y must be numbers of class double.

Jacob
  • 34,255
  • 14
  • 110
  • 165