Assefa Seyoum
Assefa Seyoum

Reputation: 19

image inpainting | inpaintCoherent()

The task is to inpaint the timestamp of the following picture. I use MATLAB's inpaintCoherent, but the result isn't satisfactory. I have attached the original image, the mask, and the inpainted image. Here is the MATLAB code.

bill = imread('Billiards_ref.png');
mask = imread('mask.png');
bill_inpainted = inpaintCoherent(bill, logical(mask));
imshowpair(bill, bill_inpainted, 'montage')

What image pre or post-processing can I do to improve the quality of the inpainting?

The original image enter image description here

The mask image enter image description here

The inpainted image enter image description here

Upvotes: 1

Views: 506

Answers (1)

If_You_Say_So
If_You_Say_So

Reputation: 1293

You may want to consider blurring your mask image a bit prior to the use of inpaintCoherent. This will require some trial and error to see how much smoothing will give your the best image. Based on the images you have posted in your question, here is what I can suggest and the results:

bill = imread('Billiards_ref.jpg'); % Image you included is a jpg file
mask = imread('mask.png');

% Create a blurred mask using a 2D Gaussian kernel with std dev std_dev (in pixel units)
std_dev = 1; % You may want to change this for different images depending on what the resolution of the original mask is
mask_bl = imgaussfilt(double(mask), std_dev);

bill_inpainted = inpaintCoherent(bill, logical(mask_bl));

Images with original and blurred mask

Upvotes: 1

Related Questions