MagickCompositeImage BlurCompositeOp UndefinedException

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
onyxraven
Posts: 2
Joined: 2011-01-24T11:09:34-07:00
Authentication code: 8675308

MagickCompositeImage BlurCompositeOp UndefinedException

Post 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!
onedayitwillmake
Posts: 2
Joined: 2011-03-11T19:55:07-07:00
Authentication code: 8675308

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Post 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 :)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Post 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 :-)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Post 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
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Post 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
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
onedayitwillmake
Posts: 2
Joined: 2011-03-11T19:55:07-07:00
Authentication code: 8675308

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Post 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 :(
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Post 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).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: MagickCompositeImage BlurCompositeOp UndefinedException

Post 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
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
Post Reply