Creating the color-in book filter with MagickWand

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
culov
Posts: 3
Joined: 2011-06-28T22:19:27-07:00
Authentication code: 8675308

Creating the color-in book filter with MagickWand

Post by culov »

I'm trying to recreate the effect here: http://www.imagemagick.org/Usage/photos/#color-in with the identical effect in MagickWand.

Here's the command I want to duplicate in with MagickWand:

Code: Select all

 convert holocaust_sm.jpg \
          -edge 1 -negate -normalize \
          -colorspace Gray -blur 0x.5 -contrast-stretch 0x50% \
          color-in.gif
  # For heavily shaded pictures...
  #     #-segment 1x1 +dither -colors 2 -edge 1 -negate -normalize \
I've been having a good deal of trouble properly converting this command, but I think it's mostly due to the fact that I can't find a way to translate the command

Code: Select all

-contrast-stretch 0x50%
to a MagickWand function. Also, the value being passed to -edge, 1, seems to be too small. The effect is no where near what I think it ought to look like unless I bump this value up to around 20.

The code I've been working with has variables attached to sliders, so that i can change their value on the fly and regenerate the image. Heres the code:

Code: Select all

status = MagickReadImageBlob(magick_wand, [dataObject bytes], [dataObject length]);
status = MagickEdgeImage(magick_wand, edgeRadius);
status = MagickNegateImage(magick_wand, MagickTrue);
status = MagickNormalizeImage(magick_wand);
 status = MagickSetImageType(magick_wand, 2);//gray colorspace
status = MagickBlurImage(magick_wand,blurRadius, blurSigma);

size_t my_size;
	unsigned char * my_image = MagickGetImageBlob(magick_wand, &my_size);....
Any help figuring this one out is GREATLY appreciated! Thanks.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Creating the color-in book filter with MagickWand

Post by el_supremo »

Try this for the contrast stretch:

Code: Select all

status = MagickContrastStretchImage(magick_wand,0,0.5);
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.
culov
Posts: 3
Joined: 2011-06-28T22:19:27-07:00
Authentication code: 8675308

Re: Creating the color-in book filter with MagickWand

Post by culov »

el_supremo wrote:Try this for the contrast stretch:

Code: Select all

status = MagickContrastStretchImage(magick_wand,0,0.5);
Pete
Thanks that's what I needed to complete the given filter, but unforunately, the end result looks nothing like what I'm looking to achieve. To begin with, the edges are white instead of black, and the inside of the edges is for the most part black. I've found that the clostest I can get to achieving my desired result is increasing the edge detection radius to ~25 and removing the negate filter. Nevertheless, this filter still has a good deal too much black. Here are my results:

Image

The first image is the original, the second is what it looks like after I run the code mentioned in the original post plus the Contrast function provided by el_supremo, and the final one is what happens when I remove negate and set the edge detection radius to 24, with all other functions kept intact.

Thanks for all the help!
culov
Posts: 3
Joined: 2011-06-28T22:19:27-07:00
Authentication code: 8675308

Re: Creating the color-in book filter with MagickWand

Post by culov »

Just to clarify, the third frame in the previous post, is closer to the result than the second, but still a long ways off. There is still far too much black. How can I correct that?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Creating the color-in book filter with MagickWand

Post by anthony »

Must of the black is looks due to image noise from JPEG compression.

Try adjusting the 0.5 in the contrast stretch a little to remove that noise.

Edge detection of real life images is actually a real art, and there is more than one way to do in.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply