Hello SDL community , I am a very beginner with SDL and programming in general, trying to create a image processing software for my university assignment.
The reason for that I made this post is that I do get some weird results trying to create an Unsharp Mask effect. I will attach my code here and I will explain what it does and where the problems are (or at least , where I think they are).
So, as you can see, my function gets 2 arguments: the image source(from which pixel data will be extracted, and a target, where the image will be projected). I blur the original image, then i substract the RGB value of the blurred image from the source image to get “the mask” and then , i add the mask to the original image and that’s it. I added some clamping to make sure everything stays in the correct range and then I draw every pixel resulted on the output surface. All these surfaces have been converted in an SDL_PIXELFORMAT_ARGB8888 . The output surface is loaded into a texture (also SDL_PIXELFORMAT_ARGB8888) and rendered on the screen.
The results are pretty good in 90% of the image, I get the effect I want, however , there are some pixels that look weird in some places. I will also attach some results here(Original/Result):
I tried to fix this in any possible way I knew. I thought is a format problem and played with the pixel bit depth , but I couldn’t get to a good result. What i found is that all the values > 255 are negative values and I tried to make them completely white. And it works for the skies ,for example, but if you can see on my examples, the dark values, on the grass are also affected, which makes this not a good solution.
I also get this kind of wrong pixels when I want to add a contrast, and the values are really bright/dark.
In my opinion there may be a problem with the pixel format, but I’m not sure if that’s true.
Is there anyone that had this kind of problem before or knows a potential solution?
Thank you for your time and support !