Effacer les filtres
Effacer les filtres

Hi Im trying ti run this code but im getting "??? Cell contents assignment to a non-cell array object. Error in ==> dataemb at 29 HEAD{POS}=Data{i}; " can anybody help me out soon please...

1 vue (au cours des 30 derniers jours)
%%Metadata to be Encoded
% clc;
fid = fopen('m1.txt');
inputimg = textscan(fid,'%s','delimiter','\n');
lines = inputimg{1,1};
vecImg = reshape(inputimg,1,[]);
Data = vecImg;
% % inputimg = fread(file);imview('lena.jpg');
% % vecImg = reshape(inputimg,1,[]);
% % Data = vecImg;
% Perform Huffman Encoding
HEAD=0;
%--Compute Header--------
POS=0;
S_=size(Data);
for i=1:S_(2)
if (POS~=0)
S=size(HEAD); F=0;
k=1;
while (F==0 && k<=S(2))
if (Data(i)==HEAD(k)) F=1; end;
k=k+1;
end;
else F=0;
end;
if (F==0)
POS=POS+1;
HEAD{POS}=Data{i};
end;
end;
fprintf('Header:\n');
display(HEAD);
%%%%%%%%Compute probability for symbols%%%%%%%%%%%%
S_H=size(HEAD);
Count(1:S_H(2))=0;
for i=1:S_H(2)
for j=1:S_(2)
if (Data(j)==HEAD(i))
Count(i)=Count(i)+1;
end;
end;
end;
Count=Count./S_(2);
fprintf('probability for symbols\n');
display(Count);
%%%Sort accoridng to maximum number%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:S_H(2)-1
for j=i+1:S_H(2)
if (Count(j)>Count(i))
T1=Count(i); Count(i)=Count(j); Count(j)=T1;
T1=HEAD(i); HEAD(i)=HEAD(j); HEAD(j)=T1;
end;
end;
end;
fprintf('Sort Results\n');
display(HEAD);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[dict,avglen] = huffmandict(HEAD,Count); % Create dictionary.
hcode = huffmanenco(Data,dict); % Encode the data.
display (hcode);
% %Cover Image
img = imread('images.jpg');imview('images.jpg');
sX=size(img);
% Discrete Wavelet Transform
[LL LH HL HH]=dwt2(img,'haar');
dec=[LL,LH
HL,HH
];
figure;imshow(dec,[]);title ('DWT');
%Embedding Image in 3 X 3 bit Propagation
% Selected Band is HH.
b = 3;
txt = hcode;
I = LL;
N = 8*numel(txt);
S = numel(I);
if N > S
warning('Content Truncated')
txt = txt(1:floor(S/8));
N = 8*numel(txt);
end
p = 2^b;
h = 2^(b-1);
I1 = reshape(I,1,S);
addl = S-N;
dim = size(I);
I2 = round(abs(I1(1:N)));
si = sign(I1(1:N));
for k = 1:N
if si(k) == 0
si(k) = 1;
end
I2(k) = round(I2(k));
if mod((I2(k)),p) >= h
I2(k) = I2(k) - h;
end
end
bt = dec2bin(txt,8);
bint = reshape(bt,1,N);
d = h*48;
bi = (h*bint) - d;
I3 = double(I2) + bi;
binadd = [bi zeros(1,addl)];
I4 = double(si).*double(I3);
I5 = [I4 I1(N+1:S)];
img = reshape(I5,dim);
%img = embedAction(double(HH),hcode,3);
%Perform Inverse Wavelet Transform
X = idwt2(img,LH,HL,HH,'haar',sX);
figure;imshow(uint8(X));title('IDWT');
% Writing Embedded Image file
imwrite(uint8(X),'embed.jpg','jpg');
figure;
imshow(uint8(X));title('EMBEDDED OUTPUT');

Réponses (0)

Catégories

En savoir plus sur Denoising and Compression 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!

Translated by