Referencing specific areas of an image
Show older comments
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)
Image Analyst
on 13 Jan 2014
0 votes
[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
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
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
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
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.
Image Analyst
on 15 Jan 2014
Moved: DGM
on 13 Feb 2023
0 votes
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
Categories
Find more on Template Matching in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!