How i can insert file *.docx/*.pdf into image using LSB?

I have trouble finding a tutorial to insert a file * .docx / *. pdf into image using LSB. Please, help me!

1 comentario

% This numerical method scheme is for Caputo differential equation
clc; clear; close all;
% Inputs
h = 0.01;
t(1) = 0.1;
tfinal = 10;
t = t(1):h:tfinal;
N = ceil((tfinal - t(1)) / h);
% Initial Conditions
x(1) = 0.05;
y(1) = 0.009;
z(1) = 0.5;
p(1) = 0.0004;
q(1) = 0;
% Constants and parameters of the model
alpha = 0.976;
b = 1/365*75.65;
m = 0.001;
p_value = 0.0004; % Changed variable name to avoid conflicts
fraction = 0.1; % Changed variable name to avoid conflicts
mu = 1/365*75.65;
beta = 0.1;
eta = 0.15;
r_1 = 0.01;
r_2 = 0.1;
% ODEs (Financial System given in the above paper by (3.1a--3.1c))
f1 = @(t, x, y, z, p, q) b * N - beta * x * (z + p) - mu * x;
f2 = @(t, x, y, z, p, q) beta * x * (z + p) - m * y * 1 / eta - (1 - m) * y * 1 / eta - mu * y;
f3 = @(t, x, y, z, p, q) m * y * 1 / eta - r_1 * z - mu * z;
f4 = @(t, x, y, z, p, q) (1 - m) * y * 1 / eta - r_2 * p - mu * p;
f5 = @(t, x, y, z, p, q) r_1 * z + r_2 * p - mu * q; % Corrected the function and variable names
% Caputo Algorithm
for n = 2:N
% Calculation of x(n+1)
sum_term = 0;
for v = 2:n
sum_term = sum_term + f1(t(v - 1), x(v - 1), y(v - 1), z(v - 1), p(v - 1), q(v - 1));
end
x(n + 1) = ((h^alpha) / gamma(alpha + 1)) * sum_term;
% Calculation of y(n+1)
sum_term = 0;
for v = 2:n
sum_term = sum_term + f2(t(v - 1), x(v - 1), y(v - 1), z(v - 1), p(v - 1), q(v - 1));
end
y(n + 1) = ((h^alpha) / gamma(alpha + 1)) * sum_term;
% Calculation of z(n+1)
sum_term = 0;
for v = 2:n
sum_term = sum_term + f3(t(v - 1), x(v - 1), y(v - 1), z(v - 1), p(v - 1), q(v - 1));
end
z(n + 1) = ((h^alpha) / gamma(alpha + 1)) * sum_term;
% Calculation of p(n+1)
sum_term = 0;
for v = 2:n
sum_term = sum_term + f4(t(v - 1), x(v - 1), y(v - 1), z(v - 1), p(v - 1), q(v - 1));
end
p(n + 1) = ((h^alpha) / gamma(alpha + 1)) * sum_term;
% Calculation of q(n+1)
sum_term = 0;
for v = 2:n
sum_term = sum_term + f5(t(v - 1), x(v - 1), y(v - 1), z(v - 1), p(v - 1), q(v - 1));
end
q(n + 1) = ((h^alpha) / gamma(alpha + 1)) * sum_term;
end
% Plotting results
figure(1)
plot(t, x, '-b', t, y, '-r', t, z, '-m', t, p, '-g', t, q, '-c');
legend('S(t)', 'V(t)=0.25', 'E(t)', 'I(t)', 'R(t)');
xlabel('time t (Days)')
ylabel('Population')

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 18 de Oct. de 2018
You can use fopen/fread/fclose to read in any kind of file as uint8. Then dec2bin and subtract '0' (the character) to get bits that you can embed.

1 comentario

I have error with this code. Please help me!
tic;
clc;
clear;
file_name = '2.png';
binary = fopen('Test.docx')';
binary = fread(binary, 'uint8')';
img =imread(file_name);
j=1;
MSB3 = bitshift(img,-5);
LSB4 = double(bitshift(img-bitshift(bitshift(img,-5),5),-1));
LSB_Dec = img-bitshift(bitshift(img,-1),1);
for i=1:numel(img)
bits = binary(j:j+3);
j=j+4;
bits_val = dec2bin(bits);
bits_comp = 15-bits_val;
if abs(LSB4(i)-bits_val) < abs(LSB4(i)-bits_comp)
LSB4(i)=bits_val;
LSB_Dec(i)=0;
else
LSB4(i)=bits_comp;
LSB_Dec(i)=1;
end
end
LSB5 = bitshift(uint8(LSB4),1)+LSB_Dec;
SIMG = bitshift(MSB3,5)+LSB5;
imwrite(SIMG,['Stego_' file_name],'png');
subplot(2,1,1), imshow(img);title('Original Image');
subplot(2,1,2), imshow(SIMG);title('Stego Image');
toc;

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Images en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 18 de Oct. de 2018

Comentada:

el 10 de Feb. de 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by