QbGenericImageDataClass is derived from the QbGenericDataClass. It includes all the methods of the superclass, plus other methods specific to processing images, such as reading the image from memory or disk, getting the image's size, and specifying a mask image which allow you to query a subpart of an image based on a reference image (the mask).
ToQueryString in the derived class is implemented to encode the domain-specific data, and then to call the base class ToQueryString method to encode the generic information. FromQueryString reverses this process.
QbGenericImageDataClass includes methods ReadImageDataFromFile and ReadImageDataFromPickerFile, which perform image I/O. They support reading a variety of common image formats, including:
In addition to the standard image formats listed above, the QbGenericImageDataClass can also read a QBIC Picker Image Description string either in memory (ReadPickerImageDescriptionString) or in a file (ReadPickerImageDescriptionFile). This description string is a simple encoding of an image in a text string. Currently, this method only recognizes rectangles. The string format is:
Dwidth,height:Rulx,uly,rwidth,rheight,R,G,B:...
You can specify multiple rectangles (R strings), but the first rectangle must be "painted" in the drawing area first, and subsequent rectangles which overlap are painted over it. QBIC considers any area that is not painted is "to be ignored". Color information inside the "to be ignored" region does not affect the QBIC distance evaluation.
The QBIC Picker Image Description string is useful for sending image descriptions from a client to a server so that the server can construct a query image based on the description, and then search for similar images in the database. The description string is heavily used in the QBIC demo.
This chapter describes the following methods:
You can see coding examples in Appendix C, "Sample Code" on page 185. Other programs are located in the qbic/QbicApi
directory.
This is the constructor for the class.
QbGenericImageDataClass( void )
This is the destructor for the class.
virtual ~QbGenericImageDataClass( void )
This method decodes a subpart definition from a QbDatumClass instance, and initializes the object's private variables describing the subparts. This method assumes the image that corresponds to the parent key has already been stored in the object. If not, this method will give unexpected results.
virtual int DecodeSubPartDef( const QbDatumClass &subPartDatum )
subPartDatum-A reference to a QbDatumClass object whose byte string holds the subpart information to be decoded
An integer value: 0 indicates success; -1 indicates failure
This method encodes the subpart definition inside the object to a byte string, and assigns it to the byte string of the input QbDatumClass object.
virtual int EncodeSubPartDef( QbDatumClass &subPartDatum )
subPartDatum-A reference to a QbDatumClass object that will hold the encoded subpart description
An integer value: 0 indicates success; -1 indicates failure
This method decodes a byte string of a QbDatumClass object to initialize the object.
virtual int FromQueryString( const QbDatumClass &datum, const char *featureClassname )
An integer value: 0 indicates success; -1 indicates failure
This method returns the image name whose data the current object represents.
const char * GetFilename( void )
A pointer to a string to hold the file name
This method returns a pointer to an array of image pixel indexing.
unsigned char * GetImage( void )
A pointer to an unsigned char. Its size is Xsize*Ysize, where Xsize and Ysize are the width and height of the image. The pixel index value at point (x,y) should be:
GetImage()[y*Xsize+x]For more information, see the "GetLut method" on page 131, "GetXsize method" on page 132, and "GetYsize method" on page 132. Also, see the "GetImageDataFromMemory method" on page 130.
This method initializes a QbGenericImageDataClass object using a given image in memory. The memory image should include a palette with a color table or look-up table.
int GetImageDataFromMemory( const unsigned long width, const unsigned long height, unsigned char *imageArg, unsigned char *lutArg, unsigned char *maskArg, const Boolean subpart = False, Boolean deletesStorageArg = False )
An integer value: 0 indicates success; -1 indicates failure
This method returns a pointer to the look-up table, which has an array size of 768 (256 * 3).
unsigned char * GetLut( void )
A pointer to an unsigned char array
This method returns a pointer to the array to hold the image mask.
unsigned char * GetMask( void )
A pointer to an unsigned char array that holds the image mask
This method returns the mask image name whose data the current object represents.
const char * GetMaskname( void )
A pointer to a string to hold the mask file name
This method returns the width of the image.
unsigned long GetXsize( void )
An unsigned long integer to hold the image's width
This method returns the height of the image.
unsigned long GetYsize( void )
An unsigned long integer to hold the image's height
This method returns the interface type defined in the base class.
virtual const QbInterfaceType Itype( void )
GenericDataInterfaceType of QbInterfaceType defined in the QbBaseClass. See page 49.
This method reads in image data from a file.
int ReadImageDataFromFile( const char *filename, const char *maskFileName = NULL, const Boolean subpart = False )
An integer value: 0 indicates success; -1 indicates failure
This method reads in image data from a picker file.
int ReadImageDataFromPickerFile( const char *filename, const char *maskFileName = NULL, const Boolean subpart = False )
An integer value: 0 indicates success; -1 indicates failure
This method reads a picker image description from a file.
int ReadPickerImageDescriptionFile( const char *filename, const Boolean subpart = False )
An integer value: 0 indicates success; -1 indicates failure
This method reads a picker image description from a string. QBIC currently supports only rectangles for this method.
int ReadPickerImageDescriptionString( const char *dstr, const Boolean subpart = False )
An integer value: 0 indicates success; -1 indicates failure
This method encodes the content of the object to a byte string and assigns it to the byte string of the input QbDatumClass object.
virtual int ToQueryString( QbDatumClass &datum )
datum-A reference to a QbDatumClass object that will hold the byte string that encodes the object data
An integer value: 0 indicates success; -1 indicates failure
This method returns a constant string of the class name.
virtual const char * Type( void )
A constant string, QbGenericImageDataClass
This method reads the given maskFileName and updates the object's image mask.
int UpdateMaskInImageObject( const char *maskFileName )
maskFileName-A pointer to a string that contains the mask file name
An integer value: 0 indicates success; -1 indicates failure