OriginLab Corporation - Scientific Graphing and Data Analysis Software - 2D graphs, 3D graphs, Contour Plots, Statistical Charts, Data Exploration, Statistics, Curve Fitting, Signal Processing, and Peak Analysis

imgPixlog

Contents

Menu Information

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>;

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 the specified logic function on the image pixels. It allows you to remap the pixel values of the images.

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.
    Image:imgPixlog_help_English_files_image002.jpg
    A new image is created as a result.
Image:imgPixlog_help_English_files_image004.jpg
Image:imgPixlog_help_English_files_image006.jpg
Input image
Output image


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