Page 1 of 1

MagickCompositeImage BlurCompositeOp UndefinedException

Posted: 2011-01-25T17:07:19-07:00
by onyxraven
I'm attempting to use the BlurCompositeOp composition method on the iPhone build (ImageMagick 6.6.7-0 2011-01-13 Q8 http://www.imagemagick.org).

status = MagickCompositeImage(magick_wand, clone, BlurCompositeOp, 0, 0);

status is always MagickFalse, the severity is UndefinedException and the description is empty. (well, the debugger shows it as "0 '\000'")

Over op works fine, but obviously doesnt get me where I want to go.

(I'm attempting to recreate the tilt-shift effect like http://www.imagemagick.org/Usage/photos/#tilt_shift)

Any help would be greatly appreciated. I'm pretty new to the MagickWand API. I wouldn't mind using the commandline converter, but I need to be able to populate the wand with the image bits, not have it read from a file.

Thanks!

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Posted: 2011-03-11T19:56:36-07:00
by onedayitwillmake
Hi has anyone had any luck with this, I ran into the same problem - actually trying to achieve the same effect as well :)

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Posted: 2011-03-12T03:39:36-07:00
by anthony
I am not certain of what you are getting a bad Exception. You should be getting something.
Hmmm perhaps that should be reported in teh Bugs forum. (The exception, not your requested problem).


However....

The Blur Composite Op requires some extra data such as "Maximum Blur Sigma" which is passed to it via a "compose:args" artifact define. Without that operational control artifact the operation is incomplete.

Examples of the argument to control the bluring is in IM Examples, Mapping, Variable Blur Mapping
http://www.imagemagick.org/Usage/mapping/#blur
As well as in Phot Handling, Tilt Shift (where a lareg value of 20 is being used).
http://www.imagemagick.org/Usage/photos/#tilt_shift

The setting is added as a string 'Artifact' which is on the command line set using "-define ..." or "-set option:...", and should be added to at least the first (destination) image of the CompositeImage() function.

This is in lower level library MagicCore code I have used to do this...

Code: Select all

SetImageArtifact(composite_image,"compose:args", "10");
CompositeImage(composite_image,BlurCompositeOp,blur_mask,0,0);
I do not know how it should be applied in MagickWand, but it should be very similar.

Oh and don't forget to increase contrast first, and/or saturate the colors, so as to make the image look more artificial, like a model in a studio. That is a very important element of tilt-shift :-)

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Posted: 2011-03-12T09:09:25-07:00
by el_supremo
If I precede a BlurComposite with the MagickCore call:

Code: Select all

SetImageArtifact(dest->images,"compose:args","15");
then the MagickCompositeImage succeeds.

But if I precede it with the MagickWand call:

Code: Select all

MagickSetImageArtifact(dest,"compose:args","15")
then this function returns MagickFalse and then the BlurComposite also fails.

Bug?

Pete

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Posted: 2011-03-12T18:26:34-07:00
by anthony
Depends on what 'dest' is in MagickWand. I don't know as I don't use that interface normally. I know some MagickCore as I often program new functions in MagickCore. In fact I was the one to re-design the 'extra argument' passing for ImageComposite() so as to follow new standard way of passing such 'out of band' data.

You may like to read the updated sections in IM examples, Basics, on Attributes, Settings (Properities) and Defines (Atrifacts)... http://www.imagemagick.org/Usage/basics/#settings

More than likely the function is applied to the image and it the looks up the global "image_info" for that image list from the pointer in the image itself. The structures are highly interconnected. Only Cristy would know for sure without following the code itself.

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Posted: 2011-03-12T20:49:32-07:00
by el_supremo
Depends on what 'dest' is in MagickWand
Indeed it does :-)
This works:

Code: Select all

MagickSetImageArtifact(src,"compose:args","15");
MagickCompositeImage(dest,src,BlurCompositeOp,0,0);
Pete

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Posted: 2011-03-13T11:43:45-07:00
by onedayitwillmake
Thanks, that's what i was missing!

I got it to work before by just creating a blurred version, alpha-ing out some of it using the gradient, then using regular OverCompositeOp to combine blurred and original.

Code: Select all

	// create blurred version
	MagickWand * blurred = CloneMagickWand( aMagickWand );	
	status = MagickGaussianBlurImage(blurred, 4, 4);
	checkImageMagick( status, blurred, true );
	
	// Mask out part of the blurred version
	status = MagickCompositeImage(blurred, aGradientWand, CopyOpacityCompositeOp, 0, 0);
	checkImageMagick( status, blurred, true );
	
	// copy blured over original
	status = MagickCompositeImage(aMagickWand, b
The BlurComposite version is much slower (1 second, vs ~25 seconds) and produces a motion blurred looking result :(

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Posted: 2011-03-13T18:37:40-07:00
by anthony
CompositeBlur is slow, because it is highly variable. It often has to redefine the filter for every pixel.

In previous versions of IM I only defined the filter once, and then adjusted the ellipse size, but that fails when ellipse sizes become too small for 'micro blurs'. It resulted in a sudden cutoff when the blur for a specific pixel went below 1 pixel.

I am looking for a better solution. But it has now become a much lower priority for me.
You are welcome to look at the code in "composite.c" (search for Blur).

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Posted: 2011-03-14T17:46:40-07:00
by el_supremo
FYI: I've added Anthony's tilt_shift example (http://www.imagemagick.org/Usage/photos/#tilt_shift) to my Magickwand Examples (see my sig).

Pete