You can use a query string to identify the features, feature values, and feature weights for your query. A query string is a character string that has the form feature_name value, where feature_name is a QBIC feature name, and value is a value associated with the feature.
You can specify multiple features in a query. You then specify a feature name-value pair for each feature, as described in Feature value. Each pair is separated by the clause AND. When you specify multiple features in a query, you can also assign a weight to one or more of the features, as described in Feature weight. The query string then has the form feature_name value weight, where weight is the weight assigned to the feature.
The Image Extender provides an API (QbQueryStringSearch) and two UDFs (QbScoreFromStr and QbScoreTBFromStr) that use a query string. When you issue a query, you use the appropriate API or UDF and specify the query string as an input parameter. (See Issuing queries by image content for details.)
Specify a feature value in the query string for each feature in the query.
When passing a query inside a DB2 command, certain file-naming conventions must be followed for the query to function properly. You must enclose file names that contain spaces or closing angle brackets (>) in double quotation marks; other file names can optionally be enclosed in double quotation marks. If you use quotations marks surrounding a file name, each quotation mark must be preceded by an escape character (\). If the query is not passed within a DB2 command, then there is no need to include escape characters with the quotation marks.
In the following example, a query string is passed within a DB2 command:
db2 "select image_id from table (mmdbsys.QbScoreTBFromStr ('texture file=<server,patterns/ptrn07.gif>', 'fabric', 'swatch_img', 10)) as T1"
The following table lists the values that you can specify for each
feature. Directly below each feature name is a short version that can
be used instead.
Table 8. Feature values that can be specified in query string
Feature name | Value |
---|---|
averageColor, average, or QbColorFeatureClass | color=<Rvalue, Gvalue, Bvalue>
Each color value is an integer from 0 to 255 that identifies the red value (Rvalue), green value (Gvalue), and blue value (Bvalue) of the image. file=<file_location, filename> The file_location is server for a server file. The filename is the complete file path specified in the format appropriate for the system in which the file resides, or a relative file name. DB2 extenders resolves the relative file name using environment variables (see How environment variables are used to resolve file names). |
histogram, histogramcolor, or QbColorHistogramFeatureClass | histogram=<(hist_value, Rvalue, Gvalue,
Bvalue>), ...
Each histogram color value is specified in a clause that identifies the percent (1 to 100) of that color in the histogram (hist_value), and the red value (Rvalue), green value (Gvalue), and blue value (Bvalue) of that color. file=<file_location, filename> The file_location is server for a server file. The filename is the complete file path specified in the format appropriate for the system in which the file resides, or a relative file name. DB2 extenders resolves the relative file name using environment variables. |
draw, positional, or QbDrawFeatureClass | file=<file_location, filename>
handle=<image_handle> The file_location is server for a server file. The filename is the complete file path specified in the format appropriate for the system in which the file resides, or a relative file name. DB2 extenders resolves the relative file name using environment variables. |
texture or QbTextureFeatureClass | file=<file_location, filename>
handle=<image_handle> The file_location is server for a server file. The filename is the complete file path specified in the format appropriate for the system in which the file resides, or a relative file name. DB2 extenders resolves the relative file name using environment variables. |
If you specify multiple features in a query string, you can also specify a weight for one or more of the features. The weight of a feature indicates the emphasis that the Image Extender places on the feature when it computes similarity scores and returns results for a query by image content. The higher the weight you specify for a feature, the greater the emphasis on that feature in the query. The weight is a real number greater than 0.0, for example, 2.5 or 10.0. If you do not assign a weight in a query string, the Image Extender will use the default weight for the feature. Assigning a weight has no meaning if that feature is the only feature that is specified in a query string. (That feature will always have full weight in the query.)
The weight for a feature is relative to other features that are specified in the query. For example, suppose you specify the average color and texture features in a query string, and also specify a weight value of 2.0 for average color. This tells the Image Extender to give the average color value twice the emphasis as the texture value.
The following query string specifies an average color of red:
averageColor color=<255, 0, 0>
The following query string specifies a histogram comprised of 10% red, 50% green, and 40% blue:
histogram histogram=<(10, 255, 0, 0), (50, 0, 255, 0), (40, 0, 0, 255)>
The following query string specifies an average color value and a texture value. The texture value is provided by an image in a server file. The weight of the texture is twice that of the average color:
averageColor color=<30, 200, 25> and texture file=<server, "\patterns\pattern7.gif"> weight=2.0