2.6.4.7 imgPalette


Brief Information

Apply palette to image

Command Line Usage

1. imgPalette palfile:=system.path.program$+"Palettes\green.pal";
2. imgPalette palfile:=system.path.program$+"Palettes\rainbow.pal" oimg:=mat(2); 

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 source image to be manipulated. The default input is the active image.

Palette File palfile

Input

string

"grayscale"

Specifies the palette file to use.

Output Image oimg

Output

Image

<input>

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

See the syntax here.

Description

Gray Colorize is a tool to transform the grayscale image to a color image with pseudocolor by applying a palette. The imgPalette function in Origin applies a palette to an 8-bit grayscale image. You can specify a color palette to perform the conversion. Origin provides many built-in palettes. Also, you can opt to use your own palettes. By doing this, we are actually applying pseudocolor to the grayscale image, where the palette file is used as the pseudocolor lookup table.

This X-Function works with 8-bit grayscale images only. If the image to be processed does not meet this requirement, you will have to convert it to an 8-bit grayscale image first. In Origin, you can use the imgC2gray X-Function to perform the conversion.

Note: Another two color resolution conversion tool, Color to B/W (Dynamic Binary) and Thresholding, is included in OriginPro only.

Examples

  • Code Sample
//Create a new folder in the Project Explorer
pe_mkdir Conversion path:=aa$;
pe_cd aa$;
//Create a matrix and import a sample image
window -t m;
path$ = System.path.program$;
fname$ = path$ + "samples\Image Processing and Analysis\leaves.jpg";
impimage;
window -r %h Original;
window -d;	//Duplicate the image
window -r %h BlueLeave;

imgC2gray;	//Convert to gray
imgUnsharpmask a:=80 r:=30; //Strenghen details
//Apply pallete
fname$ = System.path.program$ + "palettes\blue.pal";
imgpalette palfile:=fname$;

window -s T;	//Tile the windows horizontally

Algorithm

The gray levels of the original image are mapped to different colors according to the palette file.

References

Kenneth R.Castleman.1996. Digital Image Processing. Prentice Hall, Upper Saddle River, NJ, USA.

Related X-Functions

imgC2gray