简体   繁体   中英

MATLAB : Why does a Threshold value get normalized?

I get my ' T ' by this (Iterative global thresholding ) way :

count = 0;
 T = mean2(f); %Average or mean of matrix elements
 done = false;
 while -done
 end

Now, I get T :

T =

  122.7068

Now I go Segment the image using :

g = im2bw(f, T/255);

T is divided by 255 (normalized to the range [0, 1] )

Why do we need to normalized the T ?

I'm sorry for this noob question.

As I have a look at my histogram (of gray level image):

在此处输入图片说明

Isn't T=122.7068 is all need, why I need such a normalization?

Lots of uint16 images floating around. So I might have some kind of algorithm that first tries to naively threshold using the mode of the possible data range, so 128 with uint8. Then I could plug in a uint16 image, for which the max is 65535 and the algorithm would threshold everything as the foreground for its first guess. Stupid example, but the point is the same. Normalisation is often a good idea.

Also historical reasons. Steve Eddins talks about thresholds in his Mathworks blog:

http://blogs.mathworks.com/steve/2016/05/09/image-binarization-im2bw-and-graythresh/

"At this point in the early history of MATLAB, the language really only had one type. Everything in MATLAB was a double-precision matrix. This affected the early functional design in two ways. First, the toolbox established [0,1] as the conventional dynamic range for gray-scale images. This choice was influenced by the mathematical orientation of MATLAB as well as the fact that there was no one-byte-per-element data type. "

Also amusing:

"Experienced software developers will be amused by the code comment above, "Use default for now". This indicates that the developer intended to go back and do something else here before shipping but never did. Anyway, you can see that a LEVEL of 0.5 is used if you don't specify it yourself."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM