Page 1 of 2

Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-14T13:25:37-07:00
by ImageGandalf
Hey all,

I have the following image:

Image

Which has a halftone effect and maybe some other effect applied to it:

Image

I am wondering, is it possible to replicate this effect in ImageMagick? I've played around a little with the halftone dither 8x8a and it seems to produce a similar halftone effect, but it lightens the image:

Image

Can anyone think of a way I might be able to reproduce this?

Thanks,

ImageGandalf

Re: Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-14T13:35:48-07:00
by fmw42
create an image of a grid of black and white squares (you can create a 2x2 pattern and tile it out). Then use -compose multiply to apply the pattern to the image

Try this:

Code: Select all

convert -size 5x5 xc:"gray(128)" xc:white +append \
\( +clone -flop \) -append -write mpr:cell +delete \
-size 640x1136 tile:mpr:cell \
2anczm.jpg -compose multiply -composite tmp.jpg
You can adjust the apparent darkness by changing the gray(128) to some darker or lighter value

I am not sure this is exactly what you want, but that is a start.

Perhaps another use who knows more about dithering can provide a better solution.

Re: Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-14T17:57:50-07:00
by ImageGandalf
Thanks! Going to try that out.

Re: Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-14T19:23:44-07:00
by anthony
You say the Imagemagick half toning lighten the image. To me the method you provided (second example) darkened the image!

There are lots of ways to get effects like what you exampled, though your example looks more like offset hafltone screening, with a very bad or 'slightly randomized' halftone pattern. Offset halftoning is not directly implemented in IM but can still be done, and is actually exampled in IM Examples, Quantization & Dithering
http://www.imagemagick.org/Usage/quanti ... one_offset

The Question however is not your you exampled, but what is behind your example. What is it that you want the effect for? That would probably be more useful in determining the best way of generating the desired effect, than the single example you have provided. Specifically how 'true' do you want the effect, or would a 'faked' or not quite right but looks better, version of the effect be better.

so.. What is it do you want and what for?

Re: Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-14T21:50:15-07:00
by ImageGandalf
anthony wrote:You say the Imagemagick half toning lighten the image. To me the method you provided (second example) darkened the image!

There are lots of ways to get effects like what you exampled, though your example looks more like offset hafltone screening, with a very bad or 'slightly randomized' halftone pattern. Offset halftoning is not directly implemented in IM but can still be done, and is actually exampled in IM Examples, Quantization & Dithering
http://www.imagemagick.org/Usage/quanti ... one_offset

The Question however is not your you exampled, but what is behind your example. What is it that you want the effect for? That would probably be more useful in determining the best way of generating the desired effect, than the single example you have provided. Specifically how 'true' do you want the effect, or would a 'faked' or not quite right but looks better, version of the effect be better.

so.. What is it do you want and what for?
I'm trying to produce an image that looks like it's from a comic book. To be honest, I don't care that the halftone filter in Image Magick EXACTLY match the one in the picture, what I'm trying to reproduce is the effect as a whole, for which you are right, there is another underlying effect aside from the halftone filter that is making the photo dark. Actually, here is that effect alone without the halftone filter:

BEFORE

Image

AFTER

Image

Possible to produce that effect in ImageMagick?

Re: Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-14T22:23:20-07:00
by fmw42
try -posterize. see http://www.imagemagick.org/Usage/quantize/#posterize and http://www.imagemagick.org/script/comma ... #posterize.

If on unix (linux or mac osc) or windows w/cygwin, you might take a look at my lichtenstein script at the link below.

Re: Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-14T22:27:25-07:00
by anthony
The comic book effect is essentially a halftone screen. A true half tone screen.

However try the method in the link I gave, it will probably achieve what you want. With or without 'posterize'
http://www.imagemagick.org/Usage/quanti ... one_offset

Re: Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-15T09:41:19-07:00
by ImageGandalf
Thank you guys will try both things.

Re: Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-15T10:02:43-07:00
by fmw42
Your output seems to have some kind of posterize effect. The black squares may come from the darker colors being assigned to black in the posterize process or just a final -black-threshold.

Re: Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-15T17:24:05-07:00
by ImageGandalf
fmw42 wrote:Your output seems to have some kind of posterize effect. The black squares may come from the darker colors being assigned to black in the posterize process or just a final -black-threshold.
Yeah I've actually tried posterize and it looks better than what I linked to. Thanks!

Re: Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-15T17:25:36-07:00
by ImageGandalf
anthony wrote:The comic book effect is essentially a halftone screen. A true half tone screen.

However try the method in the link I gave, it will probably achieve what you want. With or without 'posterize'
http://www.imagemagick.org/Usage/quanti ... one_offset
Had another question (a noob question). I am trying to type in that script from the link you provided and can't get it to run. I assume it's because I'm not accounting for spaces at the end of the line breaks (or I'm not sure if there is a space or not). Simply copy / pasting it doesn't work. Is there an easier way to get the bit of text to run in a command prompt on windows?

Re: Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-15T19:48:53-07:00
by snibgo
You are probably using Unix syntax on Windows. See http://www.imagemagick.org/Usage/windows/ for how to convert the syntax.

Re: Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-15T23:38:19-07:00
by ImageGandalf
snibgo wrote:You are probably using Unix syntax on Windows. See http://www.imagemagick.org/Usage/windows/ for how to convert the syntax.
Thanks, that helped me get it and it looks great! I was wondering, is it possible to specify a size for the halftone squares? When I apply the filter to smaller images the squares are big and to larger ones they are small. Just wondering if there is a way to specify a consistent size that will be the same for all images.

Re: Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-16T00:01:50-07:00
by anthony
the second example in the IM Examples link shows how you can scale it.

However using the builtin "pattern:gray50" pixel level checkerboard image may work better. You can then just scale it during the rotation distortion, to whatever size you like.

That is to get the screen part (usually as part of the larger command)

Code: Select all

   convert pattern:gray50 -filter gaussian +distort SRT 5,30 show:
The '5' is the scale of the pattern! - I may change the second example to use the above.

There are gaussian filter options that can be used to adjust how 'fuzzy' the resulting screen is, though the default seems pretty good.

Now if we can get a blurred pattern of dots in a hexagonal grid, as a starting image, it would look even better!

Re: Possible to repeat enclosed effect with ImageMagick?

Posted: 2014-04-16T12:01:51-07:00
by ImageGandalf
anthony wrote:the second example in the IM Examples link shows how you can scale it.

However using the builtin "pattern:gray50" pixel level checkerboard image may work better. You can then just scale it during the rotation distortion, to whatever size you like.

That is to get the screen part (usually as part of the larger command)

Code: Select all

   convert pattern:gray50 -filter gaussian +distort SRT 5,30 show:
The '5' is the scale of the pattern! - I may change the second example to use the above.

There are gaussian filter options that can be used to adjust how 'fuzzy' the resulting screen is, though the default seems pretty good.

Now if we can get a blurred pattern of dots in a hexagonal grid, as a starting image, it would look even better!
Thanks! Going to try this out today.