a=imread('cameramen.jpg'); b= round(a./256); but i got binary bits like this 1 0 1 0 0 1 0 0 0 0 0 0 0 1 0 1 0 1 0 0 . . . 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 . . 1 0 1 0 1 0 0 0 0 0 0 0 but what i want is: b = (1 0 1 0 1 0 0 0 .....n)
Neeta Dsouza answered .
2025-11-20
orig_image = imread('cameraman.tif'); %demo image shipped with matlab
lsb_replacement = uint8(randi([0 1], size(orig_matrix))); %random replacement
%set lsb to 0 (with AND 254) and replace with OR:
new_image = bitor(bitand(orig_matrix, 254), lsb_replacement);
imshowpair(orig_image, new_image, 'montage')
isequal(bitget(new_image, 1), lsb_replacement) %should return true