Operation compare-image
The compare-image operation allows for the comparison of differences between two provided images.
Available Options
Option Name | Type | Possible Values | Description |
---|---|---|---|
method | string | AE, MAE, NCC, PSNR, RMSE | The algorithm to use for image comparison. |
diff_color | string | red, green, blue, yellow, orange, violet, black, white | The color to use to show the pixels that are different in the diff image. |
threshold | integer | 0-100 | Sets the threshold in percentage above which color is to be considered different between the two images. A zero means that the pixels must be identical to be considered equal. |
allow_multiple_outputs | boolean | true, false | If the comparison produces more than one output file, by default all of them are compressed in just one file. Set this option to true if you want a download link for each file. |
Options Details
Value | Description |
---|---|
AE | The Absolute Error (AE) algorithm measures the absolute differences between the pixel values of the two images being compared. |
MAE | The Mean Absolute Error (MAE) algorithm calculates the average absolute differences between the pixel values of the two images being compared. |
NCC | The Normalized Cross-Correlation (NCC) algorithm measures the similarity between the two images by comparing the correlation of the pixel values. |
PSNR | The Peak Signal-to-Noise Ratio (PSNR) algorithm calculates the ratio between the maximum possible pixel value of the image and the difference between the two images being compared. |
RMSE | The Root Mean Squared Error (RMSE) algorithm calculates the square root of the average of the squared differences between the pixel values of the two images being compared. |
Example
{ "conversion": [{ "category": "operation", "target": "compare-image", "options": { "method": "mae", "diff_color": "orange", "threshold": "25", "allow_multiple_outputs": true } }] }
Output Details
The output of this image comparison operation may include two files:
- A binary image file containing the difference between the two input images, highlighted in the color specified by the diff_color option.
- A JSON object with the following structure:
{ "method": "Mean Absolute Error", "fe194466-3df5-4baf-8138-511d874e583e": { "red": "1911.56 (0.0291685)", "green": "1813.52 (0.0276726)", "blue": "2007.71 (0.0306357)", "all": "1910.93 (0.029159)" } }
The JSON output provided in this example is a representation of the results of an image comparison operation and can be used to determine the degree of similarity or difference between the two input images.
It allows to have a per channel comparison and have a relative idea of the difference between the images.
It includes information about the comparison method used and the resulting color values and, since the method used in the call was mae, their Mean Absolute Error values.
The top-level key "method" is a string representing the method used for the comparison. In this example, it is set to "Mean Absolute Error".
The next key is an identifier, "fe194466-3df5-4baf-8138-511d874e583e", that it is associated with the comparison result containing the color channels: red, green, blue, and all.
Each color channel is associated with a string that contains two parts: the first is the Mean Absolute Error value, and the second (the value in parenthesis) represents the relative error as a ratio (range between 0 and 1) and this can be useful to understand how much different the two images are.
For example, the value "1911.56 (0.0291685)" for the "red" color channel means that the Mean Absolute Error for the red channel is 1911.56 and the relative error is 0.0291685.