2.6.3.5 imgPixlog(Pro)

Menu Information

Image: Arithmetic Transform: Pixel Logic

Brief Information

Perform logic operation on pixels

Additional Information

This feature is for OriginPro only.

Command Line Usage

1. imgPixlog f:=128 func:=xor;

2. imgPixlog f:=120 func:=add c:=red;

3. imgPixlog f:=128 func:=abs oimg:=<new>;

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input Matrix img

Input

Image

<active>

Specifies the input image. The default input is the active image.

Factor f

Input

int

255

Specifies the logical operation factor. The default is 255.

Logic func

Input

int

Or

Specifies the logic function to apply.
Option list

  • and:And
    Combine each pixel component value and factor using a bitwise AND (&).

(pixel = pixel & factor)

  • or:Or
    Combine each pixel component value and factor using a bitwise OR (|).
    (pixel = pixel | factor)
  • xor:Xor
    Combine each pixel component value and factor using a bitwise XOR (^).
    (pixel = pixel ^ factor)
  • add:img+ factor
    Add pixel component value to the factor clamping the result to the maximum allowed pixel value.
    (pixel = min(pixel + factor, MAX_PIXEL_VALUE) )
    subfi:factor - img
    Subtract each pixel component value from the factor, clamping the result to the allowed pixel range.
    (pixel = min(max(factor - pixel, MIN_PIXEL_VALUE), MAX_PIXEL_VALUE) )
  • subif:img- factor
    Subtract the factor from each pixel component value, clamping the result to the allowed pixel range
    (pixel = min(max(pixel ??C factor), MIN_PIXEL_VALUE, MAX_PIXEL_VALUE) )
  • abs:abs(img-factor)
    Calculate the absolute difference between the factor and each pixel component value.
    (pixel = abs(pixel ??C factor))
  • mul:img*factor
    Multiply each pixel component value by a hundredth of the factor.
    (pixel = pixel * factor / 100)
  • divif:img/factor
    Divide each pixel component value by a hundredth of the factor. An error will be returned if factor is 0.
    (pixel = pixel * 100 / factor)
  • divfi:factor/img
    Divide the factor by each pixel values. If the pixel values are 0, the result set to maximum allowed pixel value.
    (pixel = pixel ? min(factor / pixel, MAX_PIXEL_VALUE) : MAX_PIXEL_VALUE)
  • avg:avg (img,factor)
    Use the average of the each pixel component value and the factor.
    (pixel = (pixel+factor) / 2).
  • min:min (img,factor)
    Use the lesser of the pixel component values and the factor:
    (pixel = min(pixel, factor) )
  • max:max(img,factor)
    Use the greater of the pixel component values and the factor:
    (pixel = max(pixel, factor) )
Channel c

Input

int

all

Specifies the color channel to apply the function. The default is all.
Option list

  • all:All
    All channels.
  • red:Red
    The red channel.
  • green:Green
    The green channel.
  • blue:Blue
    The blue channel.
Output Image oimg

Output

Image

<input>

Specifies the output image. By default, it is the same as the input image.

See the syntax here.

Description

This function applies basic mathematical logic operations on the pixels of an image. It allows you to remap the pixel values of the images.

The Pixel Logic tool can be used to perform calculations on the pixels of an image or a color channel of it. With this tool, you can specify a factor and a function that will be used in the logic operation. Available logic functions include:

  • And
  • Or
  • Xor
  • img+factor
  • factor-img
  • img-factor
  • abs(img-factor)
  • img*factor
  • img/factor
  • factor/img
  • avg(img,factor)
  • min(img,factor)
  • max(img,factor)
LogicSetting1.png

Examples

In this example, we use the imgPixlog function to subtract the pixel values of the image from 255:

  1. Create a new matrix and import cell.jpg under \Samples\Image Processing and Analysis folder into it.
  2. When the input image is active, select Image: Arithmetic Transform: Pixel Logic. This opens the dialog of the X-Function.
  3. In the X-Function dialog, change the settings as the screenshot below and click OK to close the dialog.
    ImgPixlog help English files image002.jpg
    A new image is created as a result. We can see that the cells are more clearly defined.
ImgPixlog help English files image004.jpg
ImgPixlog help English files image006.jpg
Input image
Output image


Note: OriginPro includes the ability to automatically recalculate the analysis result of the Pixel Logic operation any time you change the parameters or update your source data. In addition, the settings for the analysis routine can be saved to an analysis theme for later use with similar data.

Algorithm

The computation mainly uses L_ApplyMathLogicBitmap() function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_ApplyMathLogicBitmap topic.

References

LEADTOOLS Main API Help file, Version 14

Related X-Functions

imgMathfun