To solve this problem I moved to the hsv colour space which is the perfect environment were to perform such kind of analyses. To summarise: my package was stupid, it was unable to reasonate about relationship among colours avaiable. What was wrong with the palette employed? We can pick at least three answers: I clearly remember my feeling when the first palette came out of kmeans: it was thrilling, but the results were undeemebly poors. What we need to repeat here is that by applying the kmeans algo on the array we get a list of RGB colours, selected as the most representative of the ones available within the image. You can also read more about this algo and its inner rationales within R for data mining a data mining chrime book. Please refere to the How to build a color palette from any image with R and k-means algo post to get a proper explanation of this. Within tht post I devoted the right time to expose some theoretical reference to the kmeans algo and it application to images. This processing step was actually the first developed of the package and I already described it in a previous post. We now apply some statistical learning on the array, to select most representative colours and create an optimized palette. This will generate an array having for each point within the image both the cartesian coordinates and the R, G and B values of the related colours. To perform this transformation we use the readJPEG() function from Jpeg package: painting <- readJPEG(image_path) Within the matrix to each image pixel three numbers are associated:Īll those three attributes range from 0 to 255, as requested by the rules of the RGB colourspace ( find out more on the related RGB colourspace page on wikipedia). To do so we read the image file and convert it into a three multidimensional matrix. This first step involves transforming the image into an abstract object on which we can apply statistical learning. Reading a picture into the RGB colourspace – further sample colours to select the most “distant” ones. – remove too bright and too dark colours leveraging HSV colour system properties – apply kmeans algo on it and draw a sample of representative colours – convert into a three-dimensional RGB matrix The main idea behind paletteR code is quite simple: Here it is the code (you can donwload the picture from wikicommons visiting ): create_palette(image_path = "~/Desktop/410px-Piero_della_Francesca_046.jpg",Īs you see the palette drawn contains all the most representative colours, like the red of the carpets or the wonderful blue of San Giovanni Battista on the left of the painting. – make clear if we need a palette for quantitative or qualitative variables, using the _type_of_variable_ arg. – specify tcolorser of colours we want to draw specifying the _number_of_colours_ attribute – pass the full path to the image through the _image_path_ arg Install_github("andreacirilloac/paletter") Since paletteR is available only trough Github we have to install it using devtools: library(devtools) Let’s try to apply it on the “Vergine con il Bambino, angeli e Santi” before looking into its functional specification. The package extracts a custom number of representative colours from the image. PaletteR is a lean R package which lets you draw from any custom image an optimized palette of colours. This is where Paletter comes from: bring the Renaissance wisdom and beauty within the plots we produce every day. While I was looking at the painting I started, wondering how we moved from this wisdom to the ugly charts you can easily find within today’s corporate reports ( find a great sample on the WTF visualization website) If you see this painting you will find a profound of colours with a great equilibrium between different hues, the hardy usage of complementary colours and the ability expressed in the “chiaroscuro” technique. During my visit I was particularly impressed from one of them: “La Vergine con il Bambino, angeli e Santi”, by Piero della Francesca. This museum is full of incredible paintings from the Renaissance period. During a lunch break I was visiting the Pinacoteca di Brera, a 200 centuries old museum. I live in Italy, and more precisely in Milan, a city known for fashion and design events.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |