horizontal and vertical blur?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jnimo

horizontal and vertical blur?

Post by jnimo »

hi, sorry if i'm asking to much this days.


i have already solve the problem of make a pdf in multiple steps :D this is a really fun lib :D

i have another question, there is a way to make a horizontal blur and a vertical blur?, i mean the -blur make a blur but from center, i want to make a left to right blur, or a up to down blur.


Thanks for reading, and thanks for the solution
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: horizontal and vertical blur?

Post by fmw42 »

-motion-blur should be what you want, but it may not be working correctly. Give it a try, but if it does not work to your satisfaction then you need to compose a filter using -convolve. Here is an example of a horizontal blur 15 pixels wide:

filt15="\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
"
convert inputimage -convolve $filt15 outputimage
jnimo

Re: horizontal and vertical blur?

Post by jnimo »

i try to make that command but it give me a malloc problem


convert prueba.jpg_2 -convolve $filt15 salida.jpg
*** glibc detected *** convert: malloc(): memory corruption: 0x08207a70 ***


i don't know what could be
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: horizontal and vertical blur?

Post by fmw42 »

I am not sure. You may not have enough memory? But try taking out all the backslashes and make the filt15 variable definition all one long line. Be sure not to remove any commas or the quotes.

If you are on Windows, you may need to use double backslashes \\ (escape the backslash as that is a special character on Windows) or remove them.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: horizontal and vertical blur?

Post by Bonzo »

Not quite sure what the effect is supposed to be but this created an image for me using php on a windows XP machine.

Code: Select all

<?php

$filt15 = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,";
exec("convert print2.jpg -convolve $filt15 blur.png");

?>
The original post didn't work neither did changing the \ to \\
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: horizontal and vertical blur?

Post by fmw42 »

It is supposed to create the equivalent of a 1D horizontal blur of 15 pixels using a uniform convolution kernel. IM -convolve cannot handle 1D, non-square or even kernels. This is the equivalent of a proper motion blur as a camera would see it. IM has -motion-blur, but it is not symmetric nor does it have uniform weights, but is 1D.

The filter as I created it with the continuation backslashes works fine in Unix. But I am afraid that \ is not a continuation character in Windows. Thus the need to remove them all.

Even though IM -convolve requires square filters, they have to be expressed as one long comma delimited string. The \ for continuation was just a convenience to make it look like it is 2D.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: horizontal and vertical blur?

Post by anthony »

If you don't mind it being exact.

Do two motion blurs, one in each direction, and then average those two images together. I do this for creating 'star' rays in
http://imagemagick.org/Usage/advanced/#stars
Though I repeat it at multiple angles.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply