Hi, I'm trying to use the bitand function to drop the two least significant bits off of an image (basically forcing an 8-bit image to be displayed as 6 bit) using the bitand function. the code i'm using goes as
bubbles6 = bitand(bubbles , 252) ;
with 252 being the new assumed bit total (11111100 in binary since the two lowest are dropped), but the function keeps returning the erros message
'Error using bitand
Double inputs must have integer values in the range of ASSUMEDTYPE.'
Could someone explain what this means and why?

댓글 수: 5

Walter Roberson
Walter Roberson 2022년 9월 26일
what is class(bubbles)? And does it contain any negative values?
Anthony Koning
Anthony Koning 2022년 9월 26일
Bubbles is the name of the image that I am trying to reduce the bit value of. The actual image (using the whos command) is a unit8 class grayscale image, and as such, should contain no negative values.
Works when I test it in r2022b.
try
bubbles6 = bitand(bubbles , 252, 'uint8') ;
and please confirm
min(bubbles, [], 'all')
max(bubbles, [], 'all')
Anthony Koning
Anthony Koning 2022년 9월 26일
Unfortunaetly, it does not work on my current build of Matlab (2021a). Inputting the code you sent just leads to an error message of 'Operands to BIT Ops must be numeric.'
Walter Roberson
Walter Roberson 2022년 9월 26일
편집: Walter Roberson 2022년 9월 26일
I just tried in R2021a pre-release that I happen to have installed on a drive.
bubbles = imread('flamingos.jpg');
bubbles6 = bitand(bubbles , 252, 'uint8') ;
min(diff(unique(ubbles6)))
worked fine.
In your code, put in a breakpoint at the bitand line. Then what shows up for
which bitand(bubbles)
min(bubbles(:))
max(bubbles(:))

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

릴리스

R2021a

태그

질문:

2022년 9월 26일

편집:

2022년 9월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by