views:

106

answers:

1

Hello,

I'm trying to come up with a way to distort an image similar to the example here: http://tinypic.com/r/16gn60o/7

The idea is to remove any hard lines in the original image. I would like the original image to be "about the same" not a hard swirl effect you see in some screensavers or anything like that.

Any pointers or idea would be great!

A: 

You could make a "stamp" that pushes pixels out radially. That is, precalculate a mapping (for a patch smaller than your image) that takes pixels from the center of the patch to a point a little further out, and have this displacement start at zero in the center, grow with the radius, but then get smaller as you approach the boundary of the patch so that it's zero at the edges. Then apply this deformation at random points around your image until you've covered the whole image.

Note that this will will actually sharpen the edges a bit, but make them not straight, like your example image. Note that in the example, the edges are actually more sharp and defined (see the edge of the dog's right ear for example), but just not straight, so I'm assuming this is what you mean by "hard".

tom10
You're correct, I don't mind sharp edges, just no straight ones. I'll try to implement something like this an see how it works. I'm still looking for an algorithm though. Ideally I could pass an x,y position into the algorithm and get a displacement from x and y back so I know how much to shift the pixel. I could iterate over the original image and place the pixels in the new position on a new image type of thing.
Justin808
Just to get the terminology right, I think what I suggest is an algorithm, and I guess what you want is a function. Although I think I could come up with such an animal, it would be a bit contrived, since the distortion that you want has a lot of non-local correlation, so to give it (x,y) and get a new position back, you'll need to build the correlation into the function. That is, it's just as easy to build the distortion map ahead of time and address it through a function. I'm not saying there's no reason to have such a function, but I don't understand the motivation at this point.
tom10
@tom10, I guess there really isn't a reason other than thats what i know... And as I delve into graphics like this, I'm finding out I don't know a lot. If I understand what you are suggesting is to create a function that given a x,y position will push everything out in a ring away from that point. Pixels closer to the center getting pushed out more than pixels at the edge of the ring? Take that and use it randomly over the image until the desired effect is reached?
Justin808
@tom10, If more of an explanation of what I'm trying to achieve would help... I'm trying to generate a heightmap for terrain. I'm creating a Voronoi diagram and some perlin noise. i'm taking 2/3 voronoi and 1/3 noise and adding them together. This is working great but I want to remove the straight edges from the voranoi diagram. From what I've been reading If i take the resulting image/data and use a perturbation filter on it similar to what the image i linked above shows, then i should be good. I'm just stuck on the how to do it part :)
Justin808
My apologies, but it seems that I'd need to do some type of full example for this to explain it, and I don't have time for that now. Basically, I suggest doing this as a two step process: 1) make a distortion map, then, 2) apply it to the image. For the type of distortion you want, you will find this easier than making a one-step function. To make the distortion map, start with an identity map, and then make a little function to warp a local region of it. Then apply this at random points around the map. Play with the shape of the local warping function until you have a look that you like.
tom10
For starters, I'd suggest a Gaussian warp, g(s) = e^-((x-x0)^2/s^2+(y-y0)^2/s^2), or the function I suggested earlier could get written g(s)-g(2s). Anyway, play around a bit with this. And just to be clear, I mean move each pixel (x,y) in a direction radially away form (x0,y0), by an amount given by g. (But if I get a chance, and remember to do it, I'll try to write up the code at some point.)
tom10
If you do get a chance I would like to see some code. I think I'm starting to understand this. Thanks for taking the time to help!
Justin808