Delete a specific pixels of an image
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
David Zapata
el 7 de Oct. de 2017
Comentada: David Zapata
el 9 de Oct. de 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);
0 comentarios
Respuesta aceptada
Nada Kamona
el 8 de Oct. de 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 comentarios
Image Analyst
el 8 de Oct. de 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.
Más respuestas (1)
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!