Image: Arithmetic Transform: Simple Math
Perform simple math operations between two images
This feature is for OriginPro only.
1. imgSimpleMath img2:=[blue]1!mat(1); 2. imgSimpleMath img1:=[mbook1]msheet1!mat(1) img2:=[mbook2]msheet1!mat(1); 3. imgSimpleMath c1:=green f1:=10 img2:= [mbook2]msheet1!mat(1) c2:=green f2:=2 func:=xor oimg:=result;
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
Input Matrix | img1 |
Input Image |
|
Specifies the first input image (Image1). The default input is the active image. |
Channel of Image1 | c1 |
Input int |
|
Specifies the channel of Image1, on which the function will be operated. The default is all.
|
Factor *Image1 | f1 |
Input double |
|
Specifies a factor, by which image1 will be first multiplied before the math operation. The default factor is 1.0. |
Offset Z of Image1 | z1 |
Input int |
|
Specifies a constant, by which image1 will be added after it is multiplied the factor and before the math operation. |
Input Matrix | img2 |
Input Image |
|
Specifies the second input image (Image2), with which the first image will be combined. |
Channel of Image2 | c2 |
Input int |
|
Specifies the channel of Image2, on which the function will be operated. The default is all.
|
Factor * Image2 | f2 |
Input double |
|
Specifies a factor, by which image2 will be first multiplied before the math operation. The default factor is 1.0. |
Math Function | func |
Input int |
|
Specifies the math function used to combine two images.
|
Output Image | oimg |
Output Image |
|
Specifies the output image. By default, a new image will be created and used as output. See the syntax here. |
Offset X | x |
Input int |
|
Specifies the horizontal offset for Image2. A non-zero value will cause the relative position of two images to be changed. |
Offset Y | y |
Input int |
|
Specifies the vertical offset for Image2. A non-zero value will cause the relative position of two images to be changed. |
Crop to Common Area | crop |
Input int |
|
Specifies whether to crop the output to the common area of two input images. |
The imgSimpleMath function combines data from two images, using the specified mathematic function.
// Subtract background from a cell image then detect the cell edges. //Create a new folder in the Project Explorer pe_mkdir EdgeDetection path:=aa$; pe_cd aa$; //Create a matrix and import the cell image into it window -t m; fname$ = System.path.program$ +"samples\Image Processing and Analysis\cell.jpg"; impimage; CellBk$ = %h; //Create a matrix and import the background image into it window -t m; fname$ = System.path.program$ +"samples\Image Processing and Analysis\bgnd.jpg"; impimage; //Subtract background and pre-processing imgSimpleMath img2:=cellbk$ func:=4 x:=7 y:=13 crop:=1; imgBinary t1:=65 t2:=255; imgMedian d:=18; //Edge detection imgEdge t:=12 f:=shv; //Add the edges back to the cell image imgSimpleMath img2:=cellbk$ func:=3; window -z; //Maximize window
The imgSimpleMath function combines the data byte-by-byte using specified math function. The computation mainly uses L_CombineBitmapExt() function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_CombineBitmapExt topic.
LEADTOOLS Main API Help file, Version 14