-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.m
76 lines (61 loc) · 2.32 KB
/
main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
clear;
close all;
clc;
% ---------- Image initialization --------------------------------
mask = im2double(imread(uigetfile('*.jpg; *.png; *.bmp', "Choose the mask")));
im = im2double(imread(uigetfile('*.jpg; *.png; *.bmp', "Choose the image to restore")));
inpainted_image = zeros(size(im));
%----------------Image Inpainting---------------------------------------
while 1
switch input("Choose one of the following options: \n " + ...
" 1) Interpolation \n " + ...
" 2) Liner Diffusion\n " + ...
" 3) Exit \n ")
case 1
% 1) Interpolation
%image inpainting for gray-scale images
if(size(im,3) == 1)
figure
[inpainted_image_L, inpainted_image_N] = interp_inpainting(im, mask);
else
%image inpainting for RGB images
[im_R_L, im_R_N] = interp_inpainting(im(:,:,1), mask);
[im_G_L, im_G_N] = interp_inpainting(im(:,:,2), mask);
[im_B_L, im_B_N] = interp_inpainting(im(:,:,3), mask);
inpainted_image_L = cat(3, im_R_L, im_G_L, im_B_L);
inpainted_image_N = cat(3, im_R_N, im_G_N, im_B_N);
end
figure
subplot(1,3,1);
imshow(im);
title('Image to be inpainted');
subplot(1,3,2);
imshow(inpainted_image_L);
title('Linear Interpolation');
subplot(1,3,3);
imshow(inpainted_image_N);
title('Nearest Neighbors Interpolation');
case 2
% 2) Linear PDE
if(size(im,3) == 1)
inpainted_image = PDE_inpainting(im,mask);
else
im_R_L = PDE_inpainting(im(:,:,1),mask);
im_G_L = PDE_inpainting(im(:,:,2),mask);
im_B = PDE_inpainting(im(:,:,3),mask);
inpainted_image = cat(3, im_R_L, im_G_L, im_B);
end
figure;
subplot(1,2,1);
imshow(im);
title("Image to Be Inpainted");
subplot(1,2,2);
imshow(inpainted_image);
title("PDE - Inpainted Image");
case 3
%exit
break
otherwise
disp('Unrecognized option');
end
end