# LEL Examples

The following examples show some LEL expressions (equally valid in C++ or Glish).

Note that LEL is readonly; i.e. it does not change any value in the images given. A function in the image client has to be used to do something with the result (e.g. storing in another image).

• lat1+lat2 -- adds 2 lattices
• mean(myimage:nomask) -- results in a scalar value giving the mean of the image. No mask is used for the image, thus all pixels are used. The scalar value can be used as a lattice. E.g. it can be used as the source in the image function replacemaskedpixels to set all masked-off elements of a lattice to the mean.
• complex(lat1,lat2) -- results in a complex lattice formed by lat1 as the real part and lat2 as the imaginary part.
• min(lat1, 2*mean(lat1)) -- results in a lattice where lat1 is clipped at twice its mean value.
• min(myimage, 2*mean(mymage[myregion])) -- results in an image where myimage is clipped at twice the mean value of region myregion in the image..
• lat1[lat1>2*min(lat1)] -- results in a lattice with a mask. Only the pixels greater than twice the minimum are valid.
• replace(lat1)  -- results in a lattice where each masked-off element in lat1 is replaced by 0.
• iif(lat1results in a lattice where the elements less than the mean are doubled and the elements greater or equal to the mean are divided by 2.

Here follows a sample Glish session showing some of the LEL capabilities and how Glish variables can be used in LEL.

```duw01> glish -l image.g
- a := array(1:50,5,10)              # make some data
- global im1 := imagefromarray('im1', a);   # fill an image with it
- im1.shape()
[5 10]
- global reg:=drm.box([1,1],[4,4]);  # a box region
- im2 := imagecalc(pixels='\$im1[\$reg]')     # read-only image applying region
- print pixels2
[[1:4,]
1 6 11 16
2 7 12 17
3 8 13 18
4 9 14 19]
[[1:4,]
F T T T
T T T T
T T T F
T T T T]