photo effect - Warholize - line art
photo effect - Warholize - line art
hello,
sorry for bizzarre post, but is only for fun
(apologize, is 1st day of year...)
Find nice imagemagick use :
Warholize http://www.vincent-richard.net/blog/ind ... ndy-warhol
but script is for linux only, is possible to have counterpart for windows ?
and an effect that i ask only if is replicable with IM, line art as found:
http://fotofamilymemories.com/category/phototechnique/
thank you for your attention,
m.
sorry for bizzarre post, but is only for fun
(apologize, is 1st day of year...)
Find nice imagemagick use :
Warholize http://www.vincent-richard.net/blog/ind ... ndy-warhol
but script is for linux only, is possible to have counterpart for windows ?
and an effect that i ask only if is replicable with IM, line art as found:
http://fotofamilymemories.com/category/phototechnique/
thank you for your attention,
m.
Last edited by myspacee on 2015-05-05T01:44:48-07:00, edited 1 time in total.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: photo effect - Warholize - line art
The technique from what I can see uses GIMP which is available both in linux and in windows!
It is not automatic, and requires input from the user to get right for each photo involved.
IM can do the steps specified but the steps will be slightly different for each photo involved.
It is not automatic, and requires input from the user to get right for each photo involved.
IM can do the steps specified but the steps will be slightly different for each photo involved.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: photo effect - Warholize - line art
Cute effect. Here's one with many cat photos.anthony wrote: IM can do the steps specified but the steps will be slightly different for each photo involved.
http://www.urban-warrior.org/mosaicks/m ... osaick.jpg
Rick
Re: photo effect - Warholize - line art
find linux bash script :
but have some problem to 'convert' script for windows:
(replace all variables with value)
for first thing don't understand and replace code for :
anyone can help me ?
m.
Code: Select all
#!/bin/bash
#
# 'Andy Warhol'-like effect using ImageMagick
#
# Copyright (c) Vincent RICHARD, 2007
# vincent@vincent-richard.net
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
###################
# CONFIGURATION #
###################
# Quality for output image (if compressed)
QUALITY="90%"
# Define colors to be used in output image
# -- top-left quadrant
C1_B="#342b7c"
C1_G="#94c015"
C1_W="#fefc09"
# -- top-right quadrant
C2_B="#ee6807"
C2_G="#9ec038"
C2_W="#fff9a3"
# -- bottom-left quadrant
C3_B="#734995"
C3_G="#79bef9"
C3_W="#f58508"
# -- bottom-right quadrant
C4_B="#e60877"
C4_G="#fdf107"
C4_W="#0483ee"
############
# SCRIPT #
############
# Check arguments
if [ $# -ne 2 ]; then
echo "Usage: $0 input-file output-file"
exit 1
fi
# Reduce the number of colors to 3 (black, white and a level of gray).
# Store the output in a temporary file.
TEMP_FILE=`tempfile --suffix=.png`
convert "$1" -background white -flatten +matte -colorspace gray -colors 3 -colorspace rgb -type TrueColor -matte "$TEMP_FILE" \
|| ( echo "$0: could not reduce colors in input image" ; exit 2 )
convert "$TEMP_FILE" -channel ALL -normalize "$TEMP_FILE" \
|| ( echo "$0: could not normalize input image" ; rm -f "$TEMP_FILE" ; exit 3 )
# Extract histogram (list of colors) from the image.
# We are only interested in the gray color, so remove black and white lines.
HISTO=`convert "$TEMP_FILE" histogram:- | identify -format %c - | grep -vre "black\|white"`
# Ensure we got only one line
HISTO_LINES=`echo "$HISTO" | wc -l`
if [ $HISTO_LINES -eq 0 ]; then
echo "$0: could not get histogram"
rm -f "$TEMP_FILE"
exit 4
fi
if [ $HISTO_LINES -ne 1 ]; then
echo "$0: cannot extract colors from histogram"
rm -f "$TEMP_FILE"
exit 5
fi
# Extract the color from a line in the form:
# 105037: (119,119,119, 0) #77777700
# or: 32765: (163,163,163, 0) grey64
GRAY=`echo $HISTO | expand | sed 's/ /\n/g' | grep -E -m 1 "^(#[0-9a-zA-Z]{3,12}|[a-zA-Z][a-zA-Z0-9]+)$" | tr -d " \t"`
if [ -z "$GRAY" ]; then
echo "$0: cannot extract gray color value"
rm -f "$TEMP_FILE"
exit 6
fi
# We can now set colors to replace
BLACK="#000000000000"
WHITE="#FFFFFFFFFFFF"
GRAY="$GRAY"
# Apply filter.
#
# * Step 1: apply median filter to get ride on small details
#
# * Step 2: repeat 4 times:
# - clone the 3-color image ("TEMP_FILE")
# - replace black, gray and white with their corresponding values Ci_B, Ci_G, Ci_W;
# to do this we use "-fill TO_COLOR -opaque FROM_COLOR" command
# - stack the resulting image after the previous one (2 columns, 2 rows)
#
# * Step 3: apply spread filter to "soften" edges
convert "$TEMP_FILE" -median 2 -fuzz 0% \( -clone 0 \( -clone 0 -fill "$C1_W" -opaque "$WHITE" -fill "$C1_G" -opaque "$GRAY" -fill "$C1_B" -opaque "$BLACK" \) \( -clone 0 -fill "$C2_W" -opaque "$WHITE" -fill "$C2_G" -opaque "$GRAY" -fill "$C2_B" -opaque "$BLACK" \) -delete 0 +append \) \( -clone 0 \( -clone 0 -fill "$C4_W" -opaque "$WHITE" -fill "$C4_G" -opaque "$GRAY" -fill "$C4_B" -opaque "$BLACK" \) +append \( -clone 0 -fill "$C3_W" -opaque "$WHITE" -fill "$C3_G" -opaque "$GRAY" -fill "$C3_B" -opaque "$BLACK" \) -delete 0 \) -delete 0 -append -spread 1 -quality $QUALITY "$2" \
|| ( echo "$0: could not apply filter" ; rm -f "$TEMP_FILE" ; exit 7 )
# Delete temporary file
rm -f "$TEMP_FILE"
# Success
exit 0
(replace all variables with value)
Code: Select all
convert DSCFinput.JPG -background white -flatten +matte -colorspace gray -colors 3 -colorspace rgb -type TrueColor -matte DSCF999.JPG
convert DSCF999.JPG -channel ALL -normalize DSCF999.JPG
convert DSCF999.JPG histogram:- | identify -format %c
convert DSCF999.JPG -median 2 -fuzz 0%% \( -clone 0 \( -clone 0 -fill #fefc09 -opaque #FFFFFFFFFFFF -fill #94c015 -opaque #F0F0F0F0F0F0 -fill #342b7c -opaque #000000000000 \) \( -clone 0 -fill #fff9a3 -opaque #FFFFFFFFFFFF -fill #9ec038 -opaque #F0F0F0F0F0F0 -fill #ee6807 -opaque #000000000000 \) -delete 0 +append \) \( -clone 0 \( -clone 0 -fill #0483ee -opaque #FFFFFFFFFFFF -fill #fdf107 -opaque #F0F0F0F0F0F0 -fill #e60877 -opaque #000000000000 \) +append \( -clone 0 -fill #f58508 -opaque #FFFFFFFFFFFF -fill #79bef9 -opaque #F0F0F0F0F0F0 -fill #734995 -opaque #000000000000 \) -delete 0 \) -delete 0 -append -spread 1 -quality 90%% FINAL.JPG \
Code: Select all
convert DSCF999.JPG histogram:- | identify -format %c
m.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: photo effect - Warholize - line art
It extracts the JPEG images 'comment'. probably storing it in some variable so it can later draw/annotate it onto the resulting image.myspacee wrote:for first thing don't understand and replace code for :
Code: Select all
convert DSCF999.JPG histogram:- | identify -format %c
See percent escapes
http://imagemagick.org/script/escape.php
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: photo effect - Warholize - line art
thank you for reply, now reading...
anyone can help to adjust linux script to obtain working example for windows geeks ?
thank you,
m.
anyone can help to adjust linux script to obtain working example for windows geeks ?
thank you,
m.
Re: photo effect - Warholize - line art
This part is the main problem, as you noted:myspacee wrote: anyone can help to adjust linux script to obtain working example for windows geeks ?
Code: Select all
HISTO=`convert "$TEMP_FILE" histogram:- | identify -format %c - | grep -vre "black\|white"`
But a batch file is doable, I'l bet, with loads of work. I suspect you need to write the histogram to a separate file and then use identify on that if you want to replicate the rest of your process.
But I also suspect that there is a much easier way to achieve a similar effect without resorting to the histogram. Something along these lines:
Code: Select all
convert ( warhol-in.jpg -colorspace gray -colors 3 ) ( -size 3x1 xc:white -fill red -draw "color 0,0 point" -fill green -draw "color 1,0 point" -fill blue -draw "color 2,0 point" ) -interpolate integer -clut cat.gif
Rick
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: photo effect - Warholize - line art
Right you are -unique-colorsrmabry wrote:Most of that is just to get the three colors into a 3-pixel file that can them be used for color replacement using -clut, and there is surely a more elegant way to create a 3-pixel file.
This just creates a image 1 pixel high, and N pixels long where N is the number of colors in the image.
Extracting Image Colors
http://www.imagemagick.org/Usage/quantize/#extract
However the order of the colors are undefined as it depends on the oct-tree representation of the color space used by Colro Quantization. Basically the color reduction data handling.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: photo effect - Warholize - line art
But here we want to choose the colors. What's the nicest way to get a 3x1 image cosisting of purple, then white, then #2277ff?anthony wrote:Right you are -unique-colors
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: photo effect - Warholize - line art
What's the nicest way to get a 3x1 image cosisting of purple, then white, then #2277ff?
Code: Select all
convert xc:purple xc:white xc:'#2277ff' -append 3_colors.png
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: photo effect - Warholize - line art
Ha! Super slick. So -size defaults to 1x1, not bad. The earlier command is now much faster:
That's for Windows only, of course --- no escapes of parentheses. No quotes on the # needed in Windows, either, but it doesn't hurt.
Thanks, Anthony.
Code: Select all
convert ( warhol-in.jpg -colorspace gray -colors 3 ) ( xc:purple xc:"#123456" xc:yellow -append ) -interpolate bicubic -clut cat.gif
Thanks, Anthony.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: photo effect - Warholize - line art
You can also use ^ to continue onto the next line to make it look neater and seperate actions by lines
PS: the first set of parenthesis is not needed as there are no image in memory yet, but it don't hurt either
Code: Select all
convert ( warhol-in.jpg -colorspace gray -colors 3 ) ^
( xc:purple xc:"#123456" xc:yellow -append ) ^
-interpolate bicubic -clut cat.gif
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: photo effect - Warholize - line art
The comments so far on this warhol script have asked how to convert it to windows... anyone have an idea why these problems came up in Cygwin for windows?
T3500 ~
$ ./warhol test400.jpg warhol.jpg
./warhol: line 18: $'\r': command not found
./warhol: line 22: $'\r': command not found
./warhol: line 25: $'\r': command not found
./warhol: line 43: $'\r': command not found
./warhol: line 44: $'\r': command not found
./warhol: line 48: $'\r': command not found
./warhol: line 60: syntax error near unexpected token `||'
./warhol: line 60: ` || ( echo "$0: could not reduce colors in input image" ;
'xit 2 )
T3500 ~
$ ./warhol test400.jpg warhol.jpg
./warhol: line 18: $'\r': command not found
./warhol: line 22: $'\r': command not found
./warhol: line 25: $'\r': command not found
./warhol: line 43: $'\r': command not found
./warhol: line 44: $'\r': command not found
./warhol: line 48: $'\r': command not found
./warhol: line 60: syntax error near unexpected token `||'
./warhol: line 60: ` || ( echo "$0: could not reduce colors in input image" ;
'xit 2 )
Re: photo effect - Warholize - line art
Below is the rough version of how I got a Warhol style image.
Question, though: could anyone point me to a guide on combining this many commands in windows command prompt? Or, put another way, is it possible to create and manipulate four seperate images within the same command? I'm hoping to do batch processing with this.
convert test.jpg -resize 400 hue1.jpg
convert test.jpg -resize 400 hue2.jpg
convert test.jpg -resize 400 hue3.jpg
convert test.jpg -resize 400 hue4.jpg
convert -modulate 100%,100%,15% hue1.jpg hue1.jpg
convert -modulate 100%,100%,55% hue2.jpg hue2.jpg
convert -modulate 100%,100%,95% hue3.jpg hue3.jpg
convert -modulate 100%,100%,145% hue4.jpg hue4.jpg
convert -size 800x600 xc:white warholize.jpg
composite -gravity NorthEast hue1.jpg warholize.jpg warholize.jpg
composite -gravity NorthWest hue2.jpg warholize.jpg warholize.jpg
composite -gravity SouthEast hue3.jpg warholize.jpg warholize.jpg
composite -gravity SouthWest hue4.jpg warholize.jpg warholize.jpg
Question, though: could anyone point me to a guide on combining this many commands in windows command prompt? Or, put another way, is it possible to create and manipulate four seperate images within the same command? I'm hoping to do batch processing with this.
convert test.jpg -resize 400 hue1.jpg
convert test.jpg -resize 400 hue2.jpg
convert test.jpg -resize 400 hue3.jpg
convert test.jpg -resize 400 hue4.jpg
convert -modulate 100%,100%,15% hue1.jpg hue1.jpg
convert -modulate 100%,100%,55% hue2.jpg hue2.jpg
convert -modulate 100%,100%,95% hue3.jpg hue3.jpg
convert -modulate 100%,100%,145% hue4.jpg hue4.jpg
convert -size 800x600 xc:white warholize.jpg
composite -gravity NorthEast hue1.jpg warholize.jpg warholize.jpg
composite -gravity NorthWest hue2.jpg warholize.jpg warholize.jpg
composite -gravity SouthEast hue3.jpg warholize.jpg warholize.jpg
composite -gravity SouthWest hue4.jpg warholize.jpg warholize.jpg
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: photo effect - Warholize - line art
Here is one way using the cat image and my tricolorize script:
convert cat1.jpg -colorspace gray catgray.jpg
tricolorize -l yellow -m blue -h red catgray.png cat1gray_tri1.jpg
tricolorize -l green -m magenta -h violet catgray.png cat1gray_tri2.jpg
tricolorize -l blue -m green -h orange catgray.png cat1gray_tri3.jpg
tricolorize -l magenta -m yellow -h cyan catgray.png cat1gray_tri4.jpg
montage cat1gray_tri1.jpg cat1gray_tri2.jpg cat1gray_tri3.jpg cat1gray_tri4.jpg \
-tile 2x2 -geometry +5+5 -background white \
catgray_warhol.jpg
convert cat1.jpg -colorspace gray catgray.jpg
tricolorize -l yellow -m blue -h red catgray.png cat1gray_tri1.jpg
tricolorize -l green -m magenta -h violet catgray.png cat1gray_tri2.jpg
tricolorize -l blue -m green -h orange catgray.png cat1gray_tri3.jpg
tricolorize -l magenta -m yellow -h cyan catgray.png cat1gray_tri4.jpg
montage cat1gray_tri1.jpg cat1gray_tri2.jpg cat1gray_tri3.jpg cat1gray_tri4.jpg \
-tile 2x2 -geometry +5+5 -background white \
catgray_warhol.jpg