Difference between revisions of "Converting microarray images"
m (→Commands for microarray images: In BASH, could do a perl script) |
m (quote output file to allow spaces in filenames) |
||
Line 58: | Line 58: | ||
do | do | ||
echo "[ Converting $file ]" | echo "[ Converting $file ]" | ||
− | convert $file -resize 7% -rotate -90 -quality 0 ../$dir/${file%%_*.jpg}.png | + | convert $file -resize 7% -rotate -90 -quality 0 ../$dir/"${file%%_*.jpg}.png" |
done | done | ||
Revision as of 22:01, 12 September 2006
Microarray images are generally stored as 16-bit TIFF images (usually around 100Mb in size. An alternative lossy image format is JPEG format, which is still bloated at around 40Mb filesize. Investigating the image size of a typical GenePix derived JPEG image, the pixel size is 4400 × 14300 pixels (72 pixels per inch) with an aspect ratio of 3.25 . A general visual summary of these lossy images is all that is required where they could be converted to a much smaller thumbnail PNG type image using an appropriate program such as ImageMagick or Gimp which allows batch processing of multiple images a once.
Imagemagick
Once installed, all image magick tools are accessed through the command line. The identify binary describes the format and characteristics of one or more image files. e.g.
identify rose.jpg rose.jpg JPEG 640x480 DirectClass 87kb 0.050u 0:01 |
The convert binary is useful for resizing images, for example;
convert -size 800x600 input.jpg'[80x60]' output.png convert input.jpg --resize 80x60 output.png convert input.jpg --resize 10% output.png convert input.jpg -resize 8% -quality 0 output.png |
will resize and convert a JPEG to a PNG. The mogrify binary will convert an entire directory of images;
mogrify -format png -size 800x600 *.jpg # reverse input/output order mogrify -format png -resize 8% -rotate -90 *.jpg |
Note- This appears to be memory hungry for a directory with images of large file size. In this case use the bash binary 'xargs' of a for loop, for example;
# Use a shell loop mkdir thumbnails for $f in *.jpg do convert $f -thumbnail 200x90 thumbnails/$f.gif done # Use find # this also provides the ability to recurse though directories by removing # the -prune option, as well as doing other file checks (like imgae type, # or the disk space used by an image). find * -prune -name '*.jpg' \ -exec convert '{}' -thumbnail 200x90 thumbnails/'{}'.gif \; # Use xargs -- with a shell wrapper to duplicate the argument. # This can be combined with find insted of "ls" ls *.jpg | xargs -n1 sh -c 'convert $0 -thumbnail 200x90 thumbnails/$0.gif' # an alturnive method on linux (rather than plain unix) # is the simpler (without needing a sub-shell) form... ls *.jpg | xargs -I FILE convert FILE -thumbnail 200x90 th_FILE.gif |
Commands for microarray images
# Use a BASH shell loop dir=PNG if [ ! -d $dir ] ; then mkdir ../$dir fi for file in *.jpg do echo "[ Converting $file ]" convert $file -resize 7% -rotate -90 -quality 0 ../$dir/"${file%%_*.jpg}.png" done |