Not logged in, Join Here! or Log In Below:  
News Articles Search    

Submitted by Jeff Lee, posted on June 05, 2001

Image Description, by Jeff Lee

This is a screenshot of a small C++ app I wrote for a final project over at Johns Hopkins University. Its a demonstration of texture synthesis given source images (The 3 small images in the upper left) and a "blend" image (The grayscale images in the center column). The algorithm I used for synthesis is based on the paper "Synthesizing Natural Textures" by Michael Ashikhmin ( . Whereas the original algorithm allowed for only one source image, the modifications allow for 2 independent source images to be used in texture syntehsis.

Here's the genearl idea of the algorithm. The output texture is created in scan line order left to right, top to bottom. At each destination pixel in the output texture the algorithm looks at its surrounding neighborhood of pixels and computes the best match (L2 norm) from each source. So it computes 2 norms for each pixel, one from source 1 and one from source 2. Typically the one with the lowest norm would be placed at the destination pixel. However, we have the blend image.

The blend image is something like a weighting between the norms. 0 (black) represents 100% source 1, 0% source 2 and 255 (white) represents the inverse. As the blending comes closer to 128 the weighting becomes 50/50. The blend image is how we can influence what the output texture looks like, as seen in the happy face.

The interface to this sucker is really rough. Its a barebones MFC app with some functionality to read/write PPM files and of course to generate the texture. The results are decent, but could do a little better. The main difficulty seem to be getting the source images to look right toghether on the output texture. Also very important is to have a believable blend. For some reason I don't imagine happy faces occuring in nature =)

Image of the Day Gallery


Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

June 05, 2001, 03:38 PM

Allthough a smiley wouldnt look to natural in the nature, the blends actually look quite natural, nice!


June 05, 2001, 03:46 PM

Very cool! nice job


June 05, 2001, 04:06 PM

Can you save those images too, or do you just present the results... also, may I have a copy of it?



June 05, 2001, 04:11 PM

Now don't blend'em yourself but output this as sourcecode / script-file for a shader-language, and it's actually usable in-game!

Keep up the cool stuff,


June 05, 2001, 04:19 PM

Have you ever done any small demo-ish stuff?

zed zeek

June 05, 2001, 06:13 PM

i take it youre doing the blending yourself in software. something i recommend everyone to do to understand blending better i know it help my understanding. btw i have a very similar extenion on me site (with source) for ppl who are interested 'nv_texcombine4' extension it blends 2 textures together based on the colour of a third (greyscale)

George Ziniewicz

June 05, 2001, 09:32 PM

Nice texture blending, I need to write me one of those combiners, I do procedural textures all the time.

I agree it is very important to understand blending.

I write my OpenGL apps with on-screen popup sliders/key controls where I can shift through all of the src & dst blending operations on arbitrary scene elements and see the effects interactively.

I am often completely and pleasantly surprised what I find with some of the modes.

It has to be seen to be "understood", and differently for every single effect you are trying to achieve.



June 05, 2001, 10:38 PM

I've noticed that it's not a true blend but a sort of sampling frequency blend. How do you blend?

Also, what are you planning to do with this? Can I have a copy of the app? :-)



June 06, 2001, 01:55 AM

We're actually doing this kind of blending in realtime on the Xbox game i'm working on.. It's pretty cool and we get a lot of variation in all our textures, and saves memory!


June 06, 2001, 03:02 AM

You know, statistically speaking, the probability of seing a happy face in nature is probably just a good as seing any of the other textures you've done above.

Nature has a way of building structure on many different levels (you all know this already - it's fractals). Noise with variations. And I'd bet that walking around in nature for half an hour, you could find several happy face-like structures.

Dom Penfold

June 06, 2001, 11:10 AM

>And I'd bet that walking around in nature for half an hour, you could find several happy face-like structures.

Depends how many happy people you meet on your walk I guess...


June 06, 2001, 11:20 AM



June 06, 2001, 11:43 AM

>>And I'd bet that walking around in nature for half an hour, you could find several happy face-like structures.

>Depends how many happy people you meet on your walk I guess...

More like how many magic mushrooms you consumed before going for the walk... =]


June 06, 2001, 04:19 PM

I love deadlines


June 06, 2001, 05:24 PM

I am surrounded by idiots.

No, not really.



June 06, 2001, 05:46 PM

MCBaxton - are you hitting on me..?


June 06, 2001, 07:48 PM

ask him if he likes long walks on the beach.


June 07, 2001, 02:05 PM

Happy faces in nature actually do happen. One good example of this is the "smiley face crater" on Mars - yes, there's actually a crater which looks like a smileyface. :) I'm sure one of the many astronomy geeks here could find a link to a picture of it.


June 19, 2001, 04:07 PM

Is the crater you are talking about? :) Anyways your blending thing looks very cool, are you going to release the source or something? That would be very helpful.

This thread contains 19 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.