Wiki
Clone wikianima / component_ImageMagick
Learn more about ImageMagick: http://www.imagemagick.org/Usage/
Nice collection of 'tidbits': http://www.fmwconcepts.com/imagemagick/tidbits/image.php
Example use cases
- Montage (gray background, 2 pixel border, force original size, force horizontal montage)
- Note: ImageMagick has sometimes issues with low number of colors + creating the correct palette - so force the 24bit mode.
#!Scala val montage = ImageMagick(in1=input1,in2=input2, binary="montage", command="-background '#888888' @in1@ @in2@ -tile 2x -geometry +2+0 PNG24:@out@")
-
Montage from one folder of images:
#!Scala val montage = ImageMagick(in1=input_images, files=1, extension=".png", binary="montage", command="-tile 6x @dir1@/* -geometry 200x200!+0+0 @out@")
-
Image resize
val halfsize = ImageMagick(in1=input, command="-resize 50%x @in1@ @out@") val exactsize = ImageMagick(in1=input, command="-resize 640x480 @in1@ @out@")
-
Logical operations (faster than using -fx)
val and_operation=ImageMagick(in1=input1, in2=input2, command="-compose Multiply @in1@ @in2@ -composite @out@")
-
Morphological operations
- Dilate first input by disk of 5 px radius
- Complement the second input
- Perform AND operation between the two
val dilate_neg_and = ImageMagick(in1=BWinput1, in2=BWinput2, command="@in1@ -morphology Dilate Disk:5 @in2@ -fx \"u[0] & (1-u[1])\" @out@")")
-
Filling masks
- rather tricky in imagemagick, but doable:
val filled=ImageMagick(in1=mask_with_holes, command="@in1@ -bordercolor black -border 1 -fuzz 10% "+ "-fill red -floodfill +0+0 black -fill white +opaque red "+ "-fill black -opaque red -shave 1x1 @out@")
- rather tricky in imagemagick, but doable:
-
Marking mask perimeter
val perimeter=ImageMagick(in1=mask, command="@in1@ -morphology EdgeIn Disk:1 -threshold 0 @out@")
-
Image sequence operations
- read all images in folder, produce 1 image
val median = ImageMagick(in1=input_images, files=1, extension=".png", command="@dir1@/* -evaluate-sequence median @out@")
- read all images in folder, produce 1 image
-
Marking pixels with rings
val rings = ImageMagick(in1=input_images, command="@in1@ -morphology Dilate Ring @out@")
-
Colorization of multiple gray scale images
val colored=ImageMagick(in=makeArray(red,green,blue,nuclei.perimeter), command=" -compose Plus "+ " \\( @a1@ -auto-level +level-colors ,Red \\) "+ " \\( @a2@ -auto-level +level-colors ,Green \\) -composite "+ " \\( @a3@ -auto-level +level-colors ,Blue \\) -composite "+ " \\( @a4@ -auto-level +level-colors ,White \\) -composite "+ "@out@")
Updated