Click or drag to resize

IMcRegionAccessSetRegionMaskOffset Method

Sets the current RegionMask offset values

Namespace:  MediaCy.IQL.Engine
Assembly:  MediaCy.IQL.Engine (in MediaCy.IQL.Engine.dll) Version: 10.0.6912.0
Syntax
VB
Sub SetRegionMaskOffset ( 
	lOffsetX As Integer,
	lOffsetY As Integer
)

Parameters

lOffsetX
Type: SystemInt32
long : The new X offset value.
lOffsetY
Type: SystemInt32
long : The new Y offset value.
Remarks
The RegionMask Offset is the positive X,Y offset from the origin of the coordinates in the RegionMask property from this IMcRegionAccess.Image origin. It will almost always be zero for both X and Y for a RegionMask property that is assigned from an McRegions instance with the same parent image as the image backing this IMcRegionAccess. The masked region of this image is computed by subtracting the RegionMask Offset from the coordinates gotten from the RegionMask.
Note Note
The RegionMaskOffset is always set to zero when any assignment is made to the RegionMask property, so if must call SetRegionMaskOffset after assigning your RegionMask property.
Examples
VB
'Copy the pixels within the ActiveImage.Aoi to the center of a new image,
'having twice the size of the bounds as the ActiveImage.Aoi
Sub CopyAoiPixelsToCenterOfNewImage()
'Open test image
ThisApplication.Images.Open( ThisApplication.Path(mcPathType.mcptSampleImages) + "Count And Size\NUCSTAIN.TIF")
'Make an irregular Aoi
ThisApplication.ActiveImage.Aoi.SetEllipse(-1,200,200,160,110,55) '160x110 Ellipse centered at 200,200 at 55degree angle
'From here we work with the active image
Dim srcImage As MediaCy.IQL.Engine.McImage = ThisApplication.ActiveImage
'get src IMcRegionAccess for bounds of Aoi
Dim srcRA As MediaCy.IQL.Engine.McRegionAccess = srcImage.Aoi.AccessMaskedImageData
'create destination image of correct size
Dim lW, lH, lAoiW, lAoiH As Integer
lAoiW = srcRA.Width
lAoiH = srcRA.Height
lW = lAoiW * 2
lH = lAoiH * 2
Dim newImg As MediaCy.IQL.Engine.McImage
newImg = ThisApplication.Images.Add("MyAoiCopy", lW, lH, 1, srcImage.Type)
'Get the bounds of the source Aoi
Dim lLeft, lTop, lRight, lBottom As Integer
srcImage.Aoi.GetBounds lLeft, lTop, lRight, lBottom
'Figure Left,Top location in the new image that would center those bounds
Dim lDstLeft As Integer = (lW - lAoiW) / 2
Dim lDstTop As Integer = (lH - lAoiH) / 2
Dim lDstRight As Integer = lDstLeft + lAoiW -1
Dim lDstBottom As Integer = lDstTop + lAoiH -1
'Make a destination of the size of the bounds McRegionAccess at this location
Dim destRA As MediaCy.IQL.Engine.McRegionAccess = newImg.CreateRegionAccess(newImg.Type,-1,0,lDstLeft,lDstTop,lDstRight,lDstBottom)
'use src Aoi as destination RegionMask
destRA.RegionMask = srcImage.Aoi
'Figure the relative offset from the Aoi location in the src image to it's location in the Dst image
Dim lAoiOffsetLeft As Integer = lLeft - lDstLeft
Dim lAoiOffsetTop As Integer = lTop - lDstTop
'And set the offset of the Dst RegionMask so it is positioned correctly in the Dst image
destRA.SetRegionMaskOffset lAoiOffsetLeft, lAoiOffsetTop
'Above, RegionMaskOffset is set so that the Left,Top of the
'srcImage.Aoi maps onto lDstLeft,lDstTop of the destination image
'In this example, src should use FastAccess if possible
srcRA.FastAccess = True ' this will not interfere with the destRA.PutArea
'region masking, because the src image is different than the dest
'Copy block of pixels from src to dest
Dim objArea As Object
srcRA.GetArea objArea 'get block of src pixels
destRA.PutArea objArea 'put the block, doing region masking
MsgBox("Pixels from under the ROI in the source image are shown centered in the new image. OK closes both images.",,"CopyAoiPixelsToCenterOfNewImage")
srcImage.Close
newImg.Modified = False 'avoid "Do you want to save" prompt
newImg.Close
End Sub 'CopyAoiPixelsToCenterOfNewImage
See Also