Page 1 of 1
Composite: Person & checkerboard pattern
Posted: 2019-09-18T02:43:36-07:00
by claus_01
Hello,
I want to modify an image with a female head in ImageMagick (see attached image), so that the checkerboard pattern grows in size from left to right. In addition, I want to apply a wave form to the checkerboard pattern.
The example was made in Gimp 2.10. Ideally, I want to make the pixels in the portrait grow in size from left to right, but I think this is very hard to accomplish. I'm using IM 6.9.7-4 on Ubuntu 18.04.
Thanks,
Claus
Re: Composite: Person & checkerboard pattern
Posted: 2019-09-18T05:26:14-07:00
by snibgo
I suppose you want these operations to apply to each separate image before compositing them together.
"... grows in size from left to right" sounds like a simple perspective projection. See
http://www.imagemagick.org/script/comma ... hp#distort
"...apply a wave form" see
http://www.imagemagick.org/script/comma ... s.php#wave
"Ideally, I want to make the pixels in the portrait grow in size from left to right, but I think this is very hard to accomplish." Pixels are pixels. All pixels in the image are the same size. Perhaps you want some effect that seems to have variable-size pixels. I expect something like that could be done.
Re: Composite: Person & checkerboard pattern
Posted: 2019-09-18T08:44:44-07:00
by fmw42
Input:
Code: Select all
WxH=`convert Bill_Murray.jpg -format "%wx%h" info:`
ww=`echo $WxH | cut -dx -f1`
hh=`echo $WxH | cut -dx -f2`
convert Bill_Murray.jpg \
\( -size ${ww}x$((hh+80)) pattern:checkerboard -distort perspective \
"0,0 0,%[fx:-$hh] $((ww-1)),0 $((ww-1)),0 $((ww-1)),$((hh-1)) $((ww-1)),$((hh-1)) 0,$((hh-1)) 0,%[fx:+2*$hh]" \
-wave 40x$((ww/2)) -gravity center -crop ${ww}x${hh}+0+0 +repage \) \
\( -size ${hh}x${ww} gradient: -rotate 90 \) \
-compose over -composite Bill_Murray_result.jpg
Re: Composite: Person & checkerboard pattern
Posted: 2019-09-19T05:12:14-07:00
by claus_01
Hi Snibgo & Fred,
many thanks for your response to my query. That's indeed the direction I would like to take. Additionally, I discovered the command 'virtual pixels'. Would it be feasible to use this instead of an overlay checkerboard pattern? There's the method 'checker-tile'. Could that be used?
Greetings,
Claus
Re: Composite: Person & checkerboard pattern
Posted: 2019-09-19T06:02:14-07:00
by claus_01
Hi again,
here's the result of my attempts to use the script Fred provided. I edited the image in Gimp with the layer mode 'grain merge'.
Now I will try to improve this using 'virtual pixels'. What I'm after is to make visible that the image in question is composed of pixels.
Greetings,
Claus
Re: Composite: Person & checkerboard pattern
Posted: 2019-09-19T18:00:13-07:00
by snibgo
We can get an effect of increasing pixelation by shrinking the right side, then enlarging it with a scaling-type filter (Windows BAT syntax):
Code: Select all
magick ^
toes.png ^
-distort perspective "0,0,0,0 0,232,0,232 266,0,266,111 266,232,266,121" ^
-filter point ^
-interpolate nearest-neighbor ^
-distort perspective "0,0,0,0 0,232,0,232 266,111,266,0 266,121,266,232" ^
toes_pixelate.png
Re: Composite: Person & checkerboard pattern
Posted: 2019-09-20T06:06:42-07:00
by claus_01
> Windows BAT syntax
What would that be using a Linux shell script?
Would this be correct?
Code: Select all
#!/bin/sh
convert \
Aneta_088.png \
-distort perspective "0,0,0,0 0,232,0,232 266,0,266,111 266,232,266,121" \
-filter point \
-interpolate nearest-neighbor \
-distort perspective "0,0,0,0 0,232,0,232 266,111,266,0 266,121,266,232" \
Aneta_088_pixelate.png
Of course the numbers will have to be different.
Claus
Re: Composite: Person & checkerboard pattern
Posted: 2019-09-20T06:35:02-07:00
by snibgo
That looks about right.
Here's another example, using %[fx:...] so we have fewer magic numbers.
Code: Select all
%IMG7%magick ^
Bill_Murray.jpg ^
-distort perspective "0,0,0,0 0,%%[fx:h-1],0,%%[fx:h-1] %%[fx:w-1],0,%%[fx:w-1],%%[fx:421-10] %%[fx:w-1],%%[fx:h-1],%%[fx:w-1],%%[fx:421+10]" ^
-filter point ^
-interpolate nearest-neighbor ^
-distort perspective "0,0,0,0 0,%%[fx:h-1],0,%%[fx:h-1] %%[fx:w-1],%%[fx:421-10],%%[fx:w-1],0 %%[fx:w-1],%%[fx:421+10],%%[fx:w-1],%%[fx:h-1]" ^
Bill_Murray_pix.jpg
Bill Murray's eyes are at y=421. We shrink to that y-value, plus or minus 10.
For Windows BAT, we have doubled the %%.
We could add a "-wave" at the end. Or we could apply the same distortion to an identity absolute displacement map, and blend that with identity absolute displacement map, then apply that to the input image. The possibilities are endless.