Delete a specific pixels of an image

6 Ansichten (letzte 30 Tage)
David Zapata
David Zapata am 7 Okt. 2017
Kommentiert: David Zapata am 9 Okt. 2017
I need to delete a specific pixel of an image, I have its coordinates, x and y, but I do not know how to delete only that one pixel.
My code is this:
B6 = imread('B6.TIF');
imshow(B6);
[x, y] = ginput(1);

Akzeptierte Antwort

Nada Kamona
Nada Kamona am 8 Okt. 2017
Hi David,
I'm not sure what you mean by delete just that pixel. So I'm assuming you only want to set that pixel at value equal to zero or NaN, while keeping the image at the same size. If this is what you want, and assuming x and y are the location of the pixel, then you can simply do the following:
B6(x,y) = 0;
% Or ...
B6(x,y) = NaN;
Please note that if x and y are arrays of coordinates, the above code still works. It will set all the points to zeros/NaNs.
Hope this helps!
  2 Kommentare
Image Analyst
Image Analyst am 8 Okt. 2017
Note: for a uint8 or uint16 image, setting to nan will set it to 0, not nan. And you reversed x and y. You'd need to have
B(ceil(y), ceil(x)) = 0; % Round and put y first, NOT x.
David Zapata
David Zapata am 9 Okt. 2017
thanks for your help

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Kategorien

Mehr zu Convert Image Type 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