Click or drag to resize

IMcImage2CopyToNewImageEx Method

Copy all or a portion of an image to a new image.

Namespace:  MediaCy.IQL.Engine
Assembly:  MediaCy.IQL.Engine (in MediaCy.IQL.Engine.dll) Version: 10.0.6912.0
Syntax
VB
Function CopyToNewImageEx ( 
	<OptionalAttribute> SourceRect As Object,
	Optional Name As String = "",
	Optional ImageCreationFlags As mcImageCreateFlags = mcImageCreateFlags.mcicfDefault,
	<OptionalAttribute> vType As Object,
	Optional Channel As Integer = -1,
	Optional CopyAoiToNewImage As Boolean = true,
	Optional MaskNewImageByAoi As Boolean = true,
	<OptionalAttribute> FramesToCopy As Object,
	Optional ImportFilter As mcImportPropertiesFlags = mcImportPropertiesFlags.mcipfDefault,
	<OptionalAttribute> SizeRatioXY As Object
) As McImage

Parameters

SourceRect (Optional)
Type: SystemObject
If given, either a LONGRECT or an array of 4 values in the order Left, Top, Right, Bottom, specifying the source rectangle for the copy. If this argument is missing, then the source rectange is the bounding rectangle of any AOI or the whole image if there is no AOI. This rectangle may be larger than the image, in which case it is clipped to the image bounds, but it must intersect at least some portion of the image.
Name (Optional)
Type: SystemString
If non-empty, the name to be given the new image.
ImageCreationFlags (Optional)
Type: MediaCy.IQL.EnginemcImageCreateFlags
Flag to pass to the IMcImages::Add method. See mcImageCreateFlags for the list of supported flags. The mcImportPropertiesFlags to control which properties, if any are copied into the new image, are specified separately by the ImportFilter argument.
vType (Optional)
Type: SystemObject
The Type of the new image. If given, this can be an instance of a McImageType interface or it can be a numeric mcImageQuickTypes value. If missing, then the source image Type property is used.
Channel (Optional)
Type: SystemInt32
The default value of -1 means all channels are copied to a new image of the specified vType. If a channel from 0 up to vType.NumberOfChannels-1 is specified, then only that channel is copied. In this case the new image will be a monochrome image having the same pixel bit-depth as the vType argument. The Channel is interpreted as a channel in any given destination vType, not the source McImage.Type; that is, the source image is cast to the destination vType and then the Channel (or all channels if -1) from that vType is copied into the new image. For example, if a source RGB image is copied to a destination HSI image with the Channel argument given as 2, then the destination will be a monochrome image holding the I (intensity) channel of the RGB-to-HSI converted image.
CopyAoiToNewImage (Optional)
Type: SystemBoolean
If True (the default), then any AOI that does not exactly cover the new image is made the AOI of the new image. If False, then the new image will have no AOI.
MaskNewImageByAoi (Optional)
Type: SystemBoolean
If True (the default), any multiple or irregular source AOI is used to mask the portion of the image copied. Areas not copied are black. If False, then no AOI masking is done and a rectangular portion of the source image is always copied without masking.
FramesToCopy (Optional)
Type: SystemObject
If given, a selector giving the frame indices of the frames to copy (this selector may be formatted in the same way that the ActiveFrameRange property is to indicate one or more frames in the order they are to be copied). If missing, the ActiveFrameRange property is used, unless UseActiveFrameRange is False, in which case only the ActiveFrame is copied.
ImportFilter (Optional)
Type: MediaCy.IQL.EnginemcImportPropertiesFlags
Controls which properties of this image are to be imported into the new image. By default, all properties except the ColorMap and the File are copied.
SizeRatioXY (Optional)
Type: SystemObject
If given, can be either a scalar integral value or length-2 integral array giving the requested tiled sub-sampling of the image data from the SourceRect.

Return Value

Type: McImage
A new McImage.
Remarks
This is a general method for copying all or a portion of this image to a new, optionally named, image. The new image may optionally contain only one color channel from this image, or it may be converted to a new type. The copy can be masked by the Aoi and the Aoi itself may also be copied. At least one frame must be selected for copying. The ActiveFrame in the new image is made to be the same frame as this image's ActiveFrame, if possible. If you need to do an image copy that also involves an unusual luminance range cast, then setting the CastingSourceRange before calling CopyToNewImageEx might be necessary. However, you do not need to change CastingSourceRange and then call CopyToNewImageEx just to convert the luminance range of one image AOI to another range in another image, because the ConvertEx method takes source and destination luminance range arguments that will do the job for you.
Examples
VB
'Convert the lower half of the intensity range of a whole image to 16-bit gray
Sub DupWholeImageWithLuminanceCast()
With ActiveImage
.CastingSourceRange = Array(.RangeMin, .RangeMax / 2)
.CopyToNewImageEx Array(0, 0, .Width - 1, .Height - 1), "MyNewImage", _
mcicfDefault, mciqtGray16, -1, True, False, , mcipfAllExceptIntensity
End With 'ActiveImage
End Sub 'DupWholeImageWithLuminanceCast
See Also

Reference

Duplicate
Convert
ConvertEx
IMcImage2CopyToNewImageEx(Object, String, mcImageCreateFlags, Object, Int32, Boolean, Boolean, Object, mcImportPropertiesFlags, Object)
Clear
UseActiveFrameRange
ActiveFrameRange
ExtractChannel
ImportProperties