Oracle Visual Information Retrieval User's Guide and Reference
Release 8.1.7

Part Number A85335-01

Library

Product

Contents

Index

Go to previous page Go to next page

E
Deprecated Features

Since release 8.1.5, the ORDVirB and ORDVirF object types have been replaced by ORDVir. These object types will be supported in release 8.1.7, but will no longer exist in the next release (after release 8.1.7).

The new ORDVir type is based on the ORDImage type in the Oracle interMedia product. The old interface and object types have been replaced by the interface described in Chapter 4.

This appendix describes the old interface, for those users who still need to access legacy data. Please see the migration functions (migrateFromORDVirB( ) and migrateFromORDVirF( ) methods) in Chapter 4 for information on moving to the new object type.

The old interface will be removed in the next release after release 8.1.7.

The obsolete Visual Information Retrieval library consists of:

The examples in this chapter assume that the stockphotos table has been created and filled with some photographic images. The table was created using the following SQL statement:

CREATE TABLE stockphotos (photo_id NUMBER, photographer (VARCHAR2(64),
             annotation (VARCHAR2(255), photo ORDSYS.ORDVIRB);

When you are storing or copying images, you must first create an empty BLOB in the table. Use the empty_blob( ) function, which has the following format:

ORDSYS.ORDVIRB(empty_blob(),NULL,NULL,NULL,NULL,NULL,NULL,NULL)

E.1 Object Types

The obsolete Visual Information Retrieval object types are as follows:

This section presents reference information on the object types.

For more information on BLOBs and BFILEs, see Oracle8i Application Developers Guide: Large Objects (LOBs).


ORDVirB Object Type

The ORDVirB object type supports storage and retrieval of image data in a BLOB within an Oracle database. This object type is defined as follows:

CREATE TYPE ORDVIRB
(
-- TYPE ATTRIBUTES
content             BLOB,
height              INTEGER,
width               INTEGER,
contentLength       INTEGER,
fileFormat          VARCHAR2(64),
contentFormat       VARCHAR2(64),
compressionFormat   VARCHAR2(64),
signature           RAW(2000),
-- METHOD DECLARATION
    MEMBER PROCEDURE copyContent(dest IN OUT NOCOPY BLOB),
  MEMBER PROCEDURE setProperties(SELF IN OUT ORDVIRB),
  MEMBER PROCEDURE setProperties(SELF IN OUT ORDVIRB, description IN VARCHAR2),	
  MEMBER PROCEDURE process    (SELF    IN OUT ORDVIRB,
                               command  IN     VARCHAR2)
  MEMBER PROCEDURE processCopy(command  IN     VARCHAR2,
                               dest     IN OUT NOCOPY BLOB),
  MEMBER FUNCTION  getMimeType RETURN VARCHAR2,
  MEMBER FUNCTION  getContent  RETURN BLOB, 
  MEMBER FUNCTION  getContentLength RETURN INTEGER,
  MEMBER PROCEDURE deleteContent (SELF IN OUT ORDVirB),
  MEMBER PROCEDURE Analyze (SELF IN OUT ORDVIRB),
  MEMBER FUNCTION  getHeight   RETURN INTEGER,
  MEMBER FUNCTION  getWidth    RETURN INTEGER,
  MEMBER FUNCTION  getFileFormat RETURN VARCHAR2,
  MEMBER FUNCTION  getContentFormat RETURN VARCHAR2,
  MEMBER FUNCTION  getCompressionFormat RETURN VARCHAR2,
  MEMBER FUNCTION  getSignature RETURN RAW,
  MEMBER FUNCTION  checkProperties RETURN BOOLEAN
);

Where the attributes are:

In PL/SQL, data is moved with the DBMS LOB package. From the client, data is moved using OCI LOB calls. The ORDVirB object type does not supply routines for moving data piece by piece.


ORDVirF Object Type

The ORDVirF object type supports storage and retrieval of image data in external files (BFILEs, which are not stored in the database). BFILEs are assumed to be read-only, and this is reflected in the member procedures. This object type is defined as follows:

CREATE TYPE ORDVIRF 
(
  -- TYPE ATTRIBUTES
content             BFILE,
height              INTEGER,
width               INTEGER,
contentLength       INTEGER,
fileFormat          VARCHAR2(64),
contentFormat       VARCHAR2(64),
compressionFormat   VARCHAR2(64),
signature           RAW(2000),
-- METHOD DECLARATION
  MEMBER PROCEDURE copyContent(dest IN OUT NOCOPY BLOB),
  MEMBER PROCEDURE setProperties(SELF IN OUT ORDVIRF),
  MEMBER PROCEDURE setProperties(SELF IN OUT ORDVIRF, description IN VARCHAR2),
  MEMBER PROCEDURE processCopy(command IN VARCHAR2,   
                             dest    IN OUT NOCOPY BLOB),
  MEMBER FUNCTION  getMimeType RETURN VARCHAR2,
  MEMBER FUNCTION  getContent  RETURN BFILE, 
  MEMBER FUNCTION  getContentLength RETURN INTEGER, 
  MEMBER PROCEDURE Analyze (SELF IN OUT ORDVIRF),
  MEMBER FUNCTION  getHeight   RETURN INTEGER,
  MEMBER FUNCTION  getWidth    RETURN INTEGER,
  MEMBER FUNCTION  getFileFormat RETURN VARCHAR2,
  MEMBER FUNCTION  getContentFormat RETURN VARCHAR2,  
  MEMBER FUNCTION  getCompressionFormat RETURN VARCHAR2,  
  MEMBER FUNCTION  getSignature RETURN RAW,
  MEMBER FUNCTION  checkProperties RETURN BOOLEAN
);

Where the attributes are:

E.2 Methods

This section presents reference information on the methods used for image manipulation.

Visual Information Retrieval methods are as follows:

For more information on object types and methods, see Oracle8i Concepts.


analyze( ) Method

Format

Analyze( );

Description

Analyzes an image BLOB or BFILE, derives information relating to the visual attributes (including a score for each), and creates the image signature.

Usage

The Analyze( ) method creates the image attribute signature, which is necessary for any content-based retrieval. Whenever you are working with a new or changed image, you should also use the SetProperties( ) method to set the other image characteristics.

Signatures for facial images can be created using an optional third-party software package from Viisage Technology, Inc. After creating a facial signature, Visual Information Retrieval can convert the signature to a standard format and then compare the signatures using the Score( ) and Similar( ) operators.

The Analyze( ) method is functionally equivalent to the Analyze( ) operator. You must use the Analyze( ) method when working with foreign images.

Examples

Create the signatures for all images in the stockphotos table.

DECLARE
   temp_image   ORDSYS.ORDVirB;
   temp_id      INTEGER;
   cursor c1 is select id, image from stockphotos for update;
BEGIN
   OPEN c1;
   LOOP
      fetch c1 into temp_id, temp_image;
      EXIT WHEN c1%NOTFOUND;
  
 -- Generate signature and set the properties for the image.
      temp_image.analyze; 
      temp_image.setProperties;
      UPDATE stockphotos SET photo = temp_image WHERE photo_id = temp_id;
   END LOOP;
   CLOSE c1;
END;

checkProperties Method

Format

checkProperties RETURN BOOLEAN;

Description

Verifies that the properties stored in attributes of the image object match the properties of the image stored in the BLOB or BFILE. This method should not be used for foreign images.

Parameter

None.

Returns

BOOLEAN

Usage

Use this method to verify that the image attributes match the actual image.

Examples

Check the image attributes.

virb1            ORDSYS.ORDVirB;
properties_match BOOLEAN;
              
...
properties_match := virb1.checkProperties;


copyContent( ) Method

Format

copyContent (dest IN OUT NOCOPY BLOB);

Description

Copies an image without changing it.

Parameter

dest

The destination of the new image.

Usage

This method copies the image data into the supplied BLOB.

Examples

Create a copy of the image in image1 into myblob.

image1.copyContent(myblob);


deleteContent Method

Format

deleteContent;

Description

Deletes the contents of the image.

Parameter

None.

Usage

Use this method to delete the contents of the image BLOB. This procedure works only with BLOBs, not BFILEs.

Examples

Delete the content of an image.

virb1  ORDSYS.ORDVirB;

...
virb1.deleteContent;


getCompressionFormat Method

Format

getCompressionFormat RETURN VARCHAR2;

Description

Returns the compression type of an image. This method does not actually read the LOB; it is a simple access method that returns the value of the compressionFormat attribute.

Parameter

None.

Returns

VARCHAR2

Usage

Use this method rather than accessing the compressionFormat attribute directly to protect yourself from potential changes to the internal representation of the ORDVirB or ORDVirF object.

Examples

Get the compression type of an image.

virb1             ORDSYS.ORDVirB;
compressionFormat VARCHAR2(64);

...
compressionFormat := virb1.getCompressionFormat;

getContent Method

Format

getContent RETURN BLOB;

getContent RETURN BFILE;

Description

Returns the LOB locator of the BLOB or BFILE containing the image. This is a simple access method that returns the value of the content attribute.

Parameter

None.

Returns

BLOB or BFILE, depending on how the image is stored.

Usage

Use this method rather than accessing the content attribute directly to protect yourself from potential changes to the internal representation of the ORDVirB or ORDVirF object.

Examples

Get the LOB locator for an image.

virb1   ORDSYS.ORDVirB;
content BLOB;
...
content := virb1.getContent;


getContentFormat Method

Format

getContentFormat RETURN VARCHAR2;

Description

Returns the type of an image (such as monochrome or 8-bit grayscale). This method does not actually read the LOB; it is a simple access method that returns the value of the contentFormat attribute.

Parameter

None.

Returns

VARCHAR2

Usage

Use this method rather than accessing the contentFormat attribute directly to protect yourself from potential changes to the internal representation of the ORDVirB or ORDVirF object.

Examples

Get the type of an image.

virb1         ORDSYS.ORDVirB;
contentFormat VARCHAR2(64);

...
contentFormat := virb1.getContentFormat;

getContentLength Method

Format

getContentLength RETURN INTEGER;

Description

Returns the size of the on-disk image in bytes. This method does not actually read the LOB; it is a simple access method that returns the value of the contentLength attribute.

Parameter

None.

Returns

INTEGER

Usage

Use this method rather than accessing the contentLength attribute directly to protect yourself from potential changes to the internal representation of the ORDVirB or ORDVirF object.

Examples

Get the content length of an image.

virb1         ORDSYS.ORDVirB;
contentLength INTEGER;

...
contentLength := virb1.getContentLength;


getFileFormat Method

Format

getFileFormat RETURN VARCHAR2

Description

Returns the file type of an image (such as TIFF or JFIF). This method does not actually read the LOB; it is a simple access method that returns the value of the fileFormat attribute.

Parameter

None.

Returns

VARCHAR2

Usage

Use this method rather than accessing the fileFormat attribute directly to protect yourself from potential changes to the internal representation of the ORDVirB or ORDVirF object.

Examples

Get the file type of an image.

virb1      ORDSYS.ORDVirB;
fileFormat VARCHAR2(64);

...
fileFormat := virb1.getFileFormat;


getHeight Method

Format

getHeight RETURN INTEGER;

Description

Returns the height of an image in pixels. This method does not actually read the LOB; it is a simple access method that returns the value of the height attribute.

Parameter

None.

Returns

INTEGER

Usage

Use this method rather than accessing the height attribute directly to protect yourself from potential changes to the internal representation of the ORDVirB or ORDVirF object.

Examples

Get the height of an image.

virb1  ORDSYS.ORDVirB;
height INTEGER;

...
height := virb1.getHeight;

getMimeType Method

Format

getMimeType RETURN VARCHAR2;

Description

Returns the Multipurpose Internet Mail Extension (MIME) type of an image (such as image/jpeg or image/tiff). This method returns the MIME type based on the
fileFormat of the image. See Appendix A for the MIME type associated with each supported file format.

Parameter

None.

Returns

VARCHAR2

Usage

Use this method to obtain the MIME type of the image. The MIME type is required by Web browsers along with the image content. It tells the Web browser how to interpret the image content.

Examples

Get the MIME type of an image.

virb1      ORDSYS.ORDVirB;
mimeType   VARCHAR2(64);

...
mimeType := virb1.getMimeType;

getSignature Method

Format

getSignature RETURN RAW;

Description

Returns the signature of an image. This method does not actually create the image signature; it is a simple access method that returns the contents of the signature attribute.

Parameter

None.

Returns

RAW

Usage

Use this method rather than accessing the signature attribute directly to protect yourself from potential changes to the internal representation of the ORDVirB or ORDVirF object.

Examples

Get the signature of an image.

virb1     ORDSYS.ORDVirB;
 signature RAW(2000);

...
signature := virb1.getSignature;

getWidth Method

Format

getWidth RETURN INTEGER;

Description

Returns the width of an image in pixels. This method does not actually read the LOB; it is a simple access method that returns the value of the width attribute.

Parameter

None.

Returns

INTEGER

Usage

Use this method rather than accessing the width attribute directly to protect yourself from potential changes to the internal representation of the ORDVirB or
ORDVirF object.

Examples

Get the width of an image.

virb1  ORDSYS.ORDVirB;
width  INTEGER;

...
width := virb1.getWidth;

process( ) Method

Format

process (command IN VARCHAR2);

Description

Performs one or more image processing techniques on a BLOB, writing the image back on to itself.

Parameter

command

A list of image processing changes to make for the image.

Usage

You can change one or more of the image attributes shown in Table E-1. Table E-2 shows additional changes can be made to raw pixel and foreign images. See Appendix A for information on the supported format combinations. See Appendix C for a more complete description of each operator.

Table E-1 Image Processing Operators  
Parameter Name  Usage  Values 

compressionFormat 

Compression type/format 

JPEG, SUNRLE, BMPRLE, TARGARLE, LZW, LZWHDIFF, FAX3, FAX4, HUFFMAN3, Packbits, GIFLZW 

compressionQuality 

Compression quality 

MAXCOMPRATIO, MAXINTEGRITY,
LOWCOMP, MEDCOMP, HIGHCOMP 

contentFormat 

Image type/pixel/data format 

MONOCHROME, 8BITGRAYSCALE, 8BITGREYSCALE, 8BITLUT, 24BITRGB 

cut 

Window to cut (origin.x origin.y width height) 

(INTEGER INTEGER INTEGER INTEGER)
Maximum value is 65535. 

fileFormat 

File format of the image 

BMPF, CALS, GIFF, JFIF, PICT, RASF, RPIX, TGAF, TIFF 

fixedScale 

Scale to a specific size in pixels (width, height) 

(INTEGER INTEGER) 

maxScale 

Scale to a specific size in pixels, while maintaining the aspect ratio (maxWidth, maxHeight) 

(INTEGER INTEGER) 

scale 

Scale factor (for example, 0.5 or 2.0); preserves aspect ratio 

<FLOAT> positive 

xScale 

X-axis scale factor (Default is 1.) 

<FLOAT> positive 

yScale 

Y-axis scale factor (Default is 1.) 

<FLOAT> positive 

Table E-2 Additional Image Processing Operators for Raw Pixel and Foreign Images
Parameter Name  Usage  Values 

ChannelOrder 

Indicates the relative position of the red, green, and blue channels (bands) within the image. 

RGB (default), RBG, GRB, GBR, BRG, BGR 

InputChannels 

For multiband images, specify either one (grayscale) or three integers indicating which channels to assign to red (first), green (second), and blue (third). Note that this parameter affects the source image, not the destination. 

INTEGER or
INTEGER INTEGER INTEGER 

Interleave 

Controls band layout within the image:
Band interleaved by pixel
Band interleaved by line
Band sequential 

BIP (default), BIL, BSQ 

PixelOrder 

If NORMAL, then the leftmost pixel appears first in the image. 

NORMAL (default), REVERSE 

ScanlineOrder 

If NORMAL, then the top scanline appears first in the image. 

NORMAL (default), INVERSE 


Note:

When specifying parameter values that include floating-point numbers, you must use double quotation marks (" ") around the value. If you do not, this may result in incorrect values being passed and you will get incorrect results. 


Examples

Example 1: Change the file format of image1 to GIF.

image1.process('fileFormat=GIFF');

Example 2: Change image1 to use lower quality JPEG compression and double the size of the image, preserving the aspect ratio.

image1.process('compressionFormat=JPEG, compressionQuality=LOWCOMP, 
scale="2.0"');

Note that changing the length on only one axis (for example, xScale=2.0) does not affect the length on the other axis, and would result in image distortion. Also, only the xScale and yScale parameters can be combined in a single operation. Any other combinations result in an error.

Example 3: The maxScale and fixedScale parameters are especially useful for creating thumbnail images from various-sized originals. The following line of code creates a 32-by-32 pixel thumbnail image, preserving the original aspect ratio:

image1.process('maxScale=32 32');


processCopy( ) Method

Format

processCopy (command IN VARCHAR2,

dest IN OUT NOCOPY BLOB);

Description

Copies an image BLOB or BFILE to another BLOB.

Parameters

command

A list of image processing changes to make for the image in the new copy.

dest

The destination of the new image.

Usage

See Table E-1 and Table E-2.

When using temporary LOBs, you cannot specify the same temporary LOB as both the source and the destination.

Examples

Copy an image, changing the file format, compression format, and data format in the destination image.

create or replace procedure copyit is 
 virB1     ORDSYS.ORDVIRF; 
 virB4     ORDSYS.ORDVIRB; 
 mycommand   VARCHAR2(400); 
begin 
  select col2 into virB1 from ordvirtab  where col1 = 1; 
  select col2 into virB4 from ordvirtab  where col1 = 4 for update; 
  mycommand:= 'fileFormat=tiff compressionFormat = packbits 
  contentFormat = 8bitlut'; 
  virB1.processcopy(mycommand,virB4.content); 
  virB4.setproperties;
  update ordvirtab set col2 = virB4 where col1 = 4;
end; 

setProperties( ) Method

Format

setProperties( );

Description

Writes the characteristics of an image (BLOB or BFILE) into the appropriate attribute fields.

Parameters

None.

Usage

After you copied, stored, or processed an image, call this method to set the characteristics of the new image content.

This method sets the following information about an image:

Note that the setProperties( ) method does not create the signature required for content-based retrieval. See the Analyze( ) operator in Section E.3 for details.

Examples

Select the image type, and then set the attributes using the setProperties procedure.

virB1 ORDSYS.ORDVIRB;
.
.
.
select col2 into virB1 from ordvirtab where col1 = 1 for update;
virB1.setProperties;
dbms_output.put_line('image width = '|| virB1.width );
dbms_output.put_line('image height = '|| virB1.height );
dbms_output.put_line('image size = '|| virB1.contentLength );
dbms_output.put_line('image file type = '|| virB1.fileFormat );
dbms_output.put_line('image type = '|| virB1.contentFormat );
dbms_output.put_line('image compression = '|| virB1.compressionFormat );
-- Note: signature not meaningful as displayed output.

Example output:

image width = 360
image height = 490
image size = 59650
image file type = JFIF
image type = 24BITRGB
image compression = JPEG


setProperties( ) Method for Foreign Images

Format

setProperties(description IN VARCHAR2 );

Description

Allows you to write the characteristics of a foreign image (BLOB or BFILE) into the appropriate attribute fields.

Parameter

description

The image characteristics to set for the foreign image.

Usage

After you copied, stored, or processed a foreign image, call this method to set the characteristics of the new image content. Unlike the native image types described in Appendix A, foreign images do not contain information on how to interpret the bits in the file (or contain information that the product cannot understand), and you must set them explicitly.

You can set the following image characteristics for foreign files, as shown in
Table E-3.

Table E-3 Image Characteristics for Foreign Files 
Field  Data Type  Description 

CompressionFormat 

STRING 

Value must be CCITTG3, CCITTG4, or NONE (default). 

DataOffset 

INTEGER 

The offset allows the image to have a header that the product does not try to interpret. Set the offset to ignore any potential header. The value must be a positive integer less than the LOB length.
Default is zero. 

DefaultChannelSelection 

INTEGER 

For multiband images, specify either one (grayscale) or three integers indicating which channels to assign to red (first), green (second), and blue (third). 

Height 

INTEGER 

Height of the image in pixels. Value must be a positive integer.
There is no default, and a value must be specified. 

MIME type 

STRING

VARCHAR2 

Value must be a MIME type search as image/gif. 

Interleaving 

STRING 

Band layout within the image. Valid styles are:

  • BIP (default): Band interleaved by pixel

  • BIL: Band interleaved by line

  • BSQ: Band sequential

 

NumberOfBands 

INTEGER 

Value must be a positive integer less than 255 describing the number of color bands in the image.
Default is 3. 

PixelOrder 

STRING 

If NORMAL (default), the leftmost pixel appears first in the file. If REVERSE, the rightmost pixel appears first. 

ScanlineOrder 

STRING 

If NORMAL (default), the top scanline appears first in the file. If INVERSE, the bottom scanline appears first. 

UserString 

STRING 

A 4-character descriptive string. If used, the string is stored in the fileFormat field, appended to the file format (OTHER:).
Default is blank. 

Width 

INTEGER 

Width of the image in pixels. Value must be a positive integer.
There is no default, and a value must be specified. 

The values supplied to setProperties( ) are written to the existing ORDVirB and ORDVirF object attributes. The fileFormat is set to OTHER: and includes the user string, if supplied.

Note that setProperties( ) does not create the signature required for content-based retrieval. See the Analyze( ) operator in Section E.3 for details.

Examples

Select the image type, and then set the attributes using the SetProperties method.

virB1 ORDSYS.ORDVIRB;
select col2 into virB1 from ordvirtab where col1 = 1 for update;
virB1.setProperties('width=380 height=407 dataOffset=128 bandOrder=BIL
userString="LSAT"');

E.3 Operators

Visual Information Retrieval operators are located in the ORDSYS.VIR package. The operators, which are specific to content-based retrieval, are as follows:

For ease of use, you can create a local synonym for the ORDSYS.VIR package. Connect to your schema and issue the following command:

SVRMGR> CREATE SYNONYM VIR FOR ORDSYS.VIR; 

After creating the synonym, you can use it in calls to the operators: VIR.Analyze( ), VIR.Score( ), and so forth. Note that you must have the default CREATE SYNONYM privilege.

This section presents reference information on the operators.


Analyze( ) Operator

Format

Analyze(image IN BLOB, signature OUT RAW);

or

Analyze(image IN BFILE, signature OUT RAW);

Description

Analyzes an image BLOB or BFILE, derives information relating to the visual attributes, and creates the image signature.

Parameters

image

The BLOB or BFILE to be analyzed.

signature

The vector to contain the signature.

Usage

The Analyze( ) operator creates the image signature (or feature vector), which is necessary for any content-based retrieval. Whenever you are working with a new or changed image, you should call Analyze( ) to generate a signature and then use the SetProperties( ) method to set the other image characteristics.

Signatures for facial images can be created using an optional third-party software package from Viisage Technology, Inc. After creating a facial signature, Visual Information Retrieval can convert the signature to a standard format and then compare the signatures using the Score( ) and Similar( ) operators.

Examples

Create the signatures for all images in the stockphotos table.

DECLARE
   temp_image   ORDSYS.ORDVirB;
   temp_id      INTEGER;
   cursor c1 is select id, image from stockphotos for update;
BEGIN
   OPEN c1;
   LOOP
      fetch c1 into temp_id, temp_image;
      EXIT WHEN c1%NOTFOUND;
  
 -- Generate signature and set the properties for the image.
      ORDSYS.VIR.Analyze(temp_image.content, temp_image.signature); 
      temp_image.setProperties;
      UPDATE stockphotos SET photo = temp_image WHERE photo_id = temp_id;
   END LOOP;
   CLOSE c1;
END;


Convert( ) Operator

Format

Convert(signature IN OUT RAW, operation IN VARCHAR2);

Description

Converts the image signature to a format usable by the host machine.

Parameters

signature

The signature of the image, as created by the Analyze( ) operator or by Viisage software. Data type is raw(2000).

operation

The processing to be done to the image signature. The following operations are available:

Operation Keyword  Description 

BYTEORDER 

Converts the signature to the natural byte order of the host machine.  

VIISAGE 

Converts the signature from the format used for Viisage facial recognition to a signature usable by the Score( ) and Similar( ) operators. 

Usage

When the operation is BYTEORDER, the signature is converted to the format of the host machine regardless of its initial state.

This procedure is useful if the database is stored on a remote system, but you want to do your processing locally. If your host machine is from Sun Microsystems, Inc., the Convert( ) operator sets the signature to the big endian byte order. On an Intel Corporation machine, the operator converts the signature to the little endian byte order. Note that the images themselves are machine-independent; only the signatures need to be converted.

When the operation is VIISAGE, the signature is converted from the format used by Viisage Technology for facial recognition to the format usable by this product for Score( ) and Similar( ) operators.

Examples

Example 1: Convert the signature of the image with photo_id=1 to a signature that is usable by the host system.

DECLARE
   myimage ORDSYS.ORDVirB;
   myid      INTEGER;
BEGIN
   SELECT photo INTO myimage FROM stockphotos WHERE photo_id=1 FOR UPDATE;
   ORDSYS.VIR.Convert(myimage.signature,'BYTEORDER');
   UPDATE stockphotos SET photo=myimage WHERE photo_id=1;
END;

Example 2: Convert the signatures of the image with photo_id=1 from the format used for Viisage facial image recognition software to a signature usable by the Score( ) and Similar( ) operators.

DECLARE
   myimage ORDSYS.ORDVirB;
   myid    INTEGER;
BEGIN
   SELECT photo INTO myimage FROM stockphotos WHERE photo_id=1 FOR UPDATE;
   ORDSYS.VIR.Convert(myimage.signature,'VIISAGE');
   UPDATE stockphotos SET photo=myimage WHERE photo_id=1;
END;

Score( ) Operator

Format

Score(signature1 IN RAW,

signature2 IN RAW,

weightstring IN VARCHAR2);

where weightstring is: 'globalcolor="val" localcolor="val" texture="val" structure="val"'

or: 'facial=1'

Description

Compares the signatures of two images and returns a number representing the weighted sum of the distances for the visual attributes.

Parameters

signature1

The signature of the comparison image (the image with which other images are being compared to test for matches). Data type is RAW(2000).

signature2

The signature of the image being compared with the comparison image. Data type is RAW(2000).

weightstring

A list of weights to apply to each visual attribute. Data type is VARCHAR2.

The following attributes can be specified, with a value of 0.0 specifying no importance and a value of 1.0 specifying highest importance:

Attribute  Description 

globalcolor 

The weight value (0.0 to 1.0) assigned to the global color visual attribute. Data type is NUMBER. Default is 0.0. 

localcolor 

The weight value (0.0 to 1.0) assigned to the local color visual attribute. Data type is NUMBER. Default is 0.0. 

texture 

The weight value (0.0 to 1.0) assigned to the texture visual attribute. Data type is NUMBER. Default is 0.0. 

structure 

The weight value (0.0 to 1.0) assigned to the structure visual attribute. Data type is NUMBER. Default is 0.0. 

facial 

The two signatures are Viisage facial signatures. When comparing facial signatures, no other attributes can be included in the weightstring. Data type is NUMBER, and must be set to 1 if used. 


Note:

When specifying parameter values that include floating-point numbers, you should use double quotation marks
(" ") around the value. If you do not, this may result in incorrect values being passed and you will get incorrect results. 


Returns

A FLOAT value between 0.0 and 100.0, where 0.0 is identical and 100.0 is totally different.

Usage

Before the Score( ) operator can be used, the image signatures must be created with the Analyze( ) operator.

The Score( ) operator can be useful when an application wants to make finer distinctions about matching than the simple Yes or No returned by the Similar( ) operator. For example, using the number for weighted sum returned by Score( ), the application might assign each image being compared to one of several categories, such as definite matches, probable matches, possible matches, and non-matches. The Score( ) operator can also be useful if the application needs to perform special processing based on the degree of similarity between images.

The weights supplied for the four visual attributes are normalized before processing such that they add up to 100 percent. To avoid confusion and meaningless results, you should develop a habit of always using the same scale, whether 0 to 100 or 0.0 to 1.0.

You must specify at least one of the four image attributes or the facial attribute, in the weightstring. You cannot combine the facial attribute with any of the other attributes.

Examples

Example 1: The following example finds the weighted sum of the distances between image 1 and the other images in the stockphotos table, using the following weights for the visual attributes:

Example 2: This example assumes that the signatures were created using the Analyze( ) operator and they are stored in the database.

DECLARE
   weighted_sum     NUMBER;
BEGIN
   SELECT Q.photo_id, 
          ORDSYS.VIR.Score(S.photo.signature, 
                                 Q.photo.signature, 
                                 'globalcolor="0.2" 
localcolor="0.2"
texture="0.1"
structure="0.5"') weighted_sum FROM stockphotos Q, stockphotos S WHERE S.photo_id=1 and Q.photo_id !=S.photo_id; END;

The following shows possible output from the previous example. The first image has the lowest score, and therefore is the best match of the test image (photo_id=1). Changing the weights used in the scoring would lead to different results.

PHOTO_ID   WEIGHTED_SUM 
---------- -------------
         2    3.79988   
         3    76.0807   
         4    47.8139   
         5    80.451   
         6    91.2473   
5 rows selected.


Similar( ) Operator

Format

Similar(signature1 IN RAW

signature2 IN RAW,

weightstring IN VARCHAR2

threshold IN FLOAT);

where weightstring is: 'globalcolor="val" localcolor="val" texture="val" structure="val"'

or: 'facial=1'

Description

Determines whether or not two images match. Specifically, compares the signatures of two images, computes a weighted sum of the distance between the two images using weight values for the visual attributes, compares the weighted sum with the threshold value, and returns the integer value 1 if the weighted sum is less than or equal to the threshold value. Otherwise, the Similar( ) operator returns 0.

Parameters

signature1

The signature of the comparison image (the image with which other images are being compared to test for matches).

signature2

The signature of the image being compared with the comparison image.

weightstring

A list of weights to apply to each visual attribute. Data type is VARCHAR2.

The following attributes can be specified, with a value of 0.0 specifying no importance and a value of 1.0 specifying highest importance:

Attribute  Description 

globalcolor 

The weight value (0.0 to 1.0) assigned to the global color visual attribute. Data type is NUMBER. Default is 0.0. 

localcolor 

The weight value (0.0 to 1.0) assigned to the local color visual attribute. Data type is NUMBER. Default is 0.0. 

texture 

The weight value (0.0 to 1.0) assigned to the texture visual attribute. Data type is NUMBER. Default is 0.0. 

structure 

The weight value (0.0 to 1.0) assigned to the structure visual attribute. Data type is NUMBER. Default is 0.0. 

facial 

The two signatures are Viisage facial signatures. When comparing facial signatures, no other attributes can be included in the weightstring. Data type is NUMBER, and must be set to 1 if used. 


Note:

When specifying parameter values that include floating-point numbers, you should use double quotation marks
(" ") around the value. If you do not, this may result in incorrect values being passed and you will get incorrect results. 


threshold

The value with which the weighted sum of the distances is to be compared. If the weighted sum is less than or equal to the threshold value, the images are considered to match. The range of this parameter is from 0.0 to 100.0.

Returns

An integer value of 0 (not similar) or 1 (match).

Usage

Before the Similar( ) operator can be used, the image signatures must be created with the Analyze( ) operator.

The Similar( ) operator is useful when the application needs a simple Yes or No for whether or not two images match. The Score( ) operator is useful when an application wants to make finer distinctions about matching or to perform special processing based on the degree of similarity between images.

The weights supplied for the four visual attributes are normalized before processing such that they add up to 100 percent. To avoid confusion and meaningless results, you should develop a habit of always using the same scale, whether 0 to 100 or 0.0 to 1.0.

You must specify at least one of the four image attributes, or the facial attribute, in the weightstring. You cannot combine the facial attribute with any of the other attributes.

Examples

This example checks the first image against all the other images in the table and determines if there are any matches, using a threshold value of 75 and the following weights for the visual attributes:

The following shows a possible output from this example. See the Examples section of the Score( ) operator for a different way of viewing the results using the same images and weights.

PHOTO_ID     
----------   
         2   
         4  
2 rows selected.


Go to previous page Go to next page
Oracle
Copyright © 1996-2000, Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index