I want to embed data(binary form :0's and 1's) into the highlighted values of the matrix I've given below. But I want to embed 2 bits of data at a time. What should I do ?
4 views (last 30 days)
155 144 94 151
7 204 121 147
2 210 109 57
93 180 169 250
So this above here is the matrix, I've mentioned. And I have a .bin file having just 0's and 1's. I want to embed these binary digits into the highlighted values of the matrix, but I want to embed them considering 2 bits at a time.
And I've also created 4 Pseudo-Random arrays of size 255 and labelled them as 'R0' , 'R1', 'R2', 'R3'. I've matched these pseudo-random arrays with the 2 bits of binary digits I've mentioned earlier.
So basically what I mean is R0 maps with "00" , R1 maps with "01", R2 maps with "10", R3 maps with "11".
So for example If I want to embed the data 2 bits at a time, If I encounter the digit "01" first and I want to store it in the highlighted value of "144". Then this means the array 'R1' should be chosen and at the index "144" of R1 we should retrieve the value present in that location and replace "144" with that value in the matrix. Here, 'R1' is chosen because it maps to the data "01".
So basically I want to embed all the data that I have in my .bin file in this way. How do I write the code for this ?. Can you please help me with it. Thank you.
David Hill on 27 Jul 2022
r=[randperm(256)-1;randperm(256)-1;randperm(256)-1;randperm(256)-1];%matrix map used to replace values in R
b=num2str(randi(2,1,256)-1);b=b(b~=' ');%bitstream each two-bit stream represents the row of r to map with
n=4;%size of R (must be less than 16)
R=reshape(randperm(256,n^2),n,n)'-1;%initial values in R (must transpose for matlab indexing)
idx=find(toeplitz(mod(0:n-1,2)));%finds the indexes of R to replace from the mapping
R(idx(k))=r(bin2dec(b((k-1)*2+1:2*k))+1,R(idx(k))+1);%+1 used for matlab non-zero indexing