Download the Processing code here: mresynth.tar.gz

Click here for more examples...
How it works:
mResynth populates a database consisting of all pixels in the image first, by linking the colors of the neighboring 8 pixels to the color of the center pixel. Then this database of possible transition values are used to synthesize a new image from scratch. For each pixel, the transition possibilities for the left pixel, top-left pixel, top pixel and top-right pixel(and their mirroring bottom counterparts) are separated in database. When a new pixel is being synthesized, mResynth first selects a candidate from the possible transition set of one of the neighboring pixels, then checks to see if that candidate is also in the transition set of the other neighboring pixels. If it finds a common one, that pixel is put into its place and the process repeats for the next pixel. So this actually means that, every 2x2 block and some of the 3x3 and bigger blocks do actually exist in the source image itself, and given enough time, this software can synthesize the original image by using the database of transition possibilities, but that is very very extremely unlikely to happen(probabilistically).
How to use:
Step 1) Download the processing code, then press export to create a jar file.(Actually, the jar file is already included in the archive)
Step 2) You need to use an indexed gif image for this to work. So you need to convert your image to a 256 color gif image. The reason behind this limitation is technical, if you use millions of colors, you need a very big image to make the probability tables work(as all relationships between pixels will probably be unique), and to process big images, you would need monster computers with many many gigabytes of ram, you'd also probably need to wait for days, if not for months, to synthesize a single image because of the technique employed here. You are free to use images with more colors, the program will not complain, but due to increasing memory and storage requirements, it may fail silently.
To convert your image to 256 color indexed gif with Gimp, open your image and go to Image --> Mode --> Indexed, select 256 colors and press ok. Then save your image as "Image.gif". This is important as the program will only look for a file called "Image.gif" as a source. You can of course easily change this in the source.
Step 3) Copy image.gif to the same folder with your jar file compiled in step 1.
Step 4) Launch the program from terminal with this command:
The -mx1024m flag sets the maximum amount of memory that the program is allowed to use. To use images bigger than 800x600, you will probably need the -mx1024m flag.
Step 4) When the program launches, you will see a blank window. Press "p" and wait for the program to populate the database, when it finishes, you should see the source image loaded in window. Then press "s" and wait until the synthesis is finished. The feedback numbers you see on console are the row numbers currently being processed. This may take some minutes.
The resulting files:
When the process is finished, you should see the resulting image in the program window, and you will notice two new files created by mResynth in the program folder. "result.png" and "defects.png". The defects.png file will have red pixels(255, 0, 0) on places where the process searching common colors for pixels in the transition tables reportedly had failed to find a suitable pixel color at that point within relationship to its neighbors. In such a condition, the program inserts a random pixel from the transition tables from only one of the neighboring pixels(it cheats). The results.png file does not have the red marks in it. Since there is no way to avoid this condition without going a few rows back and trying another set of permutations; instead of failing, the program inserts a less suitable pixel at that place, and its surroundings might also look awkward because of the broken probabilistic harmony. If you want to make your images "defect free", press the "b" key to synthesize the image instead of pressing "s". The "b" mode is the brute force mode, in where if the program gets stuck on a pixel, it goes 10 rows back and uses a new random permutation. This will take more time, and sometimes a non defective result might just not be possible without re-synthesizing the whole image. You need to be patient, or start over. Rotating the image might help too, as the program uses the outermost top, right and left pixel rows an columns as a seed for the initial calculations.
Final notes:
I'd really like to see the results for higher order markov chains but to achieve that goal for this amount of data, with this method, one would need a computer with ridiculously high memory and processing power. Well, maybe that is for another time...

