徐子捷 411410030
Due date: 2025/05/03
Handed in date: 2025/05/12 (encounted lots of bugs, sorry for being this late...)
The program does Image Sharpening and High-Boost Filtering [1] by:
- Sharpening with negative Laplacian operator result (extracted details) + Origin image, by filter
then:
0 -1 0 0 0 0 0 -1 0 -1 4 -1 + 0 1 0 = -1 5 -1 0 -1 0 0 0 0 0 -1 0- clamp result range in [0, 255] (
laplacian_clamp_*.png) - transform result range back to [0, 255] by channel-wise scaling and shifting (
laplacian_scale_*.png)- transformation is done channel-wise to keep the relationship between channels.
- clamp result range in [0, 255] (
- + 0.5f * Origin image to Hight Boost result of 1.-1. (
laplacian_clamp_boost_*.png)- clamp result to 255 if it > 255
- Doesn't try transformation because boosting is meant to just brighten the image.
- Sharpening with extracted details from deblurring (Origin image - blur image) + Origin image, by filter
then, same as 1.:
0 0 0 0 0.2f 0 0 0 0 0 -0.2f 0 0 1 0 - 0.2f 0.2f 0.2f + 0 1 0 = -0.2f 1.8f -0.2f 0 0 0 0 0.2f 0 0 0 0 0 -0.2f 0- clamp result range in [0, 255] (
deblurr_clamp_*.png) - transform result range back to [0, 255] by channel-wise scaling and shifting (
deblurr_scale_*.png)- transformation is done channel-wise to keep the relationship between channels.
- clamp result range in [0, 255] (
- + 0.5f * Origin image to Hight Boost result of 3.-1. (
deblurr_clamp_boost_*.png)- clamp result to 255 if it > 255
- Doesn't try transformation because boosting is meant to just brighten the image.
Sharpening by filter is done by native convoltion each channel of the image with the filter in spatial space, then combine them back.
- when the image can't cover the filter, zero padding is used.
The program use CMake as its build tool.
cd buildcmake ../. -G "MinGW Makefiles", orcmake ../. -G "Visual Studio 17 2022", etccmake --build ., or the usual way environment do, e.g.,mingw32-make, IDE run button, etc- Executable built
Clean all files from CMake: (/s: Deletes specified dir and all its subdir)
rmdir /s .\- alt + tab out your IDE to prevent cannot delete
because it is being used by another process.
Clean built file only:
cmake --build . --target clean
- put all
.bmpand.tifinputs in./test_imagesrelative to the executable. - open
cmd.exe - enter
ImgSharpen.exeand run - Results of Image Sharpening are in
./outputsrelative to the executable.
Meaning of results image position:
0 1
2 3
4 5
6
- Deblurred Sharpening, transformed
deblurr_scale_*.png - Origin Image
- Deblurred Sharpening, clamped
deblurr_clamp_*.png - Boosted clamped Sharpen Deblurred
deblurr_clamp_boost_*.png - Laplacian Sharpening, clamped
laplacian_clamp_*.png - Boosted clamped Sharpen Laplacian
laplacian_clamp_boost_*.png - Laplacian Sharpening, transformed
laplacian_scale_*.png
Origin Image (1024×576)
Deblurred Sharpening, transformed deblurr_scale_*.png

Deblurred Sharpening, clamped deblurr_clamp_*.png
Boosted clamped Sharpen Deblurred deblurr_clamp_boost_*.png

Boosted clamped Sharpen Laplacian laplacian_clamp_boost_*.png
Laplacian Sharpening, clamped laplacian_clamp_*.png

Laplacian Sharpening, transformed laplacian_scale_*.png

Observations:
-
Laplacian images are more sharp than Deblurred images.
When pixel value is near 255, the Laplacian filter:0 -1 0 -1 5 -1 0 -1 0can produce range [-1020, 1275], but the Deblurred filter
0 -0.2f 0 -0.2f 1.f-0.2f -0.2f 0 -0.2f 0can only produce range [-204, 204].
The bigger the range, the more responsive result to edges, i.e., the stronger the sharpening is when added to origin image.
But stronger sharpening isn't always better. For example, Laplacian Sharpening of skeleton_orig.bmp sharpens tissue details, which greatly affects visibility of thigh bones. -
Transformed images are usually too gray.
If the result range is large (e.g. [-1020, 1275]), the scaling may be terribly severe (e.g. 255/2295 = 0.1111). Since most pixels don't have this much differentiation, severe scaling greatly reduce contrast of other parts (thus it unsharpens), leaving the result "too gray".The only advantage is it represents differentiation after sharpening faithfully. A person can identify the most changes part in the image by finding the clearest part of the result (e.g. HP, MP number in Color Image)
Since the faithfulness, if the result range is small (like using the Deblurred filter), using Transform can be just very slightly better than Clamping, for example, blurry_moon.bmp.
-
Boosted images look more sharp.
If origin pixel difference is$a-b$ , after the boost is$1.5a-1.5b=1.5(a-b)$ . The difference is enlarged by$1.5$ times, thus images looks more sharp. But if origin pixel value is near 255 or boosting too much (e.g.$+1.5$ of origin image), the Clamping will cut all value to 255. Not only complete an ultimate unsharpening, but also make the image tragically white.Even if we find a perfect boost times, it's disadvantage is clear: it breaks origin brightness distribution, making the result "not like" the origin.
-
Color images behave exactly the same as others.
Edge and Details seldomly live in cross channel relationships, so the divide-and-conquer works.
Conclusions:
(usually) the Best Sharpening
Laplacian Sharpening sharpen too much
Don't want Boosting to change color
Does Transformed works?
Color Image? works like a breeze.
[1] R. C. Gonzalez and R. E. Woods, Digital Image Processing, 4th Ed., Pearson, New York, NY, 2018, Chapter 3.













