CImExtract:Count


The Count method returns the number of sources extracted from the image using the CImExtract:Extract method.

Syntax

number = CImExtract:Count()

bullet.gif    On success, this method returns the number of sources extracted from the image.

bullet.gif    On failure, this method returns 0.

Example

The following script extracts sources from an image and lists the x,y coordinates for all sources.

E = new_imextract()

-- create a CImExtract

-- select the image from an image window

 

V = attachlist_imageview()

-- get an image window

Assert( V, "No Image window selected")

-- exit if no image window selected

-- choose the image if image set has > 1 image

 

if V:Count() > 1 then

-- return the number of sources found

  I = attachviewlist_image( V )

 

  if I == nil then

 

    Assert( I, "No Images are available")

 

  end

 

else

 

 

 

bSuccess = E:Extract( I )

-- extract sources from CImage I

if not bSuccess then Exit("Extract failed") end

 

 

 

nSources = E:Count()

-- Get the number of sources

for n = 1,nSources do

 

  local S = E:GetSource(n)

-- t is a table of data for source n

  if S ~= nil then

 

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

-- list x,y of source n

  end

 

end

 

Related Topics

CImExtract class, Extract, GetSource, ImExtractParams


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