Azzera filtri
Azzera filtri

How to dialte a binary matrix?

3 visualizzazioni (ultimi 30 giorni)
Ahmad Adee
Ahmad Adee il 29 Mag 2017
Risposto: Image Analyst il 29 Mag 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

Risposte (1)

Image Analyst
Image Analyst il 29 Mag 2017
Use imdilate()
B = imdilate(A, ones(3));

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by