how to convert a double matrix image to a unit8 matrix ?
조회 수: 25 (최근 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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!