Possible to repeat enclosed effect with ImageMagick?

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?".
ImageGandalf
Posts: 15
Joined: 2014-04-14T11:40:01-07:00
Authentication code: 6789

Possible to repeat enclosed effect with ImageMagick?

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible to repeat enclosed effect with ImageMagick?

Post 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.
ImageGandalf
Posts: 15
Joined: 2014-04-14T11:40:01-07:00
Authentication code: 6789

Re: Possible to repeat enclosed effect with ImageMagick?

Post by ImageGandalf »

Thanks! Going to try that out.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Possible to repeat enclosed effect with ImageMagick?

Post 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?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ImageGandalf
Posts: 15
Joined: 2014-04-14T11:40:01-07:00
Authentication code: 6789

Re: Possible to repeat enclosed effect with ImageMagick?

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible to repeat enclosed effect with ImageMagick?

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

Re: Possible to repeat enclosed effect with ImageMagick?

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ImageGandalf
Posts: 15
Joined: 2014-04-14T11:40:01-07:00
Authentication code: 6789

Re: Possible to repeat enclosed effect with ImageMagick?

Post by ImageGandalf »

Thank you guys will try both things.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible to repeat enclosed effect with ImageMagick?

Post 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.
ImageGandalf
Posts: 15
Joined: 2014-04-14T11:40:01-07:00
Authentication code: 6789

Re: Possible to repeat enclosed effect with ImageMagick?

Post 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!
ImageGandalf
Posts: 15
Joined: 2014-04-14T11:40:01-07:00
Authentication code: 6789

Re: Possible to repeat enclosed effect with ImageMagick?

Post 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?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Possible to repeat enclosed effect with ImageMagick?

Post by snibgo »

You are probably using Unix syntax on Windows. See http://www.imagemagick.org/Usage/windows/ for how to convert the syntax.
snibgo's IM pages: im.snibgo.com
ImageGandalf
Posts: 15
Joined: 2014-04-14T11:40:01-07:00
Authentication code: 6789

Re: Possible to repeat enclosed effect with ImageMagick?

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

Re: Possible to repeat enclosed effect with ImageMagick?

Post 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!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ImageGandalf
Posts: 15
Joined: 2014-04-14T11:40:01-07:00
Authentication code: 6789

Re: Possible to repeat enclosed effect with ImageMagick?

Post 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.
Post Reply