Page 1 of 1

How to combine these commands into one?

Posted: 2012-02-05T07:58:22-07:00
by MILLIONER
Hi all! :)

How to combine these commands into one?

Code: Select all

1) convert photo1.jpg -convolve "-1,0,1,-1,0,1,-1,0,1" -fx "abs(u)" edge1.jpg
2) convert photo1.jpg -convolve "1,1,1,0,0,0,-1,-1,-1" -fx "abs(u)" edge2.jpg
3) convert edge1.jpg edge2.jpg -compose plus -composite edge3.jpg
Trying to merge, but the results very different

Code: Select all

convert photo1.jpg \( -clone 0 -convolve "-1,0,1,-1,0,1,-1,0,1" -fx "abs(u)" \) \( -clone 0 -convolve "1,1,1,0,0,0,-1,-1,-1" -fx "abs(v)" -compose plus -composite edge3.jpg
Thank you! :)

Re: How to combine these commands into one?

Posted: 2012-02-05T08:20:05-07:00
by el_supremo
You are missing \) just before -compose.

Pete

Re: How to combine these commands into one?

Posted: 2012-02-05T11:37:50-07:00
by MILLIONER
el_supremo wrote:You are missing \) just before -compose.

Pete
written:

Code: Select all

convert photo1.jpg \( -clone 0 -convolve "-1,0,1,-1,0,1,-1,0,1" -fx "abs(u)" \) \( -clone 0 -convolve "1,1,1,0,0,0,-1,-1,-1" -fx "abs(v)" \) -compose plus -composite edge3.jpg
There are no results. : (

Re: How to combine these commands into one?

Posted: 2012-02-05T12:34:25-07:00
by fmw42
convert photo1.jpg \( -clone 0 -convolve "-1,0,1,-1,0,1,-1,0,1" -fx "abs(u)" \) \( -clone 0 -convolve "1,1,1,0,0,0,-1,-1,-1" -fx "abs(v)" \) -compose plus -composite edge3.jpg

First you only have one image for each convolve, so abs(v) should be abs(u). Second, it appears that you are trying to generate an approximation to a gradient edge operator. However, unless you are in HDRI mode, -fx "abs(u)" will do nothing, since non-HDRI compiles will not allow negative values. Generally one will use -bias 50% before doing this and then compensate later. see viewtopic.php?f=1&t=16158&hilit=sobel and the links within it.

See http://www.imagemagick.org/Usage/convolve/#edgedet as IM has some built in edge detectors.

You can try my script, gradient, at the link below. It has both one-sided and two sided gradients for non-HDRI mode. The one-sided gradient should work as a two sided gradient if you are in HDRI mode, but I have not tested that. You can look at the bottom of my script for the code I used in both cases.

Re: How to combine these commands into one?

Posted: 2012-02-05T17:53:25-07:00
by anthony
MILLIONER wrote:Hi all! :)

How to combine these commands into one?

Code: Select all

1) convert photo1.jpg -convolve "-1,0,1,-1,0,1,-1,0,1" -fx "abs(u)" edge1.jpg
2) convert photo1.jpg -convolve "1,1,1,0,0,0,-1,-1,-1" -fx "abs(u)" edge2.jpg
3) convert edge1.jpg edge2.jpg -compose plus -composite edge3.jpg
Trying to merge, but the results very different

Code: Select all

convert photo1.jpg \( -clone 0 -convolve "-1,0,1,-1,0,1,-1,0,1" -fx "abs(u)" \) \( -clone 0 -convolve "1,1,1,0,0,0,-1,-1,-1" -fx "abs(v)" -compose plus -composite edge3.jpg
Thank you! :)
The -fx 'abs(u)' will have NO effect unless you are using HDRI version of ImageMagick as image data values are already absolute values! The FX abs function is generally used for modifying the results of other calculations.

Basically as each image processing operation saves the values back into the image data store, whcih is generally Q16 (compile time quality). As these are 16 bit unsigned integers anything outside the range 0 to 65535 will be clipped/burned. No negatives get saved by default.

If you wish to use convolve and preserve or make use of negative results, you will need to either set the appropriate bias and scaling factors. That is not easy with the old -convolve operation, but much more controllable using the newer -morphology Convolve operator.

See IM Examples, Convolve.
http://www.imagemagick.org/Usage/convolve/
which looks at all these problems and more.