how to remove the cracks on image?
Show older comments
This code reads in an image with cracks, creates a binary mask of where the cracks are located, and then uses the inpainting function to fill in the masked areas using the 'fast marching' method. The resulting image with the cracks removed is then displayed. Note that the specific parameters used for inpainting may need to be adjusted depending on the characteristics of the image being processed.
% Read image and display it
img = imread('image.png');
imshow(img);
% Create a binary mask where the cracks are located
mask = img == 0;
% Inpaint the masked areas using the 'fast marching' method
inpaint = inpainting(img, mask, 'fast_marching');
% Display the inpainted image
imshow(inpaint);
Editor's note: moved from duplicate thread:
i want to restore the image but it is not showing any progress can you help me out
clc
clear all
img = imread('image.png');
figure(1)
imshow(img);
I=im2bw(img)
% I = rgb2gray(img);
figure(2)
imshow(I)
% Create a binary mask where the cracks are located
mask = I== 254;
% Inpaint the masked areas using the 'fast marching' method
inpaint = inpaintExemplar(I, mask);
figure(3)
% Display the inpainted image
imshow(inpaint);

1 Comment
DGM
on 11 Feb 2023
The text reads as if it were directly copied from an example or assignment. The mask generation is trivial nonsense that appears to simply be a placeholder for further work. Given that your code uses a function which isn't part of MATLAB or any of its toolboxes, and isn't on the File Exchange (that I can tell), nobody can actually run your example. If you're expected to generate the mask by some particular method covered in your studies, nobody else can know that.
This really looks like you just pasted your homework verbatim.
I posted a half-answer on your other version of this question.
Accepted Answer
More Answers (2)
Image Analyst
on 11 Feb 2023
0 votes
Honestly I'd just use the bandaid filter in Photoshop. It will do a better job than you. If you still want to do it, then try a modified median filter where you identify cracks (like they're brighter than the surrounding pixels) then replace them with the median filter in a window around the pixel, like I do in my attached salt and pepper denoising demos. You can adjust the threshold or try different segmentation methods if you want.
Akira Agata
on 11 Feb 2023
0 votes
Categories
Find more on Image Category Classification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!