Converting an image with size of [X, Y, 3, double] to another image with size of [X, Y, 3, uint8]
이전 댓글 표시
I have an image with size [X, Y, 3, double] and I need to convert this image to another image with same size but uint8 type data i.e the size will be [X, Y, 3, uint8]. I Can anyone help me?
답변 (1개)
Matt Tearle
2011년 3월 18일
Assuming the double image has values between 0 and 1,
A2 = uint8(255*A1);
댓글 수: 4
Walter Roberson
2011년 3월 18일
That doesn't give equal weight to the values. The below does:
A2 = uint8(A1 * 256 - 1/2)
Seymour
2011년 3월 28일
Hey, thanks for the answer but I guess I need another solution similar to this. Now I have an image and when it is read by matlab; its dimensions are like this:<1038x1392 uint8>
I need this image with the sizes of <1038x1392x3 uint8>. I tried to do something similar to your previous answer but could not manage it. I appreciate if you help me. Thanks
Sean de Wolski
2011년 3월 28일
repmat(I,[1 1 3]);
Walter Roberson
2011년 3월 28일
If you read in an image and it is two dimensional, then unless it is a gray-scale image, it has an associated color map. To convert gray-scale images to equivalent RGB, easiest probably what Sean de showed; to convert pseudocolor images to rgb images, you use ind2rgb() specifying the image and the colormap to lock in.
카테고리
도움말 센터 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!