Table of Contents
Subject: Suggestion to Digital Photo Handling section, part 3 Newsgroups: gmane.comp.video.image-magick.user Date: Sun, 17 Jun 2007
Hi Anthony,
On http://www.imagemagick.org/Usage/photos/, in Photo Conversion Cookbook section you have two examples on converting photos to sketches — "Childrens Color-In Images" & "Pencil Sketch".
Before going into these, maybe it is a good idea to first discuss convert's built-in -charcoal operator, just to make it a full story, because there might be people who don't know of the operator.
Taken from http://www.ibm.com/developerworks/library/l-graf/?ca=dnt-428
The charcoal effect simulates a charcoal artist's impression of the image.
$ convert -charcoal 2 input.jpg output.jpg
Moreover, when I apply the Childrens Color-In Image method to a portrait photo, it did not work well. I know that the Childrens Color-In Image method was originated from a long discussion about Generating Coloring-In Pages on the IM Users Forum. So I'm thinking, let's try another algorithm.
What I really like to see in the Photo Conversion Cookbook section, is an example for "Simplest Sketch", ie, convert the photo to a sketch that has bare minimum lines to represent the original photo. I found a very good algorithm from the gimp tutorials section.
http://www.gimp.org/tutorials/Sketch_Effect/
To be honest, I was just stunned by how good the effect can be. I had been trying to achieve the same result in gimp long time ago using my limited understanding/knowledge but failed. Looking at how a machine can do in just several simples steps, I have to say I was amazed. I think that's a very effective algorithm, but I don't know how to do it in IM.
Please help.
thanks
| Before going into these, maybe it is a good idea to first discuss | convert's built-in -charcoal operator, just to make it a full | story, because there might be people who don't know of the operator.
I'll add a link to my own discussion… http://www.imagemagick.org/Usage/transform/#charcoal :-)
But the two methods you mention are not really using charcoal as such. In that case it is used more as a edge detection method, to generate disgonal pencil lines.
I have added a new 'photo transform' for charcoal. http://www.imagemagick.org/Usage/photos/#charcoal Give it a day to so for it to appear on the main IM exmaple site.
| Moreover, when I apply the Childrens Color-In Image method to a | portrait photo, it did not work well. ... So I'm | thinking, let's try another algorithm.
Good, because I am certainly not happy with it!
| ... I found a very good algorithm from the gimp | tutorials section. | | http://www.gimp.org/tutorials/Sketch_Effect/[]
Now that is a great effect!!!
In fact such an effect of removing unimportant lines may be a good one for image comparision too!
| To be honest, I was just stunned by how good the effect can be. | I had been trying to achieve the same result in gimp long time ago | using my limited understanding/knowledge but failed. Looking at | how a machine can do in just several simples steps, I have to say I | was amazed. I think that's a very effective algorithm, but I don't | know how to do it in IM.
Hmmm
highpass fiter: -- not sure... Anyone? blur: -blur 0x7 invert -negate
we need the original then do a opacity 50% and add..
Command so far…
convert image.png \( +clone -median 2 -blur 0x7 -negate \) \ -matte -channel A -evaluate set 50% -compose plus -composite \ ...
Hmmm our image has some color in it but it is close. prehaps I have the point of cloning wrong, or I have the high pass filter wrong (likely)
Continuing increase contrast
-sigmoidal-contrast 7x50%
or -normalize prehaps with a controled 'denormalize' or greying… http://www.imagemagick.org/Usage/color/#greying
After that is simular to using various stech and edge detection.
Of course some manual (sic) handling was also done.
Anyone like to improve this?
Another technique I would like to see converted to IM is….
Watercolors from photos… http://www.state-of-entropy.com/watercolor.html
Though the title image is great looking, the example image used is not so good.
Anthony Thyssen
Newsgroups: gmane.comp.video.image-magick.user Date: Tue, 24 Jul 2007 12:44:50 +1000
| The background of pic1.png has been cleared (using gimp). After the | following command (to produce the sketch effect), the cleared background | shows up again in pic1.gif. I'm wondering why the cleared background can | still managed to show up, and how can I fix the problem.=20 | | convert pic1.png \( +clone -median 2 -blur 0x7 -negate \) \ | -matte -channel A -evaluate set 50% -compose plus -composite pic1.gif
Of course the background shows up again. You replaced all transparnency values with 50% in BOTH images, added together that is 100% opaque!
Try using
-evaluate multiply .5
or
-evaluate divide 2
Instead. Do not use a percentage, as that is a percentage of color and not 1/2:
.. evaluate functions includes the typical mathematical functions 'add',. 'subtract', 'multiply', and 'divide'… the values are the real color values of the image.
.. if you add a '%' to the argument, that argument will represent a. percentage of the maximum color value (known as 'MaxRGB' and is equal to ('2quality-1'). this means you can make your "-evaluate" arguments IM quality level independany by the appropriate use of percentages.
For example, to half the contrast of the image, you can 'divide' it by '2' then 'add' '25% to re-center it around a the perfect grey.
convert rose: -evaluate divide 2 -evaluate add 25% rose_de-constrast.gif
Also note that GIF does not allow semi-transparency, so your source image better not be using any semi-transparency.
| I've also tried to specify -channel RGBA, but the result is all grayed. | | convert pic1.png \( +clone -median 2 -blur 0x7 -negate \) \ | -matte -channel RGBA -evaluate set 50% -compose plus -composite pic1.gif
Naturally you just SET every color to 50% grey and 50% transparent!
See IM Examples Evaluate, Faster Simple Math Operations http://www.imagemagick.org/Usage/transform/#evaluate
Anthony Thyssen