Find surrounding and outer pixels
Afficher commentaires plus anciens
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.
Réponses (1)
Image Analyst
le 4 Avr 2014
1 vote
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 commentaires
Ciara
le 4 Avr 2014
Image Analyst
le 4 Avr 2014
This would be my code
outputImage = imdilate(Z, true(17));
Ciara
le 4 Avr 2014
Image Analyst
le 4 Avr 2014
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
le 7 Avr 2014
Did this answer your question Ciara?
sensation
le 7 Fév 2017
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
Catégories
En savoir plus sur Neighborhood and Block Processing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!