MATLAB : Why does a Threshold value get normalized?

时间:2016-10-15 17:09:47

标签: image matlab image-processing

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):

enter image description here

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

1 个答案:

答案 0 :(得分:0)

周围漂浮着许多uint16图像。所以我可能会使用某种算法,首先尝试使用可能的数据范围的模式进行天真阈值,因此128使用uint8。然后我可以插入一个uint16图像,其最大值为65535,算法会将所有内容阈值作为其第一次猜测的前景。愚蠢的例子,但重点是一样的。规范化通常是一个好主意。

也是历史原因。 Steve Eddins在他的Mathworks博客中讨论了阈值:

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

"在MATLAB的早期历史中,语言实际上只有一种类型。 MATLAB中的所有东西都是双精度矩阵。这以两种方式影响了早期的功能设计。首先,工具箱建立[0,1]作为灰度图像的传统动态范围。这种选择受到MATLAB的数学方向以及没有每个元素的单字节数据类型这一事实的影响。 "

也很有趣:

"有经验的软件开发人员会对上面的代码评论感到好笑,"现在使用默认值"。这表明开发人员打算在发货之前回去做其他事情,但从未这样做过。无论如何,你可以看到,如果你自己没有指定,则使用0.5的LEVEL。"