why doesn't Graythresh work with the format "double"?
조회 수: 3 (최근 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!