Effacer les filtres
Effacer les filtres

How to dialte a binary matrix?

3 vues (au cours des 30 derniers jours)
Ahmad Adee
Ahmad Adee le 29 Mai 2017
I want to dilate a binary matrix (containing 0 and 1). So if I have a matrix 10x10 Note that dilation is all 4 sides (row left, row right, column left and column right). The Output matrix should be of the same size.
if true
A=
1 1 1 1 1 1 1 1 1
1 0 0 0 1 1 0 0 1
1 0 0 0 1 1 0 0 1
1 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 1
1 0 0 1 1 0 0 0 1
1 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1
% i need this
B=
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 0 1 1 1 1 1 1
1 1 0 1 1 1 1 1 1
1 1 0 0 0 0 0 1 1
1 1 1 1 1 1 0 1 1
1 1 1 1 1 1 0 1 1
1 1 1 1 1 1 0 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
or this
B=
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 0 1 1 1 1 1 1
1 1 0 0 1 1 0 1 1
1 1 0 0 0 0 0 1 1
1 1 0 1 1 0 0 1 1
1 1 1 1 1 1 0 1 1
1 1 1 1 1 1 0 1 1
1 1 0 1 1 0 1 1 1
1 1 1 1 1 1 1 1 1
end

Réponses (1)

Image Analyst
Image Analyst le 29 Mai 2017
Use imdilate()
B = imdilate(A, ones(3));

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by