简体   繁体   中英

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. 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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