简体   繁体   English

uint8函数有什么作用?

[英]What does uint8 function do?

I'm trying to show the negative of an image and as you know it has a very simple code. 我试图显示图像的底片,并且您知道它具有非常简单的代码。
This is the original image: 这是原始图像:
在此处输入图片说明
When I use the code: 当我使用代码时:

Out = 255-img;
%Out = uint8(OutNeg);
imshow(Out);  

The result will be: 结果将是:
在此处输入图片说明

But using the code: 但是使用代码:

OutNeg = 255-img;
Out = uint8(OutNeg);
imshow(Out);  

Will make the right answer: 会做出正确的答案:
在此处输入图片说明
Now I am wondering 现在我在想

1 - what does the function uint8() does in fact? 1-uint8()函数实际上有什么作用?
2 - Do these codes make the same results? 2-这些代码产生相同的结果吗? In fact what is the usage of uint8? 实际上,uint8的用途是什么?

Code1: 代码1:

img2 = uint8(img1);  
imshow(img2); 

Code2: 代码2:

imshow(img1,[0 255]);  

3 - Do I need to normalize the image before showing it with the following code? 3-在使用以下代码显示图像之前,我需要对图像进行规范化吗?

img2 = 255/(max(max(img1))-min(min(img1)))*(img1-min(min(img1)));  

Or using uint8 or [0 255] does the same thing and no need to normalize?? 还是使用uint8或[0 255]做同样的事情,无需规范化?

4- what is the difference between normalizing, using uint8 and using [0 255]?????? 4-使用uint8和使用[0 255]进行归一化有什么区别?

please consider transformations like Log and power-low in your answers. 请在回答中考虑对数和低功耗等转换。

From help imshow : help imshow

If your grayscale image is single or double, the default display range is
[0 1]. If your image's data range is much larger or smaller than the default
display range, you may need to experiment with setting the display range to
see features in the image that would not be visible using the default
display range. For all grayscale images having integer types, the default
display range is [intmin(class(I)) intmax(class(I))].

By making your data an 8-bit unsigned integer ( uint8 ) array, the data is expected by imshow to be on [0 255] . 通过使您的数据成为8位无符号整数( uint8 )数组, imshow期望数据位于[0 255] RTM. RTM。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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