##
## crop an image
##
> croppgm ../data/9001_f_wm_s01_9001_en_1.pgm 100 250 64 32
> ls crop.pgm 

##
## shift an image
##
> shiftpgm ../data/9001_f_wm_s01_9001_en_1.pgm 50 10
> ls shift.pgm

##
## flip and mirrors an image
##
> flipmirrorpgm ../data/face003_64x80dct.pgm
> ls flip.pgm mirror.pgm

##
## sub sample an image
##
> subsamplepgm ../data/face003_64x80dct.pgm 32 40
> ls subsample.pgm

##
## zoom an image
##
> zoomppm ../data/gloves.ppm  2
> ls zoom.ppm

##
## rotate an image
##
> rotatepgm ../data/9001_f_wm_s01_9001_en_1.pgm -angle 45 -verbose
Image info:
   width = 385
   height = 451
   format = gray (1)
Go go rotate 315
process (225.0 .. 315.0]
   reminding angle: 45
   width_out: 591
   height_out: 591
> ls rotate.pgm

##
## computes the histogram of an image
##
> histopgm ../data/face003_64x80dct.pgm
> cat histo.txt

##
## filter an image using a colorcube
##
> filtercolorcube ../data/9001_f_wm_s01_9001_en_1.ppm ../data/bancaskin.colorcube -verbose
> ls filter.ppm

##
## filter an image using a colorcube and find 4-connected components (ROI represented by a rectangle)
##
> filtercolorcube ../data/9001_f_wm_s01_9001_en_1.ppm ../data/bancaskin.colorcube -verbose -cc

ROI [   0] (blob label =    1)   size= 541       center=(  269    59)
ROI [   1] (blob label =    2)   size=77232      center=(  195   263)
n_roi = 2
   x= 252   y=   36   w=  33   h=  50
   x=  61   y=   41   w= 267   h= 409

> ls filter.ppm
> ls blob.ppm

##
## filter an image using a colorcube and find 4-connected components (ROI represented by an octon)
##
> filtercolorcube ../data/9001_f_wm_s01_9001_en_1.ppm ../data/bancaskin.colorcube -cc -octon
> ls filter.ppm
> ls blob.ppm

##
## filter an image using a colorcube and find 8-connected components (ROI represented by an octon)
##
> filtercolorcube ../data/1001_f_g1_s01_1001_en_1.jpeg ../data/bancaskin.colorcube -verbose -cc -octon

ROI [   0] (blob label =    1)   size=2462       center=(  327   190)
ROI [   1] (blob label =    2)   size=55553      center=(  436   317)
ROI [   2] (blob label =    3)   size= 602       center=(  700   331)
ROI [   3] (blob label =    4)   size=5575       center=(   24   483)
ROI [   4] (blob label =    5)   size= 632       center=(  528   407)
ROI [   5] (blob label =    6)   size= 763       center=(  599   436)
ROI [   6] (blob label =    7)   size= 692       center=(  504   451)
ROI [   7] (blob label =    8)   size= 847       center=(  614   483)
ROI [   8] (blob label =    9)   size=1325       center=(  641   535)
n_roi = 9
   x= 288   y=   89   w=  95   h= 172
   x= 301   y=   89   w= 262   h= 486
   x= 681   y=  289   w=  30   h=  78
   x=   9   y=  372   w=  33   h= 203
   x= 503   y=  375   w=  59   h=  66
   x= 533   y=  395   w= 104   h=  75
   x= 494   y=  399   w=  20   h= 109
   x= 596   y=  448   w=  39   h= 115
   x= 618   y=  484   w=  43   h=  91

> ls filter.ppm
> ls blob.ppm

##
## edge detection using Sobel
##
> sobel ../data/9001_f_wm_s01_9001_en_1.pgm -threshold 120
> ls sobel.pgm gradient.pgm gradientx.pgm gradienty.pgm

##
## computes FFT 2D
##

# FFT on a 8x8 image
#
> fft2d ../data/eyecorner8x8.pgm -verbose

Image info:
   width = 8
   height = 8
   format = gray (1)
width = 8 -> new width = 8
height = 8 -> new height = 8
Computing FFT 2D ...
FFT 2D:
[0] = 4363 (0)
[1] = 245.426 (-37.7817)
[2] = -237 (298)
[3] = 160.574 (-117.782)
[4] = 35 (0)
[5] = 160.574 (117.782)
[6] = -237 (-298)
[7] = 245.426 (37.7817)
[8] = 700.966 (330.576)
[9] = 490.571 (-86.669)
[10] = 229.635 (81.6224)
[11] = 9.12489 (-183.865)
[12] = 85.0244 (-128.125)
[13] = 92.865 (-166.302)
[14] = -230.12 (-43.5391)
[15] = -362.037 (-322.492)
[16] = 389 (-896)
[17] = -99.669 (-310.024)
[18] = 177 (42)
[19] = -135.444 (-83.7889)
[20] = -71 (-44)
[21] = -6.33095 (-145.976)
[22] = -399 (246)
[23] = -166.556 (351.789)
[24] = 469.034 (62.5757)
[25] = -135.125 (-67.865)
[26] = 112.12 (-103.539)
[27] = -100.571 (-6.66905)
[28] = -79.0244 (-16.1249)
[29] = -115.963 (25.5076)
[30] = -95.6346 (161.622)
[31] = -158.865 (225.698)
[32] = 263 (0)
[33] = 2.65685 (-4.30152)
[34] = 35 (-170)
[35] = -8.65685 (63.6985)
[36] = 15 (0)
[37] = -8.65685 (-63.6985)
[38] = 35 (170)
[39] = 2.65685 (4.30152)
[40] = 469.034 (-62.5757)
[41] = -158.865 (-225.698)
[42] = -95.6346 (-161.622)
[43] = -115.963 (-25.5076)
[44] = -79.0244 (16.1249)
[45] = -100.571 (6.66905)
[46] = 112.12 (103.539)
[47] = -135.125 (67.865)
[48] = 389 (896)
[49] = -166.556 (-351.789)
[50] = -399 (-246)
[51] = -6.33095 (145.976)
[52] = -71 (44)
[53] = -135.444 (83.7889)
[54] = 177 (-42)
[55] = -99.669 (310.024)
[56] = 700.966 (-330.576)
[57] = -362.037 (322.492)
[58] = -230.12 (43.5391)
[59] = 92.865 (166.302)
[60] = 85.0244 (128.125)
[61] = 9.12489 (183.865)
[62] = 229.635 (-81.6224)
[63] = 490.571 (86.669)
DC frequency = 4363 + 0i
Nyquist frequency = 263 + 0i
log Energy = 8.47111
number of high passed = 19
number of low passed = 20

# FFT on a 64x80 image
#
> fft2d ../data/../data/face.pgm -inverse

width = 64 -> new width = 64
height = 80 -> new height = 128
Computing FFT 2D ...
DC frequency = 657365 + 0i
Nyquist frequency = 3845 + 0i
log Energy = 13.5324
number of high passed = 3353
number of low passed = 3814
Computing IFFT 2D ...
RMSE = 5.33114e-08

> ls inverse.pgm


##
## computes Gabor on a 64x80 image
##

> gabor2d ../data/face.pgm

Gabor filters:
 scale = 5
 orientation = 4
 highest spatial frequency = 0.9
 lowest spatial frequency = 0.1
 filter dimension = 12 -> 25x25
Updating image size for FFT
 width = 64 -> new width = 128
 height = 80 -> new height = 128

> ls filter_i.pgm  filter_r.pgm  gabor_i.pgm  gabor_r.pgm

##
## computes DCT
##

# DCT on a 8x8 image
#
> dct2D ../data/eyecorner8x8.pgm
[0] = 545.375
[1] = 92.3866
[2] = 17.7536
[3] = 42.639
[4] = -139.408
[5] = 92.1187
[6] = -62.9343
[7] = 85.7249
[8] = -4.54093
[9] = 8.10607
[10] = -66.875
[11] = -0.664196
[12] = 5.7667
[13] = -33.5329
[14] = 160.625

#
# DCT for a given pgm (the image is decomposed in 8x8 blocks) + iDCT to reconstruct the image
> blockDCT2Dpgm ../data/face003_64x80dct.pgm -blockoverlap 0 -inverse
# reconstructed image is in inverse.pgm


# DCT from pgm
# 
> pgm2dctbindata ../data/face.pgm 15 dct-output-pgm.bindata -blocktoframe -display

Block 0: 1193.12 99.8543 -24.1668 -95.4286 -245.23 -82.1677 17.5004 58.4297 64.6021 -31.2457 -40.8749 -41.3438 -33.8911 -33.3067 -11.8749
...
Block 284: 696.25 -160.129 -159.487 -29.9032 -25.0534 46.935 -4.10197 49.8166 88.8964 14.9737 -8.49994 23.5105 54.9559 -7.77286 -0.999925


# DCT from binary file (0..255)
#
> bindata2dctbindata ../data/face.bindata 64 80 dct-output-bindata.bindata -blocktoframe -display

Block 0: 1193.12 99.8543 -24.1668 -95.4286 -245.23 -82.1677 17.5004 58.4297 64.6021 -31.2457 -40.8749 -41.3438 -33.8911 -33.3067 -11.8749
...
Block 284: 696.25 -160.129 -159.487 -29.9032 -25.0534 46.935 -4.10197 49.8166 88.8964 14.9737 -8.49994 23.5105 54.9559 -7.77286 -0.999925

# DCT from normalized binary file (0..1)
#
> bindata2dctbindata ../data/face_norm.bindata 64 80 unnorm-dct-output-bindata.bindata -blocktoframe -display -unnorm

Block 0: 1193.12 99.8543 -24.1668 -95.4286 -245.23 -82.1677 17.5004 58.4297 64.6021 -31.2457 -40.8749 -41.3438 -33.8911 -33.3067 -11.8749
...
Block 284: 696.25 -160.129 -159.487 -29.9032 -25.0534 46.935 -4.10197 49.8166 88.8964 14.9737 -8.49994 23.5105 54.9559 -7.77286 -0.999925


##
## DCTmod2
##

# reference DCTmod2 from Conrad Sanderson
#
Block 0: 97.178 206.995 278.825 20.2261 -175.332 13.8487 41.807 18.375 -37.869 -59.5583 -16.3954 89.875 -644.375 -690.669 -237.208 -459.25 -41.8891 -393.26
...
Block 220: -18.8911 14.0759 12.3447 5.10221 -16.1544 -6.71622 -0.0607193 -4.37498 25.5817 15.0826 10.2927 5.12502 -232.875 -216.321 -136.251 -25.125 -139.306 -106.821

#
# DCTmod2 from pgm
#
> pgm2dctbindata ../data/face.pgm 15 dctmod2-output-pgm.bindata -dctmod2 -blocktoframe -display

Block 0: 97.178 206.995 278.825 20.2262 -175.332 13.8487 41.807 18.375 -37.869 -59.5583 -16.3954 89.875 -644.375 -690.668 -237.208 -459.25 -41.8889 -393.26
...
Block 220: -18.8911 14.0759 12.3447 5.10222 -16.1544 -6.71622 -0.0607208 -4.37498 25.5817 15.0826 10.2927 5.12502 -232.875 -216.321 -136.251 -25.125 -139.306 -106.821


#
# DCTmod2 from binary file (0..255)
#
> bindata2dctbindata ../data/face.bindata 64 80 dctmod2-output-bindata.bindata -dctmod2 -blocktoframe -display

Block 0: 97.178 206.995 278.825 20.2262 -175.332 13.8487 41.807 18.375 -37.869 -59.5583 -16.3954 89.875 -644.375 -690.668 -237.208 -459.25 -41.8889 -393.26
...
Block 220: -18.8911 14.0759 12.3447 5.10222 -16.1544 -6.71622 -0.0607208 -4.37498 25.5817 15.0826 10.2927 5.12502 -232.875 -216.321 -136.251 -25.125 -139.306 -106.821

#
# DCTmod2 from normalized binary file (0..1)
#
> bindata2dctbindata ../data/face_norm.bindata 64 80 unnorm-dctmod2-output-bindata.bindata -dctmod2 -blocktoframe -display -unnorm

Block 0: 97.178 206.995 278.825 20.2262 -175.332 13.8487 41.807 18.375 -37.869 -59.5583 -16.3954 89.875 -644.375 -690.668 -237.208 -459.25 -41.8889 -393.26
...
Block 220: -18.8911 14.0759 12.3447 5.10222 -16.1544 -6.71622 -0.0607208 -4.37498 25.5817 15.0826 10.2927 5.12502 -232.875 -216.321 -136.251 -25.125 -139.306 -106.821

##
## computes blob features from an image and a colorcube
##
> oneblob ../data/gloves.ppm ../data/blue.colorcube

x mean = 158
y mean = 176
excentricity = 0.984248
angle = 0.0976101
surface = 2929.94

> oneblob ../data/gloves.ppm ../data/yellow.colorcube

x mean = 150
y mean = 119
excentricity = 0.995864
angle = -0.0960774
surface = 2098.17

## image segmentation using GMM via ML
> segmentml ../data/1001_f_g1_s01_1001_en_1.jpeg -g 4 -xy -norm -verbose
> ls blob.ppm

## image warping
> warp ../data/003_1_1.jpeg ../data/003_1_1.ldm ../data/1001.ldm
> ls warp.pgm