WEBVTT

0
00:00.230 --> 00:06.050
This might seem a bit of an odd question, but have you ever been to an art museum and looked at the

1
00:06.050 --> 00:13.430
exhibition and thought to yourself, "I think I could probably do this, and I don't really understand why

2
00:13.430 --> 00:14.780
it's considered art."

3
00:15.050 --> 00:21.590
Well, this is a piece of art by Goldschmied and Chiari called, "Where Should We Go Dancing Tonight?"

4
00:21.800 --> 00:25.010
And it's meant to be a piece of concept art,

5
00:25.010 --> 00:31.820
but when the museum cleaners came here at the end of the day and looked at this mess of cigarette butts

6
00:31.820 --> 00:39.290
and shoes and random bottles, they thought it was rubbish, and they promptly cleaned everything up.

7
00:39.290 --> 00:44.090
So this is what the exhibition looked like after the cleaners were done the next day.

8
00:44.090 --> 00:52.430
So to the museum's horror, their star exhibition gets cleared up and mistaken for rubbish.

9
00:52.580 --> 00:58.550
So I was talking to a friend and I said, well, you know, a lot of these modern art pieces, I could

10
00:58.550 --> 00:59.450
probably do it, right?

11
00:59.450 --> 01:04.670
We could probably get together, put some bottles on the floor, make a mess, call it art.

12
01:04.700 --> 01:07.070
And he told me, "Actually, no, you can't.

13
01:07.070 --> 01:10.970
And you should read this book called, the $12 million Stuffed Shark."

14
01:10.970 --> 01:14.090
And it talks all about the Economics of Contemporary Art.

15
01:14.090 --> 01:15.620
And it's a fascinating read.

16
01:15.620 --> 01:22.190
I've learned so much more about how contemporary art is priced, and why they're priced the way they are,

17
01:22.190 --> 01:26.900
but it also led me to discover some pretty big, shocking discoveries.

18
01:26.900 --> 01:33.830
Like, for example, the art piece that's referred to on the cover of the page is this shark.

19
01:33.830 --> 01:39.980
It's a shark that was fished off of the coast of Australia, and then it was preserved in formaldehyde,

20
01:40.070 --> 01:44.000
but it was preserved really badly, like they didn't use enough chemicals,

21
01:44.000 --> 01:50.300
and the shark started going a bit green and a bit of gray in other places, and it also started molding,

22
01:50.300 --> 01:56.120
but this moldy, green shark was bought for $12 million.

23
01:56.120 --> 01:59.390
And this is not even the craziest piece.

24
01:59.390 --> 02:04.910
So, for example, this diamond encrusted skull was reportedly sold for $50 million.

25
02:04.910 --> 02:12.990
And these butterfly wings, which have been dissected and stuck to a canvas, was sold for 8.5 million.

26
02:13.020 --> 02:20.040
So who exactly is this crazy man who's creating all of these pieces of art that's fetching these insane

27
02:20.040 --> 02:21.060
valuations?

28
02:21.450 --> 02:27.390
Well, it's a guy called Damien Hirst, and I think out of all his paintings, the craziest ones are

29
02:27.390 --> 02:36.440
the spot paintings, because it's literally spots of color that are organized randomly on a page.

30
02:36.440 --> 02:38.060
And check this out,

31
02:38.060 --> 02:49.190
this particular piece was sold for a whopping £1.275 million, so maybe like $1.5 million.

32
02:49.340 --> 02:53.390
It's insane for a painting of dots.

33
02:53.390 --> 02:59.240
But what I thought was even crazier is if you look at this painting, at least it's got quite a few

34
02:59.240 --> 03:00.020
dots, right?

35
03:00.050 --> 03:02.360
You're getting your money's worth of dots,

36
03:02.360 --> 03:04.130
but look at this one.

37
03:04.130 --> 03:06.590
This is the same artist, Damien Hirst,

38
03:06.590 --> 03:15.230
and this painting I counted only has 25 spots, and this sold for £0.5 million.

39
03:15.230 --> 03:21.590
It's not even about the number of spots, so I personally still, as you can see, can't really work

40
03:21.590 --> 03:22.550
out contemporary art.

41
03:22.940 --> 03:31.730
But what I can work out is how to get Python code to crack Damien Hirst's colour palette, and use those

42
03:31.730 --> 03:42.710
colours to generate a random canvas of spot paintings that look equally, if not more appealing, than

43
03:42.740 --> 03:44.870
some of the original Damien Hirst's.

44
03:44.870 --> 03:48.740
So this is what we're going to be making as our project.

45
03:48.800 --> 03:55.490
And we're going to be using that Package, colorgram to get hold of the color palette,

46
03:55.490 --> 04:02.450
and then we're going to use those colors to create our own spot painting that's going to look like this.

47
04:02.750 --> 04:11.450
Firstly, we're going to be using a package called colorgram, and colorgram is a library of code written

48
04:11.450 --> 04:14.870
in Python that lets you extract colors from images.

49
04:14.870 --> 04:21.920
So for example, if you take a look at this picture, once it was run through color gram and ten of

50
04:21.920 --> 04:28.580
the most common colors extracted, you end up with a palette that pretty much looks the same as the

51
04:28.580 --> 04:29.840
colors in the image.

52
04:30.200 --> 04:37.970
This is the example of how you would use this colorgram package, and in this case, they're extracting

53
04:37.970 --> 04:39.530
six colors from an image.

54
04:39.530 --> 04:44.900
So it basically takes two inputs an image, and the number of colors.

55
04:45.260 --> 04:51.140
If we go into Google image search and we search for a Hirst spot painting, you can see that there's

56
04:51.140 --> 04:54.200
a lot of spot paintings that this guy created.

57
04:54.230 --> 04:59.030
I want you to pick a painting with a color palette that you like.

58
04:59.150 --> 05:04.640
Maybe something like this, or maybe a bit brighter, like this one.

59
05:04.640 --> 05:09.950
But essentially, pick one of these images and then go ahead and download it.

60
05:09.950 --> 05:16.520
So save image, and then you're going to save that image as image.jpeg.

61
05:16.520 --> 05:21.080
So jpg, and then go ahead and hit Save.

62
05:22.280 --> 05:28.190
Now go ahead and create a new PyCharm project I've called mine hirst-painting.

63
05:28.190 --> 05:30.350
You can call yours whatever you want.

64
05:30.500 --> 05:38.870
Now we're going to drag our newly downloaded image, image.jpg into this project folder, hirst-painting.

65
05:38.870 --> 05:43.790
And it's going to ask you whether, if you want to move the file from, in my case, the downloads folder

66
05:43.790 --> 05:46.250
to my hirst-painting project.

67
05:46.310 --> 05:49.640
So then we're going to agree and click Refactor.

68
05:49.670 --> 05:54.710
So now this painting is inside my hirst-painting project,

69
05:54.710 --> 06:02.090
and I'm ready to go ahead and create a new file called main.py, which is what I'm going to use to extract

70
06:02.090 --> 06:04.310
the colors from this image.

71
06:05.570 --> 06:06.980
Here's a challenge for you.

72
06:07.010 --> 06:14.780
See if you can figure out how to use this package, colorgram, using their project description here and

73
06:14.780 --> 06:16.550
using the example code.

74
06:16.550 --> 06:24.350
What you're aiming for is to be able to print out a list of all the colors extracted from the image,

75
06:24.350 --> 06:29.390
and each item in the list to be a tuple that you create.

76
06:29.390 --> 06:37.220
So remember previously we saw how the turtle module likes to work with color tuples, which are created

77
06:37.220 --> 06:44.660
with an amount of red, the amount of green, and the amount of blue, all contained inside a tuple.

78
06:44.660 --> 06:48.140
This is the format that you're going to try and get your data into.

79
06:48.170 --> 06:50.930
It might take a little bit of wrangling and a little bit of thought.

80
06:51.200 --> 06:53.780
Pause the video and complete this challenge.

81
06:55.370 --> 06:55.940
All right.

82
06:55.940 --> 07:02.280
So we know that in order to use external packages, ones that weren't installed with the Python standard

83
07:02.280 --> 07:06.390
library, we have to first install the package.

84
07:06.720 --> 07:12.900
To install a package, we go to our Preferences and then we select our project,

85
07:12.900 --> 07:15.720
and then we go to our Project Interpreter.

86
07:15.720 --> 07:19.740
Now we click the plus button and we search for colorgram.

87
07:19.740 --> 07:21.420
And there it is.

88
07:21.450 --> 07:24.150
Now let's go ahead and install the package.

89
07:24.150 --> 07:30.060
And once that's installed successfully, then we can close all of this and click Okay.

90
07:30.930 --> 07:34.800
Now that we've got our package we can actually import it.

91
07:34.800 --> 07:36.960
So we'll import colorgram.

92
07:37.110 --> 07:46.410
And we can use the method that's described here called color gram.extract() in order to get hold of

93
07:46.410 --> 07:47.460
six colors.

94
07:47.490 --> 07:53.520
Now, if we want more colors, for example, in this image there's probably a good 30 colors,

95
07:53.520 --> 07:57.870
so let's go ahead and extract 30 colors from this image,

96
07:57.870 --> 08:02.160
but of course our image is not called, sweet_pic.jpg,

97
08:02.190 --> 08:04.800
ours is actually called image.jpg.

98
08:04.800 --> 08:10.110
So let's go ahead and rename this image so that it matches with our file.

99
08:10.110 --> 08:17.160
And remember that your image has to be at the same level as your main.py for this kind of code to work.

100
08:17.160 --> 08:23.010
So make sure that you've got it inside the hirst-painting project folder on the same indentation level

101
08:23.010 --> 08:23.910
as main.

102
08:23.940 --> 08:29.130
Now let's go ahead and print out our colors that are generated.

103
08:29.130 --> 08:33.600
And remember that when you hit Run, this process might take a little while.

104
08:33.600 --> 08:41.280
And the author of the library says that for a 512 * 512 image, it takes about 0.66 of

105
08:41.280 --> 08:42.180
a second.

106
08:42.360 --> 08:45.990
Obviously, if the image is larger, it'll probably take a bit longer.

107
08:46.020 --> 08:50.760
Let's go ahead and hit Run and see what we get.

108
08:51.600 --> 09:00.300
Once the process is finished, you can see it's created some colors and these colors are in a list.

109
09:00.480 --> 09:03.600
And it's got some different formats for the color.

110
09:04.620 --> 09:08.700
To understand that we have to go back to our documentation.

111
09:08.700 --> 09:14.580
You can see that the color that's extracted can either be a RGB color, which is what we're interested

112
09:14.580 --> 09:19.080
in, or a HSL color, which is not quite what we want.

113
09:19.080 --> 09:25.770
So let's go ahead and write a for loop that taps into each of those colors.

114
09:28.260 --> 09:37.830
So 'for color in colors:' let's go ahead and create a new list called rgb_colors,

115
09:39.060 --> 09:41.730
and we'll just leave it as an empty list.

116
09:41.730 --> 09:49.890
And then for each of these colors, we're going to add to our rgb_colors by appending.

117
09:49.890 --> 09:54.450
And the thing we're going to append() is each of these individual color objects,

118
09:54.450 --> 09:57.270
and then we're going to get the rgb value.

119
09:57.690 --> 10:04.260
And once this process is done then let's go ahead and print our rgb_colors.

120
10:05.070 --> 10:11.610
So now you can see we've got a whole bunch of rgb_colors with r equals what, g equals what, and b equals

121
10:11.610 --> 10:11.940
what,

122
10:11.940 --> 10:14.940
but this is not quite the format that we need it.

123
10:14.940 --> 10:20.340
In order to use it inside the turtle, we actually have to go one step further,

124
10:20.340 --> 10:29.730
we have to create an r, which is from the color.rgb.r.

125
10:29.880 --> 10:34.230
And then we repeat this process for green.

126
10:35.370 --> 10:37.050
and blue.

127
10:39.060 --> 10:48.270
And then we create our tuple by creating our new_color, which is going to be equal to a tuple with

128
10:48.270 --> 10:49.500
a parentheses.

129
10:49.500 --> 10:52.740
And then r, g, and b.

130
10:53.400 --> 11:00.210
Finally, we're going to add to our rgb colors by appending this new_color.

131
11:00.360 --> 11:04.170
Now let's print our rgb colors,

132
11:08.940 --> 11:16.230
and you can see we've finally got it in the format that we need, a tuple with the r value, g value,

133
11:16.230 --> 11:20.460
and b value that we can use in our project.

134
11:20.880 --> 11:27.630
Now we've managed to get the first part of the problem solved, so we can go ahead and copy this entire

135
11:27.630 --> 11:32.640
list, and paste it into our main.py.

136
11:32.970 --> 11:39.630
I recommend actually testing out these colors using the W3 schools, RGB tool.

137
11:39.660 --> 11:44.670
Go ahead and paste your color to replace this current tuple here.

138
11:44.670 --> 11:50.610
Make sure that you've still got that word rgb there, and then hit Enter and it will insert each of

139
11:50.610 --> 11:53.100
these values into the r, g, and b.

140
11:53.100 --> 11:56.760
So you can see the first color we got is actually a shade of white.

141
11:56.760 --> 11:59.070
So it probably one of the backgrounds.

142
11:59.160 --> 12:01.980
So we can go ahead and delete that one,

143
12:01.980 --> 12:04.710
because we're not going to be painting the background in our dot,

144
12:04.710 --> 12:06.000
it's just going to be white.

145
12:06.000 --> 12:08.040
Now let's check the next one.

146
12:08.040 --> 12:15.270
As you can see, the closer the numbers are to 255, the more likely it is that it's a shade of white.

147
12:15.270 --> 12:20.070
So this one is probably one of the other background colors in this image.

148
12:20.070 --> 12:22.230
So we can delete that one as well.

149
12:22.230 --> 12:27.480
And finally, this last one is probably going to be also quite whitish,

150
12:27.480 --> 12:29.970
and we can probably delete that one too.

151
12:30.030 --> 12:34.290
This one because of the blue that's 109,

152
12:34.290 --> 12:38.640
I'm going to be pretty sure that this is actually a real color,

153
12:38.640 --> 12:39.450
and there we go.

154
12:39.450 --> 12:45.570
We get this kind of sand color, which looks very similar to some of these colors that we see on here.

155
12:45.570 --> 12:51.360
So we can presume that the rest of these, because they're sampled by the frequency of occurrence,

156
12:51.360 --> 12:55.290
are probably going to be real colors that we can put into our painting.

157
12:55.290 --> 12:59.280
Let's save this list as our color_list.

158
13:01.530 --> 13:08.340
And we can comment out the rest of this code, because we don't need to run this computation every single

159
13:08.340 --> 13:08.820
time,

160
13:08.820 --> 13:11.070
we just want to extract the colors,

161
13:11.070 --> 13:15.960
and then you can delete or comment out the colorgram-related code.

162
13:16.530 --> 13:22.170
In the next lesson, we're going to be using this color_list to create our hirst-painting.

163
13:22.170 --> 13:24.840
So for all of that and more, I'll see you there.