why doesn't Graythresh work with the format "double"?
1 次查看(过去 30 天)
显示 更早的评论
I have an image (gray scale, 0-255) in the form of "uint8". I only need a part of it and as such I do the following:
Part_of_the_Image=original_Image(1:H,1:W);
the above, gives me an Image in the form "double". If I plot it (via imagesc and setting the colormap to gray), I would get a "white" image in the figure. In addition, the "graythresh" function does not work on it either (would give 0 as the threshold).
All of the problems are NOT encountered if I convert "Part_of_the_Image" to uint8.
I am just wondering why "double" yields to such problems!
Any comment would be appreciated.
0 个评论
采纳的回答
Image Analyst
2014-6-19
If your original_Image is truly uint8, then Part_of_the_Image will also be uint8. It will not convert it. Use class() or whos() to check. Post proof if you think otherwise. Here's my proof:
original_Image = 255 * ones(200, 'uint8');
H = 15;
W = 9;
Part_of_the_Image = original_Image(1:H,1:W);
whos original_Image
whos Part_of_the_Image
In the command window:
Name Size Bytes Class Attributes
original_Image 200x200 40000 uint8
Name Size Bytes Class Attributes
Part_of_the_Image 15x9 135 uint8
If an image is floating point, it's expected to be in the range 0-1 and pixels outside that range will be black or white. If you have some arbitrary range that's different than that, you can display the full dynamic range with [] option in imshow():
imshow(doubleImage, []);
2 个评论
Image Analyst
2014-6-19
You can pass in 'uint8' into zeros() and ones() like I did to make it be uint8.
graythresh() can take a double but, like with all image processing toolbox functions, it needs to be in the range 0-1. It's a pain so I never use it.
I don't see anything in the help about imagesc() taking doubles. If this answers your questions, please vote for and Accept the Answer.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!