
Show HN: Reorganize pixels of a painting into a smooth color palette using PCA - dontreact
https://github.com/ardila/paintingReorganize
======
dontreact
Shameless plug/relevant background: I did this in order to make a flyer for a
show I am playing with my band Congratulatinos in Oakland, CA on Dec. 17th
Band:
[http://congratulatinos.bandcamp.com/](http://congratulatinos.bandcamp.com/)
Event:
[https://www.facebook.com/events/661571907356009/](https://www.facebook.com/events/661571907356009/)

~~~
pavel_lishin
I opened a small PR - scipy was missing as a requirement (I'm guessing you
already had it installed, and didn't stick it in requirements.txt)

~~~
dontreact
thanks. right on all counts.

------
pavel_lishin
I think there's a bug in there that flipped a few columns - but I actually
really like the output better that way:
[http://imgur.com/RErXOF6](http://imgur.com/RErXOF6)

~~~
dontreact
That is weird. It decides to flip a column by summing up the vector distances
between the pixels in that column vs. the pixels in the previous column. I'm
wondering if that since there is so much gray in the painting, this causes a
large accumulation of error in gray vs. slightly different gray which
outweighs the orange vs gray.

I do know that euclidean distance in RGB space is not that great a metric for
perceptual similarity. Perhaps everything should be done in YUV instead? I
will try tonight. Thanks.

~~~
iverjo
I recommend you to try the LAB color space and to use delta E 94 [1] for
computing distances between colors in the color space

[1]
[https://en.wikipedia.org/wiki/Color_difference#CIE94](https://en.wikipedia.org/wiki/Color_difference#CIE94)

------
xbryanx
The colors in that image seem super bright compared to the original.

[https://www.moma.org/collection/works/79971?locale=en](https://www.moma.org/collection/works/79971?locale=en)

~~~
dontreact
The output for that version of the painting looks similar. I just image
searched for "kupka" and tried a few different results.

Result for your image: [http://imgur.com/fp9i8BP](http://imgur.com/fp9i8BP)

Do you think I should update the repo with this version?

~~~
xbryanx
I do, only because it's from the institution that actually owns the real
painting. Museums try pretty hard to get colors right on the digital images
that they put online. And since the project is about color, it seems like an
important detail. Thanks for being open to my nitpicking. Very cool project.

------
tomek_zemla
Made somewhat similar project by organizing pixels in three dimensional space
of HSL (hue saturation lightness) color model:
[http://www.pixelbox.com/colorclouds/](http://www.pixelbox.com/colorclouds/)

Note that this reduces identical pixels into one point in 3D space. The key
idea behind the experiment was to learn more about the palettes used by
painters.

------
binarymax
I love pixel sorting! I had seen it done by rows or cols before, but never the
whole thing, and the result is beautiful.

------
teaearlgraycold
I'm curious where the noise is coming from, as some pixels appear to be out of
place.

~~~
dontreact
Yes: it seems to be for colors where they are similar to two or more other
clusters of pixels. I imagine that these are just really hard to place without
seeming too out of place? Also probably has to do with the column by column
"greedy" approach that isn't really global.

------
throwaway049
In one Iain M Banks story, it is mentioned that a character was ordered not to
destroy a library, so he had all the paintings given the treatment provided by
this software and all the books cut up and arranged so that individual letters
were in alphabetical order.

------
pbhjpbhj
My first thought was "paintings don't have pixels"; but colour is quantised I
guess. I wonder how many pixels you need to get the same graduation between
color tones as the original image, presumably enough to provide atom level
resolution.

~~~
mistercow
I believe the term you want is "discretized", not "quantized". They're
quantized too, but that's about there being a finite number of shades rather
than a finite number of subdivisions of the image.

------
dweinus
As a graphic designer turned data scientist, that is the coolest poster art
backstory I have ever heard.

------
Houshalter
Are there any more examples?

~~~
dontreact
I just put up 3 more. Starry night turned out very nicely. Anything you'd like
to see in particular?

