Enhancement Suggestion
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Enhancement Suggestion
If this is not a large effort, then perhaps compare might be enhanced to permit other operations within parenthesis processing, such as:
-resize
-rotate
-trim
-crop
-distort SRT
-brightness-contrast
-level
-sigmoidal-contrast
This would allow modification of the reference image in-line (without having to process externally and save to file) the image so that one may be able to loop over compare more efficiently to test different rotations and/or sizes (and possibly adjust the brightness/contrast).
Alternately, perhaps enhance
convert .... -compare -format "%[distortion] info:
to allow subimage-search and to report the coordinates of the best match.
-resize
-rotate
-trim
-crop
-distort SRT
-brightness-contrast
-level
-sigmoidal-contrast
This would allow modification of the reference image in-line (without having to process externally and save to file) the image so that one may be able to loop over compare more efficiently to test different rotations and/or sizes (and possibly adjust the brightness/contrast).
Alternately, perhaps enhance
convert .... -compare -format "%[distortion] info:
to allow subimage-search and to report the coordinates of the best match.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Enhancement Suggestion
This would be useful. My preference would be to allow "-subimage-search", "‑dissimilarity‑threshold" and "‑similarity‑threshold" within both "convert" and "magick", with reporting of the found coordinates.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Enhancement Suggestion
If the developers want to rewrite compare or convert ... -compare, a large degree of speedup can be achieved using summed area tables. See
https://en.wikipedia.org/wiki/Summed_area_table
https://classes.soe.ucsc.edu/cmps160/Fa ... 7-crow.pdf
https://computersciencesource.wordpress ... ral-image/
P.S. Here are fast histograms and median filtering using summed area tables. See
https://nomis80.org/ctmf.pdf
http://www.merl.com/publications/docs/TR2005-057.pdf
https://en.wikipedia.org/wiki/Summed_area_table
https://classes.soe.ucsc.edu/cmps160/Fa ... 7-crow.pdf
https://computersciencesource.wordpress ... ral-image/
P.S. Here are fast histograms and median filtering using summed area tables. See
https://nomis80.org/ctmf.pdf
http://www.merl.com/publications/docs/TR2005-057.pdf
Re: Enhancement Suggestion
We'll add the operators you suggested to the 'compare' command-line utility in the next point release of ImageMagick.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Enhancement Suggestion
Thanks. Would you add the following also, so that the background can be set during rotation and the texture under transparency can be set to a constant color and a mask extracted from the transparent reference
-background
-virtual-pixel
-alpha (background, extract, off)
-background
-virtual-pixel
-alpha (background, extract, off)
Re: Enhancement Suggestion
We added support for -background. The other two options are already supported.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Enhancement Suggestion
I tried this command in the latest beta:
but it errors with regard to +repage. Would you add repage, please.
(Images from viewtopic.php?f=1&t=31928&start=15#p146149)
Code: Select all
im6beta compare -metric rmse -subimage-search -dissimilarity-threshold 1 \
\( 370669patch.png +repage -background black -alpha background \) \
\( 224977object4.png +repage -background black -alpha background -rotate 180 -trim +repage \) \
diff.png
(Images from viewtopic.php?f=1&t=31928&start=15#p146149)
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Enhancement Suggestion
Thanks. This command works now in the latest IM 6.9.8.6 beta as of today.
4808.31 (0.0733701) @ 269,40
Code: Select all
compare -metric rmse -subimage-search -dissimilarity-threshold 1 \
\( 370669patch.png +repage -background black -alpha background \) \
\( 224977object4.png +repage -background black -alpha background -rotate 180 -trim +repage \) \
diff.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Enhancement Suggestion
Sorry, one more request. Would you add +-write and +-delete so that I can save to mpr: format, such as in the following for IM 7 with masking:
magick compare -metric rmse -subimage-search -dissimilarity-threshold 1 \
\( 370669patch.png +repage -background black -alpha background \) \
\( 224977object4.png +repage -background black -alpha background -write mpr:ref +delete \
mpr:ref -alpha extract -write mpr:mask +delete \) \
\( -read-mask mpr:mask mpr:ref \) diff.png
compare: unrecognized option `-write' @ error/compare.c/CompareImagesCommand/1079.
Or if this extra parens to create the mpr: images in the above is not possible, then would you allow parenthesis processing for the mask image and reference image separately, so that I can do
im7beta magick compare -metric rmse -subimage-search -dissimilarity-threshold 1 \
\( 370669patch.png +repage -background black -alpha background \) \
\( -read-mask \
\( 224977object4.png +repage -background black -alpha background -alpha extract \) \
\( 224977object4.png +repage -background black -alpha background \) \
\) diff.png
compare: unable to open image '(': No such file or directory @ error/blob.c/OpenBlob/3094.
compare: no decode delegate for this image format `' @ error/constitute.c/ReadImage/509.
magick compare -metric rmse -subimage-search -dissimilarity-threshold 1 \
\( 370669patch.png +repage -background black -alpha background \) \
\( 224977object4.png +repage -background black -alpha background -write mpr:ref +delete \
mpr:ref -alpha extract -write mpr:mask +delete \) \
\( -read-mask mpr:mask mpr:ref \) diff.png
compare: unrecognized option `-write' @ error/compare.c/CompareImagesCommand/1079.
Or if this extra parens to create the mpr: images in the above is not possible, then would you allow parenthesis processing for the mask image and reference image separately, so that I can do
im7beta magick compare -metric rmse -subimage-search -dissimilarity-threshold 1 \
\( 370669patch.png +repage -background black -alpha background \) \
\( -read-mask \
\( 224977object4.png +repage -background black -alpha background -alpha extract \) \
\( 224977object4.png +repage -background black -alpha background \) \
\) diff.png
compare: unable to open image '(': No such file or directory @ error/blob.c/OpenBlob/3094.
compare: no decode delegate for this image format `' @ error/constitute.c/ReadImage/509.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Enhancement Suggestion
The commands below do not seem to work to rotate the small image 180 deg and compare to the larger image in the latest IM release 7.0.5.7.
Inputs:
This command errors:
compare: unable to open image '(': No such file or directory @ error/blob.c/OpenBlob/3094.
compare: no decode delegate for this image format `' @ error/constitute.c/ReadImage/509.
This command finishes but is not the proper match:
It should produce something similar to the IM 6.9.8.6 command that does not use a mask and achieves a perfect match as follows:
0 (0) @ 353,6
Was the last set of changes folded into this release or the upcoming Beta? Or am I not doing something correctly?
Inputs:
This command errors:
Code: Select all
magick compare -metric rmse -subimage-search -dissimilarity-threshold 1 \
\( 370669patch.png +repage -background black -alpha background \) \
\( -read-mask \
\( 224977object4.png +repage -background black -alpha background -alpha extract \) \
\( 224977object4.png +repage -background black -alpha background \) \
\) diff7.png
compare: no decode delegate for this image format `' @ error/constitute.c/ReadImage/509.
This command finishes but is not the proper match:
Code: Select all
magick compare -metric rmse -subimage-search -dissimilarity-threshold 1 \
\( 370669patch.png +repage -background black -alpha background \) \
\( -read-mask 224977object4.png +repage -background black -alpha background -alpha extract \) \
\( 224977object4.png +repage -background black -alpha background \) diff7.png
It should produce something similar to the IM 6.9.8.6 command that does not use a mask and achieves a perfect match as follows:
Code: Select all
convert \
\( 370669patch.png +repage -background black -alpha background \) \
\( 224977object4.png +repage -background black -alpha background \) miff:- |\
compare -metric rmse -subimage-search -dissimilarity-threshold 1 - diff6.png
Was the last set of changes folded into this release or the upcoming Beta? Or am I not doing something correctly?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Enhancement Suggestion
Sorry, the following does work properly in IM 7.0.5.7 with the following command approach and shows a perfect match at the proper location
0 (0) @ 353,6
Thanks. So I can use parenthesis processing with mpr:
Code: Select all
magick compare -metric rmse -subimage-search -dissimilarity-threshold 1 \
\( 224977object4.png +repage -background black -alpha background -write mpr:ref +delete \
mpr:ref -alpha extract -write mpr:mask +delete \) \
\( 370669patch.png +repage -background black -alpha background \) \
\( -read-mask mpr:mask mpr:ref \) -alpha off diff.png
Thanks. So I can use parenthesis processing with mpr: