Image resizing and sharpening


#1

Thanks @patdavid for thread splitting from [PlayRaw] Battle of Light and Darkness.

It might be a bit confusing at first since whole posts were copied over but I hope that this won’t detract from your reading experience :sunny:.


@paperdigits Hmm… not a fan of that crop because the top right is kind of boring. What I like about your take is that it is like I am looking up at the sky but it is kind of bright up there.

@ggbutcher Like how you captured the light and dark theme. The sharpened noise however is kind of distracting. Maybe denoise before sharpening? Or not sharpen at all because resizing already sharpens.


[PlayRaw] Battle of Light and Darkness
(Glenn Butcher) #2

@ggbutcher Like how you captured the light and dark theme. The sharpened noise however is kind of distracting. Maybe denoise before sharpening? Or not sharpen at all because resizing already sharpens.

@afre, thanks, always interested in what others see, as I’m currently hobbled with small and uncalibrated displays. I usually resize for web posting, and my software doesn’t automatically sharpen post-resize so I have to put it in. I forget pixls.us is tolerant of camera-sized images…

I reprocessed the image without resize/sharpen, and applied a NLMeans denoise:


Processing:
rawproc-0.6 IMG_20170729_185409.dng:colorspace=prophoto;gamma=prophoto; blackwhitepoint:25,193 curve:rgb,0.0,0.0,72.0,53.0,164.0,185.6,255.0,255.0 saturation:2.00 crop:613,374,5291,2990 denoise:23,3,1


#3

@ggbutcher I think that shrinking generally makes an image appear sharper. My camera, display and software aren’t profiled or color-managed either but I don’t see it as a hindrance. What I see won’t be what others would see anyway even if I did those things, given my eyes, viewing condition and psycho-physical makeup :nerd_face:. It is until I start printing stuff that I would care a smidgen.


(Glenn Butcher) #4

@afre: I think that shrinking generally makes an image appear sharper.

Actually, I’ve observed the opposite, with even the better resize interpolators. If you think about what’s going on, you’re taking a matrix of pixels and “averaging” them to a single pixel in the reduced image. The interpolators help in various ways to weigh that average toward the nearer pixels, but the apparent sharpness (acutance) does decrease.

So, when I reduce to 640x480 or so for posting, I generally add a minimal USM sharpen to increase the edge contrast. The effect is better with substantial shapes with sharp edges than with something confusing like foliage, and, per your earlier point, noisy regions. You’ve made me reconsider my arbitrary application of post-resize sharpen.

@Andrius, sorry to hijack. Thanks for giving us a nice image with which to learn…


(John) #5

Off topic but it always a good idea to sharpen after a reduction in size. Settings vary in packages but a rad of 2 pixels is usually about right and apply so that an increase in sharpening is just about apparent. Wisdom also states a rad of 1 again with a relatively low level should be applied to the full sized image to tidy up debayering. Personally to improve clarity if needed I find a rad of 5 is better at this stage. The results aren’t really apparent until the image is finally set to size. It tends to gain detail over when this isn’t done - if that is needed. Poor monitor settings can mean that images need more sharpening to get them to look right. Some packages eg I think Adobe automatically sharpen when an image is reduced.

On this one I just developed in Rawtherapee all adjustments off. Excellent exposure. In fotoxx I used the zonal brightness flattening. This brings up shadow and brings down highlights. It tends to allow more shadow detail to be bought up usually by subsequent mid tone tone mapping. I used an adjustment curve instead. Still needed a bit more oomph in my view so loaded it into the gimp, duplicate layer and then set soft light mode. Then new from visible and a bit of the thumb in places to smooth out slight mist detail that the processing had exaggerated.

John


(Glenn Butcher) #6

Yes, post-resize sharpen isn’t done to sharpen, it’s done to put back in some of the edge acutance lost by “averaging” a matrix of pixels down to one. It’s a contrivance, to be sure, but it puts some ‘pop’ back into small images.

It’s why I usually post resized images for web viewing, rather than have the browser resize to fit the allocated space on the page. I’d rather have control of the operation.


#7

I assumed that shrinking would sharpen the image because the info density would be higher. It would be great if someone could provide me a suggested reading list or write a small primer with examples. Thanks.


(Glenn Butcher) #8

I did that investigation to implement a quality resize algorithm for my gimage library. I put a short missive about the process in the library as a comment, you’ll find it at https://github.com/butcherg/gimage/blob/master/gimage.cpp, starting at line 1647

The resize algorithms I considered basically work one dimension at a time, width then height, or vice versa. In each operation, one of the interpolation algorithms is used to calculate each resized pixel based on the neighbors of the corresponding center location in the original image. So, when you see a reference to, say, the lancosz3 algorithm, they’re referring to the interpolation, not the overall reduction.

The Graphics Gems book series is probably the definitive reference for most basic image processing. Vol III, article 1.2, “General Filtered Image Rescaling”, by Dale Schumacher, is particularly responsive to your need. My gimage code is an adaptation of the code described therein, with appropriate credit.


(Morgan Hardwood) #9

There are various resizing algorithms. Most programs seem to package a single, non-tweakable instance of the most popular ones. However these algorithms do have tweakable parameters, exposed to the programmer if not the user, and can be adjusted (something about adjusting the window, the sync function and the kernel) to mitigate aliasing, blocking, ringing and other artifacts.

The math for Lanczos is described in wikipedia and there is more information in the ImageMagick docs:


http://www.imagemagick.org/Usage/filter/

I think it’s more user-friendly to ship a resizing algorithm that behaves best on average, for example stock Lanczos in RawTherapee does a great job generally, avoids aliasing and renders smooth edges. The user can optionally sharpen afterwards.


(Simon Frei) #10

I found the following article pretty good - Stage 3 is mostly relevant to your question:
http://www.cambridgeincolour.com/tutorials/image-sharpening.htm


(Glenn Butcher) #11

If you download the FreeImage API documentation (.pdf), in the Appendix there is a rather informative section titled, “Choosing the right resampling filter”, complete with sample images for the available interpolation algorithms.

http://downloads.sourceforge.net/freeimage/FreeImage3170.pdf


(John) #12

There is a lot of very good reliable tutorials on that site. Both these and help from the forum tend to be PS related but other packages can usually be persuaded to do the same things some how.

There is a need to click on the tutorials link on their home page to see all of them. They cover most aspects of photography.

John