# an image processing package
module ImageTools:
# clip intensity to specified levels
Clip( img::ImageTools:-Image,
{ high::{realcons, identical(NULL)} := NULL, inplace::truefalse := false, low::{realcons, identical(NULL)} := NULL, output::{ImageTools:-Image, identical(NULL)} := NULL }, $ )
Create( height::{nonnegint, range(integer)} := 0, width::{nonnegint, range(integer)} := 0, layers::{1, 3, 4, identical(NULL), 1 .. {3, 4}} := NULL, data::{Array, Matrix, table, procedure, list(procedure), set(`=`), listlist(realcons), listlist(list(realcons))} := {},
{ background::{realcons, list(realcons), identical(black,white)} := ':-black', channels::identical(NULL,1,3,4) := NULL, copy::truefalse := false, fit::truefalse := false, format::identical(Array,Matrix) := Array, order::identical(C_order,Fortran_order) := 'C_order' }, $ ) :: ImageTools:-Image
module Draw:
Line( )
Circle( )
FilledCircle( )
Text( )
TextSize( )
FilledRectangle( img, x0, y0, x1, y1, color )
# embed images in an open worksheet
Embed( imgarg::{list({list(Image), Image}), Image},
{ exterior::identical(group,all,none) := ':-all', interior::identical(group,all,none) := ':-all', mode::identical(direct,task) := ':-direct', tempdir::string := GetTempDir(), title::{string, identical(NoUserValue)} := ':-NoUserValue', titleposition::identical(top,bottom) := ':-bottom' }, $ )
# compute the entropy of the layers of an image
Entropy( img, N::posint := 256,
{ autorange::truefalse := false, range:::-range(numeric) := 0 .. 1 }, $ )
# flip an image horizontally or vertically
Flip( img::ImageTools:-Image, dir::identical(horizontal,vertical),
{ inplace::truefalse := false, output::{ImageTools:-Image, identical(NULL)} := NULL }, $ )
Formats::set = {BMP, JPEG, TIFF}
# adjust the gamma of an image; values < 1 lighten, values > 1 darken
Gamma( img::ImageTools:-Image, gamma::realcons,
{ inplace::truefalse := false, output::{ImageTools:-Image, identical(NULL)} := NULL }, $ )
# return height of image, in pixels
Height( img::ImageTools:-Image, info::identical(size,range,lower,upper) := ':-size', $ )
Image::symbol = ImageTools:-Image
# return number of layers in image
Layers( img::ImageTools:-Image, info::identical(size,lower,upper,range) := ':-size', $ )
# mask intensity of an image with another image
Mask( img::ImageTools:-Image, mask::ImageTools:-Image, $ )
# preview an image in the worksheet as a thumbnail plot
module Preview( img::ImageTools:-Image, maxH::{posint, identical(NULL)} := NULL, maxW::{posint, identical(NULL)} := NULL,
{ chars::string := "@Oo*+=~- ", method::identical(bspline,nearest) := ':-bspline', output::identical(image,text) := ':-image' }, $ )
# preview an image in the worksheet as a thumbnail plot
Preview( img::ImageTools:-Image, maxH::{posint, identical(NULL)} := NULL, maxW::{posint, identical(NULL)} := NULL,
{ chars::string := "@Oo*+=~- ", method::identical(bspline,nearest) := ':-bspline', output::identical(image,text) := ':-image' }, $ )
# compute the quality of a reconstructed image
Quality( img_r::ImageTools:-GrayImage, img_s::ImageTools:-GrayImage, meas::identical(mse,psnr,rmse,snr) := ':-mse',
{ peak::realcons := 1 }, $ )
# read an image from a file or URL
Read( input::string, img::{ImageTools:-Image, identical(NULL)} := NULL,
{ format::identical(BMP,JPEG,TIFF) := NULL, output::{ImageTools:-Image, identical(NULL)} := NULL }, $ )
# rotate an image in increments of 90 degrees
module Rotate( img::ImageTools:-Image, angle::{integer, identical(left,right)},
{ output::{ImageTools:-Image, identical(NULL)} := NULL }, $ )
# rotate an image in increments of 90 degrees
Rotate( img::ImageTools:-Image, angle::{integer, identical(left,right)},
{ output::{ImageTools:-Image, identical(NULL)} := NULL }, $ )
# scale the size of an image
Scale( img::ImageTools:-Image, scaleY::{realcons, integer .. integer}, optScaleX::{realcons, identical(NULL), integer .. integer} := NULL,
{ antialias::{posint, identical(none)} := ':-none', method::identical(bspline,nearest) := ':-bspline' }, $ )
# stack images horizontally or vertically
Stack( img_list::list(ImageTools:-Image), dir::identical(horizontal,vertical) := ':-horizontal',
{ halign::identical(left,center,right) := ':-left', valign::identical(top,center,bottom) := ':-top' }, $ )
# convert an image to an RGB representation
ToRGB( img::ImageTools:-Image,
{ output::{ImageTools:-ColorImage, identical(NULL)} := NULL }, $ )
# convert an image to an RGBA representation
ToRGBA( img::ImageTools:-Image,
{ output::{ImageTools:-ColorAImage, identical(NULL)} := NULL }, $ ) :: ImageTools:-ColorAImage
# display images in a maplet
View( { borderheight::posint := 120, borderwidth::posint := 80, maxmapletheight::posint := 800, maxmapletwidth::posint := 800, tempdir::string := GetTempDir(), title::string := "Image View" } )
# return width of image, in pixels
Width( img::ImageTools:-Image, info::identical(size,range,lower,upper) := ':-size', $ )
# write an image to a file
Write( file::string, image::ImageTools:-Image,
{ format::identical(BMP,JPEG,TIFF) := FormatFromName(file,true), quality::{numeric, identical(NULL)} := NULL }, $ )
# create a checkerboard image
Checkerboard( n::posint := 20, height::posint := 8, width::posint := height,
{ background::realcons := 0., foreground::realcons := 1.0 } )
ColorAImage::symbol = ImageTools:-ColorAImage
ColorImage::symbol = ImageTools:-ColorImage
# linearly transform the colors of an image
ColorTransform( img::{ImageTools:-ColorAImage, ImageTools:-ColorImage}, m::Matrix(And(realcons,Not(infinity))),
{ inplace::truefalse := false, output::{ImageTools:-ColorAImage, ImageTools:-ColorImage, identical(NULL)} := NULL }, $ )
# combine monochromatic images to create a color image
CombineLayers( img1::ImageTools:-GrayImage, img2::ImageTools:-GrayImage, img3::ImageTools:-GrayImage, img4::{ImageTools:-GrayImage, identical(NULL)} := NULL,
{ output::{ImageTools:-ColorAImage, ImageTools:-ColorImage, identical(NULL)} := NULL }, $ )
# compute the complement of an image
Complement( img::ImageTools:-Image, peak::realcons := 1,
{ inplace::truefalse := false, output::{ImageTools:-Image, identical(NULL)} := NULL }, $ )
# apply a spatial convolution mask/kernel to an image
Convolution( image::ImageTools:-Image, kernel::rtable,
{ edges::{numeric, identical(compute,leave)} := ':-compute', exterior::{numeric, identical(ignore)} := ':-ignore', shape::identical(same,full,valid) := ':-same', weight::{numeric, identical(none)} := ':-none' }, $ )
# scale intensity to a given range
FitIntensity( img::ImageTools:-Image, intensity::range(And(realcons,Not(infinity))) := 0 .. 1, channel::{1, 2, 3, 4, identical(all)} := 'all',
{ inplace::truefalse := false, output::{ImageTools:-Image, identical(NULL)} := NULL }, $ )
# guess the image format from the filename
FormatFromName( file::string, errorOnFailure::truefalse := false, $ )
# extract one layer from a colored image
GetLayer( img::{ImageTools:-ColorAImage, ImageTools:-ColorImage}, layer::{1, 2, 3, 4},
{ output::{ImageTools:-GrayImage, identical(NULL)} := NULL }, $ )
# extract a subimage from an image
GetSubImage( img::ImageTools:-Image, row::integer, col::integer, ht::posint, wd::posint,
{ output::{ImageTools:-Image, identical(NULL)} := NULL, reindex::truefalse := false }, $ )
GrayImage::symbol = ImageTools:-GrayImage
# convert HSV color image to RGB
module HSVtoRGB( img::{ImageTools:-ColorAImage, ImageTools:-ColorImage},
{ inplace::truefalse := false, output::{ImageTools:-ColorAImage, ImageTools:-ColorImage, identical(NULL)} := NULL }, $ )
# convert HSV color image to RGB
HSVtoRGB( img::{ImageTools:-ColorAImage, ImageTools:-ColorImage},
{ inplace::truefalse := false, output::{ImageTools:-ColorAImage, ImageTools:-ColorImage, identical(NULL)} := NULL }, $ )
# compute a histogram of an image
Histogram( img::ImageTools:-Image, buckets::posint := 256,
{ autorange::truefalse := false, centers::truefalse := false, cumulative::truefalse := false, normalized::truefalse := false, range:::-range(numeric) := 0 .. 1 }, $ )
# measure intensity of layers of an image
Intensity( img::ImageTools:-Image, meas::identical(minimum,maximum,range,mean,variance,rms,energy) := ':-range', $ )
# pad image, increasing its size
PadImage( img::ImageTools:-Image, ht_rng::{range(integer), identical(NULL)} := NULL, wd_rng::{range(integer), identical(NULL)} := NULL,
{ border::nonnegint := 0, bottom::{nonnegint, identical(NULL)} := NULL, fill::{numeric, list(numeric), identical(reflect,replicate)} := 0, left::{nonnegint, identical(NULL)} := NULL, reindex::truefalse := false, right::{nonnegint, identical(NULL)} := NULL, top::{nonnegint, identical(NULL)} := NULL }, $ )
# plot intensity histogram of an image
PlotHistogram( img::ImageTools:-Image, buckets::posint := 256,
{ autorange::truefalse := false, cumulative::truefalse := false, decomb::truefalse := false, normalized::truefalse := false, range:::-range(numeric) := 0 .. 1 } )
# convert an image to grayscale
RGBtoGray( img::ImageTools:-Image,
{ output::{ImageTools:-GrayImage, identical(NULL)} := NULL }, $ ) :: ImageTools:-GrayImage
# convert RGB to HSV
module RGBtoHSV( img::{ImageTools:-ColorAImage, ImageTools:-ColorImage},
{ inplace::truefalse := false, output::{ImageTools:-ColorAImage, ImageTools:-ColorImage, identical(NULL)} := NULL }, $ )
# convert RGB to HSV
RGBtoHSV( img::{ImageTools:-ColorAImage, ImageTools:-ColorImage},
{ inplace::truefalse := false, output::{ImageTools:-ColorAImage, ImageTools:-ColorImage, identical(NULL)} := NULL }, $ )
# convert RGB to YUV
RGBtoYUV( img::{ImageTools:-ColorAImage, ImageTools:-ColorImage},
{ inplace::truefalse := false, output::{ImageTools:-ColorAImage, ImageTools:-ColorImage, identical(NULL)} := NULL }, $ )
# scale the intensities of selected layers of an image
ScaleIntensity( img::ImageTools:-Image, scale::realcons, offset::realcons := 0,
{ inplace::truefalse := false, layers::{posint, list(posint), identical(all,color)} := 'all', output::{ImageTools:-Image, identical(NULL)} := NULL } )
# insert a layer into an image
SetLayer( img::ImageTools:-Image, img_layer::ImageTools:-GrayImage, layer::{1, 2, 3, 4},
{ inplace::truefalse := false, output::{ImageTools:-ColorAImage, ImageTools:-ColorImage, identical(NULL)} := NULL }, $ )
# insert a subimage into a main image
SetSubImage( img::ImageTools:-Image, sub::ImageTools:-Image, row::{integer, identical(NULL)} := NULL, col::{integer, identical(NULL)} := NULL,
{ inplace::truefalse := false, output::{ImageTools:-Image, identical(NULL)} := NULL }, $ )
# perform threshold operation on a grayscale image
module Threshold( img, threshold::{numeric, identical(NULL)} := NULL,
{ buckets::posint := 100, high::numeric := 1.0, low::numeric := 0., method::identical(both,above,below) := 'both' }, $ )
# perform threshold operation on a grayscale image
Threshold( img, threshold::{numeric, identical(NULL)} := NULL,
{ buckets::posint := 100, high::numeric := 1.0, low::numeric := 0., method::identical(both,above,below) := 'both' }, $ )
# convert an image to grayscale
ToGrayscale( img::ImageTools:-Image,
{ output::{ImageTools:-GrayImage, identical(NULL)} := NULL }, $ ) :: ImageTools:-GrayImage
# transpose an image
Transpose( img::ImageTools:-Image,
{ output::{ImageTools:-Image, identical(NULL)} := NULL }, $ )
# return the type of an image
WhatTypeImage( image )
# convert YUV to RGB
YUVtoRGB( img::{ImageTools:-ColorAImage, ImageTools:-ColorImage},
{ inplace::truefalse := false, output::{ImageTools:-ColorAImage, ImageTools:-ColorImage, identical(NULL)} := NULL }, $ )
module ColouringProcedures:
HueToRGB( img::Array(datatype = float[8]) )
FlameToRGB( data::Array(datatype = float[8]), gam::numeric, samplesize::posint := 2 )
| |