CImage:ExtractChan


The ExtractChan method creates a new image containing a channel from the original color image.

Syntax

CImage = CImage:ExtractChan( nChan )

bullet.gif    nChan is string representing the channel name, like "R", "G", "B", or "A", or the corresponding channel number beginning at 1.

bullet.gif    On success, this method returns a new CImage.

bullet.gif    On failure, this method return nil.

Example

Suppose that a CImage I exists and has RGB color pixel type. The following script creates 3 new images, one each for the red, green, and blue channels (channels 1 through 3):

S = new_imageset()

-- create an image set to hold the images

for i=1, 3 do

-- do for each of the 3 channels

  Inew = I:ExtractChan(i)

-- extract the channel to a new CImage

  S:Append( Inew )

-- add to the end of the image set

end

 

I = S:GetImage(2)

-- retrieve the green image...

S:delete();

 

Related Topics

CImage class, CImageSet:RgbMerge, ExtractByte


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.