I have a binary image having pixels 288*543

1 Ansicht (letzte 30 Tage)
vetri veeran
vetri veeran am 21 Okt. 2014
Beantwortet: Image Analyst am 21 Okt. 2014
I have a binary image having pixels 288*543(rows and columns). To that i need to assign zeros for 1 row and 1 column surrounding the 288*543. How can i achieve this.can anyone suggest some code for this.
Thank you.

Akzeptierte Antwort

Guillaume
Guillaume am 21 Okt. 2014
If you have the image processing toolbox, use padarray, otherwise:
newm = zeros(size(m) + 2);
newm(2:end-1, 2:end-1) = m;

Weitere Antworten (1)

Image Analyst
Image Analyst am 21 Okt. 2014
Try this
binaryImage(:,1) = false; % Make first column false.
binaryImage(:,end) = false; % Make last column false.
binaryImage(1,:) = false; % Make first row false.
binaryImage(1,end) = false; % Make last row false.
If your binary image is not really binary (of logical class) but actually something else (like uint8 or double), then replace false with 0 (zero).
This actually makes the edge layer of pixels false. If what you mean by "surround" is that you need to enlarge the image, then use padarray(), which will add a layer of pixels all around the image and enlarge it.

Kategorien

Mehr zu Geometric Transformation and Image Registration 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