1
00:00:00,480 --> 00:00:02,370
This might seem a bit of an odd question,

2
00:00:02,400 --> 00:00:07,260
but have you ever been to an art museum and looked at the exhibition and thought

3
00:00:07,260 --> 00:00:08,093
to yourself,

4
00:00:08,550 --> 00:00:13,550
I think I could probably do this and don't really understand why it's considered

5
00:00:14,160 --> 00:00:16,880
art. Well, this is a piece of art

6
00:00:16,940 --> 00:00:21,320
by Goldschmied and Chiari called 'Where should we go dancing tonight?'.

7
00:00:22,130 --> 00:00:24,950
And it's meant to be a piece of concept art,

8
00:00:25,280 --> 00:00:30,110
but when the museum cleaners came here at the end of the day and looked at this

9
00:00:30,110 --> 00:00:35,110
mess of cigarette butts and shoes and random bottles,

10
00:00:35,600 --> 00:00:39,140
they thought it was rubbish and they promptly cleaned everything up.

11
00:00:39,590 --> 00:00:43,640
So this is what the exhibition looked like after the cleaners were done the next

12
00:00:43,640 --> 00:00:46,190
day. So to the museum's horror,

13
00:00:46,550 --> 00:00:51,550
their star exhibition gets cleared up and mistaken for rubbish.

14
00:00:52,880 --> 00:00:56,480
So I was talking to a friend and I said, well, you know,

15
00:00:56,540 --> 00:00:59,510
a lot of these modern art pieces, I could probably do it, right?

16
00:00:59,540 --> 00:01:03,680
We could probably get together, put some bottles on the floor, make a mess,

17
00:01:03,710 --> 00:01:07,070
call it art. And he told me, actually, no, you can't.

18
00:01:07,220 --> 00:01:10,820
And you should read this book called the $12 million stuffed shark.

19
00:01:11,360 --> 00:01:14,150
And it talks all about the economics of contemporary art.

20
00:01:14,210 --> 00:01:15,650
And it's a fascinating read.

21
00:01:15,680 --> 00:01:20,680
I've learned so much more about how contemporary art is priced and why they're

22
00:01:20,720 --> 00:01:25,670
priced the way they are. But it also led me to discover some pretty big,

23
00:01:25,700 --> 00:01:28,190
shocking discoveries. Like for example,

24
00:01:28,190 --> 00:01:33,190
the art piece that's referred to on the cover of the page is this shark.

25
00:01:33,920 --> 00:01:37,040
It's a shark that was fished off of the coast of Australia

26
00:01:37,370 --> 00:01:42,200
and then it was preserved in formaldehyde. But it was preserved really badly

27
00:01:42,200 --> 00:01:44,060
like they didn't use enough chemicals

28
00:01:44,090 --> 00:01:48,500
and the shark started going a bit green and a bit of gray in other places

29
00:01:48,500 --> 00:01:50,060
and it also started molding.

30
00:01:50,660 --> 00:01:55,660
But this moldy green shark was bought for $12 million.

31
00:01:56,510 --> 00:02:00,470
And this is not even the craziest piece. So for example,

32
00:02:00,470 --> 00:02:04,790
this diamond encrusted skull was reportedly sold for $50 million.

33
00:02:05,150 --> 00:02:07,130
And these butterfly wings

34
00:02:07,130 --> 00:02:12,130
which have been dissected and stuck to a canvas was sold for 8.5 million.

35
00:02:13,280 --> 00:02:15,920
So who exactly is this crazy man

36
00:02:15,950 --> 00:02:20,090
who's creating all of these pieces of art that's fetching these insane

37
00:02:20,090 --> 00:02:23,180
valuations? Well, it's a guy called Damien Hirst.

38
00:02:23,750 --> 00:02:28,460
And I think out of all his paintings, the craziest ones are the spot paintings,

39
00:02:28,790 --> 00:02:33,790
because it's literally spots of color that are organized randomly on a page. And

40
00:02:37,130 --> 00:02:38,060
check this out.

41
00:02:38,120 --> 00:02:43,120
This particular piece was sold for a whopping 1.275

42
00:02:43,700 --> 00:02:45,920
million pounds.

43
00:02:46,580 --> 00:02:48,950
So maybe like $1.5 million.

44
00:02:49,580 --> 00:02:53,120
It's insane for a painting of dots.

45
00:02:53,720 --> 00:02:57,770
But what I thought was even crazier is if you look at this painting,

46
00:02:57,800 --> 00:02:59,920
at least it's got quite few dots, right?

47
00:03:00,340 --> 00:03:04,150
You're getting your money's worth of dots. But look at this one!

48
00:03:04,550 --> 00:03:07,740
This is the same artist, Damien Hirst, and this painting,

49
00:03:07,770 --> 00:03:12,770
I counted only has 25 spots and this sold for half a million pounds.

50
00:03:15,390 --> 00:03:19,980
It's not even about the number of spots. So I personally still,

51
00:03:19,980 --> 00:03:22,560
as you can see, can't really work out contemporary art,

52
00:03:23,070 --> 00:03:28,070
but what I can work out is how to get Python code to crack Damien Hirst's color

53
00:03:29,520 --> 00:03:30,353
palette,

54
00:03:30,360 --> 00:03:35,360
and use those colors to generate a random canvas of spot paintings that look

55
00:03:39,540 --> 00:03:40,373
equally,

56
00:03:40,470 --> 00:03:44,670
if not more appealing than some of the original Damien Hirst.

57
00:03:45,180 --> 00:03:48,480
So this is what we're going to be making as our project.

58
00:03:49,080 --> 00:03:54,080
And we're going to be using that package, colorgram, to get hold of the color

59
00:03:54,810 --> 00:03:55,643
palette

60
00:03:55,800 --> 00:04:00,780
and then we're going to use those colors to create our own spot painting

61
00:04:01,020 --> 00:04:03,600
that's going to look like this. Firstly,

62
00:04:03,630 --> 00:04:08,630
we're going to be using a package called colorgram and colorgram is a library

63
00:04:10,560 --> 00:04:14,700
of code written in Python that lets you extract colors from images.

64
00:04:15,150 --> 00:04:18,149
So for example, if you take a look at this picture,

65
00:04:18,360 --> 00:04:23,360
once it was run through colorgram and 10 of the most common colors extracted,

66
00:04:24,690 --> 00:04:29,160
you end up with a palette that pretty much looks the same as the colors in the

67
00:04:29,160 --> 00:04:29,993
image.

68
00:04:30,360 --> 00:04:35,340
This is the example of how you would use this colorgram package.

69
00:04:35,760 --> 00:04:39,480
And in this case, they're extracting six colors from an image,

70
00:04:39,750 --> 00:04:44,670
so it basically takes two inputs, an image, and the number of colors.

71
00:04:45,510 --> 00:04:49,860
If we go into Google image search, and we search for a Hirst spot painting,

72
00:04:50,280 --> 00:04:53,940
you can see that there's a lot of spot paintings that this guy created.

73
00:04:54,480 --> 00:04:59,460
I want you to pick a painting with a color palette that you like, um,

74
00:04:59,790 --> 00:05:04,470
maybe something like this, or maybe a bit brighter like this one.

75
00:05:05,010 --> 00:05:05,850
But essentially,

76
00:05:05,910 --> 00:05:09,810
pick one of these images and then go ahead and download it.

77
00:05:10,260 --> 00:05:11,910
So save image.

78
00:05:12,600 --> 00:05:16,560
And then you're going to save that image as image.jpg, 

79
00:05:16,620 --> 00:05:20,820
so jpg. And then go ahead and hit save.

80
00:05:22,620 --> 00:05:26,070
Now go ahead and create a new PyCharm project.

81
00:05:26,130 --> 00:05:30,090
I've called mine hirst-painting, you can call yours whatever you want.

82
00:05:30,870 --> 00:05:33,720
Now we're going to drag our newly downloaded image,

83
00:05:33,990 --> 00:05:38,640
image.jpeg into this project folder, hirst-painting.

84
00:05:39,210 --> 00:05:42,120
And it's going to ask you whether if you want to move the file from,

85
00:05:42,150 --> 00:05:46,020
in my case, the downloads folder to my hirst-painting project.

86
00:05:46,620 --> 00:05:49,470
So then we're going to agree and click refactor.

87
00:05:50,040 --> 00:05:54,600
So now this painting is inside my hirst-painting project,

88
00:05:54,990 --> 00:05:59,180
and I'm ready to go ahead and create a new file called main.py

89
00:05:59,570 --> 00:06:04,160
which is what I'm going to use to extract the colors from this image.

90
00:06:05,720 --> 00:06:06,920
Here's a challenge for you.

91
00:06:07,070 --> 00:06:10,790
See if you can figure out how to use this package,

92
00:06:10,820 --> 00:06:15,820
colorgram, using their project description here and using the example code.

93
00:06:16,880 --> 00:06:21,880
What you're aiming for is to be able to print out a list of all the colors

94
00:06:22,520 --> 00:06:27,520
extracted from the image and each item in the list to be a tuple that you

95
00:06:28,610 --> 00:06:29,443
create.

96
00:06:29,690 --> 00:06:34,690
So remember previously we saw how the turtle module likes to work with color

97
00:06:34,940 --> 00:06:38,900
tuples which are created with a amount of red,

98
00:06:39,200 --> 00:06:44,200
the amount of green and the amount of blue, all contained inside a tuple.

99
00:06:44,900 --> 00:06:47,990
This is the format that you're going to try and get your data into.

100
00:06:48,340 --> 00:06:50,720
Might take a little bit of wrangling and a little bit of thought,

101
00:06:50,990 --> 00:06:54,440
but just before you get started, here's a quick heads up.

102
00:06:54,980 --> 00:06:59,630
I noticed that when I was testing this on repl.it and when I searched for color

103
00:06:59,630 --> 00:07:01,880
gram in the packages,

104
00:07:02,060 --> 00:07:06,560
I couldn't actually find the package to install into the project.

105
00:07:06,980 --> 00:07:10,790
So this is another good reason for using PyCharm.

106
00:07:11,120 --> 00:07:15,320
It just gives you all the professional tools and it has access to all the things

107
00:07:15,320 --> 00:07:18,830
that you need. So pause the video and complete this challenge.

108
00:07:20,870 --> 00:07:24,260
All right. So we know that in order to use external packages,

109
00:07:24,290 --> 00:07:28,010
ones that weren't installed with the Python standard library,

110
00:07:28,340 --> 00:07:33,340
we have to first install the package. To install a package

111
00:07:33,410 --> 00:07:38,000
we go to our preferences and then we select our project

112
00:07:38,450 --> 00:07:40,700
and then we go to our project interpreter.

113
00:07:41,240 --> 00:07:44,720
Now we click the plus button and we search for colorgram.

114
00:07:45,500 --> 00:07:49,250
And there it is. Now let's go ahead and install the package.

115
00:07:49,640 --> 00:07:54,470
And once that's installed successfully, then we can close all of this and click

116
00:07:54,500 --> 00:07:58,400
okay. Now that we've got our package,

117
00:07:58,430 --> 00:08:01,910
we can actually import it. So we'll import colorgram,

118
00:08:02,780 --> 00:08:07,780
and we can use the method that's described here called cologram.extract in

119
00:08:10,160 --> 00:08:15,050
order to get ahold of six colors. Now, if we want more colors,

120
00:08:15,620 --> 00:08:18,830
for example, in this image, that's probably a good 30 colors.

121
00:08:18,920 --> 00:08:23,060
So let's go ahead and extract 30 colors from this image.

122
00:08:23,360 --> 00:08:27,320
But of course our image is not called sweet_pic.jpg.

123
00:08:27,440 --> 00:08:29,870
Ours is actually called image.jpg.

124
00:08:30,320 --> 00:08:35,150
So let's go ahead and rename this image so that it matches with our file.

125
00:08:35,630 --> 00:08:40,520
And remember that your image has to be at the same level as your main.py for

126
00:08:40,520 --> 00:08:42,380
this kind of code to work.

127
00:08:42,590 --> 00:08:46,820
So make sure that you've got it inside the hirst-painting project folder, on the

128
00:08:46,820 --> 00:08:48,980
same indentation level as main.

129
00:08:49,400 --> 00:08:54,260
Now let's go ahead and print out our colors that are generated.

130
00:08:54,710 --> 00:08:58,620
And remember that when you hit run, this process might take a little while.

131
00:08:59,100 --> 00:09:02,370
And the author of the library says that for a

132
00:09:02,370 --> 00:09:07,170
512 by 512 image, it takes about 0.6 of a second.

133
00:09:07,770 --> 00:09:10,980
Obviously, if the image is larger, it'll probably take a bit longer.

134
00:09:11,580 --> 00:09:15,720
Let's go ahead and hit run and see what we get.

135
00:09:17,070 --> 00:09:19,350
Once the process is finished,

136
00:09:19,380 --> 00:09:24,380
you can see it's created some colors and these colors are in a list and it's got

137
00:09:26,730 --> 00:09:31,730
some different formats for the color. To understand that we have to go back to

138
00:09:32,280 --> 00:09:33,720
our documentation.

139
00:09:34,260 --> 00:09:38,610
You can see that the color that's extracted can either be a RGB color

140
00:09:38,640 --> 00:09:42,120
which is what we're interested in, or an HSL color

141
00:09:42,330 --> 00:09:44,130
which is not quite what we want.

142
00:09:44,610 --> 00:09:49,610
So let's go ahead and write a for loop that taps into each of those colors.

143
00:09:53,750 --> 00:09:56,210
So for color in colors,

144
00:09:56,810 --> 00:10:01,810
let's go ahead and create a new list called rgb_colors,

145
00:10:04,700 --> 00:10:09,470
and we'll just leave it as an empty list. And then for each of these colors,

146
00:10:09,530 --> 00:10:14,530
we're going to add to our rgb_colors by appending.

147
00:10:15,440 --> 00:10:19,550
And the thing we're going to pend is each of these individual color objects,

148
00:10:19,970 --> 00:10:22,400
and then we're going to get the RGB value.

149
00:10:23,240 --> 00:10:25,820
And once this process is done,

150
00:10:26,120 --> 00:10:29,330
then let's go ahead and print our RGB colors.

151
00:10:30,500 --> 00:10:35,480
So now you can see we've got a whole bunch of RGB colors with r equals what, g

152
00:10:35,480 --> 00:10:37,130
equals what and b equals what,

153
00:10:37,430 --> 00:10:41,870
but this is not quite the format that we need it in order to use it inside the

154
00:10:41,870 --> 00:10:45,380
turtle. We actually have to go one step further.

155
00:10:45,830 --> 00:10:47,900
We have to create a r

156
00:10:48,110 --> 00:10:53,110
which is from the color.rgb.r

157
00:10:55,520 --> 00:10:59,180
and then we repeat this process for green

158
00:11:00,890 --> 00:11:02,090
and blue.

159
00:11:04,700 --> 00:11:09,700
And then we create our tuple by creating our new_color

160
00:11:10,850 --> 00:11:14,780
which is going to be equal to a tuple with a parentheses

161
00:11:14,810 --> 00:11:19,490
and then r, g and b. Finally,

162
00:11:19,490 --> 00:11:24,490
we're going to add to our rgb_colors by appending this new color.

163
00:11:25,910 --> 00:11:29,150
Now let's print our rgb_colors.

164
00:11:34,550 --> 00:11:35,600
And you can see

165
00:11:35,600 --> 00:11:40,600
we finally got it in the format that we need, a tuple with the r value, g value

166
00:11:41,600 --> 00:11:45,530
and b value that we can use in our project.

167
00:11:46,190 --> 00:11:50,990
Now we've managed to get the first part of the problem solved so we can go ahead

168
00:11:50,990 --> 00:11:55,990
and copy this entire list and paste it into our main.py.

169
00:11:58,270 --> 00:12:01,540
I recommend actually testing out these colors

170
00:12:01,840 --> 00:12:04,780
using the w3schools RGB tool.

171
00:12:05,050 --> 00:12:09,760
Go ahead and paste your color to replace this current tuple here.

172
00:12:10,180 --> 00:12:14,230
Make sure that you still got that word rgb there, and then hit enter

173
00:12:14,680 --> 00:12:18,190
and it will insert each of these values into the r, g and b.

174
00:12:18,640 --> 00:12:22,030
So you can see the first color we got is actually a shade of white,

175
00:12:22,030 --> 00:12:24,100
so probably one of the backgrounds.

176
00:12:24,730 --> 00:12:28,630
So we can go ahead and delete that one because we're not going to be painting

177
00:12:28,630 --> 00:12:31,090
the background in our own. It's just going to be white.

178
00:12:31,510 --> 00:12:36,310
Now let's check the next one. As you can see, the closer the numbers are to

179
00:12:36,340 --> 00:12:40,450
255, the more likely it is that it's a shade of white.

180
00:12:40,840 --> 00:12:45,280
So this one is probably one of the other background colors in this image

181
00:12:45,490 --> 00:12:48,730
so we can delete that one as well. And finally,

182
00:12:48,730 --> 00:12:52,570
this last one is probably going to be also quite white-ish,

183
00:12:53,020 --> 00:12:58,020
and we can probably delete that one too. This one because of the blue that's

184
00:12:58,810 --> 00:13:03,580
109 I'm going to be pretty sure that this is actually a real color.

185
00:13:04,270 --> 00:13:06,370
And there we go, we get this kind of sand color,

186
00:13:06,910 --> 00:13:10,690
which looks very similar to some of these colors that we see on here.

187
00:13:11,080 --> 00:13:13,060
So we can presume that the rest of these,

188
00:13:13,120 --> 00:13:17,770
because they're sampled by the frequency of occurrence, are probably going to be

189
00:13:17,770 --> 00:13:20,290
real colors that we can put into our painting.

190
00:13:20,770 --> 00:13:24,340
Let's save this list as our color_list,

191
00:13:27,070 --> 00:13:32,070
and we can comment out the rest of this code because we don't need to run this

192
00:13:32,110 --> 00:13:33,970
computation every single time.

193
00:13:34,240 --> 00:13:39,240
We just want to extract the colors and then you can delete or comment out the

194
00:13:39,490 --> 00:13:43,030
colorgram related code. In the next lesson,

195
00:13:43,060 --> 00:13:47,230
we're going to be using this color list to create our Hirst painting.

196
00:13:47,650 --> 00:13:49,210
So for all of that and more, I'll see you there.

