The primary type of document managed by the application is an image. This overview will discuss working with images and their properties, as well as present some examples. Related information can be found in the Processing Images and Analysis overviews.

Obtaining an image to work with

Using the Active Image

Most operations in the application take place on the active image, which is represented in the object model as the ActiveImage. When there are no images open in application workspaces, this property will return Nothing, otherwise it will return the one that is active.

Using the Images collection

The application's Images collection is guaranteed to contain all images visible within image workspaces, and may contain other named images that are non-visible. When there are no images open in application workspaces, the collection count will be zero. The collection can be indexed by image name or by the numeric index.

Opening an Image from a File

There are two main ways to load an existing image into the Application. The first is to load the image from one of the supported image file formats such as BMP, JPEG or TIFF. The other is to load the Image from a Database node.

Images are stored as format specific files on a storage medium such as your hard drive, a network server, or within the database.  There are many industry standard file formats, each allowing different combinations of compression and information storage.  Some formats store only pixel imformation, such as JPEG and BMP.  Other formats, such as TIFF and IPW, are able to store any information the client wishes, along with the Images' Pixel data.  Each Imaging Format has one or more supported Compression schemes.  These compression's only apply to the Image Pixel data, not to the other information stored within the file.  Some Compression schemes are lossless, meaning that while the size of the data is smaller no data precision is lost.  Others are lossy, usually meaning that while visually similiar, the data is altered and may affect filters and measurements.  The higher the level of Lossy Compression, the more the data is affected.  Another key difference in file formats is that some will support Multiple Images in one file, a Sequence, while others support only a single image.  Because of these vast differences in types of storage, not all formats are suitable for all purposes, and the balance between size and data integrity must be weighed. 

Please refer to the application manual's appendices for a list of supported file formats

To read an image into the application using the Images collection:

Images.Open "C:\Program Files\Media Cybernetics\IQbase 5.0\Images\GRAINS.tif"

This is equivalent to:

Images.File.Open "C:\Program Files\Media Cybernetics\IQbase 5.0\Images\GRAINS.tif", mcSTREAM_READ
Images.File.Read
Images.File.Close

To save an image to a file:

ActiveImage.Save "c:\images\new.tif"

This is equivalent to:

ActiveImage.File.Open "c:\images\new.tif", mcSTREAM_WRITE
ActiveImage.File.Write
ActiveImage.File.Close

Refer to McStream to see a listing of Advanced Stream methods and Properties.

Opening an Image from a Database Node

The other way to load an existing image is to load the Image from a Database node. This topic will be covered in detail in the Managing Data and Working with Databases section.

Image display and processing

Simple images may have a single frame, but often an image will have many frames, each of which represents the image captured at a particular position on the sample, or point in time. Multiple-frame images are often referred to as Sequences.

The image workspace displays a single frame of the image, which is represented by the ActiveFrameIndex property. Changing this property will change the frame displayed in the workspace. Multiple-frame or Sequence workspaces will also have controls that allow you to play through the sequence, or to step to a desired frame.

Processing, such as the operations discussed in the Processing Images overview, will take place on the ActiveFrameRange, which by default will include all frames of the image.

Image properties

Images have many built-in properties, such as the image's width and height, and also support an extensible list of other user-defined properties. One of these properties is the collection of image Frames, each of which may also have a collection of user-defined properties.

Built-in Image properties

The built-in image properties can be explored by referring to the documentation of the Image object. A few of the important types of image properties include the following.

Characteristics

Basic characteristics such as the image's name, width and height have corresponding image properties. The Type property returns an ImageType object that describes the pixel data organization of a given image.

Frames

An image is composed of one or more image frames, which contain the actual pixel data. The collection of frames for an image can be accessed through the Frames property.

Visualization

Display of the image can be adjusted for better visualization of the data through the display lookup tables and by adding pseudo-coloring using the PseudoColor object.

Calibration

For an image taken of an essentially planar surface, a pixel may represent an area of a fixed size, for instance some area in nanometers in an electron microscope image, or some area in kilometers in a satellite phote. The SpatialCalib property of an image such as the ActiveImage can return a SpatialCalib object that describes the known spatial characteristics of the image. The property will return Nothing if the spatial calibration has not been set.

Similarly, a pixels intensity may represent a known value, for instance a temperature in an infrared image. The IntensityCalib property of an image can return an IntensityCalib object that describes the known intensity characteristics of the image, or will return Nothing if the intensity calibration has not been set.

Refer to the section on Analysis for more details on calibration and measurements.

Dynamic Image properties

The image's Properties collection supports any number of dynamically added properties.

Examples

' ActiveImage example
Sub ProcessActiveImage()
' Our tool requires an active image, so check for that and
' report an error if necessary
If ActiveImage Is Nothing Then
MsgBox "ProcessActiveImage requires an active image. Please use OpenAnImage to open one."
Exit Sub
End If
' Apply the Sharpen filter to the active image
ActiveImage.Enhance.Sharpen
End Sub

' Open an existing image from file example
Sub OpenAnImage()
' You will probably not write your code with hard-coded file names
' so prompt the user to select a file
Images.Open
' If you did want to open a specified file, you could specify the file name
' Images.Open "C:\Program Files\Media Cybernetics\IQbase 5.0\Images\SPOTS.TIF"
End Sub

' Image Properties example
' The first routine displays the current category of properties
Sub DisplayProperties()
Dim Prop
Dim i As Long
Dim iCount As Long
Dim strMsg As String

iCount = ActiveImage.Properties.Count
If iCount = 0 Then
Output.PrintMessage ActiveImage.DisplayName + " has no properties."
End If
For i = 0 To iCount - 1
strMsg = ActiveImage.DisplayName + "'s property '" + ActiveImage.Properties.ItemName(i) + "' (#" + CStr(i + 1) + ") is "
Prop = ActiveImage.Properties(i)
If IsNumeric(Prop) Or IsDate(Prop) Then
strMsg = strMsg + CStr(Prop)
Else
If IsObject(Prop) Then
strMsg = strMsg + "an object"
Else
strMsg = strMsg + "'" + Prop + "'"
End If
End If
Output.PrintMessage strMsg
Next i
' Note: This could also have been written using the following kind of for/next loop
' for each Prop in ActiveImage.Properties ... Next Prop
End Sub

' Image Properties example continued
' This routine displays different categories of imageproperties, and
' illustrates adding and setting user-defined properties.
' Note: Image Frames have Properties collections also.
' Essentially the same code can be used to manage per-frame properties,
' after accessing the frames Properties collection:
' ActiveImage.Frames.Item(ActiveImage.ActiveFrameIndex).Properties
Sub DisplayImageProperties()
' We'll be displaying the properties of the active image, so
' make sure there's an image open
If ActiveImage Is Nothing Then
MsgBox "DisplayImageProperties requires an active image. Please use OpenAnImage to open one."
Exit Sub
End If
' Display the user-defined properties on the image
' If this has not been run before, there won't be any, so DisplayProperties
' will output "<image name> has no properties."
DisplayProperties
' Double-check that our properties haven't been added yet (it's an
' error to try to add the property if it already exists)
If Not ActiveImage.Properties.Exists("MyFirstProperty") Then
ActiveImage.Properties.Add "MyFirstProperty", ""
End If
' Now set the property
ActiveImage.Properties("MyFirstProperty") = "MyFirstProperty is set"
If Not ActiveImage.Properties.Exists("SecondProperty") Then
ActiveImage.Properties.Add "SecondProperty", ""
End If
ActiveImage.Properties("SecondProperty") = 2
' DisplayProperties should now list our properties
DisplayProperties
' Now let's list all the properties, including built-in properties like image Name and Date
ActiveImage.Properties.CategoryFilter = "AllProperties"
DisplayProperties
' Note: To list just the built-in properties, we'd set CategoryFilter="Data"
' To go back to listing just user-defined properties, we'd set CategoryFilter="Properties"
End Sub