interleave_channels
— Create an interleaved image from a multichannel image.
interleave_channels(MultichannelImage : InterleavedImage : PixelFormat, RowBytes, Alpha : )
The operator interleave_channels
creates an InterleavedImage
from the input MultichannelImage
containing three or four
channels. This is useful to prepare a color image for visualization, e.g., by
converting it to a .NET Bitmap.
The format of the pixels in InterleavedImage
is specified with
PixelFormat
. Possible formats are 'rgb' ,'rgba' ,
'argb' ,'bgr' ,'bgra' , and 'abgr' , where 'a'
denotes the 4th ('alpha') channel.
Be aware that, in contrast to gen_image_interleaved
, LittleEndian
byte ordering is used in PixelFormat
.
channels | domain | |
---|---|---|
3 | not specified/full | Value of Alpha is set for the complete image. |
3 | reduced | Inside the domain: alpha is set to Alpha .
Outside the domain: alpha is set to zero. |
4 | Alpha is set to the respective value of the fourth channel,
domain and Alpha are ignored.
|
The number of bytes between the beginning of two rows in the output
image can be set in RowBytes
, e.g. to fulfill specific
alignment criteria.
Set RowBytes
to 'match' if no additional padding is
required. RowBytes
must be at least the number of bytes in
PixelFormat
times the width of MultichannelImage
.
MultichannelImage
(input_object) multichannel-image →
object (byte)
Input multichannel image.
InterleavedImage
(output_object) singlechannelimage →
object (byte)
Output interleaved image.
PixelFormat
(input_control) string →
(string)
Target format for InterleavedImage.
Default value: 'rgba'
List of values: 'abgr' , 'argb' , 'bgr' , 'bgra' , 'rgb' , 'rgba'
RowBytes
(input_control) integer →
(string / integer)
Number of bytes in a row of the output image.
Default value: 'match'
Suggested values: 'match'
Alpha
(input_control) integer →
(integer)
Alpha value for three channel input images.
Default value: 255
Suggested values: 255, 0
HTuple type, width, height; HImage patras = new HImage("patras"); HImage interleaved = patras.InterleaveChannels("argb", "match", 255); IntPtr ptr = interleaved.GetImagePointer1(out type, out width, out height); Image img = new Bitmap(width/4, height, width, PixelFormat.Format32bppPArgb, ptr); pictureBox.Image = img;
Foundation