How to reduce code execution time ?

1 view (last 30 days)
Nimisha
Nimisha on 8 Aug 2018
Edited: KALYAN ACHARJYA on 8 Aug 2018
clc;
clear all;
%secret image
a=imread('secret1.bmp');
%a=rgb2gray(a);
a=a(:,:,1);
figure,
imshow(a);
title('secret image');
%cover image1
b=imread('secret2.bmp');
%b=rgb2gray(b);
b=b(:,:,1);
figure,
imshow(b);
title('Cover image 1');
%cover image2
e=imread('secret3.bmp');
e=e(:,:,1);
figure,
imshow(e);
title('Cover image 2');
d=uint8(zeros(size(a)));
%output
for i=1:256;
for j=1:256;
d(i,j)=bitset(d(i,j),8,bitget(e(i,j),8));
h=fi(b(i,j),0,8,0);
%b=bin(a);
k(i,j)=bitror(h,1);
g(i,j)= uint8(k(i,j));
d(i,j)=bitset(d(i,j),7,bitget(bitxor(a(i,j),(g(i,j))),7));
d(i,j)=bitset(d(i,j),6,bitget(bitxor(a(i,j),(g(i,j))),6));
d(i,j)=bitset(d(i,j),5,bitget(bitxor(a(i,j),(g(i,j))),5));
d(i,j)=bitset(d(i,j),4,bitget(bitxor(a(i,j),(g(i,j))),4));
d(i,j)=bitset(d(i,j),3,bitget(bitxor(a(i,j),(g(i,j))),3));
d(i,j)=bitset(d(i,j),2,bitget(bitxor(a(i,j),(g(i,j))),2));
d(i,j)=bitset(d(i,j),1,bitget(bitxor(a(i,j),(g(i,j))),1));
end
end
figure,
imshow(d);
title('output');
Above image Pixels having 8bits. I want to Read 1 to 7 BITS of Image1, and 8th BIT from Image2. And create a New Image then i want to Hide Image3 in Newly Created Image and want to Generate Output. Code for same is working very slow.! Please suggest to do fast operation.
  1 Comment
KALYAN ACHARJYA
KALYAN ACHARJYA on 8 Aug 2018
Edited: KALYAN ACHARJYA on 8 Aug 2018
Attach the images, so that we can try, What is the execution time in your case? use tic toc. Try to avoid multiple for loops

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!