Referencing specific areas of an image

Hi all,
I need to do some template matching in locations that are specified using a binary image. All of the areas that have pixel value of 1 need to be checked. There are several clusters of these.
Using the LOC command i can specify the region of interest , the area I need to search, but how can I find the pixel locations of the ones in the binary image??
Thanks

Answers (2)

[rows, columns] = find(binaryImage);
That gives you the rows and columns of every true pixel in the binary image. Most likely you don't need those (though you think you do) and can just use the binary image itself. I could tell you how, if I only knew what "check" meant.

6 Comments

matlabjo
matlabjo on 13 Jan 2014
Moved: DGM on 13 Feb 2023
well generally im trying to identify an object in a crowded image using a reference image. The image in which i am searching for this object is full of similar objects.
Ive isolated objects of the same colour, however some are square and some are rectangle (lego bricks). so what i am trying to do, is using my binary image, which is all white in the presence of the same colour blocks. I will multiply it by the true image, in order to make all yellow blocks stand out as figure in a black background, and now i need to sort between the 2x2 blocks and the 2x4 blocks.
(some are occluded, and some are at different orientations) but this is my best approximation. My idea was that if i can do an edge filter on the template image, which is just the block by itself, then i could match that template to all locations in the image(that was multiplied by the binary image) to show me which ones had the dimensions most similar to the shape of the block in the reference image.
I know.. It all sounds a little abstract. Applause
matlabjo
matlabjo on 13 Jan 2014
Moved: DGM on 13 Feb 2023
apologies, sorry. not applause.
Image Analyst
Image Analyst on 13 Jan 2014
Moved: DGM on 13 Feb 2023
I'll accept both. You can edit a response, you know. Also, you should have posted them as comments to my answer since you were relying to me, rather than as "Answers" to your original question.
Image Analyst
Image Analyst on 13 Jan 2014
Moved: DGM on 13 Feb 2023
It would be less abstract if you posted your original image, your binary image, and your "template" image. But it sounds like you don't want to, or need to, do what you originally asked for, as I suspected. You don't want to, or need to, find the location of every pixel in the mask. And I seriously doubt you need to use an edge filter either. But I can't tell for sure until I see some images.
Image Analyst
Image Analyst on 14 Jan 2014
Moved: DGM on 13 Feb 2023
You can find the yellow blocks by running my demo http://www.mathworks.com/matlabcentral/fileexchange/28512-simple-color-detection-by-hue. In fact that demo finds yellow so you can run it practically right out of the box. Simply change the filename. You might have to tweak a few threshold somewhat but not much.
Image Analyst
Image Analyst on 14 Jan 2014
Moved: DGM on 13 Feb 2023
Why not just set the blocks level? Why do they have to be all in a jumbled pile? The key to getting good measurements is to always start with the best image possible. If you're looking at the end of a block you can't tell what size it is.

Sign in to comment.

Image Analyst
Image Analyst on 15 Jan 2014
Moved: DGM on 13 Feb 2023
matlabjo, you can just do color segmentation like I said. There is no reason to do edge detection that I can see. And I don't see a reason to do normalized cross correlation either since the shapes are so very different. It won't be that robust in this situation to the various sizes and orientations of the yellow regions. I have a number of color segmentation methods in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Asked:

on 13 Jan 2014

Moved:

DGM
on 13 Feb 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!