Enhance Images
Enhance Image Quality of all images if all CBZs of a directory
Last updated
Enhance Image Quality of all images if all CBZs of a directory
Last updated
Looking at scans from books that were published in decades past or by now defunct publishers, there quick and easy image enhancements that could be done to the images.
This function will run an image enhancement algorithm (documented below) on all images in a CBZ and all files in a directory. This feature does not traverse directory/sub-directories.
Below are a few Before/After examples
For processing images, I didn't want to just simply adjust the contrast. This could have unintended consequences and make the image less legible overall. Below, I explain the logic behind the image processing and welcome any comments and refinements.
The app uses the Python PIL (Pillow) library to apply an "intelligent" adjustment to each image in the CBZ.
Analyzing Each Image
The function modified_s_curve_lut()
generates a lookup table (LUT) with 256 values (one for each possible brightness level in an 8-bit image).
The S-curve is a mathematical way of adjusting brightness—darker areas get a bit darker, mid-tones are slightly boosted, and highlights remain close to their original brightness.
For pixels with brightness below 128, the full S-curve effect is applied.
For pixels above 128, the function blends the original brightness with the S-curve, making the effect more subtle in brighter areas.
The code will attempt to determine if the image is grayscale, RGBA or RGB and apply the defined S-Curve accordingly
It improves contrast by deepening shadows and slightly boosting mid-tones.
It avoids extreme changes in bright areas, preserving detail.
The effect is smoother and more natural compared to a standard contrast adjustment.