CImExtract:Extract


The Extract method of the CImExtract class performs "source extraction" on an image by identifying separated sources and then computing more than 40 properties in both coordinate space and intensity space. These properties include the mean x,y coordinates, mean value and standard deviation, axis of elongation, and others. The extraction process is highly configurable and may involve any combination of background compensation, thresholded pixel collection, and property filtering using criteria such as maximum area, minimum elongation, and so on. The process is driven by a configuration with default properties which may be changed using the ImExtractParams table.

Extraction creates a table of properties for each source that is held within the CImExtract object. After extraction, the properties may be fetched from by passing their table index to GetSource. See the Mira User's Guide for more information under the main topic Extracting Sources from Images.

Syntax

bSuccess = CImExtract:Extract( Image_obj )

bullet.gif    where Image_obj is a CImage class object containing an image. The image may be displayed or opened from a file without display.

bullet.gif    On success, true is returned.

Example

Suppose an image window exists on the Mira screen. The script below performs source extraction on an image from this window and then lists the (x,y) coordinates for the first 3 sources. The default configuration is updated using a CImExtractParams table. Note that your table does not need to be named Params.

V = attachlist_imageview()

-- attach an image window

Assert( V, "No image window")

-- leave script if no image window

 

 

I = V:GetImage()

-- get the top-most or only image

Assert( I, "No image selected")

-- leave script if no image

 

 

E = new_imextract()

-- create a CImExtract object

Params =

-- setup an ImExtractParams table

{

-- use a comma after each "name=value" pair

  bProcFilter = true,

 

  bFilterUseSepMin = true,

 

  nFilterSepMin = 10,

 

  bFilterUseAreaMax = true,

 

  nFilterAreaMax = 100,

 

  nBgMethod = 1,

 

  nDetectTreshold = 45,

-- threshold value = 45

  nDetectTest = 0,

-- use pixels greater than or equal to threshold

}

 

E:SetParams(Params)

-- set new configuration properties

 

 

bOK = E:Extract( I )

-- extract sources from image I

if not bOK then Exit("Extract failed.\n") end

 

 

 

-- report the number of sources extracted:

 

nCount = E:Count()

 

if nCount < 1 then Exit("No sources.\n") end

 

Printf("Number of sources = %d\n", nCount)

 

 

 

-- list the x,y coordinates for all sources:

 

for i = 1,nCount do

 

  local S = E:GetSource(i)

 

  Printf("[%d]:%lg,%lg\n", i,S.nCenterX,S.nCenterY)

-- fetch the properties of source i

end

 

Related Topics

CImExtract class, GetSource, ImExtractParams table


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