Fast Version on a Gaussian Pyramid with K Nearest Search
This algorithm is a cut down version of the algorithm published in IEEE Transactions on Image Processing 1998. In this version, it has been rewritten for a single cpu machine. To maintain speed of synthesis, the update function pUpdateFn() has been set to return the maximum value. If this was modified to return a portion of the maximum value, then the synthesis would take longer, but there would be a gain in quality. If you do decide to modify the code, be careful, as I have not put in any safeguard checks. Best to fully understand the whole code, before modifying it.
This fast version implements a modification based on Ashikhmin's Synthesizing Natural Textures. As noted in his work, the L2 norm may not be the best measure to test for perceptual similarity between two neighbourhoods. Instead, we may note that if we are only taking pixels from the input image (and not sampling from a larger distribution), then when we iterate a respective pixel, we can be assured that each of its defined neighbours occur within the input image. Speed can be gained if, instead of doing a exhaustive search, we only sample from those pixels which have the same neighbour. In this algorithm I have modified Ashikhmin's approach by using my previous algorithm, and sampling from all pixels which have at least one of its neighbours the same colour as its respective neighbour of the pixel being iterated.
Recently there has been quite an influx of nonparametric sampling techniques for texture synthesis (,here is a brief list). This is because it has been the nonparametric models that have had the greatest success at synthesising arbitrary textures. This technique uses a multiscale approach, which has the advantage that only a small neighbourhood is required.
However the basis of the algorithm first appeared in:
Download Source Code | Copyright (C) 2002, by Rupert Paget, all rights reserved. |
The source code requires ImageMagick to be preinstalled. To compile the code, run gmake in the parent directory. There are two makefiles, one in parent directory, and in the src directory. If the code does not compile, both makefiles will need to be edited. I have written one for a sun (default) and one for an sgi machine, but I give no guarantees that they will work.
nonparaMRF_fast [-l levels] [-n neighOrder] [-s] [-t treeMax] [-c] [-x cols] [-y rows] [-m maskfile] [-h] texturefile
where
Default values are : levels = 256, neighOrder = 1, square = false, treeMax = 6, cyclic = false
These times were compiled on a distributed system of mainly SunBlades 100: 500 MHz, 256 MBytes RAM. The input textures were 128x128 pixel images, and the output synthesised textures were 256x256 pixel images. The run times are basically dependent on output image size and the type of input texture. This is due to the nearest neighbour search algorithm used in the code. If the input texture is fairly uniform in colour, then the search algorithm will be more of an exhaustive search, and therefore more dependent on input image size. Time stamps are in "Days Hours:Minutes:Seconds".
Neighbourhood | # of Tests | Min Run Time | Max Run Time | Mean Run Time | Stdev Run Time |
---|---|---|---|---|---|
1 | 165 | 0 0:03:47 | 0 0:20:34 | 0 0:04:45 | 0 0:06:46 |
1 -c | 165 | 0 0:03:45 | 0 0:12:58 | 0 0:04:35 | 0 0:01:26 |
1 -s | 165 | 0 0:01:42 | 0 0:09:23 | 0 0:02:17 | 0 0:00:59 |
1 -s -c | 165 | 0 0:01:43 | 0 0:09:53 | 0 0:02:19 | 0 0:00:59 |
2 | 165 | 0 0:01:43 | 0 0:08:38 | 0 0:02:17 | 0 0:00:51 |
2 -c | 165 | 0 0:01:43 | 0 0:07:28 | 0 0:02:20 | 0 0:00:58 |
2 -s | 165 | 0 0:01:52 | 0 0:31:54 | 0 0:04:42 | 0 0:07:57 |
2 -s -c | 165 | 0 0:01:51 | 0 0:38:09 | 0 0:05:04 | 0 0:08:15 |
3 | 165 | 0 0:01:44 | 0 0:17:32 | 0 0:02:31 | 0 0:01:35 |
3 -c | 165 | 0 0:01:43 | 0 0:07:01 | 0 0:02:15 | 0 0:00:51 |
3 -s | 165 | 0 0:01:59 | 0 1:44:45 | 0 0:12:05 | 0 0:19:34 |
3 -s -c | 165 | 0 0:01:58 | 0 1:49:56 | 0 0:13:28 | 0 0:22:08 |
4 | 165 | 0 0:01:45 | 0 0:10:54 | 0 0:02:41 | 0 0:01:34 |
4 -c | 165 | 0 0:01:45 | 0 0:10:54 | 0 0:02:46 | 0 0:01:32 |
4 -s | 165 | 0 0:02:13 | 0 4:47:03 | 0 0:27:17 | 0 0:46:45 |
4 -s -c | 165 | 0 0:02:08 | 0 4:20:26 | 0 0:30:18 | 0 0:52:10 |
Email Rupert Paget at: dr@rupertpaget.com
This site was proofread by
English Editing Experts.