How to dialte a binary matrix?

5 Ansichten (letzte 30 Tage)
Ahmad Adee
Ahmad Adee am 29 Mai 2017
Beantwortet: Image Analyst am 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

Antworten (1)

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

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!

Translated by