proper scaling of the Jinc filter for EWA use

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Post Reply
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux »

Also try http://www.imagemagick.org/Usage/images/shape_lines.gif:

Code: Select all

convert shape_lines.gif -define filter:filter=Jinc -define filter:window=Jinc -define filter:blur=0.943159799432847711 -define filter:lobes=4 -distort Resize 1600% JincJinc4blur4overr4.png
convert shape_lines.gif -define filter:filter=Sinc -define filter:window=Sinc -define filter:lobes=4 -resize 1600% oSincSinc4.png
convert shape_lines.gif -define filter:filter=Jinc -define filter:window=Jinc -define filter:blur=0.88451002338585141 -define filter:lobes=4 -distort Resize 1600% JincJinc4blur0p88451002338585141.png
convert shape_lines.gif -define filter:filter=Jinc -define filter:window=Jinc -define filter:blur=.9264075766146 -define filter:lobes=3 -distort Resize 1600% JincJinc3blur3overr3.png
convert shape_lines.gif -define filter:filter=Sinc -define filter:window=Sinc -define filter:lobes=3 -resize 1600% oSincSinc3.png
convert shape_lines.gif -define filter:filter=Jinc -define filter:window=Jinc -define filter:blur=0.88549061701764 -define filter:lobes=3 -distort Resize 1600% JincJinc3blur0p88549061701764.png
For this one, it's no contest: sharpened EWA wins. Although, and this should be no surprise to Imaggie, 3-lobe is best.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux »

@Imaggie: Please feel free to contradict me: I'm trying to make the best design decisions, irregardless of where the "evidence" comes from.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux »

This last test gave me an idea of another thing to optimize by "blur"ing: MInimize the depth of the "light" halo ("bounceback") of Jinc-windowed Jinc 3 and 4 which arises from upsampling a white 1-pixel wide line on a black background. P.S. This is a more complex optimization to perform exactly.

imaggie
Posts: 88
Joined: 2011-12-19T04:15:36-07:00
Authentication code: 8675308

Re: proper scaling of the Jinc filter for EWA use

Post by imaggie »

Image

could I suggest you take a look at this as a test image. While not a block graphic, it does have high contrast edges and sharp diagonals which are useful picking up some defects in various filters.

I just ran the following three rescalings:

Code: Select all

convert cameraman.png -define filter:filter=Sinc -define filter:window=Sinc -define filter:lobes=4\
 -distort Resize 300% ewaSincSinc4.png

convert cameraman.png -define filter:filter=Sinc -define filter:window=Sinc -define filter:lobes=4\
 -resize 300% oSincSinc4.png

convert cameraman.png -define filter:filter=Sinc -define filter:window=Sinc -define filter:lobes=3\  
 -resize 300% oSincSinc3.png
EWA sinc4 loses by a mile. This does not surprise me because sinc is probably not the correct function to use, other than in the orthogonal case.

oSinc3 is marginally better than oSinc4 which tends show slightly more defects : see neck, camera lens, tripod tilt mechanism, ghosting over shoulder.

The differences are subtle but I put oSinc3 ahead of oSinc4 by a nose. This is in agreement with what I found doing Lanczos in gimp.


Similarly doing -distort Resize with jinc3 and jinc4 the ringing is slightly more pronounced on J4.

Code: Select all

convert cameraman.png -define filter:filter=Jinc -define filter:window=Jinc -define filter:lobes=3\
 -distort Resize 300% JincJinc3.png

convert cameraman.png -define filter:filter=Jinc -define filter:window=Jinc -define filter:lobes=4\
 -distort Resize 300% JincJinc4.png
Again, it's marginal but despite a general appearance of being slightly sharper this is due to increased ringing adding contrast to edges (interesting analogy to unsharp mask) . Closer inspection shows more pronounced ghosting on camera lens, back of head and tripod legs and rougher features on face.

This image confirms EWA dealing better with diagonals than orthogonal and this has a positive effect on the image in general , removing some roughness from the features of the subject.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux »

imaggie wrote:...
oSinc3 is marginally better than oSinc4 which tends show slightly more defects : see neck, camera lens, tripod tilt mechanism, ghosting over shoulder.

The differences are subtle but I put oSinc3 ahead of oSinc4 by a nose. This is in agreement with what I found doing Lanczos in gimp.


Similarly doing -distort Resize with jinc3 and jinc4 the ringing is slightly more pronounced on J4.
...
Funny enough, before reading your email, I had figured that 3-lobe is probably better than 4-lobe because when 4-lobe artifacts are noticeable, they are very much so.

I'll run this (famous) test image through the sharpened ones when I have a minute.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux »

The whole enchilada:

Code: Select all

convert cameraman.png -define filter:filter=Jinc -define filter:window=Jinc -define filter:blur=0.943159799432847711 -define filter:lobes=4 -distort Resize 1600% \
JincJinc4blur4overr4.png
convert cameraman.png -define filter:filter=Sinc -define filter:window=Sinc -define filter:lobes=4 -resize 1600% \
oSincSinc4.png
convert cameraman.png -define filter:filter=Jinc -define filter:window=Jinc -define filter:blur=0.88451002338585141 -define filter:lobes=4 -distort Resize 1600% \
JincJinc4blur0p88451002338585141.png
convert cameraman.png -define filter:filter=Jinc -define filter:window=Jinc -define filter:blur=.9264075766146 -define filter:lobes=3 -distort Resize 1600% \
JincJinc3blur3overr3.png
convert cameraman.png -define filter:filter=Sinc -define filter:window=Sinc -define filter:lobes=3 -resize 1600% \
oSincSinc3.png
convert cameraman.png -define filter:filter=Jinc -define filter:window=Jinc -define filter:blur=0.88549061701764 -define filter:lobes=3 -distort Resize 1600% \
JincJinc3blur0p88549061701764.png
Last edited by NicolasRobidoux on 2012-04-30T11:11:30-07:00, edited 2 times in total.

imaggie
Posts: 88
Joined: 2011-12-19T04:15:36-07:00
Authentication code: 8675308

Re: proper scaling of the Jinc filter for EWA use

Post by imaggie »

Well, blur=0.943159799432847711 is a tad sharper with all that that implies. More jaggies on tripod, sharper look overall, slightly more intense look of concentration for the cameraman.

I think the most accurate is a straight jinc3 without the deblur. With blur=0.88549061701764 I see a bit of roughness in the face that seems artificial.

Another test I think is important is a female portrait. These are horrendously intolerant of sharpening that quickly makes a beautiful face look decidedly disease ridden. Subtle flesh tones get spots and the result is not pretty.

I just did a quick check on such an image and straight j3 looks good (without looking for a misty softness, it looks accurate) , however with deblur factor it starts to look unflattering. I don't have a public domain image to post but such an example would be easy to find. ( I'd defavour the equally famous "Lena" since it is too soft to start with ).

I suspect at this level it's a case of horses for courses and that there is not an objective "best" that applies to all types of image.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux »

Imaggie: If I try to boil down your comments and mix with my own preferences, it appears that EWA LanczosSharp (in the current or "improved" version discussed in http://imagemagick.org/discourse-server ... =60#p79475 that would be the "all-purpose winner" over the maximally or "balanced" sharpened ones:

Code: Select all

convert original.* -filter LanczosSharp -distort resize 1600% LanczosSharp.png
(current) or

Code: Select all

convert original.* -define filter:filter=Jinc -define filter:window=Jinc -define filter:blur=0.9891028367558475 -define filter:lobes=3 -distort resize 1600% newLanczosSharp.png
("improved").

User avatar
fmw42
Posts: 26106
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: proper scaling of the Jinc filter for EWA use

Post by fmw42 »

You might find some suitable face image or other test images at the external links section of http://en.wikipedia.org/wiki/Standard_test_image

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux »

@fmw42: Thank you Fred, as always.

User avatar
fmw42
Posts: 26106
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: proper scaling of the Jinc filter for EWA use

Post by fmw42 »

This was posted some time ago on the forum and I have used it for examples, but I cannot say for sure if it is license free. But it might help for a start.

Image

imaggie
Posts: 88
Joined: 2011-12-19T04:15:36-07:00
Authentication code: 8675308

Re: proper scaling of the Jinc filter for EWA use

Post by imaggie »

the Kodac suite (24bit PNG) http://r0k.us/graphics/kodak/ has a girl in red hat that looks suitable. Preamble says images are "for unrestricted usage".

Image

Between the smooth flesh tones and freckles that should some provide fairly exacting tests.

imaggie
Posts: 88
Joined: 2011-12-19T04:15:36-07:00
Authentication code: 8675308

Re: proper scaling of the Jinc filter for EWA use

Post by imaggie »

Of course, it was right in front of me all the time !

Why don't we use some of the russian tarts that adorn my screen every time I visit this forum ??? :lol:

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux »

I gave a spin to freckles.jpg (only at 400% because it is already quite large), and showed the results to my wife. We both agree that the sharpened EWA 3-lobes are sharper, but that the new EWA LanczosSharp (essentially same as the current LanczosSharp as well as the current EWA Lanczos) avoid slightly off-colour spottiness under the eyes. So, imaggie's prognostic seems to hold.
Last edited by NicolasRobidoux on 2012-01-03T07:40:54-07:00, edited 2 times in total.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux »

The differences are subtle, though, I think it may be worth it to pass things through a gamma-corrected toolchain (and a calibrated monitor).
Last edited by NicolasRobidoux on 2012-01-03T07:41:13-07:00, edited 1 time in total.

Post Reply