Professional Documents
Culture Documents
Arithmetic on a matrix provides for a wide variety of image processing techniques. The vectorize operator f ( M) applies a function to an entire image at once. Image coordinates allow more complicated transformations and synthetic constructions. Some of these matrix operations can be conveniently performed via the Picture toolbar instead. D := READRGB "dog") ( cols( D) 3 rdog := submatrixD , 0 , rows( D) 1 , 0 , w 1) ( w := gdog := submatrixD , 0 , rows( D) 1 , w , 2 w 1) ( bdog := submatrixD , 0 , rows( D) 1 , 2 w , 3 w 1) (
rdog , gdog , bdog For example, divide all the blue pixel values by 2:
rdog , gdog ,
bdog 2
gdog , rdog , bdog Apply logarithm function to red component (via vectorize):
log ( rdog) , gdog , bdog Here is another use of the vectorize operator in allowing us to visualize a particular complex matrix. lo := 0 hi := 1 N := 200 . . . size of the matrix . . . range of the region in the complex plane
step :=
del N1
Ci , j := ( lo + j step) + ( hi i step) i . . . generate the matrix args ( z) := arg ( z) if z > 0 0 otherwise color ( M) := N rows ( M) Args args ( M) R sin ( Args) 255 GN1 , N1 0 B cos ( Args) 255 . . . a safe arg function (returning zero if given a zero rather than aborting)
. . . define colorizing function: red dominates for angles close to 0, blue for angles close to /2 and green is null
R G B
P := color ( C)
P0 , P1 , P2