Dull Razor algorithm : Problem with inpainting values
3 次查看(过去 30 天)
显示 更早的评论
Hi guys, I am trying to implement the Rull Razor algorithm in matlab but when I try to inpaint the rgb image values with the binary mask, I can't find a function to do that .
PS: I tried inpaintCoherent and inpaintExemplar but I got the error that they are not defined
PS: I tried regionfill but its only applicated on the rgb image so the problem is that Ican't get the rgb image back
I will be grateful for anyone that help me with, thank you in advance
here is my code :
i=imread('ISIC_0031023.JPG');
%crop
[x,y,z] = size(i);
d = y-x;
i = i(:,round(d/2)+1:y-(d-round(d/2)),:);
figure,imshow(i);
%convert the rgb image to grayscale image
img=rgb2gray(i);
figure,imshow(img);
%black hat filter
SE=strel('disk',3);
J = imbothat(img,SE);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/908465/image.jpeg)
figure, imshow(J);
%apply gaussian filter
Iblur1 = imgaussfilt(J);
figure,imshow(Iblur1);
%Binary thresholding (MASK)
BW = imbinarize(Iblur1);
figure, imshow(BW);
%replace the pixels of the mask
%f =inpaintExemplar(i,BW,'FillOrder','tensor','PatchSize',7);
%f=inpaintCoherent(i,BW);
%f=regionfill(img,BW);
figure,imshow(f);
0 个评论
回答(1 个)
Image Analyst
2022-2-26
You can use regionfill() on each color channel one at a time.
[r,g,b] = imsplit(i);
r = regionfill(r, BW);
g = regionfill(g, BW);
b = regionfill(b, BW);
Why do you do this:
[x,y,z] = size(i);
instead of
[rows, columns, numberOfColorChannels] = size(rgbImage);
??? First of all i should not be used since it's the imaginary variable. Secondly rows is called, by nearly everyone except you, as the y value, not "x" as you called it. And the columns is x, not y.
3 个评论
Image Analyst
2022-2-27
Yeah it's just that most people in the world call the vertical (rows) direction y, and you are not following that naming convention. And the rest of the world calls the horizontal direction x, and again, you're not following the worldwide convention. Yes, the code still works because you are consistent in the way you name and use the indexes.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!