Hello,
I have following image.
And I would like to fill the white whole, with the same color as the gray circle outside, so that would like as the following image:
Here what I have done just know:
close all; clear all;
Im1=imread('Im1.bmp');Im2 = rgb2gray(Im1);figure; imshow(Im1);bw=im2bw(Im1,0.9);bw_dilated = imdilate(bw,strel('disk',3));%[I,J,V] = find(Im2, B{1,1}(1:end,1));
avgPrecisionSize = 16; % smaller is better, but takes longer
G = fspecial('gaussian',[1 1]*100,50);H = fspecial('average', [1,1]*avgPrecisionSize);%# User a big filter to get started:
newImage = imfilter(Im2,G,'same');newImage(~bw_dilated) = Im1(~bw_dilated);numIterations = 30;for count = 1:numIterations newImage = imfilter(newImage, H, 'same'); newImage(~bw_dilated) = Im1(~bw_dilated);end%%Plot the results
figure(123);clf;% Display the mask:
subplot(1,2,1);imagesc(Im1);axis imagetitle('Region Of the Bad Pixels');% Display the result:
subplot(1,2,2);imagesc(newImage);axis imageset(gca,'clim', [0 255])title('Infilled Image');colormap gray
And here is what I got:
[MATLAB] version 2015b
Best Answer