**General Format for ImageWorks Modelling**

-channels are always referred to as %1 (note this applies to image plane 1 not database channel 1)

-bitmaps are always referred to as %%1 (or %%2)

**The IF statement**

** **-if statements are fairly straightforward and similar to simple programming languages

**the then statement also has an implicit ‘begin’ statement within it**

if (expression) then

operation 1

operation 2

operation 3

endif

-expressions can be any type of logical expression, for example

%%1=1 (if bitmap 1 is true then perform the following operations)

%1>50 (if the value in image plane 1 is greater than 50 then perform the following operations)

%2<=%3 (if the value in image plane 2 is less than or equal to the value in image plane 3 then perform the following operations)

-compound expressions

if %%1=1 and %1>50 then (performs the following operations if both expressions are true)

if %%1=1 and %1>50 or %2<=%3 then (performs the following operations if the first two expressions are true or if the last expression is true)

**note how the use of brackets alters what the expression says**

if %%1=1 and (%1>50 or %2<=%3) then (performs the following operations if the first expression is true and if one of the last two expressions is true)

-using the else statement

the else statement triggers the modeller to perform the operations that follow it if the expression(s) in the if statement are false

if %%1=1 and %1>50 then

operation 1

operation 2

else

operation 3

operation 4

endif

-compound if statements (the following model performs a type of operation to image plane 1 depending on the value of image plane 1)

if %1<=50 then

operation 1

else

if %1>50 and %1<=200 then

operation 2

else

if %1>200 then

operation 3

endif

endif

endif

-operations

an operation is any type of defined change for example

%1=0 (writes the value of zero to every pixel in image plane 1)

%2=%1 (copies image plane 2 into image plane 1)

**Common Operators**

+,-,*,/ (add,subtract,multiply,divide)

^ (power function) ie 2^3 = 8 and 3^2=9 and 4^2 = 16

-mod (return the remainder of the first input divided by the second input)

mod[1001,2] (returns a value of 1)

mod[1345,1000] (returns a value of 345)

%1=mod[%2,%3] (image plane 1 will now equal the remainder of image plane 2 divided by image plane 3

-abs (returns the absolut value of an input)

abs[%1] (returns the absolut value of image plane 1)

**Image Defined Operaters**

@sizex, @sizey (return the value of the size of a pixel in the x or y direction (i.e. resolution))

@geox, @geoy (return the value of the pixel’s georeferenced coordinate for the x or y direction)

@x, @y (return the value of the pixel’s pixel/line location pixel location = x direction, line location = y direction)

**Basic Models**

** ***NDVI*

%1=(%4-%3)/(%4+%3)

**logically the highest and lowest values this can return is where the difference between 4 and 3 is greatest

%1=(255-0)/(255+0) {this would equal 1}

%1=(0-255)/(0+255) {this would equal -1}

**so this equation results in values of -1 to 1, so it would be good to scale this to 0 to 255**

**if we add 1 to the end value we will now have values ranging from 0 to 2**

**if we multiply this by 127.5 we will now have values ranging from 0 to 255**

%1=((%4-%3)/(%4+%3)+1)*127.5

**many indices do not result in values that can be so easily scaled, if this is the case, output the index into a 32-bit channel and then use the easi routine “scale”**

*Bitmap over certain ranges of a channel*

if %1>50 and %1<=100 then

%%1=1

endif

**Advanced Models**

*Drape a colour image over shaded relief *(%2 = colour image, %3 = shaded relief)

* *%1=(%2/255)*(%3/255)*255

**takes the colour image and compresses it to values from zero to one, multiplies this by the shaded relief compressed to zero to one, takes this and multiplies by 255 to stretch the data to possible values of zero to 255.**

**if more evidence of the shaded relief is necessary try adding another “*(%3/255)” before the final “*255″**

*Burn gridlines into the image*

* ***it is best to first do this into a bitmap so you can see the placement**

**if the lines you burn in are only one pixel wide you will not see them if you’re image is too large to view at 100%**

if mod[@geox,10000]<@sizex or mod[@geoy,10000]<@sizey then

%%1=1

endif

**this creates a 1 pixel wide line for every pixel in the image where the remainder of either the x or y coordinate (divided by 10000) is less than the size of one pixel**

**to create a thicker line, you must know how thick and then use the following equation

if (mod[@geox,10000]<@sizex*A) or (mod[@geox,10000]>(10000-@sizex*A)) then

if (mod[@geoy,10000]<@sizey*A) or (mod[@geoy,10000]>(10000-@sizey*A)) then

%%1=1

endif

endif

**this creates a line of A*2 thickness with the center of the line being at the desired coordinate