how to change the value of Neighbour pixels

3 visualizaciones (últimos 30 días)
daniel
daniel el 31 de Jul. de 2013
hello,
i wonder how can i change the value of Neighbour pixels around specific point without using massive loop..?
for example:
i have binary image and i want to remove (change the value of the pixel) an area of 5x5 pixels around specific point (x,y). i.e
is there any easy way to do this?
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
i want to the pixels in the range of 3x3 matrix around the point i,j=(3,5) will turn zero's
1 1 1 1 1 1 1 1 1 1
1 1 1 0 0 0 1 1 1 1
1 1 1 0 1 0 1 1 1 1
1 1 1 0 0 0 1 1 1 1
1 1 1 1 1 1 1 1 1 1

Respuesta aceptada

Iain
Iain el 31 de Jul. de 2013
map = false(size(image_to_mod));
map(down,along) = true;
dmap = imdilate(map,true(3,3));
change = xor(map,dmap);
image_to_mod(change) = false;

Más respuestas (1)

Image Analyst
Image Analyst el 31 de Jul. de 2013
% Create original binary image.
binaryImage = true(5, 10)
% Assign ring of false
binaryImage(2:4, 4:6) = [false, false, false; false, true, false; false, false, false]

Community Treasure Hunt

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

Start Hunting!

Translated by