简体   繁体   English

MATLAB ::在MATLAB的图像(矩阵)上绘制数字

[英]MATLAB:: Drawing a number on a image (Matrix) on MATLAB

I'm using matlab in order to perform modifications on an image. 我正在使用matlab以便对图像进行修改。 I have loaded an image on Matlab. 我已经在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. 我的问题是,由于在X轴和Y轴上束起图像,因此可能会有1000个正方形。

I'd like to numbering the squares in that image. 我想对这张图中的方块编号。

Is there an option of drawing numbers on Matlab ? 在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... ). 我很高兴收到有关此的任何信息(除了是一只可单击的猴子,并且在paint haha​​上写0到1000。)。

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');

在此处输入图片说明

Use text 使用text

text is the low-level function for creating text graphics objects. text是用于创建文本图形对象的低级功能。 Use text to place character strings at specified locations. 使用text将字符串放置在指定位置。

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. text(x,y,'string')将引号中的字符串添加到点( xy )指定的位置xy必须是double类的数字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM