Is Pixel Interpolation possible in MATLAB? If so, how?
10 次查看(过去 30 天)
显示 更早的评论
Hey guys. So I have a picture, but unfortunately, some pixels in it are completely black (the RGB values are 0,0,0). For those specific pixels, I would like to do some sort of pixel interpolation (replace those black pixels by a pixel that is interpolated from the surrounding area). I tried doing it myself but I struggled with multiple things, one of them is how to tell MATLAB what are the pixels that I want to replace and what are the pixels that I want it to interpolate from. Any ideas?
0 个评论
采纳的回答
DGM
2022-7-30
You should be able to use regionfill()
% a test array with a zero pixel
A = uint8(randi([0 255],5,5));
A(3,3) = 0;
imshow(A)
% create a mask that describes the zeros
mk = A == 0;
% inpaint
B = regionfill(A,mk);
imshow(B)
2 个评论
Image Analyst
2022-7-31
% Split RGB image apart into separate color channels.
[r,g,b] = imsplit(rgbImage);
% Fill holes in each channel individually.
r = regionfill(r, mask);
g = regionfill(g, mask);
b = regionfill(b, mask);
% Recombine
rgbImage = cat(3, r, g, b);
There are other ways (some are perhaps more "accurate"), but this might be the simplest and be good enough.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!