The Image Extender provides four UDFs that you can use in an SQL statement to retrieve
the score of a cataloged image in a table column. The score is a double-precision, floating point value from 0.0 to a very large number approaching infinity. The lower the score, the closer the feature values of the image matches the feature values specified in the query. A score of 0.0 means that the image is an exact match.
The UDFs are:
Recommendation: Use the QbScoreFromStr UDF to get the score of a single cataloged image. Use the QbScoreTBFromStr UDF to get the score of multiple cataloged images in a table column.
Use the QbScoreFromStr UDF to get the score of a single cataloged image in a table column. Specify a query string as input to the QbScoreFromStr UDF. If you use the QbScoreFromName UDF, specify the name of a query object as input to the QbScoreFromName UDF. With either UDF, you also specify the name of the table column that contains the target image.
In the following query, the QbScoreFromStr UDF is used to find the cataloged images in a table column whose average color score is very close to red.
SELECT name, description decimal (QbScoreFromStr(swatch_img, 'QbColorFeatureClass color=<255, 0, 0>'), /* query string * 10, 5) AS score FROM fabric /* table column */ ORDER BY score
Use the QbScoreTBFromStr UDF to get the score of multiple cataloged images in a table column. You can use the QbScoreTBFromName UDF, if you have a named query. Both UDFs return a two-column table of image handles and scores; the rows in the table are in ascending order of score. The name of the handle column in the result table is IMAGE_ID; the name of the score column is SCORE.
Specify a query string as input to the QBScoreTBFromStr UDF. Specify the name of a query object as input to the QbScoreTBFromName UDF. With either UDF, you also specify the name of the table and column that contains the target images. You can also specify the maximum number of rows to return in the result table. If you do not specify a maximum number of results, the UDF will return a row for each cataloged image in the target table column.
In the following query, the QbScoreTBFromStr UDF is used to find the ten cataloged images in a table column whose texture is closest to that of an image in a server file.
SELECT name, description FROM fabric WHERE CAST (swatch_img as varchar(250))IN SELECT CAST (image_id as varchar(25)) FROM TABLE (QbScoreTBFromStr (QbTextureFeatureClass file=<server,"patterns/ptrn07.gif">' /*query string */ 'fabric', /* table */ 'swatch_img', /* table column */ 10)) /* maximum number of results */ AS T1));