Combining Images using Criteria


The CImCombine class combines images referenced by a CImageSet object. Often, images being combined must be chosen from a larger set using some selection criteria before being combined. For example, it is required that images being combined have the same dimensions. Suppose the image set contains a mixture of images having different dimensions. To combine them requires creating an auxiliary image set that contains only those images that meet the criterion of having equal dimensions. Examples of other selection criteria include having equal exposure time, similar mean value, or using the same optical filter.

Strategy

Suppose that a CImageSet named ImSet exists and contains many CImage objects. However, you want to combine only the particular images that meet specific criteria. In general, the following strategy is used to perform this task:

  1. Create an auxiliary image set using the CImageSet class. Into this set will be inserted a reference to each image that matches the selection criteria. This does not mean that the images are duplicated, just that a "pointer" to each selected image is stored in the auxiliary set.

  2. Create a CImCombine object for combining the selected images.

  3. Using the original image set, test each image for matching the selection criteria. For each image that passes the test, save a reference to it (i.e., a "pointer") into the auxiliary image set. Use the CImCombine:Append method to save each image pointer into the auxiliary image set.

  4. Use CImCombine methods to combine the images in the auxiliary image set.

  5. Delete the auxiliary image set when it is no longer needed.

The procedure outlined above is implemented in the example, below.

Example

The following script creates an auxiliary image set containing images chosen from the original image set. In this example, images are combined if their dimensions match those of the first image. To keep the script simple, only a simple mean value combining is used.

Io = ImSet:GetImage(1)

-- choose the reference image

if Io == nil then exit("error") end

-- be sure it exists, exit if not

S = CImageSet:new()

-- create an auxiliary image set

S:Add( Io )

-- add the first image to the image set

for i=2, ImSet:Count() do

-- test each of the images 2 through n

  I = ImSet:GetImage(i)

 

  if I and I:DimEq(Io) then

-- check the pointer and if dimensions match

    S:Add(I)

-- Add to the auxiliary image set

  end

 

end

 

C = new_imcombine()

-- create an image combining object

 

-- (the default case uses no normalization)

Icomb = C:Mean(S)

-- combine S and return a new CImage Icomb

C:delete()

--delete the combining object if no longer needed

S:delete()

-- delete the new image set, if not needed

Related Topics

CImCombine class, CImageSet class, CImage class


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