Delete a specific pixels of an image
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Nada Kamona
2017-10-8
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 个评论
Image Analyst
2017-10-8
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.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!