Auto Filter Expert setting do not match Keys Filter

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Carlos82

Auto Filter Expert setting do not match Keys Filter

Post by Carlos82 »

Setting C = 0.5 results in B = 0.25, when it should be 0.0 as the Catrom filter.

So:
convert rings_lg_orig.png -filter Cubic -set option:filter:c 0.5 -resize 600x rings_lg_orig_im_cubic_c05.png

gives the same result as:
convert rings_lg_orig.png -filter Cubic -set option:filter:b 0.25 -set option:filter:c 0.5 -resize 600x rings_lg_orig_im_cubic_b025_c05.png

As reported by compare.exe.

Regards.
Last edited by Carlos82 on 2009-06-22T02:47:38-07:00, edited 1 time in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Auto Filter Expert setting do not match Keys Filter

Post by anthony »

Could your IM be older than version 6.3.7-1 whcih was when I did ten re-programming o fthe filters with the addition of the Expert Controls.

If it is older than the settings would not work and all you would get is the default cubic filter which uses the values B=0 C=1

As such on an IM that is too old you would get the same result.


I checked the source code, and added a debugging print to the handling of B and C
-set option:filter:b 0.0 -set option:filter:c 0.746
sets B=0.000000 C=0.746000

-set option:filter:b 0.25 -set option:filter:c 0.5
sets B=0.250000 C=0.500000

A flicker comparison using
http://www.imagemagick.org/Usage/scripts/flicker_cmp
of the two images rings_lg_orig_im_cubic_c05.png and rings_lg_orig_im_cubic_b025_c05.png
shows a definite difference in results with a less blurred (more aliased) result for the first image (b=0).

Code: Select all

compare -metric PAE rings_lg_orig_im_cubic_b025_c05.png \
         rings_lg_orig_im_cubic_c05.png null:
6425 (0.0980392)
A peak difference of about 10% so I would definably not say they were the same.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Carlos82

Re: Auto Filter Expert setting do not match Keys Filter

Post by Carlos82 »

Sorry the first command was wrong, I have edited the first post to fix it.

The version is 6.5.3-0 as reported by convert -version.
Carlos82

Re: Auto Filter Expert setting do not match Keys Filter

Post by Carlos82 »

Do you get the same result now?

Regards.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Auto Filter Expert setting do not match Keys Filter

Post by anthony »

Hmm yes they appear the same now... Checking with a debug statement...
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Auto Filter Expert setting do not match Keys Filter

Post by anthony »

Hmmm...

Code: Select all

convert rings_lg_orig.png -filter Cubic -set option:filter:c 0.5 -resize 600x rings_lg_orig_im_cubic_c05.png
when C=0.5 but B is undefined , so IM set B to 0.25

that is definitely not correct... For a Keys filter B should be set to 0 to
create a Catmull-Rom Filter (equivelent to -filter catrom)

The opposite also does not seem to be right.. B=0.25 causes C to be 0.5

I think my formula is wrong...

Hmm going back to basics, a Keys filter is when... 2*C + B = 1
So B = 1-2*C or C = (1-B)/2
yes that checks out

Hmmm In my code I have
C=1.0-2.0*B and B=(1.0-C)/2.0
Damn I had the right formulas but with B and C swapped!! Fixing.

thank you for the pickup. This has been fixed, and will be release in IM v6.5.4-1

I will also note that automatic selection of the keys filter was broken in IM examples up until that version.

Thank you for the bug report.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply