I had some magical tasks to do on my lessons. I had to write an app which performs some operations: basic (adding, subtracting, 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 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
- normalization 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, because 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:
- $f_{norm}$ - final pixel (normalized)
- $f$ - given pixel
- $f_{min}$ - minimum
- $f_{max}$ - extremum
- $Z_{rep}$ - clamp 0-255?
I have the following questions:
Are $f_{min}$ and $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 $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 subtract 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 you are truly normalizing the data, the only cause of overflow I can think of is due to rounding issues which can definitely happen.
Yeah, but If I put value 400 to this formula (which can happen when I add a high number to the image) I get a normalized value of 555 which is not in the expected range :D There's something wrong with these extremes O.o – Jacob Jan 23 '17 at 18:52Output = (Input - 400) / (555-400)
If you plug an input value of 400 into that equation you get an output of 0. If you plug an input value of 555 into that equation you get an output value of 1. For values between 400 and 555 you'll get values between 0 and 1.
This result should then be multiplied by 255 to make it [0,255].
– Alan Wolfe Jan 23 '17 at 18:56I have them in PCX format cause I chose it as a working for lessons (it's the least complicated one :D). You'll need a photoshop or pcx viewer to view it, but you probably know that ;D
– Jacob Jan 23 '17 at 19:29fmin
. – jiggunjer Jan 26 '17 at 03:05