Help using the bitand function
显示 更早的评论
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
2022-9-26
what is class(bubbles)? And does it contain any negative values?
Anthony Koning
2022-9-26
Walter Roberson
2022-9-26
Works when I test it in r2022b.
try
bubbles6 = bitand(bubbles , 252, 'uint8') ;
and please confirm
min(bubbles, [], 'all')
max(bubbles, [], 'all')
Anthony Koning
2022-9-26
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 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!