필터 지우기
필터 지우기

how to change the value of Neighbour pixels

조회 수: 1 (최근 30일)
daniel
daniel 2013년 7월 31일
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

채택된 답변

Iain
Iain 2013년 7월 31일
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;

추가 답변 (1개)

Image Analyst
Image Analyst 2013년 7월 31일
% 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