Clear Filters
Clear Filters

Dull Razor algorithm : Problem with inpainting values

3 views (last 30 days)
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);
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);

Answers (1)

Image Analyst
Image Analyst on 26 Feb 2022
Never heard of Rull Razor. Is that some kind of variant on the original Dull Razor?
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 Comments
Image Analyst
Image Analyst on 27 Feb 2022
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.
Hend Abouche
Hend Abouche on 1 Mar 2022
okay I got your idea, thank you so much for explaining

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!