image steganography using LSB?
1 view (last 30 days)
Show older comments
how can i segment image array every 3 bytes?
1 Comment
DGM
on 7 Dec 2021
Edited: DGM
on 7 Dec 2021
Define "segment array every three bytes". Are we to assume that the image is uint8? Is it a vectorized RGB image where each pixel is represented by three sequential bytes (assuming uint8)? ... or is it a proper MxNx3 array? If it's a MxNx3 array, which three bytes? columnwise? pagewise? What does any of this have to do with the title?
Maybe these will serve as examples:
% test RGB image
A = uint8(randi([0 50],10,10,3) + permute([0 100 200],[1 3 2]));
% rearrange pagewise into 3-element blocks
% each row is a color tuple representing one pixel
B = permute(reshape(A,[],1,3),[1 3 2])
% test RGB image (vectorized)
A = reshape(permute(A,[3 1 2]),[],1);
% rearrange into 3-element blocks
% each row is a color tuple representing one pixel
B = permute(reshape(A,3,[]),[2 1 3])
Answers (1)
yanqi liu
on 8 Dec 2021
yes,sir,may be use the byte to lsb image,such as
clc; clear all; close all;
% information
str = 'Hello, Abduellah Elbakoush';
txt_file = fullfile(pwd, 'demo.txt');
fid=fopen(txt_file,'wt');
fprintf(fid,'%s',str);
fclose(fid);
fid=fopen(txt_file,'r');
[msg, msg_num] = fread(fid,'ubit1');
fclose(fid);
% image
img=imread('cameraman.tif');
imo = img;
img=double(img);
[M, N] = size(img);
% LSB
k=1;
for c = 1:N
for r = 1:M
if k>msg_num
break;
end
img(r,c) = img(r,c) - mod(img(r,c),2) + msg(k,1);
k=k+1;
end
end
% show
figure; imshow(uint8(img))
0 Comments
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!