# Downsampling oversampled image (smallest size which retains image 'detail' within acceptable limits)

I have a large collection of oversampled images (family photos of varying 'sharpness' scanned at a uniformly high dpi) and would like to downsample them to optimise storage space whilst retaining detail within some reasonable threshold.

I am hoping to find (or build) a tool that can help me identify what I (a confessed layman) would call the 'natural resolution' of the scanned image.

For example a 70 year old black & white 6x4" print scanned at 600dpi might be downsampled to 253dpi and look 'sharp' (for some definition of sharp). The downsampled image might then be upsampled to 600dpi again with a deviation from the original that falls within an acceptable threshold. Downsampling the original to 252dpi then upsampling might result in too much deviation, therefore the tool may decide that 253dpi is the sweet spot for that image. Ideally the tool could determine the sweet spot without having to iteratively downsample and upsample.

There are many complications (noise, dust, sharp edges that represent the edges of the photo instead of the photo itself) so the tool may require user supervision. At the moment I'm just looking for pointers as to what techniques and terms I should be familiarising myself with. I have put many hours into googling this issue but all results are either overly simple pc mag stuff (e.g. 'always scan at X dpi') or impenetrable research papers.

Edit (clarification, 2014-01-11)

The paragraph above about downsampling then upsampling is just to illustrate my point about determining loss of detail. In my actual workflow I only intend to downsample (no subsequent upsample step). The goal is to find an algorthm that on a per-image basis will determine the lowest resolution I can downsample to without sacrificing image detail (or sacrificing within an acceptable limit).

There are many options yet it is highly dependent on the properties of the image being resampled. Images downsampled with bicubic interpolation are regarded as smoother and with fewer interpolation artifacts. You may also try nearest neighbor interpolation and bilinear interpolation. Make sure a low pass filter is applied before further processing with downsampling strategies, otherwise the aliasing artifacts may be induced.

Besides, you may also consider vectorization algorithm in which a resolution independent vector representation is created before rendered to the image at a desired resolution. it is mainly used in up-sampling but the vectorization method is helpful in preserving the feature connectivity in down-sampling as well.

Another interesting blog on comparison between different image re-size approaches.

EDIT

Regarding the design of low pass filter served as a pre-processing method before downsampling, you can consider this way:

Suppose a low pass filter $g$ works on the image $x$, and the filtered image is $u = x*g$. After that, simply decimate $u$ by 2, you get $v$. Now you want to recover the original image. You can zero-upsample the $v$ into $w$ where $w_{2n} = v_{n}$, and $w_{2n-1} = 0$. Then another filter $h$ is applied, trying to obtain $\hat{x} = w * h$. After Z-transform, $U(z) = X(z)G(z)$, $\hat{X}(z) = W(z)H(z)$.

Since $W(z) = 1/2(U(z) + U(-z))$, we have $\hat{X}(z)=1/2(H(z)G(z))X(z) + 1/2(H(z)G(-z))X(-z)$

A good downsampling is equivalent to a good recovery to some extent. In order to best recover the original image ($\hat{X}(z)=X(z)$), you are trying to make $H(z)G(z)$ as close to $2$ as possible, while $H(z)G(-z)$ as close to $0$ as possible. The design of low pass filter $G(z)$ is based on this criteria.

• your initial answer focuses on the downsampling process, which is important but requires a known target resolution (this is what I am trying to determine). The edit goes into some detail about low-pass filters which, I'm embarrassed to say, is beyond me at this point. I will investigate low-pass filters, but at the moment my primary goal is determining the target resolution to downsample to. The downsampling algorithm is important, I will likely choose one of photoshop's presets. Also, as you rightly point out, the target resolution will vary from image to image. – Jaysen Marais Jan 11 '14 at 6:23