Image Particles

A set of experimental image data types, designed to make it convenient to manipulate images and video sequences in MLDesigner, were defined by Paul Haskell. They are based on MLDesigner’s built-in Message type.

A few primitives that use these image data types can be found in the DE domain. Namely the CellToImage and ImageToCell primitives in MLD Libraries→DE→Networking, as well as MxToImage and ImageToMx in MLD Libraries→DE→Conversion.

This set of classes is being replaced by the PtMatrix classes. The SDF image classes all use PtMatrix now. We give here a brief introduction to the image data types used in the DE domain, although a new user should consider using PtMatrix classes instead. Class definitions can be found in $MLD/MLD_Libraries/DE/kernel.

The base class of all the image classes is called BaseImage. It has some generic methods and members for manipulating images. Most of the methods are redefined in the derived classes. The fragment method partitions an image into many smaller images, which together represent the same picture as the original. The assemble method combines many small images which make up a single picture into a single image that contains the picture. The fragment method works recursively, so an image that has been produced by a previous fragment call can be further fragmented. assembly always produces a full-sized image from fragments, however small.

Use of the size, fullSize, and startPos members varies within each subclass. Typically the size variable holds the number of pixels that an object is storing. If an object is not produced by fragment(), then (size == fullSize). If the object is produced by a fragment() call, size may be less than or equal to fullSize. An object’s fullSize may be bigger or smaller than width*height. It would be bigger, for example, in DCTImage, where the amount of allocated storage must be rounded up to be a multiple of the blocksize. It would be smaller, for example, for an object that contains run-length coded video.

The frameId variable is used during assembly. Fragments with the same frameIds are assembled into the same image. So, it is important that different frames from the same source have different frameIds.

The comparison operators ==, !=, <, >, etc. compare two objects’ frameIds. They can be used to resequence images or to sort image fragments.

The copy constructor and clone methods have an optional integer argument. If a non-zero argument is provided, then all state values of the copied object are copied to the created object, but none of the image data is copied. If no argument or a zero argument is provided, then the image data is copied as well. Classes derived from BaseImage should maintain this policy.

The GrayImage class, derived from BaseImage, is used to represent gray-scale images. The DCTImage class is used to represent images or image fragments that have been encoded using the discrete-cosine transform. The MVImage class is a bit more specialized. It stores a frame’s worth of motion vectors.