Вопрос

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

Это было полезно?

Решение

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

Другие советы

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top