1Math_arithmetic_item = class 2 Menupullright "_Arithmetic" "basic arithmetic for objects" { 3 Add_item = class 4 Menuaction "_Add" "add a and b" { 5 action a b = map_binary add a b; 6 } 7 8 Subtract_item = class 9 Menuaction "_Subtract" "subtract b from a" { 10 action a b = map_binary subtract a b; 11 } 12 13 Multiply_item = class 14 Menuaction "_Multiply" "multiply a by b" { 15 action a b = map_binary multiply a b; 16 } 17 18 Divide_item = class 19 Menuaction "_Divide" "divide a by b" { 20 action a b = map_binary divide a b; 21 } 22 23 Remainder_item = class 24 Menuaction "_Remainder" 25 "remainder after integer division of a by b" { 26 action a b = map_binary remainder a b; 27 } 28 29 sep1 = Menuseparator; 30 31 Absolute_value_item = class 32 Menuaction "A_bsolute Value" "absolute value of x" { 33 action x = map_unary abs x; 34 } 35 36 Absolute_value_vector_item = class 37 Menuaction "Absolute Value _Vector" 38 "like Absolute Value, but treat pixels as vectors" { 39 action x = map_unary abs_vec x; 40 } 41 42 Sign_item = class 43 Menuaction "S_ign" "unit vector" { 44 action x = map_unary sign x; 45 } 46 47 Negate_item = class 48 Menuaction "_Negate" "multiply by -1" { 49 action x = map_unary unary_minus x; 50 } 51} 52 53Math_trig_item = class 54 Menupullright "_Trigonometry" "trigonometry operations (all in degrees)" { 55 Sin_item = class 56 Menuaction "_Sine" "calculate sine x" { 57 action x = map_unary sin x; 58 } 59 60 Cos_item = class 61 Menuaction "_Cosine" "calculate cosine x" { 62 action x = map_unary cos x; 63 } 64 65 Tan_item = class 66 Menuaction "_Tangent" "calculate tangent x" { 67 action x = map_unary tan x; 68 } 69 70 sep1 = Menuseparator; 71 72 Asin_item = class 73 Menuaction "Arc S_ine" "calculate arc sine x" { 74 action x = map_unary asin x; 75 } 76 77 Acos_item = class 78 Menuaction "Arc C_osine" "calculate arc cosine x" { 79 action x = map_unary acos x; 80 } 81 82 Atan_item = class 83 Menuaction "Arc T_angent" "calculate arc tangent x" { 84 action x = map_unary atan x; 85 } 86 87 sep2 = Menuseparator; 88 89 Rad_item = class 90 Menuaction "_Degrees to Radians" "convert degrees to radians" { 91 action x = map_unary rad x; 92 } 93 94 Deg_item = class 95 Menuaction "_Radians to Degrees" "convert radians to degrees" { 96 action x = map_unary deg x; 97 } 98 99 sep3 = Menuseparator; 100 101 Angle_range_item = class 102 Menuaction "Angle i_n Range" 103 "is angle within t degrees of r, mod 360" { 104 action t r angle 105 = clock (max - angle) < 2*r 106 { 107 max = clock (t + r); 108 109 clock a 110 = a + 360, a < 0; 111 = a - 360, a >= 360; 112 = a; 113 } 114 } 115} 116 117Math_log_item = class 118 Menupullright "_Log" "logarithms and anti-logs" { 119 Exponential_item = class 120 Menuaction "_Exponential" "calculate e ** x" { 121 action x = map_unary (power e) x; 122 } 123 124 Log_natural_item = class 125 Menuaction "Natural _Log" "log base e of x" { 126 action x = map_unary log x; 127 } 128 129 sep1 = Menuseparator; 130 131 Exponential10_item = class 132 Menuaction "E_xponential base 10" "calculate 10 ** x" { 133 action x = map_unary (power 10) x; 134 } 135 136 Log10_item = class 137 Menuaction "L_og Base 10" "log base 10 of x" { 138 action x = map_unary log10 x; 139 } 140 141 sep2 = Menuseparator; 142 143 Raise_to_power_item = class 144 Menuaction "_Raise to Power" "calculate x ** y" { 145 action x y = map_binary power x y; 146 } 147} 148 149Math_complex_item = class 150 Menupullright "_Complex" "operations on complex numbers and images" { 151 Complex_extract = class 152 Menupullright "_Extract" "extract fields from complex" { 153 Real_item = class 154 Menuaction "_Real" 155 "extract real part of complex" { 156 action in = map_unary re in; 157 } 158 159 Imaginary_item = class 160 Menuaction "_Imaginary" 161 "extract imaginary part of complex" { 162 action in = map_unary im in; 163 } 164 } 165 166 Complex_build_item = class 167 Menuaction "_Build" "join a and b to make a complex" { 168 action a b = map_binary comma a b; 169 } 170 171 sep1 = Menuseparator; 172 173 Polar_item = class 174 Menuaction "_Polar" 175 "convert real and imag to amplitude and phase" { 176 action a = map_unary polar a; 177 } 178 179 Rectangular_item = class 180 Menuaction "_Rectagular" 181 ("convert (amplitude, phase) image to rectangular " ++ 182 "coordinates") { 183 action x = map_unary rectangular x; 184 } 185 186 sep2 = Menuseparator; 187 188 Conjugate_item = class 189 Menuaction "_Conjugate" "invert imaginary part" { 190 action x = map_unary conj x; 191 } 192} 193 194Math_boolean_item = class 195 Menupullright "_Boolean" "bitwise boolean operations for integer objects" { 196 And_item = class 197 Menuaction "_And" "bitwise and of a and b" { 198 action a b = map_binary bitwise_and a b; 199 } 200 201 Or_item = class 202 Menuaction "_Or" "bitwise or of a and b" { 203 action a b = map_binary bitwise_or a b; 204 } 205 206 Eor_item = class 207 Menuaction "E_xclusive Or" "bitwise exclusive or of a and b" { 208 action a b = map_binary eor a b; 209 } 210 211 Not_item = class 212 Menuaction "_Not" "invert a" { 213 action a = map_unary not a; 214 } 215 216 sep1 = Menuseparator; 217 218 Right_shift_item = class 219 Menuaction "Shift _Right" "shift a right by b bits" { 220 action a b = map_binary right_shift a b; 221 } 222 223 Left_shift_item = class 224 Menuaction "Shift _Left" "shift a left by b bits" { 225 action a b = map_binary left_shift a b; 226 } 227 228 sep2 = Menuseparator; 229 230 If_then_else_item = class 231 Menuaction "_If Then Else" 232 "b where a is non-zero, c elsewhere" { 233 action a b c 234 = map_trinary ite a b c 235 { 236 // can't use if_then_else, we need a true trinary 237 ite a b c = if a then b else c; 238 } 239 } 240 241 Band_or_item = class 242 Menuaction "Band O_r" "or the bands of an image together" { 243 action im = map_unary (foldr1 bitwise_or @ bandsplit) im; 244 } 245 246 Band_and_item = class 247 Menuaction "Band A_nd" "and the bands of an image together" { 248 action im = map_unary (foldr1 bitwise_and @ bandsplit) im; 249 } 250} 251 252Math_relational_item = class 253 Menupullright "R_elational" "comparison operations" { 254 Equal_item = class 255 Menuaction "_Equal to" "test a equal to b" { 256 action a b = map_binary equal a b; 257 } 258 259 Not_equal_item = class 260 Menuaction "_Not Equal to" "test a not equal to b" { 261 action a b = map_binary not_equal a b; 262 } 263 264 sep1 = Menuseparator; 265 266 More_item = class 267 Menuaction "_More Than" "test a strictly greater than b" { 268 action a b = map_binary more a b; 269 } 270 271 Less_item = class 272 Menuaction "_Less Than" "test a strictly less than b" { 273 action a b = map_binary less a b; 274 } 275 276 sep2 = Menuseparator; 277 278 More_equal_item = class 279 Menuaction "M_ore Than or Equal to" 280 "test a greater than or equal to b" { 281 action a b = map_binary more_equal a b; 282 } 283 284 Less_equal_item = class 285 Menuaction "L_ess Than or Equal to" 286 "test a less than or equal to b" { 287 action a b = map_binary less_equal a b; 288 } 289} 290 291Math_list_item = class 292 Menupullright "L_ist" "operations on lists" { 293 Head_item = class 294 Menuaction "_Head" "first element in list" { 295 action x = map_unary hd x; 296 } 297 298 Tail_item = class 299 Menuaction "_Tail" "list without the first element" { 300 action x = map_unary tl x; 301 } 302 303 Last_item = class 304 Menuaction "_Last" "last element in list" { 305 action x = map_unary last x; 306 } 307 308 Init_item = class 309 Menuaction "_Init" "list without the last element" { 310 action x = map_unary init x; 311 } 312 313 sep1 = Menuseparator; 314 315 Reverse_item = class 316 Menuaction "_Reverse" "reverse order of elements in list" { 317 action x = map_unary reverse x; 318 } 319 320 Sort_item = class 321 Menuaction "_Sort" "sort list into ascending order" { 322 action x = map_unary sort x; 323 } 324 325 Make_set_item = class 326 Menuaction "_Make Set" "remove duplicates from list" { 327 action x = map_unary mkset equal x; 328 } 329 330 Transpose_list_item = class 331 Menuaction "Tr_anspose" 332 "exchange rows and columns in a list of lists" { 333 action x = map_unary transpose x; 334 } 335 336 Concat_item = class 337 Menuaction "_Concat" 338 "flatten a list of lists into a single list" { 339 action l = map_unary concat l; 340 } 341 342 sep2 = Menuseparator; 343 344 Length_item = class 345 Menuaction "L_ength" "find the length of list" { 346 action x = map_unary len x; 347 } 348 349 Subscript_item = class 350 Menuaction "S_ubscript" 351 "return element n from list (index from zero)" { 352 action n x = map_binary subscript n x; 353 } 354 355 Take_item = class 356 Menuaction "_Take" "take the first n elements of list x" { 357 action n x = map_binary take n x; 358 } 359 360 Drop_item = class 361 Menuaction "_Drop" "drop the first n elements of list x" { 362 action n x = map_binary drop n x; 363 } 364 365 sep3 = Menuseparator; 366 367 Join_item = class 368 Menuaction "_Join" "join two lists end to end" { 369 action a b = map_binary join a b; 370 } 371 372 Difference_item = class 373 Menuaction "_Difference" "difference of two lists" { 374 action a b = map_binary difference a b; 375 } 376 377 Cons_item = class 378 Menuaction "C_ons" "put element a on the front of list x" { 379 action a x = map_binary cons a x; 380 } 381 382 Zip_item = class 383 Menuaction "_Zip" "join two lists, pairwise" { 384 action a b = map_binary zip2 a b; 385 } 386} 387 388Math_round_item = class 389 Menupullright "_Round" "various rounding operations" { 390 /* smallest integral value not less than x 391 */ 392 Ceil_item = class 393 Menuaction "_Ceil" "smallest integral value not less than x" { 394 action x = map_unary ceil x; 395 } 396 397 Floor_item = class 398 Menuaction "_Floor" 399 "largest integral value not greater than x" { 400 action x = map_unary floor x; 401 } 402 403 Rint_item = class 404 Menuaction "_Round to Nearest" "round to nearest integer" { 405 action x = map_unary rint x; 406 } 407} 408 409Math_fourier_item = class 410 Menupullright "_Fourier" "Fourier transform" { 411 Forward_item = class 412 Menuaction "_Forward" "fourier transform of image" { 413 action a = map_unary (rotquad @ fwfft) a; 414 } 415 416 Reverse_item = class 417 Menuaction "_Reverse" "inverse fourier transform of image" { 418 action a = map_unary (invfft @ rotquad) a; 419 } 420 421 Rotate_quadrants_item = class 422 Menuaction "Rotate _Quadrants" "rotate quadrants" { 423 action a = map_unary rotquad a; 424 } 425} 426 427Math_stats_item = class 428 Menupullright "_Statistics" "measure various statistics of objects" { 429 Value_item = class 430 Menuaction "_Value" "value of point in object" { 431 action a = class _result { 432 _vislevel = 3; 433 434 position = Expression "Coordinate" (0, 0); 435 436 _result = map_binary point position.expr a; 437 } 438 } 439 440 Mean_item = class 441 Menuaction "_Mean" "arithmetic mean value" { 442 action a = map_unary mean a; 443 } 444 445 Gmean_item = class 446 Menuaction "_Geometric Mean" "geometric mean value" { 447 action a = map_unary meang a; 448 } 449 450 Zmean_item = class 451 Menuaction "_Zero-excluding Mean" "mean value of non-zero elements" { 452 action a = map_unary meanze a; 453 } 454 455 Deviation_item = class 456 Menuaction "_Standard Deviation" "standard deviation of object" { 457 action a = map_unary deviation a; 458 } 459 460 Zdeviation_item = class 461 Menuaction "Z_ero-excluding Standard Deviation" 462 "standard deviation of non-zero elements" { 463 action a = map_unary deviationze a; 464 } 465 466 Stats_item = class 467 Menuaction "Ma_ny Stats" "calculate many stats in a single pass" { 468 action a = map_unary stats a; 469 } 470 471 sep1 = Menuseparator; 472 473 Max_item = class 474 Menuaction "M_aximum" "maximum of object" { 475 action a = map_unary max a; 476 } 477 478 Min_item = class 479 Menuaction "M_inimum" "minimum of object" { 480 action a = map_unary min a; 481 } 482 483 Maxpos_item = class 484 Menuaction "_Position of Maximum" "position of maximum in object" { 485 action a = map_unary maxpos a; 486 } 487 488 Minpos_item = class 489 Menuaction "P_osition of Minimum" "position of minimum in object" { 490 action a = map_unary minpos a; 491 } 492 493 Gravity_item = class 494 Menuaction "Centre of _Gravity" 495 "position of centre of gravity of histogram" { 496 action a = map_unary gravity a; 497 } 498 499 sep2 = Menuseparator; 500 501 Count_set_item = class 502 Menuaction "_Non-zeros" "number of non-zero elements in object" { 503 action a 504 = map_unary cset a 505 { 506 cset i = (mean (i != 0) * i.width * i.height) / 255; 507 } 508 } 509 510 Count_clear_item = class 511 Menuaction "_Zeros" "number of zero elements in object" { 512 action a 513 = map_unary cclear a 514 { 515 cclear i = (mean (i == 0) * i.width * i.height) / 255; 516 } 517 } 518 519 Count_edges_item = class 520 Menuaction "_Edges" 521 "count average edges across or down image" { 522 action x = class 523 _result { 524 _vislevel = 3; 525 526 edge = Option "Count" [ 527 "Horizontal lines", 528 "Vertical lines" 529 ] 0; 530 531 _result 532 = map_unary process x 533 { 534 process image = Number (edge.labels?edge) 535 (im_cntlines image.value edge.value); 536 } 537 } 538 } 539 540 sep3 = Menuseparator; 541 542 Linear_regression_item = class 543 Menuaction "_Linear Regression" "fit a line to a set of points" { 544 action xes yes = linreg xes yes; 545 } 546 547 Weighted_linear_regression_item = class 548 Menuaction "_Weighted Linear Regression" 549 "fit a line to a set of points and deviations" { 550 action xes yes devs = linregw xes yes devs; 551 } 552 553 Cluster_item = class 554 Menuaction "_Cluster" "cluster a list of numbers" { 555 action l = class { 556 _vislevel = 3; 557 558 thresh = Expression "Threshold" 10; 559 560 [_r, _w] = cluster thresh.expr l; 561 562 result = _r; 563 weights = _w; 564 } 565 } 566} 567 568Math_base_item = class 569 Menupullright "Bas_e" "convert number bases" { 570 Hexadecimal_item = class 571 Menuaction "_Hexadecimal" "convert to hexadecimal (base 16)" { 572 action a = map_unary (print_base 16) a; 573 } 574 575 Binary_item = class 576 Menuaction "_Binary" "convert to binary (base 2)" { 577 action a = map_unary (print_base 2) a; 578 } 579 580 Octal_item = class 581 Menuaction "_Octal" "convert to octal (base 8)" { 582 action a = map_unary (print_base 8) a; 583 } 584} 585