Mathematica, 100%, 141 bytes
Well, this feels more than a little like cheating. It's also incredibly slow as well as being very silly. Function f sees roughly ...
Java - GUI with progressive randomized transformation
I tried a LOT of things, some of them very complicated, then I finally came back to this relatively-simple code:
This is an implementation of the Object Removal by Exemplar-Based Inpainting algorithm developed by A. Criminisi, P. Perez (Cambridge Microsoft Research Ltd.) and K. Toyama (Microsoft) [X]. This algorithm is targeted at high-information images (and video frames) and aims to be the balance between structural reconstruction and ...
Python + scipy + scikit-image, weighted Poisson disc sampling
My solution is rather complex. I do some preprocessing on the image to remove noise and get a mapping how 'interesting' each point is (using a combination of local entropy and edge detection):
Then I choose sampling points using Poisson disc sampling with a twist: the distance of the circle is ...
Perl, with Lab color space and dithering
Note: Now I have a C solution too.
Uses a similar approach to aditsu's, (choose two random positions, and swap the pixels at those positions if it would make the image more like the target image), with two major improvements:
Uses the CIE Lab* color space to compare colors — the Euclidean metric on this space is a ...
C: 3863 1144 1023 999 942 927
The original solution saves 2 pnm files per run (one with g appended, before dithering). Because the dithering wasn't beautiful for the first few lines, there is a hack in place to render more lines than needed, and crop during output.
The golfed solution has a simpler dithering and saves only the dithered image.
(no warnings ...
The idea is simple: Every pixel has a point in the 3D RGB space. The goal is matching each a pixel of the source and one of the destination image, preferably they should be 'close' (represent the 'same' colour). Since they can be distributed in pretty different ways, we cannot just match the nearest neighbour.
Let n be an integer (small, 3-...
Live demo | GitHub repository
How to use
Reload the page for a new random image. If you want to feed in a particular seed, open your browser's console and call drawScreen(seed). The console should display the seed used on load.
I haven't really tested this on a lot of platforms, so let me know if it doesn't work for you. Of ...
My approach is quite slow, but I'm very happy with quality of the results that it gives, particularly with respect to preserving edges. For example, here's Yoshi and the Cornell Box with just 1000 sites each:
There are two main parts that make it tick. The first, embodied in the evaluate() function takes a set of candidate site locations, sets the ...
Python 2.7 (with PIL) - No Pseudorandomness
I break the image into 2 by 2 blocks (ignoring the remainder) and rotate each block by 180 degrees, then I do the same with 3 by 3 blocks, then 4, etc. up to some parameter BLKSZ. Then I do the same for BLKSZ-1, then BLKSZ-2, all the way back down to 3, then 2. This method reverses itself exactly; the unscramble ...
Java, 93.9% 100%
This works by determining the row contrast in the upper and lower part of the image. I assume that the contrast in the bottom half of the image is bigger for 2 reasons:
the 4 legs are in the bottom part
the background in the upper part will be blurred because it is usually the out-of-focus-area
I determine the contrast for each row by ...
I've improved my method by adding actual compression. It now operates by iteratively doing the following:
Convert the image to YUV
Downsize the image preserving the aspect ratio (if the image is color, the chroma is sampled at 1/3 the width & height of the luminance)
Reduce the bit depth to 4 bits per sample
Apply median prediction to the image, making ...
Python, Score: 24 16
This solution, like Falko's one, is based on measuring the "foreground" area and dividing it by the average grain area.
In fact, what this program tries to detect is the background, not so much as the foreground.
Using the fact that rice grains never touch the image boundary, the program starts by flood-filling white at the top-...
IDL, adaptive refinement
This method is inspired by Adaptive Mesh Refinement from astronomical simulations, and also Subdivision surface. This is the kind of task that IDL prides itself on, which you'll be able to tell by the large number of builtin functions I was able to use. :D
I've output some of the intermediates for the black-background yoshi test ...
Edit Changing the way you fill the coordinates array you can have different patterns - see below
Do you like this kind of pattern?
Random swap exactly one time all pixels in upper half with all pixels in lower half.
Repeat the same procedure for unscrambling (bonus).
Python - A theoretically optimal solution
I say theoretically optimal because the truly optimal solution is not quite feasible to compute. I start off by describing the theoretical solution, and then explain how I tweaked it to make it computationally feasible in both space and time.
I consider the most optimal solution as the one yielding the lowest total ...
C, arbitrary blurring, easily reversible
Late to the party. Here is my entry!
This method does a scrambling blur. I call it scramblur. It is extremely simple. In a loop, it chooses a random pixel and then swaps it with a randomly chosen nearby pixel in a toroidal canvas model. You specify the maximum distance defining what "nearby pixel" means (1 means ...
This is a simple interpolation approach. The idea is first mirroring what is on each side of the patch. Then those mirror image pixels are interpolated by how close they are to the corresponding edge:
The tricky part was finding a nice interpolation weights. After some playing around I came up with a rational function that is zero on all edges ...
Bonus 1: Self inverse: repeating restores the original image.
Optional key image: original image can only be restored by using the same key image again.
Bonus 2: Producing pattern in the output: key image is approximated in the scrambled pixels.
When bonus 2 is achieved, by using an additional key image, bonus 1 is not lost. The program is still ...
Full of deep, twisting undergrowth, this is a forest not easily traversed.
It's basically a fractal random walk with slowly shrinking, twisty vines. I draw 75 of them, gradually changing from white in the back to black up front. Then I dither the whole thing, shamelessly adapting Averroes' code here for that.
Golfed: (Just because ...
C# Winform - Visual Studio 2010
Edit Dithering added.
That's my version of random-swap algorithm - @hobbs flavour. I still feel that some sort of non-random dithering can do better...
Color elaboration in Y-Cb-Cr space (as in jpeg compression)
Two phase elaboration:
Copy of pixel from source in luminance order. This already gives a good image, but ...
Edit: Just realized that you can actually sharpen the source with ImageFilter to make the results more well-defined.
Rainbow -> Mona Lisa (sharpened Mona Lisa source, Luminance only)
Rainbow -> Mona Lisa (non-sharpened source, weighted with Y = 10, I = 10, Q = 0)
Mona Lisa -> American Gothic (non-sharpened source, Luminance only)
Mona Lisa -> ...
Python 2 with PIL (Gallery)
from __future__ import division
from PIL import Image
import random, math, time
from collections import Counter, defaultdict, namedtuple
Configure settings here
INFILE = "spheres.png"
OUTFILE_STEM = "out"
P = 30
N = 300
OUTPUT_ALL = True # Whether to output the image at ...
Python 3, 91.6%
-edited with the new test cases
set filename to the goat picture you wish to test.
It uses a kernel to make an image top/bottom asymmetric.I tried the sobel operator, but this was better.
from PIL import Image, ImageFilter
Works by dividing the image into regions recursively. I try to divide regions with high information content, and pick the dividing line to maximize the difference in color between the two regions.
Each division is encoded using a few bits to encode the dividing line. Each leaf region is encoded as a single color.
Encoding requires numpy, SciPy and scikit-image.
Decoding requires only PIL.
This is a method based on superpixel interpolation. To begin, each image is divided into 70 similar sized regions of similar color. For example, the landscape picture is divided in the following manner:
The centroid of each region is located (to the nearest raster point on ...