Page 1 of 2

Zoom Blur

Posted: 2010-09-29T13:11:07-07:00
by 3DTOPO
Greetings,

Can anyone recommend an approach to creating a zoom blur type filter?

The effect is similar to a motion blur, but has a center and the blur are rays from the center.

Any suggestions would be greatly appreciated!


Thank you.

Re: Zoom Blur

Posted: 2010-09-29T13:57:17-07:00
by fmw42
see my zoomblur script at the link below. it iterates on zooming and blending. sorry it is a bash shell script. I don't know any of the IM APIs.

But IM now can do a variable blur, but I don't know if that is what you want. See http://www.imagemagick.org/Usage/mapping/#blur

Re: Zoom Blur

Posted: 2010-09-29T14:48:14-07:00
by 3DTOPO
Nice collection of scripts!

Do you know if it is possible to use the "convert" IM command from a C/C++ interface?

Re: Zoom Blur

Posted: 2010-09-29T15:53:39-07:00
by fmw42
3DTOPO wrote:Nice collection of scripts!

Do you know if it is possible to use the "convert" IM command from a C/C++ interface?

You should be able to do the equivalent in C or C++, but some functions especially in C++ may not be fully implemented. I really don't know much for sure. But usually if something is missing, the IM folks will generally add it depending upon their time availability.

Unfortunately, you would have to take all my commands and convert them from command line format using convert to your API calls. Convert itself as far as I know does not exist per se in those APIs. But again I am not an expert on any of them.

Re: Zoom Blur

Posted: 2010-09-30T08:59:18-07:00
by el_supremo
In the C API there is a function, ConvertImageCommand, which takes exactly the same arguments as the command line version.

Pete

Re: Zoom Blur

Posted: 2010-09-30T09:59:45-07:00
by fmw42
el_supremo wrote:In the C API there is a function, ConvertImageCommand, which takes exactly the same arguments as the command line version.

Pete
Pete,

Thanks for correcting me.

Fred

Re: Zoom Blur

Posted: 2010-09-30T13:09:23-07:00
by 3DTOPO
el_supremo wrote:In the C API there is a function, ConvertImageCommand, which takes exactly the same arguments as the command line version.

Pete
That is Excellent!

Thank you very much both Fred and Pete!

Re: Zoom Blur

Posted: 2010-09-30T14:16:40-07:00
by 3DTOPO
Hey Fred,

I was wondering if you knew of a way to get a "reverse fisheye" effect?

I tried entering negative values but they are not accepted from your script.

Example, original on the left, inverse fisheye on the right:

Image


Thanks!

Re: Zoom Blur

Posted: 2010-09-30T15:15:01-07:00
by fmw42
For a reverse fisheye type distortion, try my bubblewarp script with -t sin -m polar. Note my spherize script is the same, but faster and also more limited. So right now I trap for positive warp (outward sphere) only. I suspect I could relax that if you need it.

You can also see my pinbarrel script for examples. IM now has -distort barrel, so you can do something similar with it.

PS I forgot to mention that the order of my coefficients in pinbarrel is opposite to what was used by Anthony in -distort barrel and the apparent conventional ordering. Note -distort barrelinverse is not the inverse of -distort barrel. Its results are similar, but uses inverse radial powers rather than radial powers.

Re: Zoom Blur

Posted: 2010-09-30T16:54:08-07:00
by 3DTOPO
fmw42 wrote:For a reverse fisheye type distortion, try my bubblewarp script with -t sin -m polar.
Thanks Fred!

bubblwrap -t sin from your examples looks perfect!

But I am getting identical results using sin and arcsin which both appear to be an arcsin result.

I can show my test images if it might help....

Re: Zoom Blur

Posted: 2010-09-30T17:41:45-07:00
by fmw42
bubblwrap -t sin from your examples looks perfect!

But I am getting identical results using sin and arcsin which both appear to be an arcsin result.
You found an oversight in my conversion of my test script to a formal script. I have corrected it now. You can download it from my web site or send me email (fmw at alink dot net) and I can send you the revised script.

Thanks for finding that and pointing it out. It has been there since the script was first posted and no one has commented on that.

Fred

Re: Zoom Blur

Posted: 2010-10-01T06:05:20-07:00
by anthony
A new alternative for radile blurring is to use "Variable Blur Mapping".
http://www.imagemagick.org/Usage/mapping/#blur

With the right mapping file you can generate basically any type of blur effect you want.

How about a spiral blur? Or a mix of distortions (by whatever means) and blurring?

And please let us see your results (and source images) for your own mapping effects.

Re: Zoom Blur

Posted: 2010-10-01T11:48:24-07:00
by fmw42
for reverse fisheye type distortion, try


Image

bubblewarp -t sin -m polar zelda3.jpg zelda3_bubble_sin.jpg
Image



or

convert zelda3.jpg -distort barrel "0 0 -0.5 1.5" zelda3_pincushion.jpg
Image


For radial blur, try

convert zelda3.jpg \( -size 128x128 radial-gradient: -negate \) \
-compose blur -set option:compose:args 5 -composite zelda3_radialbur_5.jpg
Image

Re: Zoom Blur

Posted: 2010-12-22T22:23:53-07:00
by siuying
Hi,

I'm using MagickWand and based on your post i were able to create radial-blur effect using code below:

Code: Select all

	MagickWand* tWand = NewMagickWand();
	MagickSetOption(tWand, "compose:args", "5");
	MagickSetSize(tWand, w, h);
	MagickReadImage(tWand, "radial-gradient:black-white");
	MagickCompositeImage(mainWand, tWand, BlurCompositeOp, 0, 0);		
	DestroyMagickWand(tWand);
Unfortunately the result is not exactly what i wanted:

Image http://screencast.com/t/yn2wpCbF

For some reason the center part of the image is blurred, where i expect it should be 0% blur at center.

Could you see anything I'm doing wrong? Or would you have any recommendation? Thanks in advance.

Re: Zoom Blur

Posted: 2010-12-22T22:45:03-07:00
by anthony
The very center isn't blured. but that is only a single pixel.

If you want to make the area near the center less blurred you will need to create a blur map of some kind.