Up | ScorpionEx.py | SetValue | GetValue | SetConfigValue | GetConfigValue | GetImageMatr | DecimateMatr | RegisterCallback | RegisterPlugin | RegisterUserManager | PluginChanged | ExecuteCmd | Other

 

  

 
GetImageMatr

GetImageMatr(name) - returns the image as an uint8Mat or RGBMatr defined in the arr module.

SetImageMatr(name,matr) - set image

Additional support functions

GetImageMatrDim(name) - return size as tuple (rows, cols)
GetImageMatrInfo(name) - return dictionary with rows, cols and type, where type is datatype as string

For Get functions, name may contain color plane postfix separated by '.' H/S/I/R/G/B to extract specific color planes from color images.

In addition, the Get functions may access images from histroylist by adding a index postfix in square braces, where index of 0 is current images, 1 is previous etc.

SetImageMatr can only access current images and origin image format only.

Syntax:

im = GetImageMatr(name<.colorplane><[historyindex])
im = GetImageMatr("Image")      # return color or 8bit intensity image
im = GetImageMatr("Image.H")    # return hue component as 8bit image from a color image
im = GetImageMatr("Image.S")    # return saturation component as 8bit image from a color image
im = GetImageMatr("Image.I")    # return intensity component as 8bit image from a color image
im = GetImageMatr("Image.R")    # return red component as 8bit image from a color image
im = GetImageMatr("Image.G")    # return green component as 8bit image from a color image
im = GetImageMatr("Image.B")    # return blue component as 8bit image from a color image
im = GetImageMatr("Image[1]")   # return previous image from history
im = GetImageMatr("Image.H[1]") # return previous hue image from history
im = GetImageMatr("Image.R[2]") # return even older red image from history

Example 1: Access Image and process the image from python

# used to provide access to image from python
img=GetImageMatr('Image') #get the image

blob=GetTool('Blob')
status = blob.execute(img) 

cx=blob.getValue('CenterOfGravity_x') #get result x
cy=blob.getValue('CenterOfGravity_y') #get result y

Example 2: Get the size of a 2D Image

img = GetImageMatr('Image')
dx,dy = img.dim()		#returns a tuple (size_x,size_y)
print 'image size',dx,dy

Example 3: Modify an image

img = GetImageMatr('Image')
SetImageMatr('Reduced',DecimateMatr(img,2))	#reduces the image size by 2

Note: The name of an image is defined under Service.Camera.Image

 

Scorpion Vision Version XV  : Build 764 - Date: 20200529
Scorpion Vision Software® is a registered trademark of Tordivel AS.
Copyright © 2000 - 2020 Tordivel AS.