how to change the value of Neighbour pixels

3 views (last 30 days)
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

Accepted Answer

Iain
Iain on 31 Jul 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;

More Answers (1)

Image Analyst
Image Analyst on 31 Jul 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]

Categories

Find more on Modify Image Colors in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!