# 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, datatype::identical(integer[1],float[8]) := float[8], fit::truefalse := false, format::identical(Array,Matrix) := Array, order::identical(C_order,Fortran_order) := 'C_order' }, $ ) :: ImageTools:-Image
DWT2D( )
module Draw:
CYRILLIC_COMPLEX::integer = 0
GOTHIC_ENGLISH_TRIPLEX::integer = 1
GOTHIC_GERMAN_TRIPLEX::integer = 2
GOTHIC_ITALIAN_TRIPLEX::integer = 3
GREEK_COMPLEX::integer = 4
GREEK_COMPLEX_SMALL::integer = 5
GREEK_PLAIN::integer = 6
GREEK_SIMPLEX::integer = 7
ITALIC_COMPLEX::integer = 8
ITALIC_COMPLEX_SMALL::integer = 9
ITALIC_TRIPLEX::integer = 10
ROMAN_COMPLEX::integer = 11
ROMAN_COMPLEX_SMALL::integer = 12
ROMAN_DUPLEX::integer = 13
ROMAN_PLAIN::integer = 14
ROMAN_SIMPLEX::integer = 15
ROMAN_TRIPLEX::integer = 16
SCRIPT_COMPLEX::integer = 17
SCRIPT_SIMPLEX::integer = 18
CYRILLIC::integer = 0
GOTHIC::integer = 1
GERMAN::integer = 2
ITALIAN::integer = 3
GREEK::integer = 4
ROMAN::integer = 11
ITALIC::integer = 8
SCRIPT::integer = 17
SERIF::integer = 11
SANS_SERIF::integer = 13
CENTER::string = "*"
NORTH::string = "N"
SOUTH::string = "S"
EAST::string = "E"
WEST::string = "W"
NORTHEAST::string = "NE"
SOUTHEAST::string = "SE"
NORTHWEST::string = "NW"
SOUTHWEST::string = "SW"
BASELINE::string = "B"
BASELINE_EAST::string = "BE"
BASELINE_WEST::string = "BW"
Poly( )
Line( )
SolidRectangle( )
Circle( )
SolidCircle( )
Text( )
TextSize( )
# 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, PNG, 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*+=~- ", dither::truefalse := true, method::identical(bspline,nearest) := ':-bspline', output::identical(image,text,colortext,char,colorchar) := NULL, sixteen::truefalse := false }, $ )
# 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*+=~- ", dither::truefalse := true, method::identical(bspline,nearest) := ':-bspline', output::identical(image,text,colortext,char,colorchar) := NULL, sixteen::truefalse := false }, $ )
NearestXTermColor( )
NearestANSIColor( )
# 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,
{ datatype::identical(integer[1],float[8]) := float[8], format::identical(BMP,JPEG,PNG,TIFF) := NULL, output::{ImageTools:-Image, identical(NULL)} := NULL }, $ )
# rotate an image by an arbitrary angle
Rotate( img::ImageTools:-Image, angle::{numeric, identical(left,right)},
{ background::{numeric, list(numeric), identical(black,white,NULL)} := NULL, degrees::truefalse := false, extent::truefalse := false, 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,PNG,TIFF) := _FormatFromName(file,true), quality::{numeric, identical(NULL)} := NULL }, $ )
CannyEdgeDetect( )
# 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' }, $ )
EdgeDetect( image::rtable,
{ method::identical(Sobel,Robert,Prewitt3,Prewitt4) := Sobel }, $ )
# 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, $ )
module GenerateBarcode( input::{string, ByteArray},
{ errorcorrection::{1, 2, 3, 4, identical(low,medium,quartile,high)} := 4, preferredheight::{posint, identical(auto)} := ':-auto', version::{integer[1 .. 40], range(integer[1 .. 40])} := 1 .. 40 }, $ )
# 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 }, $ )
HoughLine( )
# measure intensity of layers of an image
Intensity( img::ImageTools:-Image, meas::identical(minimum,maximum,range,mean,variance,rms,energy) := ':-range', $ )
InverseDWT2D( )
# 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 }, $ )
SampleImage( n::integer )
# 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 )
ImagePeriodogram( img,
{ center::identical(:-none,"none",:-horizontal,"horizontal",:-vertical,"vertical",:-both,"both") := ':-both', scaling::identical(:-sqr,"sqr",:-log,"log",:-sqrt,"sqrt",:-none,"none") := ':-log' }, $ )
ProbabilisticHoughLine( )
| |