I had some magical tasks to do on my lessons. I had to write an app which performs some operations: basic (adding, substractingsubtracting, multiplying a constant and a second image), geometric, filtering, histograms etc. There were ~50 tasks.
I've made them all, even with Prewitt filters and other down/upbandwith and gradient things.
Now, my teacher sent me an info, that I did my normalization wrong in basic operations, for ex.example in adding a constant.
As he wrote in his document there are 3 ways of handling the pixel overflow >255 or <0:
- cutting the overflow - which means a simple clamp
- scaling images before processing - dafuq
- NORMALIZATIONnormalization of the final image - scaling and moving the image function with a specified range that the final image fills the given range.
I've left first two and got the third one, causebecause he said it's the correct way. I've read somewhere that I still need to combine it with a clamp (0,255).
Now, I got his formula:
$$\large f_{norm}=Z_{rep}[(f-f_{min})\div(f_{max}-f_{min})]$$
And I thought it's easy to understand, but I have some problems with it.
As I understand:
- Fnorm$f_{norm}$ - final pixel (normalized)
- f$f$ - given pixel
- fmin$f_{min}$ - minimum
- fmax$f_{max}$ - extremum
- Zrep$Z_{rep}$ - clamp 0-255?
I have the following questions:
Are
fmin
$f_{min}$ andfmax
$f_{max}$ taken from the given image, or from the image after the operation (for ex. adding a constant)? I know what extremes are, but I can't figure it out which two should I use in this formula.Is Zrep$Z_{rep}$ really a clamp method as I thought which just cuts to 0-255? I've read somewhere that even with normalization there can be an overflow.
Does normalization work like: no matter what value you'll add or substractsubtract from the image, I'll make for you a beautiful 0-255 values? Or am I wrong?
I've even made some calculations, made some images in photoshop with extremes 30,200 and even 0,255, put them into the formula and got some results, but I still don't know if it's done well.
I'm sitting here for 3 weeks, really and can't get which extremes should I use and if I should clamp or not.
If there's anyone that could help me with it I would be grateful! Thanks very much!