how can I read and extract the 2 LSBs of every byte from the RGB image array ?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Abduellah Elbakoush
le 26 Déc 2021
Réponse apportée : yanqi liu
le 27 Déc 2021
i want to read the 2 LSbs of every byte for exaple i want to read (00) from this byte (11111100) for the whole of the image
0 commentaires
Réponse acceptée
yanqi liu
le 27 Déc 2021
clc; clear all; close all;
img = imread('cameraman.tif');
img2 = blockproc(img,[1 1],@sp);
figure; imshowpair(img,img2,'montage')
function y=sp(x)
% every byte
x2 = dec2bin(x.data);
% 2 LSB of every byte
y=bin2dec(x2(end-1:end));
end
0 commentaires
Plus de réponses (1)
Voss
le 26 Déc 2021
One way is to read the data as bytes (type uint8) like usual, then the 2 LSBs are the remainder after dividing by 4, e.g.:
b = uint8(0:255)
r = rem(b,4)
s = dec2bin(r)
a = s-'0'
0 commentaires
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
