Page 1 of 1

Creating the color-in book filter with MagickWand

Posted: 2011-06-28T23:07:23-07:00
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.

Re: Creating the color-in book filter with MagickWand

Posted: 2011-06-29T09:01:35-07:00
by el_supremo
Try this for the contrast stretch:

Code: Select all

status = MagickContrastStretchImage(magick_wand,0,0.5);
Pete

Re: Creating the color-in book filter with MagickWand

Posted: 2011-06-29T11:38:52-07:00
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!

Re: Creating the color-in book filter with MagickWand

Posted: 2011-07-09T17:31:50-07:00
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?

Re: Creating the color-in book filter with MagickWand

Posted: 2011-07-18T22:42:09-07:00
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.