× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Normalization of an image

Ray Phan
Apr 29, 2015
<p>That totally depends on the image content itself. Both of those methods are valid to ensure that the range of values is between <code>[0,255]</code>. However, before you decide on what method you're using, you need to ask yourself the following questions:</p> <h1>Question #1 - <em>What</em> is my image?</h1> <p>The first question you need to ask is <strong>what</strong> does your image represent? If this is the output of an edge detector for example, the method you choose will depend on the dynamic range of the values seen in the result (more below in Question #2). For example, it's preferable that you use the second method if there is a good distribution of pixels and a low variance. However, if the dynamic range is a bit smaller, then you'll want to use the first method to push up the contrast of your result.</p> <p>If the output is an image subtraction, then it's preferable to use the first method because you want to visualize the exact differences between pixels. Truncating the result will not give you a good visualization of the differences.</p> <h1>Question #2 - What's the dynamic range of the values?</h1> <p>Another thing you need to take note of is <strong>how wide</strong> the dynamic range of the minimum and maximum values are. For example, if the minimum and maximum are not that far off from the limits of <code>[0,255]</code>, then you can use the first or second method and you won't notice much of a difference. However, if your values are within a small range that is within <code>[0,255]</code>, then doing the first method will increase contrast whereas the second method won't do anything. If it is your goal to also increase the contrast of your image and if the intensities are within the valid <code>[0,255]</code> range, then you should do the first method.</p> <p>However, if you have minimum and maximum values that are quite far away from the <code>[0,255]</code> range, like <code>min=-50</code> and <code>max=350</code>, then doing the first method won't bode very well - <strong>especially</strong> if the grayscale intensities have huge variance. What I mean by huge variance is that you would have values that are in the high range, values in the low range and nothing else. If you rescaled using the first method, this would mean that the minimum gets pushed to 0, the maximum gets shrunk to 255 and the rest of the intensities get scaled in between so for those values that are lower, they get scaled so that they're visualized as gray.</p> <h1>Question #3 - Do I have a clean or noisy image?</h1> <p>This is something that not many people think about. Is your image very clean, or are there a couple of spurious noisy spots? The first method is <strong>very bad</strong> when it comes to noisy pixels. If you only had a couple of pixel values that have a very large value but the other pixels are within the range of <code>[0,255]</code>, this would make all of the other pixels get rescaled accordingly and would thus decrease the contrast of your image. You probably want to <strong>ignore</strong> the contribution made by these pixels and so the second method is preferable.</p> <h1>Conclusion</h1> <p>Therefore, there is nothing wrong with either of those methods that you have talked about. You need to be cognizant of <strong>what the image is</strong>, the dynamic range of values that you see once you examine the output and whether or not this is a clear or noisy image. You simply have to make a smart choice keeping those two factors in mind. So in your case, the first output probably didn't work because you have very large negative values and large positive values and perhaps very few of those values too. Doing a truncation is probably better for your application.</p> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/29853497/Normalization%20of%20an%20image/29853663">Stack Overflow</a>.</p>
comments powered by Disqus