What's new

sharpening via weighted discrete cosine transforms

James L. Dean

TPF Noob!
Joined
Feb 23, 2026
Messages
6
Reaction score
2
Location
New Orleans
Can others edit my Photos
Photos NOT OK to edit
I've written a C command line program to sharpen images.

Around each pixel in the image, this program calculates the fast 2D discrete cosine transform for the shades of the pixels in a rectangle of a specified size around the given pixel, multiplies the AC components of the transform by a specified value, inverts the 2D DCT, and sets the shade of the given pixel to the resulting shade while preserving the hue of the pixel.

Here is an example of an image from my camera and the output from my program:

The program handles the grayscale version of the image similar to the way described by "Discrete Cosine Transform for Enhancing the Contrast of Gray Image" by Nivedita V. Deshmukh (Hippalgaonkar) in the International Journal of Novel Research and Development, Volume 10, Issue 4, April 2025.

Here is an example of an image and the output from my program:
SharpenViaWeightedDCTs.demo.webp

I have attached the C program.
 

Attachments

Very interesting. I've done some programming in the past but I am so out of practice it would take me some time to shake the rust off. I do have Visual Studio on my machine and I may try to compile it. Thanks for sharing.
 
Looks good, "too slow" how slow is it compared to conventional and is it sharper I guess is the bigger question.
 
Very interesting. I've done some programming in the past but I am so out of practice it would take me some time to shake the rust off. I do have Visual Studio on my machine and I may try to compile it. Thanks for sharing.
 
The version of the program attached to this reply takes about three fifths of the time to run (and does the same thing).
 

Attachments

❔ Does it grossly oversharpen like the original posted version or is it tunable ❔
On the command line, you specify the size of the rectangle to use around each pixel and a multiplier. The multiplier has the biggest effect on sharpening. A value near 1.0 does almost no sharpening. I used 4.0 for the sample image.
 
Attached is a new version of my command line sharpening program (written in C) that applies more sharpening to less sharp pixels.

Also attached is a screen shot of an example of before and after processing.
AdaptiveSharpening.Example.webp
AdaptiveSharpening.Example.webp
 

Attachments

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

New Topics

Back
Top Bottom