Minimum width across any part of a connected component in matlab
Ältere Kommentare anzeigen
In order to label connected components in a matrix composed of double format values (not binary values), I am using a Matlab Central File Exchange program: LABEL
So, let's say I have a double format matrix of the form:
A = [1 3 3 3 3 6 6;
1 3 3 0 6 6 6;
1 3 3 0 4 4 6;
1 2 2 0 4 4 6;
1 2 2 0 5 5 6;
1 1 1 0 5 5 6;
1 1 1 0 5 5 6]
If I run the above mentioned LABEL function with 4-connectivity, I get the results in the form of labels, area of each connected components and number of connected components.
Labels:
1 2 2 2 2 5 5
1 2 2 4 5 5 5
1 2 2 4 6 6 5
1 3 3 4 6 6 5
1 3 3 4 7 7 5
1 1 1 4 7 7 5
1 1 1 4 7 7 5
Area of each connected component:
11 8 8 8 8 10 10
11 8 8 6 10 10 10
11 8 8 6 4 4 10
11 4 4 6 4 4 10
11 4 4 6 6 6 10
11 11 11 6 6 6 10
11 11 11 6 6 6 10
and 7 number of components.
If we look at the A matrix that I have written above, we can see the connected component with value 1 is only 1 cell wide at some places (see first column of A matrix). Similarly for components with elements 0, 6, 3.
Is there any way that I can replace the cells which are only 1 cell wide (in any component) with NaN values. Basically, from all the components, I would like to remove the parts which are only 1 cell wide, and replace those parts (cells) with NaN values.
My attempts: I tried using the ratio of horizontal width to vertical width of a
BoundingBox
and
Eccentricity
from
regionprops
function, but I could not achieve any satisfactory results.
Can anybody please help me out with this? Thanks!
P.S. : The "1" cell wide value can be any threshold that we can decide in our code. If possible, I would like to be able to remove any parts which are only "threshold" cells wide (threshold can be 1 or 2 or any positive integer).
1 Kommentar
Ankit Sahay
am 1 Sep. 2020
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Computer Vision with Simulink finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!