这里面有详细讨论,结论是
转换为灰度值阈值 threshold_gray = level * 255;
实际上, 该函数内部对图像进行uint8转换。
If you look at the source code for graythresh, it first converts the image to uint8 and uses imhist to compute a 256 bin image histogram before computing the actual otsu threshold. The normalization later happens using the following code : level = (idx-1) / (num_bins-1);. Working backward from this helps drive my point. When level is 0, the first bin of the histogram is where the threshold lies. For a 256 bin uint8 histogram, that means 0. When the level is 1, this corresponds to 255.