Page 1 of 3
Help: mirroring along a diagonal
Posted: 2011-03-19T15:06:41-07:00
by kolorman
Hi,
for example I have a image with 400x400px an I wish a mirroring along a diagonal line like -transpose
How can I cut a triangle like 0,0+0,400+400,400 and flip along the line 0,0 -> 400,400??
Thanks
kolorman
Re: Help: mirroring along a diagonal
Posted: 2011-03-19T15:27:01-07:00
by fmw42
Rotate 180 the rectangular image first then draw your triangle to create a b/w mask and and composite as alpha channel to make that side transparent.
see -rotate and -draw and -composite
http://www.imagemagick.org/Usage/draw/
http://www.imagemagick.org/Usage/compose/#copyopacity
#cyclops image is 100x100
convert \( cyclops.gif -rotate 180 \) \
\( +clone -fill white -colorize 100% -fill black -draw "polygon 0,0 100,0 0,100" \) \
-alpha off -compose copy_opacity -composite cyclops_rotate180_triangle.gif
Re: Help: mirroring along a diagonal
Posted: 2011-03-19T16:02:03-07:00
by kolorman
Thanks for your fast answer!
I try this
convert \(myfile.gif -rotate 180 \) \(+clone -fill white -colorize 100% -fill black -draw "polygon 0,0 100,0 0,100" \) -alpha off -compose copy_opacity -composite myfile_rotate180_triangle.gif
an I became an Error
convert: unable to open image myfile.gif....
but the file exist in the current folder??
kolorman
Re: Help: mirroring along a diagonal
Posted: 2011-03-19T16:13:20-07:00
by kolorman
... ist the same on Linux or Windows
convert: unable to open image `(myfile.gif': No such file or directory @ blob.c/
OpenBlob/2480.
???
kolorman
Re: Help: mirroring along a diagonal
Posted: 2011-03-19T16:57:08-07:00
by kolorman
hmm... this works on Linux:
convert \( frau500.png -rotate 180 \) \( +clone -fill white -colorize 100% -fill black -draw "polygon 0,0 500,0 0,500" \) -alpha off -compose copy_opacity -composite frau500_rotate180_triangle.png
but the image frau500_rotate180_triangle.png have only a triangle from the image and a half of transparency
This is my "workflow" in photoshop:
* make triangle 0,0 0,500 500,500
* cut out an delete the rest
* make a copy
* flip the copy vertical
* rotate at 90 degre clockwise
can I upload a image?
Thanks!
Re: Help: mirroring along a diagonal
Posted: 2011-03-19T17:24:35-07:00
by fmw42
convert \(myfile.gif -rotate 180 \) \(+clone -fill white -colorize 100% -fill black -draw "polygon 0,0 100,0 0,100" \) -alpha off -compose copy_opacity -composite myfile_rotate180_triangle.gif
You need a space after \(
convert
\( myfile.gif -rotate 180 \)
\( +clone -fill white -colorize 100% -fill black -draw "polygon 0,0 100,0 0,100" \) -alpha off -compose copy_opacity -composite myfile_rotate180_triangle.gif
On windows you don't have \ before ( or )
No uploads are allowed, but you can post a link to your input and output images (hosted elsewhere), then perhaps I can see more of what you are trying to do.
This is my "workflow" in photoshop:
* make triangle 0,0 0,500 500,500
* cut out an delete the rest
* make a copy
* flip the copy vertical
* rotate at 90 degre clockwise
try this
convert cyclops.gif \
\( +clone -fill black -colorize 100% -fill white -draw "polygon 0,0 0,100 100,100" \) \
-alpha off -compose copy_opacity -composite \
-flip -rotate 90 \
cyclops_triangle.gif
or
convert cyclops.gif \
\( +clone -alpha transparent -alpha extract -fill white -draw "polygon 0,0 0,100 100,100" \) \
-alpha off -compose copy_opacity -composite \
-flip -rotate 90 \
cyclops_triangle.gif
see
http://www.imagemagick.org/Usage/canvas/#other
http://www.imagemagick.org/Usage/compose/#dstout
http://www.imagemagick.org/Usage/compose/#copyopacity
Re: Help: mirroring along a diagonal
Posted: 2011-03-20T01:06:08-07:00
by anthony
Two items instead of -flip and -rotate you can use -transpose or -transverse
http://www.imagemagick.org/Usage/warping/#transpose
Second and more important.
Draw currently will draw areas that are 1/2 pixel bigger that expected.
http://www.imagemagick.org/Usage/draw/#bounds
That means your mask is not a perfect 50-50 mask of the image.
In this case the diagonal line will not be a problem, especially as you are mirroring along the diagonal so the diagonal pixels will be the same (shared) in both images. But you may get a slight mix of pixels just off to one side of the diagonal. You may want to examine your mask and perhaps threshold it in this specific case.
It is however a serious problem if you are merging two completely different images, as the diagonal will be given to one image, but not the other (even if you threshold! I have no good solution either, though am looking for one.
Re: Help: mirroring along a diagonal
Posted: 2011-03-20T01:41:59-07:00
by kolorman
Thanks for yours input - I try the different parameter...
What is the goal: I must write a script to make a kaleidoscope image like Freds
http://www.fmwconcepts.com/imagemagick/ ... /index.php but without the mathematical way
The output file is a quadratical image (eg. 500x500px) with 4 slices.
I will crop a triangle area from input file (1024x768px) with 0,0 0,250 250,250.
The position of the left corner is in the output file at the center (250,250)
If I mirror this triangle at the diagonale I have filled the (mathematical) quadrant four (count against the clockwise).
Now I must mirror this quadratic area on top (quadrant one) and mirror the right side to left (quadrant two and three)...
Thanks for your help at a IM-greenhorn
kolorman
Re: Help: mirroring along a diagonal
Posted: 2011-03-20T05:29:40-07:00
by anthony
As mentioned draw should be fine for this, Diagonals are the same when an image is flipped, and as such using a mask that is 1/2 pixel larger so as to include the diagonal will not make a difference.
Something you may be interested in is some work by Günter Bachelier
http://www.vi-anec.de/Trance-Art/Evo-Ku ... nst_e.html
Yes most of his pages are in german, but the artist created art randomly by cutting and tiling images together in various keliedoscopic ways. He looked at tiling and masking using 2006, but taht that time I did not know enough of correct masking techniques to help him.
He did have some PDF documents detailing exactly how he use IM to cut out random tiles of an image and the piece them together. The Results were then human filtered and the process repeated to create his artwork.
However he does not seem to mention or show much of some of the results he created online any more.
One (boring) example I did find is at
thttp://
www.vi-anec.de/Trance-Art/IM-examples/p ... type_2.jpg
Re: Help: mirroring along a diagonal
Posted: 2011-03-20T05:49:06-07:00
by kolorman
Hi anthony,
the websites from Günther are very old and have any dead links
to read this in german is not a problem - better as english - I live in Berlin, Germany
But, I dont find a example to make a kaleidoscopic image...???
Thanks kolorman
Re: Help: mirroring along a diagonal
Posted: 2011-03-20T17:34:21-07:00
by anthony
I have sent you privately a old PDF document from Gunther that is directly relevant.
He does further in that not only does he mirror an image across a diagonal, but he then append flips and flops of that image to form a kaleidoscope image of 8 copies of the original image.
HOWEVER as the diagonal is 'overlaid' due to the mask. I would not just simply append the flips and flops. Doing so will create 'doubled' pixels along the join. Instead I would 'chop' one pixel from the flipped (flopped) image before appending so, like diagonals you end up with a single pixel along the join.
Of course the resulting image will always then be an 'odd' size.
Hmm...
generate a random image , or use any image you like (as long as it is square)
Code: Select all
convert -size 50x50 xc: +noise Random -blur 0x5 -emboss 2 source.png
And a diagonal masking image the same size.
This uses a different technique to using draw to create a triangle
Code: Select all
convert source.png -sparse-color voronoi '%w,0 white 0,%h black' mask.png
diagonal tile.
Code: Select all
convert source.png \( +clone -transpose \) mask.png \
-compose Src -composite mirror.png
now make 8 copy kaleidoscope
Code: Select all
convert mirror.png \( +clone -flop -chop 1x0 \) +append \
\( +clone -flip -chop 0x1 \) -append \
kaleidoscope.png
See Diagonal Mirror Tiling
http://www.imagemagick.org/Usage/canvas/#tile_diagonal
NOTE there are actually only 17 ways of tiling a image across a plane using only rotations and mirrors.
perhaps you like to explore others
See
http://www.scienceu.com/geometry/articl ... index.html
and specifically Wallpaper Groups
This specific wallpaper group is known as
p4m
Re: Help: mirroring along a diagonal
Posted: 2011-03-20T19:46:08-07:00
by fmw42
NOTE there are actually only 17 ways of tiling a image across a plane using only rotations and mirrors.
perhaps you like to explore others
See lhttp://
www.scienceu.com/geometry/articles/tiling/index.html
and specifically Wallpaper Groups
This specific wallpaper group is known as p4m
Very Interesting Article And Solution:
convert zelda3.jpg \( +clone -transpose \) \
\( +clone -sparse-color voronoi '%w,0 white 0,%h black' \) \
-composite \
\( +clone -flop -chop 1x0 \) +append \
\( +clone -flip -chop 0x1 \) -append \
zelda3_kaleidoscope.jpg
Re: Help: mirroring along a diagonal
Posted: 2011-03-20T20:36:59-07:00
by anthony
NOTE in using sparse-colors. what is white and what is place really does not matter much as you are directly combining two images.
But if you need finer control over the mask, I specifically placed the white in the top-right pixel edge, simply because then white included the diagonal pixels.
If you need a perfect mask for images that are not being mirrored, those diagonal pixels should be a gray50 in color. That is a 50-50 blend along the diagonal.
I also purposely removed one set of pixels along the vertical and horizontal mirrors, as it look better, than having those pixels duplicated.
Re: How do I work out a diagonal of a rectangle using pythag
Posted: 2011-03-20T20:43:31-07:00
by anthony
vikely wrote:It is a typical Q in trig. 3-4-5
the original problem was for a square. However generating a 'correct' diagonal mask for a rectangle, Especially when trying to generate triangular tiles with a 60 degree angle in them, is not simple.
(mirror that triangle and append and you get a equilateral triangle!
It is here that the 'draw bounds' problem really starts to cause major headaches.
It gets worse when you also want to do 60 degree rotations of the resulting tile to generate proper 'hex' tilings.
It was here that Gunther (I previously mentioned) had real problems.
Re: Help: mirroring along a diagonal
Posted: 2011-03-21T21:51:42-07:00
by anthony
Additional...
Here is a p4g tiling pattern I added to
Diagonal Mirror Tiling examples.
(give it an hour or two to appear)
Note you can not generate this tile pattern from a existing image, as you will end up with ugly discontinuities. But you can tile a raw random data, then convert that data into something more interesting as in the above.
Actually I like this pattern better than the p4m tile!