Aggregate a list of numbers using the specified method.
Aggregators:
NAME DESCRIPTION l_1 return the average l_2 average the squares and return the square root l_4 average the quads and return the fourth root l_inf return the maximum
Run exquires-aggregate.
Bases: object
This class provide various ways of aggregating error data.
Parameters: | values (list of numbers) – numbers to aggregate |
---|
Average the squares and return the square root.
Returns: | the square root of the average of the squares |
---|---|
Return type: | float |
Print the result of calling a difference metric on two image files.
Difference Metrics:
NAME DESCRIPTION srgb_1 norm in sRGB colour space
srgb_2 norm in sRGB colour space
srgb_4 norm in sRGB colour space
srgb_inf norm in sRGB colour space
cmc_1 norm using the CMC(1:1) colour difference
cmc_2 norm using the CMC(1:1) colour difference
cmc_4 norm using the CMC(1:1) colour difference
cmc_inf norm using the CMC(1:1) colour difference
xyz_1 norm in XYZ colour space
xyz_2 norm in XYZ colour space
xyz_4 norm in XYZ colour space
xyz_inf norm in XYZ colour space
blur_1 MSSIM-inspired norm
blur_2 MSSIM-inspired norm
blur_4 MSSIM-inspired norm
blur_inf MSSIM-inspired norm
mssim Mean Structural Similarity Index (MSSIM)
Private method to return a Gaussian blur mask.
Note
This is a private function called by blur_1(), blur_2(), blur_4(), blur_inf(), and mssim().
Run exquires-compare.
Bases: object
This class contains error metrics to be used on sRGB images.
The ,
,
, and
metrics are normalized by L, the largest possible pixel value of the input
images (the lowest is assumed to be 0). The range of output for these
metrics is [0, 100].
The MSSIM metric produces output in the range [-1, 1], but it is unlikely that a negative value will be produced, as the image features must differ greatly. For instance, a pure white image compared with a pure black image produces a result slightly greater than 0.
The CMC and XYZ errors can be slightly outside the range [0, 100], but this will not occur for most image pairs.
Note
By default, a Metrics object is configured to operate on 16-bit images.
Parameters: |
|
---|
Compute MSSIM-inspired error.
This method performs the same greyscale conversion, Gaussian blur, and
cropping as MSSIM, but returns the error of the cropped
image.
See (2) for details on how the blurred images are compared.
Note
The images are converted to grayscale before applying Gaussian blur. The grayscale conversion is equivalent to taking the Y channel in YIQ colour space.
Returns: | MSSIM-inspired ![]() |
---|---|
Return type: | float |
Compute MSSIM-inspired error.
This method performs the same greyscale conversion, Gaussian blur, and
cropping as MSSIM, but returns the error of the cropped
image.
See (3) for details on how the blurred images are compared.
Note
The images are converted to grayscale before applying Gaussian blur. The grayscale conversion is equivalent to taking the Y channel in YIQ colour space.
Returns: | MSSIM-inspired ![]() |
---|---|
Return type: | float |
Compute MSSIM-inspired error.
This method performs the same greyscale conversion, Gaussian blur, and
cropping as MSSIM, but returns the error of the cropped
image.
See (4) for details on how the blurred images are compared.
Note
The images are converted to grayscale before applying Gaussian blur. The grayscale conversion is equivalent to taking the Y channel in YIQ colour space.
Returns: | MSSIM-inspired ![]() |
---|---|
Return type: | float |
Compute MSSIM-inspired error.
This method performs the same greyscale conversion, Gaussian blur, and
cropping as MSSIM, but returns the error of the
cropped image.
See (5) for details on how the blurred images are compared.
Note
The images are converted to grayscale before applying Gaussian blur. The grayscale conversion is equivalent to taking the Y channel in YIQ colour space.
Returns: | MSSIM-inspired ![]() |
---|---|
Return type: | float |
Compute error in Uniform Colour Space (UCS).
This method imports the images into Lab colour space, then calculates delta-E CMC(1:1) and returns the average.
See (2) for details on how the standard norm is
computed.
Returns: | ![]() |
---|---|
Return type: | float |
Compute error in Uniform Colour Space (UCS).
This method imports the images into Lab colour space, then calculates
delta-E CMC(1:1) and returns the norm.
See (3) for details on how the standard norm is
computed.
Returns: | ![]() |
---|---|
Return type: | float |
Compute error in Uniform Colour Space (UCS).
This method imports the images into Lab colour space, then calculates
delta-E CMC(1:1) and returns the norm.
See (4) for details on how the standard norm is
computed.
Returns: | ![]() |
---|---|
Return type: | float |
Compute error in Uniform Colour Space (UCS).
This method imports the images into Lab colour space, then calculates
delta-E CMC(1:1) and returns the norm.
See (5) for details on how the standard
norm is computed.
Returns: | ![]() |
---|---|
Return type: | float |
Compute the Mean Structural Similarity Index (MSSIM).
The equation for SSIM is
(1)
where and
are the sample means,
and
are the standard deviations, and
is the correlation coefficient between images
and
.
Once the SSIM map is computed, the border is trimmed by 5 pixels and the mean is returned.
This version is slightly more efficient than the method proposed by Wang et. al. because it reduces the number of Gaussian blurs from 5 to 4.
Note
The images are converted to grayscale before applying Gaussian blur. The grayscale conversion is equivalent to taking the Y channel in YIQ colour space.
Returns: | mean SSIM |
---|---|
Return type: | float |
Compute error in sRGB colour space.
The equation for the error, aka Average Absolute Error
(AAE), is
(2)
where and
are the images to compare, each
consisting of
pixels.
Returns: | ![]() |
---|---|
Return type: | float |
Compute error in sRGB colour space.
The equation for the error, aka Root Mean Squared Error
(RMSE), is
(3)
where and
are the images to compare, each
consisting of
pixels.
Returns: | ![]() |
---|---|
Return type: | float |
Compute error in sRGB colour space.
The equation for the error is
(4)
where and
are the images to compare, each
consisting of
pixels.
Returns: | ![]() |
---|---|
Return type: | float |
Compute error in sRGB colour space.
The equation for the error, aka Maximum Absolute
Error (MAE), is
(5)
where and
are the images to compare, each
consisting of
pixels.
Returns: | ![]() |
---|---|
Return type: | float |
Compute error in XYZ Colour Space.
This method imports the images into XYZ colour space, then calculates
the error.
See (2) for details on how the standard norm is
computed.
Returns: | ![]() |
---|---|
Return type: | float |
Compute error in XYZ Colour Space.
This method imports the images into XYZ colour space, then calculates
the error.
See (3) for details on how the standard norm is
computed.
Returns: | ![]() |
---|---|
Return type: | float |
Produce a Spearman’s rank cross-correlation matrix for the specified group.
By default, the -M/--metric option is selected. You can select one of the following cross-correlation groups:
- -I/--image
- -D/--down
- -R/--ratio
- -M/--metric
You can also select which upsamplers to consider when computing the matrix by using the -U/--up option.
Return the correlation group and ranks.
Note
This is a private function called by _print_matrix().
Parameters: |
|
---|---|
Returns: | the group and ranks |
Return type: | string, list of lists |
Print a cross-correlation matrix from aggregate image comparison data.
Note
This is a private function called by main().
Parameters: |
|
---|
Run exquires-correlate.
Parse the command-line arguments and print the cross-correlation matrix.
Provides an interface to the sqlite3 image error database.
This class provides an interface to the sqlite3 image error database.
The database stores error data computed by exquires-run and exquires-update. This data is retrieved and used to compute the output given by exquires-report and exquires-correlate.
Parameters: | dbasefile (path) – database file to connect to |
---|
Private method used to create a new database table.
Note
This is a private method called by add_table() and backup_table().
Parameters: |
|
---|
Add a new table to the database.
To keep track of each table in terms of the image, downsampler, and ratio that defines it, an entry is created in the TABLEDATA table.
Parameters: |
|
---|---|
Returns: | the table name |
Return type: | string |
Backup an existing image error table.
Parameters: |
|
---|---|
Returns: | name of the backup table |
Return type: | string |
Delete a row from the table.
Parameters: |
|
---|
Drop a backup table once it is no longer needed.
Parameters: | name (string) – name of the backup table to drop |
---|
Drop database tables.
All tables defined by any of the images, downsamplers, or ratios are dropped. The TABLEDATA table is updated to reflect these changes.
Parameters: |
|
---|
Return a filtered row of error data.
For the upsampler row in the table, return a dictionary containing only the error data for the specified metrics.
Parameters: |
|
---|---|
Returns: | the filtered row of error data |
Return type: | dict |
Return table names for these images, downsamplers, and ratios.
Parameters: |
|
---|---|
Returns: | names of the tables |
Return type: | list of strings |
Insert a single row into the table, or update if it exists.
Parameters: |
|
---|
Generate a new project file to use with exquires-run.
The project file is used to specify the following components of the suite:
- Images ( sRGB TIFF | 16 bits/sample (48/pixel) | 840x840 pixels )
- Downsamplers
- Resampling Ratios
- Upsamplers
- Difference Metrics
For the specified project name and list of images, a default project file will be created with the name PROJECT.ini, where PROJECT is a name specified using the -p:option:–proj option. If a name is not specified, the default name is project1.
Use the -I:option:–image option to provide a list of images to include in the project file. If no images are specified, a default image (wave.tif) is included in the project file.
Manually edit this file to customize your project.
Add the default downsamplers to the specified .ini file.
Note
This is a private function called by main().
Parameters: | ini (configobj.ConfigObj) – the .ini file to modify |
---|
Add the default images to the specified .ini file.
Note
This is a private function called by main().
Parameters: | ini (configobj.ConfigObj) – the .ini file to modify |
---|
Add the default metrics to the specified .ini file.
Note
This is a private function called by main().
Parameters: | ini (configobj.ConfigObj) – the .ini file to modify |
---|
Add the default ratios to the specified .ini file.
Note
This is a private function called by main().
Parameters: | ini (configobj.ConfigObj) – the .ini file to modify |
---|
Add the default upsamplers to the specified .ini file.
Note
This is a private function called by main().
Parameters: | ini (configobj.ConfigObj) – the .ini file to modify |
---|
Return an ImageMagick resize command as a string.
Blur and Kaiser beta values are passed as strings to avoid truncation.
Note
This is a private function called by _add_default_downsamplers(), _std_int_lin_tensor_mtds_1(), _std_int_lin_tensor_mtds_2(), _novel_int_lin_flt_mtds(), _std_nonint_lin_tensor_mtds(), _std_int_ewa_lin_flt_mtds(), _std_nonint_ewa_lin_flt_mtds(), and _novel_nonint_ewa_lin_flt_mtds().
Parameters: |
|
---|---|
Returns: | the ImageMagick command |
Return type: | string |
Return 3-element list defining a metric, an aggregator and a sort order.
Note
This is a private function called by _add_default_metrics().
Parameters: |
|
---|---|
Returns: | metric, aggregator, and sort order |
Return type: | list |
Add the novel interpolatory linear filtering methods.
Note
This is a private function called by _add_default_upsamplers().
Parameters: | ini_ups (dict) – upsamplers for the specified .ini file |
---|
Add the novel non-interpolatory EWA linear filtering methods.
Note
This is a private function called by _add_default_upsamplers().
Parameters: | ini_ups (dict) – upsamplers for the specified .ini file |
---|
Add the standard interpolatory EWA linear filtering methods.
Note
This is a private function called by _add_default_upsamplers().
Parameters: | ini_ups (dict) – upsamplers for the specified .ini file |
---|
Add the 1st part of the standard interpolatory linear tensor methods.
Note
This is a private function called by _add_default_upsamplers().
Parameters: | ini_ups (dict) – upsamplers for the specified .ini file |
---|
Add the 2nd part of the standard interpolatory linear tensor methods.
Note
This is a private function called by _add_default_upsamplers().
Parameters: | ini_ups (dict) – upsamplers for the specified .ini file |
---|
Add the standard non-interpolatory EWA linear filtering methods.
Note
This is a private function called by _add_default_upsamplers().
Parameters: | ini_ups (dict) – upsamplers for the specified .ini file |
---|
Add the standard non-interpolatory linear tensor methods.
Note
This is a private function called by _add_default_upsamplers().
Parameters: | ini_ups (dict) – upsamplers for the specified .ini file |
---|
Run exquires-new.
Create a project file to use with exquires-run and exquires-update.
A collection of classes used to compute image difference data.
The hierarchy of classes is as follows:
- Operations encapsulate a list of Images
- Images encapsulate a dict of images and a list of Downsamplers
- Downsamplers encapsulate a dict of downsamplers and a list of Ratios
- Ratios encapsulate a dict of ratios and a list Images
- Images encapsulate a dict of images and a dict of metrics
These classes work together to downsample the master images, upsample the downsampled images, and compare the upsampled images to the master images. To perform the operations, call Operations.compute().
Bases: object
A collection of Image objects to compute data with.
This class is responsible for calling all operations defined in the specified project file when using exquires-run or exquires-update.
Parameters: | images (list of Images) – images to downsample |
---|
Perform all operations.
Parameters: |
|
---|
Bases: object
This class calls operations for a particular set of images.
Parameters: |
|
---|
Perform all operations for this set of images.
Parameters: |
|
---|
Bases: object
This class calls operations for a particular set of downsamplers.
Parameters: |
|
---|
Perform all operations for this set of downsamplers.
Parameters: |
|
---|
Bases: object
This class calls operations for a particular set of ratios.
Parameters: |
|
---|
Perform all operations for this set of ratios.
Parameters: |
|
---|
Bases: object
This class upsamples an image and compares with its master image.
Parameters: |
|
---|
Perform all operations for this set of ratios.
Parameters: |
|
---|
Classes and methods used for parsing arguments and formatting help text.
Parse the module docstring and re-format all reST markup.
Note
This is a private function called when creating a new ExquiresParser object.
Parameters: | docstring (string) – docstring to format |
---|---|
Returns: | formatted docstring |
Return type: | string |
Remove duplicate entries from a list.
Note
This is a private function called by ListAction.__call__() and RatioAction.__call__().
Parameters: | input_list (list of values) – list to remove duplicate entries from |
---|---|
Returns: | list with duplicate entries removed |
Return type: | list of values |
Bases: parsing.ExquiresParser
Parser used by exquires-run and exquires-update.
Parameters: |
|
---|
Parse the received arguments.
This method parses the arguments received by exquires-run or :ref`exquires-update`.
Parameters: |
|
---|---|
Returns: | the parsed arguments |
Return type: | argparse.Namespace |
Bases: parsing.ExquiresParser
Parser used by exquires-report and exquires-correlate.
Parameters: |
|
---|
Parse the received arguments.
This method parses the arguments received by exquires-report or exquires-correlate.
Parameters: |
|
---|---|
Returns: | the parsed arguments |
Return type: | argparse.Namespace |
Bases: argparse.RawDescriptionHelpFormatter
Formatter for generating usage messages and argument help strings.
This class is designed to display options in a cleaner format than the standard argparse help strings.
Bases: argparse.Action
Parser action to read a project file based on the specified name.
Parse the -p/--project option.
Parameters: |
|
---|---|
Raises : | argparse.ArgumentError |
Bases: argparse.Action
Parser action to handle wildcards for options that support them.
When specifying aggregation options with exquires-report, this class expands any wildcards passed in arguments for the following options:
Parse any option that supports lists with wildcard characters.
Parameters: |
|
---|---|
Raises : | argparse.ArgumentError |
Bases: argparse.Action
Parser action to deal with ratio ranges.
Parse the -r/--ratio option.
Parameters: |
|
---|---|
Raises : | argparse.ArgumentError |
Bases: argparse.Action
Parser action to sort the correlation matrix.
Parse the -a/--anchor option.
Parameters: |
|
---|---|
Raises : | argparse.ArgumentError |
Bases: argparse.Action
Parser action to sort the data by the appropriate metric.
Parse the -s/--sort option.
Parameters: |
|
---|---|
Raises : | argparse.ArgumentError |
Display progress info for exquires-run and exquires-update.
When the -s/--silent option is not selected in exquires-run or exquires-update, the Progress class is used to display the appropriate information.
Bases: object
This class contains methods for displaying progress in exquires.
When exquires-run and exquires-update are used without silent mode enabled, this class is responsible for displaying information about the downsampling, upsampling, and comparison steps and the total progress.
Parameters: |
|
---|
Draw the bottom row of the progress table.
This method draws one of the middle rows of the progress table. Two lines are used to draw this section of the table.
Note
This is a private method called by cleanup(), complete(), and do_op().
Warning
To display the updated progress table, the screen must be refreshed by calling self.scr.refresh().
Parameters: |
|
---|
Draw one of the middle rows of the progress table.
This method draws one of the middle rows of the progress table. Two lines are used to draw this section of the table.
Note
This is a private method called by cleanup(), complete(), and do_op().
Warning
To display the updated progress table, the screen must be refreshed by calling self.scr.refresh().
Parameters: |
|
---|
Draw the top row of the progress table.
This method draws the first row of the progress table, which displays the project name. Three lines are used to draw this section of the table.
Note
This is a private method called by cleanup(), complete(), and do_op().
Warning
To display the updated progress table, the screen must be refreshed by calling self.scr.refresh().
Parameters: |
|
---|
Complete the progress indicator.
Call this method to indicate success once all operations have been performed.
Note
The completion screen is displayed for a half second.
Warning
To restore the terminal after completion, destruct the Progress object by calling del prg (where prg is the object to destruct).
Update the progress indicator.
Parameters: |
|
---|
Print a formatted table of aggregate image difference data.
Each database table in the current project contains data for a single image, downsampler, and ratio. Each row represents an upsampler and each column represents a difference metric. By default, the data across all rows and columns of all tables is aggregated. Use the appropriate option flags to aggregate across a subset of the database.
Features:
- -R/:option`–ratio` supports hyphenated ranges (for example, ‘1-3 5’ gives ‘1 2 3 5’)
- -U/--up, -I/--image, -D/--down and -M/--metric support wildcard characters
Print a table of aggregate image comparison data.
Since the database contains error data for several images, downsamplers, ratios, upsamplers, and metrics, it is convenient to be able to specify which of these to consider. This method aggregates the data for each relevant column in the appropriate tables.
Note
This is a private function called by main().
Parameters: |
|
---|
Run exquires-report.
Parse the command-line arguments and print the aggregate data table.
Compute error data for the entries in the specified project file.
The project file is read to determine which images, downsamplers, ratios, upsamplers, and metrics to use. If a database file already exists for this project, it will be backed up and a new one will be created.
Each image will be downsampled by each of the ratios using each of the downsamplers. The downsampled images will then be upsampled back to their original size (840x840) using each of the upsamplers. The upsampled images will be compared to the original images using each of the metrics and the results will be stored in the database file.
If you make changes to the project file and wish to only compute data for these changes rather than recomputing everything, use exquires-update.
To view aggregated error data, use exquires-report.
Create a new project database and populate it with computed data.
Note
This is a private function called by main().
Parameters: |
|
---|
Run exquires-run.
Create a database for the specified project file.
Warning
If a database already exists for this project, it will be overwritten.
A collection of methods for producing statistical output.
Return a formatted version of this cell of the data table.
Note
This is a private function called by print_normal() and print_latex().
Parameters: |
|
---|---|
Returns: | the formatted cell |
Return type: | string |
Return a table of aggregate image difference data.
Parameters: |
|
---|---|
Returns: | table of aggregate image difference data |
Return type: | list of lists |
Return a table of merged Spearman ranks based on a data table.
Parameters: |
|
---|---|
Returns: | table of merged ranks |
Return type: | list of lists |
Return a table of Spearman (Fractional) ranks based on a data table.
Parameters: |
|
---|---|
Returns: | table of ranks |
Return type: | list of lists |
Print the processed data table with LaTeX formatting.
Parameters: |
|
---|
Print the processed data table with normal formatting.
Parameters: |
|
---|
A collection of convenience methods.
Create a directory if it doesn’t already exist and return it.
Parameters: |
|
---|---|
Returns: | the created directory |
Return type: | path |
Compute new error data for changes to the user-specified project file.
The project file is inspected to determine which changes have been made. Items that have been removed will result in entries being removed from the database. Items that have been changed or added will result in new data being computed and added to the database file. If no changes have been made to the project file, the database will not be updated.
If you wish to recompute all data based on your project file rather than simply updating it with the changes, use exquires-run.
To view aggregated error data, use exquires-report.
Return all necessary configuration namespaces.
This function returns four namespaces that specify which images, downsamplers, ratios, upsamplers, and metrics to use when creating or updating a project database:
Note
This is a private function called by _update().
Parameters: |
|
---|---|
Returns: | the current, new, old, and same namespaces |
Return type: | argparse.Namespace |
Subtract dictionary dict2 from dict1 and return the difference.
This function creates a new dict, then iterates over dict1 and adds all entries that are not found in dict2.
Note
This is a private function called by _get_namespaces().
Parameters: |
|
---|---|
Returns: | dict1 - dict2 |
Return type: | dict |
Update the database.
Note
This is a private function called by main().
Parameters: |
|
---|
Run exquires-update.
Update the project database based on changes to the project file.
Note
If the update fails, the previous database will be restored.