Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i wish to give an effect to images, where the resultant image would appear as if we are looking at it through a textured glass( not plain/smooth)...please help me in writing an algo to generate such an effect
view the following link to see the type of effect i'm looking for
http://picasaweb.google.com/megha19sudan/ArtisticEffects#[^]

the first image is the original image and the second image is the output im looking for
Posted
Updated 7-Jan-10 22:05pm
v3

Do the answers to this post[^] help you?



EDIT (After the link with the example):
It looks like the pixels of the bounding areas of a color are getting moved with a certain offset inside a little circle.

Maybe you can try that, check the wide of a color and moving the pixels inside the "border - x(your distorsion range)" with a random offset (x + random, y + random) where random inside [-a, a] being "a" your distorsion level.
 
Share this answer
 
v2
Begin by creating a noise map with dimensions (width + 1) x (height + 1)that will be used displace the original image. I suggest using some sort of perlin noise so that the displacement is not to random.
Once we have the noise we can do something like this:

Image noisemap; //size is (width + 1) x (height + 1) gray scale values in [0 255] range
Image source; //source image
Image destination; //destination image
float displacementRadius = 10.0f; //Displacemnet amount in pixels
for (int y = 0; y < source.height(); ++y) {
    for (int x = 0; x < source.width(); ++x) {
        const float n0 = float(noise.getValue(x, y)) / 255.0f;
        const float n1 = float(noise.getValue(x + 1, y)) / 255.0f;
        const float n2 = float(noise.getValue(x, y + 1)) / 255.0f;
        const int dx = int(floorf((n1 - n0) * displacementRadius + 5f));
        const int dy = int(floorf((n2 - n0) * displacementRadius + 5f));
        const int sx = std::min(std::max(x + dx, 0), source.width() - 1); //Clamp
        const int sy = std::min(std::max(y + dy, 0), source.height() - 1); //Clamp
        const Pixel&amp; value = source.getValue(sx, sy);
        destination.setValue(x, y, value);
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900