Page 1 of 2

Rastr (lenticular)

Posted: 2012-02-19T04:16:13-07:00
by goldskif
Hi all,
tell me, what is the easiest way to make a picture of a width of 9000 pixels and lines of 1 pixel through 9 pixel

Image

Re: Rastr

Posted: 2012-02-19T08:46:12-07:00
by whugemann
The easiest way is creating a small tile defining your repetive pattern and then apply the technique explained at http://www.imagemagick.org/Usage/canvas/#tile_memory.

Re: Rastr

Posted: 2012-02-19T11:59:22-07:00
by fmw42
If on Linux/Mac or Windows w/ Cygwin, then you could use my script, grid, at the link below. Just start with a black (or whatever color you want) background image of the size you desire. However, Wolfgang's technique is more efficient.

Re: Rastr

Posted: 2012-02-19T12:28:50-07:00
by goldskif
Thank You.
I now have this mask cut out the photographs of thin narrow strips.
-clip-mask use is not recommended. What do you advise?
http://www.imagemagick.org/Usage/masking/ does not provide a clear separation of

Re: Rastr

Posted: 2012-02-19T13:17:32-07:00
by fmw42
Try this. It creates a 1 row image that is 20 pixels of black, then 2 pixels white. Then it puts it into mpr (in memory format) and deletes the created file image, then it tiles it out to 500x500 for the output. See http://www.imagemagick.org/Usage/canvas/#tile_memory


convert -size 20x1 xc:black -size 2x1 xc:white +append \
-write mpr:tile +delete -size 500x500 tile:mpr:tile \
grid.gif


Why do you need a clip-mask? Perhaps you can explain what your real goal is? Provide links to examples if possible and identify what version of IM and platform you are using.

Re: Rastr

Posted: 2012-02-19T14:04:34-07:00
by goldskif
This is all you need for volumetric 3D photos.
Is 8-12 photos (usually 10) , with a slight displacement.
Then all of the photos are processed.
This raster of each picture is cut 1 out of 10 bar.
Cut out the strips are formed near the overall picture.
Printing.
On top of glued lenticular image.
Through the lenses of the eyes see strips like 3D photo

Re: Rastr

Posted: 2012-02-19T14:09:26-07:00
by fmw42
Sorry, I don't really follow what you want to do. I think one would need to see an example of your input and output images. By 3D I presume you mean layers or frames as IM does not handle volumetric data.

Re: Rastr

Posted: 2012-02-19T14:14:35-07:00
by goldskif

Re: Rastr (lenticular)

Posted: 2012-02-19T14:26:05-07:00
by fmw42
Best I can suggest without actually trying with real images. You need to create the gid mask as appropriate to the spacing and number of images. Then for the first image, be sure that the white is at the left by creating the mask that way. Then put the mask into the alpha channel of the image. Then roll the mask by the offset you need for the next image, then put the rolled mask into the alpha channel of the that image. Continue for each image rolling the previous mask by the same amount. Then when you have all images with their appropriate masks in their alpha channel, flatten the images together.

see
http://www.imagemagick.org/script/comma ... s.php#roll
http://www.imagemagick.org/Usage/layers/#flatten


I don't know if this will help, but see my script, interleave and interweave, at the link below. What you need is somewhat like interweave by columns with more than two image limit.

If you can provide links to some example input images and say exactly what you need, then perhaps we can provide some code.

Re: Rastr (lenticular)

Posted: 2012-02-20T02:59:31-07:00
by whugemann
I think that the term "interweave" sets us on the right track. This is a common video technique and in case that you don't want to automise this (or as a test), you could use video software to perform it. As long as you use a power of two (say 8 photos) for the process, it's just a question of organising the weave correctly. In video, weaving is performed in vertical direction, such that you have to rotate your images by 90°.

If you are working under Windows (you haven't told us so far), you could use AVIsynth / VirtualDub for testing (see http://www.imagemagick.org/Usage/windows/#auxiliary). Here is the test code combining four photographs:

Code: Select all

V1=ImageReader("Foto1.jpg").Turnleft
V2=ImageReader("Foto2.jpg").Turnleft
V3=ImageReader("Foto3.jpg").Turnleft
V4=ImageReader("Foto4.jpg").Turnleft
I1=Interleave(v1,v3).AssumeFieldBased.Weave
I2=Interleave(v2,v4).AssumeFieldBased.Weave
Interleave(I1,I2).AssumeFieldBased.Weave

Re: Rastr (lenticular)

Posted: 2012-02-20T03:23:22-07:00
by goldskif
Thank you very much.
I have everything turned out c photographs.
About one want to ask - can you advise how best to combine all of the rasters in one photo.

Use OS Linux Ubuntu 10.04.03
IM vers - 7:6.5.7.8-1ubuntu1.1

Re: Rastr (lenticular)

Posted: 2012-02-20T11:07:15-07:00
by fmw42
As I mentioned above, you have to create a mask for each image with the mask being offset by the thickness of the columns you want, then put the mask into the alpha channel and then flatten all the images. My links should give you the idea. If you can provide an set of small example images, then I can try to create the command line(s). My interweave script could be modified to allow any number of images also.

Re: Rastr (lenticular)

Posted: 2012-02-20T12:15:29-07:00
by fmw42
Here is a bash unix test script I wrote to create the lenticular result from 4 equal size images with 2 pixel wide columns.


#!/bin/bash

#NOTE width of images must be divisible by number of images without remainder
#NOTE all images must be same size

infile1="zelda3.png"
infile2="checks.png"
infile3="lena2.png"
infile4="mandril.png"


infileArr=($infile1 $infile2 $infile3 $infile4)
echo "${infileArr[*]}"
num=${#infileArr[*]}
echo "num=$num"

thick=2 # thickness of bands


outfile="test_lenticular2_t${thick}.png"

echo "outfile=$outfile"

# set directory for temporary files
# tmpdir="/tmp"
tmpdir="."

dir="$tmpdir/LENTICULAR.$$"

mkdir "$dir" || errMsg "--- FAILED TO CREATE TEMPORARY FILE DIRECTORY ---"
trap "rm -rf $dir; exit 0" 0
trap "rm -rf $dir; exit 1" 1 2 3 15


# read input images
for ((i=0; i<num; i++)); do
convert -quiet -regard-warnings "${infileArr[$i]}" $dir/tmpI$i.mpc ||
echo "--- FILE ${infileArr[$i]} DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---"
done

# get image dimensions
ww=`convert -ping $dir/tmpI1.mpc -format "%w" info:`
hh=`convert -ping $dir/tmpI1.mpc -format "%h" info:`
thick2=`convert xc: -format "%[fx:($num-1)*$thick]" info:`
echo "ww=$ww; hh=$hh; thick2=$thick2;"


# create mask
convert -size ${thick}x1 xc:white -size ${thick2}x1 xc:black +append \
-write mpr:mask +delete -size ${ww}x${hh} tile:mpr:mask \
$dir/tmpM.mpc

#process images
convert -size ${ww}x${hh} xc:none $dir/tmpO.mpc
j=0
for ((i=0; i<num; i++)); do
echo "i=$i; j=$j"
convert $dir/tmpO.mpc $dir/tmpI$i.mpc \( $dir/tmpM.mpc -roll +$j+0 \) \
-compose over -composite $dir/tmpO.mpc
j=$((j+thick))
done
convert $dir/tmpO.mpc $outfile


exit 0


Image1:
Image

Image2:
Image

Image3:
Image

Image4:
Image

Result:
Image

I will try to formalize it and upload to my web site in the next few days.

However, it would be nice to have a real set of images that make a proper lenticular image.

Re: Rastr

Posted: 2012-02-20T20:55:58-07:00
by anthony
goldskif wrote:Thank You.
I now have this mask cut out the photographs of thin narrow strips.
A FASTER way is to simply -sample your image to a size that is 1/10th of the original width.
Sample only takes a single pixel sample, so the result is one pixel is read and 9 junked.

convert image.png -sample 10%x100x\! result.png

Note this does not fill in the 'black areas, just removes them, though a tiling composition with a -compose multiply
can blacken out pixels too.


For more examples like this see...
Video handling, De-Interlacing a video frame
http://www.imagemagick.org/Usage/video/#deinterlace

In this only every second line is wanted, but the techniques are the same.

Re: Rastr

Posted: 2012-02-20T20:58:41-07:00
by anthony
goldskif wrote:Thank You.
I now have this mask cut out the photographs of thin narrow strips.
-clip-mask use is not recommended. What do you advise?
http://www.imagemagick.org/Usage/masking/ does not provide a clear separation of
I have updated that area with more examples (though it was more for 'read masks not write masks'). Should appear (with expanded index entries) within an hour or two.

You probably should use -mask rather than -clip-mask but really that should not make a lot of difference if your mask is boolean (pure black and white).