1
00:00:00,450 --> 00:00:07,080
And welcome to Section 37, where we take a look at the painting function in open copy that we're going

2
00:00:07,080 --> 00:00:09,290
to use to restore a damaged photo.

3
00:00:09,510 --> 00:00:15,600
So let's open this notebook and Ludo libraries and immature function and downloaded images that we're

4
00:00:15,600 --> 00:00:16,950
going to use in this project.

5
00:00:17,430 --> 00:00:19,350
We're not loading any models externally.

6
00:00:19,350 --> 00:00:23,040
This time we're using Earth open the function directly.

7
00:00:23,040 --> 00:00:25,470
That's part of the library called in paint.

8
00:00:26,190 --> 00:00:28,350
So let's take a look at what we what we're doing.

9
00:00:28,860 --> 00:00:33,360
So for this, for this to work, let's take a look at what the damage photo looks like.

10
00:00:33,810 --> 00:00:37,290
So we have this damaged photo of Abraham Lincoln.

11
00:00:37,650 --> 00:00:42,660
You can see this is in an image that basically takes the kind of distracts you from the actual image

12
00:00:42,660 --> 00:00:43,200
itself.

13
00:00:43,800 --> 00:00:50,010
So we want to find a way to remove this crease in a way that it looks like it wasn't artificially removed.

14
00:00:50,550 --> 00:00:52,410
And you know, it looks nice.

15
00:00:52,410 --> 00:00:54,300
It looks like it's a seamless, corrected image.

16
00:00:54,930 --> 00:00:58,980
So what we need to do, we need to basically create a mask.

17
00:00:59,100 --> 00:01:05,640
And the mask we're creating here, which I did using windows pins, I believe, is just you draw a line

18
00:01:05,640 --> 00:01:06,990
across the crease here.

19
00:01:07,050 --> 00:01:09,030
So it wasn't typically done, in my opinion.

20
00:01:09,130 --> 00:01:16,350
I did make some mistakes, but we use dilation to increase the pixels to decrease the thickness of this

21
00:01:16,350 --> 00:01:17,160
line afterward.

22
00:01:17,220 --> 00:01:19,530
So it does cover all of the line here.

23
00:01:20,430 --> 00:01:22,620
So we have this mess that we created here.

24
00:01:23,220 --> 00:01:26,350
So this mess, we would crush all the mass to get it here.

25
00:01:26,760 --> 00:01:31,060
You can see there are some white lines in the image here that also show up.

26
00:01:31,110 --> 00:01:32,790
I didn't actually draw a mask on this.

27
00:01:33,180 --> 00:01:35,640
These are just sort of the whitish lines in the image.

28
00:01:36,060 --> 00:01:37,890
So actually, no, sorry, I didn't.

29
00:01:38,190 --> 00:01:40,320
It looks like I did draw a line under this as well.

30
00:01:40,770 --> 00:01:43,650
So we have those lines here, so we threshold.

31
00:01:43,950 --> 00:01:45,330
We do a binary Treasure Island.

32
00:01:45,780 --> 00:01:51,030
So everything outside of those lines is black, and everything along those lines are white, mostly.

33
00:01:51,420 --> 00:01:53,250
But you can see it's quite spotty.

34
00:01:53,250 --> 00:01:54,180
It's quite patchy.

35
00:01:54,690 --> 00:01:58,110
So we need to use dilation to enhance the thickness of those.

36
00:01:58,590 --> 00:02:02,370
So we use them dilation to bulk and flatten those lines up.

37
00:02:02,700 --> 00:02:05,940
And then what we do, we take the stylized mask.

38
00:02:05,940 --> 00:02:09,810
We take the image you can see in this important function.

39
00:02:09,810 --> 00:02:17,670
Here we do take the image, the input image, the mask of these some parameters in the in brain function

40
00:02:17,670 --> 00:02:20,250
that allows you to control how much you want.

41
00:02:20,880 --> 00:02:23,250
This is an algorithm we're going to use to to leave one.

42
00:02:24,000 --> 00:02:28,770
I'm not sure there are others built into Open Sea V. But you can check the documentation to see there's

43
00:02:28,770 --> 00:02:32,070
always a lot of enhancement enhancements with different versions of OpenCV.

44
00:02:32,580 --> 00:02:38,450
So they may have other ones right now, and it gives you the output, which is a restored image.

45
00:02:38,460 --> 00:02:45,180
So let's run all of this code because before we were looking at code that was previously run and saved.

46
00:02:45,300 --> 00:02:46,890
So this is a restored image.

47
00:02:47,550 --> 00:02:50,610
This looks really, really good, in my opinion.

48
00:02:51,360 --> 00:02:54,380
You can see that it does have some smudges.

49
00:02:54,390 --> 00:02:59,550
It doesn't look perfect to be done here can still see the line, but this part of the image is very

50
00:02:59,550 --> 00:02:59,730
well.

51
00:02:59,730 --> 00:03:01,310
Then his hairline.

52
00:03:01,320 --> 00:03:06,030
You can still see a faint bit of the line here, but it looks really well done.

53
00:03:06,030 --> 00:03:08,040
It looks almost seamless, almost perfect.

54
00:03:08,400 --> 00:03:11,880
And those vertical white lines here are also totally removed.

55
00:03:12,240 --> 00:03:19,230
Let's take a look at the original image and you can compare and you can see how distracting these little

56
00:03:19,230 --> 00:03:20,550
pieces were and these lines.

57
00:03:21,060 --> 00:03:23,910
So that's how we used to in paint function.

58
00:03:24,450 --> 00:03:26,070
So I hope you enjoyed this lesson.

59
00:03:26,350 --> 00:03:32,700
Now we're going to move on to removing and adding noise to images and fixing contrast with histogram

60
00:03:32,700 --> 00:03:33,450
equalization.

61
00:03:33,780 --> 00:03:39,690
It's just a more computational photography type algorithms, so I'll see you in the next lesson.

62
00:03:39,930 --> 00:03:40,350
Thank you.
