convert an 8 bit image into lower bits

조회 수: 7 (최근 30일)
Ghulam
Ghulam 2017년 12월 5일
댓글: Walter Roberson 2023년 2월 9일
Hi, I want to convert an 8bit gray scale image into lower bits. I have loaded the image and divided it by multiple numbers to downsize its number of bits, but the problem is that the result is not presenting the true form of White color, and the white color is removed with downsizing. Can you please tell me what is the correct method of downsizing the bits of an image. Regards
  댓글 수: 8
Steven Lord
Steven Lord 2023년 2월 9일
If you use the idivide function instead of / you can control how the result is rounded.
IN = uint8(0:32:255);
result = [IN; IN/128;
idivide(IN, 128, 'fix');
idivide(IN, 128, 'floor');
idivide(IN, 128, 'ceil');
idivide(IN, 128, 'round')]
result = 6×8
0 32 64 96 128 160 192 224 0 0 1 1 1 1 2 2 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 1 1 1 1 2 2 2 0 0 1 1 1 1 2 2
Walter Roberson
Walter Roberson 2023년 2월 9일
Thanks, @Steven Lord I didn't know about idivide !

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2017년 12월 5일
img8 = imread('cameraman.tif');
im4 = im8 ./ 16;
image(im4);
colormap(gray(16));

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by