4-neighbourhood - Where did those values come from?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Say we have the following matrix `x`:
>> x = [1 4 3; 6 4 3; 6 9 3; 2 4 3; 5 4 0; 5 3 1; 6 4 7]
x =
1 4 3
6 4 3
6 9 3
2 4 3
5 4 0
5 3 1
6 4 7
Now, when I select the `4-neighbourhoods` of each pixel as follows:
EDU>> four_neighbourhood_pixels = imdilate(x, strel('diamond', 1))
four_neighbourhood_pixels =
6 4 4
6 9 4
9 9 9
6 9 4
5 5 4
6 5 7
6 7 7
the results are understandable.
But, when I make a change to which neighbors to retrieve, such that, I want those neighbors that are *not* in `x` as follows:
>> four_neighbourhood_pixels = imdilate(x, strel('diamond', 1)) -x
four_neighbourhood_pixels =
5 0 1
0 5 1
3 0 6
4 5 1
0 1 4
1 2 6
0 3 0
The results I get are a bit confusing. For example, where did `5`, `0`, `1` come from? How were they calculated?
Thanks.
0 Kommentare
Antworten (2)
Walter Roberson
am 24 Feb. 2013
[6 4 4] - [1 4 3] = [5 0 1]
so if you understand the original matrix and understand where the 4-connected values come from, you should understand the subtraction.
0 Kommentare
Image Analyst
am 24 Feb. 2013
imdilate() does not "select the `4-neighbourhoods` of each pixel". imdilate() is the local maximum in a window. Since your structuring element is a diamond with radius 1, that means it is a cross 3 pixels high and 3 pixels wide. So look at those pixels when figuring out what the local max is. Then the subtraction is just a normal subtraction.
I don't know what " I want those neighbors that are not in `x` " means. Do you mean the 4 corners? That is, those pixels not in the 4-connected structuring element? If so, I don't know why you're subtracting the original matrix from the dilated (local max) matrix. Please describe exactly what "i want" means when you're referring to multiple pixels. Let's say at some particular location, that you have 4 neighbor values (how you get them I still don't know). Now, you have 4 pixels for every pixel in the image. So how do you want those values returned to you? Do you want a 3D image (N rows by M columns by 4)?
0 Kommentare
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!