Find surrounding and outer pixels
显示 更早的评论
Hi,
I have used a 16x16 window to scan an entire image in matlab. The value of the largest pixel is stored as well as its position on the image.
I need to find the pixels surrounding the largest pixels and check if they are as bright as it. I also need to find the outer pixels and check if they are darker than the largest pixel.
Could anyone tell me how to find the surrounding pixels and the outer pixels?
Thanks.
回答(1 个)
Image Analyst
2014-4-4
1 个投票
What do you mean by largest pixel? All pixels are the same size, aren't they? Do you mean brightest? You can find the brightest pixel in a neighborhood in two ways, depending on exactly how you define brightest: imregionalmax() and imdilate(). You can cast that image to double and subtract it from the original image to see how a pixel differs from the neighborhood.
6 个评论
Ciara
2014-4-4
Image Analyst
2014-4-4
This would be my code
outputImage = imdilate(Z, true(17));
Ciara
2014-4-4
Image Analyst
2014-4-4
maxValue = max(grayImage(:))
[row, col] = find(grayImage == maxValue, 1, 'first');
neighbors = [grayImage(row, col),...
grayImage(row-1, col-1),...
grayImage(row-1, col),...
grayImage(row-1, col),...
grayImage(row, col-1),...
grayImage(row, col+1),...
grayImage(row+1, col-1),...
grayImage(row+1, col),...
grayImage(row+1, col+1)];
Image Analyst
2014-4-7
Did this answer your question Ciara?
sensation
2017-2-7
Hi,
I thanks for this info. I was using part of your code to find the 3x3 neireast matrix.
And now I am tryying to find the neareast number and its id betweeen two different size arrays?
for instance, I have an array: A: 540x1 values; and another array B, 540 X 4860 consisted of 540 blocks (each one represented by 3x3 matrix-so 9X540=4860).
What I want to do is to search through each of these 9 area block numbers, compare it with single number from B and retrieve that area.
A: 45 etc X 540
B: 5 6 9
4 15 16
21 55 2
etc X 540 blocks like this;
result: would be 55 and id=8 since the counting in my code goes like:
234
516
789
for instance if I give some fix row and col: eg row=15 and col=12 I get a good result with:
[value,index]=min(abs(neighbors_area(:)-100));
but when I want to do for the whole data set, there is an error that matrix sizes doesnt match.
Any clue?
Thanks
类别
在 帮助中心 和 File Exchange 中查找有关 Neighborhood and Block Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!