简体   繁体   English

根据图像尺寸在MATLAB中的图像上放置网格

[英]Put grid on image in MATLAB based on image dimensions

I have a script in matlab that, when a certain criteria is met, it shows a portion of an image, which I manually inspect. 我在matlab中有一个脚本,当满足特定条件时,它会显示图像的一部分,我会手动检查。 I need to be able to inspect the image's individual pixels, and click on some pixels using ginput so the results of that clicking can be saved for further use. 我需要能够检查图像的单个像素,并使用ginput单击某些像素,以便可以将单击的结果保存下来以备将来使用。 Here's an example image: 这是一个示例图像: 黑白图像示例

In order to aid myself in clicking on individual pixels, I want to superimpose a grid on the image so I can see individual pixels in another color. 为了帮助自己单击单个像素,我想在图像上叠加一个网格,以便可以看到其他颜色的单个像素。 However, the size of these images varies, so I don't want to make the grid based on a certain number of segments - rather, based on the dimensions of the image segment. 但是,这些图像的大小各不相同,所以我不想基于一定数量的片段-而是基于图像片段的尺寸来制作网格。 When I put this grid on, I want to be able to see every individual pixel in a box (whether black or white) so I can inspect more easily. 当我放置此网格时,我希望能够看到一个盒子中的每个像素(无论是黑色还是白色),以便可以更轻松地检查。 How do I go about superimposing this grid on the image? 如何在图像上叠加此网格?

Thanks! 谢谢!

% Read in the image.
I = imread('http://i.stack.imgur.com/LzzD2.png');

% Display the image and the pixelregion window.
hIm = imshow(I);
hfig = impixelregion(hIm);

This creates two figure windows, where you can right-click on the grid in the Pixel Region window on the individual pixel you want to select and choose 'Copy pixel info' to copy the pixel location and values to your clipboard (exactly the same numbers as displayed on the bottom left corner of the Pixel Region Window), and use that for further processing. 这将创建两个图形窗口,您可以在“像素区域”窗口中的像素上右键单击要选择的单个像素,然后选择“复制像素信息”以将像素位置和值复制到剪贴板(数字完全相同) (显示在“像素区域”窗口的左下角),并将其用于进一步处理。

More details are available here: http://www.mathworks.com/help/images/ref/impixelregion.html 此处提供更多详细信息: http : //www.mathworks.com/help/images/ref/impixelregion.html

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

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