how to convert a double matrix image to a unit8 matrix ?
79 次查看(过去 30 天)
显示 更早的评论
Hi everybody :) I have an image ,a matrix with values between -0.0934 and 0 and i want to convert it to unit8 matrix with values between 0 ans 255.
0 个评论
采纳的回答
Azzi Abdelmalek
2013-3-8
编辑:Azzi Abdelmalek
2013-3-8
A=imread('yourimage')
B=uint8(A)
EDIT
d=linspace(min(im(:)),max(im(:)),256)
im1=uint8(arrayfun(@(x) find(abs(d(:)-x)==min(abs(d(:)-x))),im))
4 个评论
Azzi Abdelmalek
2013-3-8
编辑:Azzi Abdelmalek
2013-3-8
Try this
%If im is your image
d=linspace(min(im(:)),max(im(:)),256)
im1=uint8(arrayfun(@(x) find(abs(d(:)-x)==min(abs(d(:)-x))),im))
更多回答(1 个)
Image Analyst
2013-3-8
You can use the mat2gray() function:
image8Bit = uint8(255 * mat2gray(floatingPointImage));
It will scale your values to the range 0-255.
10 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!