how to convert a double matrix image to a unit8 matrix ?

78 次查看(过去 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.

采纳的回答

Azzi Abdelmalek
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
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
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 CenterFile Exchange 中查找有关 Image Processing and Computer Vision 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by