how to inpaint a region of interest recursively
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everyone!
I have an image called 'lion.jpg' .

I did segmentation to the lions in the center using the segmentImage.m function , and got this image:

I need to inpaint the black region that was created , and I need a solution to do that recursively from outside to inside:

I tried to use the inpaintCoherent function but the result was not acually what i needed , I got this:

You can see that the inpaintCoherent function filled the area of the mountains with colored lines , and this is not good for me. I want to fille the region smoothly.
I tried to blure the region but I really dont want to do that.
I shared my code : try1.m with you, and you can see it here too:
clc;
clear;
close all;
I = imread('lion.jpg');
figure; imshow(I,[]);
[BW,mask] = segmentImage(I);
figure; imshow(BW);
bg = I - mask;
figure; imshow(bg)
figure; montage({I,BW});
%% inpaint
title(['Image to Be Inpainted',' | ','Mask for Inpainting']);
J = inpaintCoherent(I,BW,'Radius',7);
figure; imshow(J);
figure;
montage({I,J});
title(['Image to Be Inpainted',' | ','Inpainted Image']);
%% try to blur the image:
redChannel = J(:, :, 1);
greenChannel = J(:, :, 2);
blueChannel = J(:, :, 3);
% H = fspecial('disk',20);
H = fspecial('average',33);
redChannel = roifilt2(H,redChannel,BW);
greenChannel = roifilt2(H,greenChannel,BW);
blueChannel = roifilt2(H,blueChannel,BW);
rgbImage = cat(3, redChannel,greenChannel,blueChannel);
figure;
subplot(1,2,1); imshow(J); title('Inpainted Image');
subplot(1,2,2); imshow(rgbImage); title('image after blure');
0 commentaires
Réponse acceptée
Image Analyst
le 28 Jan 2022
The function you want is called regionfill().
Description
5 commentaires
Image Analyst
le 21 Sep 2025
I haven't used those functions so I can't comment on them. You know more about them than me.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


