Azzera filtri
Azzera filtri

how to show output of this code

1 visualizzazione (ultimi 30 giorni)
veenu arora
veenu arora il 19 Ago 2015
Modificato: Walter Roberson il 11 Gen 2016
i have the following code and i want to know output of these operations, i just want my matlab to show the last result
% Author: MLAB Innovation
% wtmark function performs watermarking in DCT domain
% It processes the image into 64x64 blocks.
% im = Input Image
% wt = Watermark Image/ Image to hide
% embimg = Output Embedded image
% Checking Dimnesions
clear all;
im=imread('lena.png'); % original image
wt=imread('w.jpg'); % images used for watermark/hide
hold on;
if length(size(im))>2 % check original image is RGB or gray
im=rgb2gray(im); % convert into gray for further processing
resize the image such that it can be breaked into 8x8 blocks easily
im = imresize(im,[512 512]); % Resize original image so that to break into 8x8 blocks
watermark = imresize(im2bw((wt)),[32 32]);% Resize and Change in binary to fit into 8x8 block
x={}; % empty cell which will consist all blocks or subimage or original image
this will break the image into 8x8 blocks and than take DCT or those blocks
dct_img=blkproc(im,[8,8],@dct2); % DCT of image using 8X8 block
m=dct_img; % DCT transformed original image in which watermark will be inserted
k=1; dr=0; dc=0;
% dr is to address 1:8 row every time for new block in x
% dc is to address 1:8 column every time for new block in x
% k is to change the no. of cell
%%%%%%%%%%%%%%%%%To divide original image in to 64 sub images of 64X64 blocks each %%%%%%%%%%%%%%%%%%
for ii=1:64:512 % To address row -- 64X64 blocks of image
for jj=1:64:512 % To address columns -- 64X64 blocks of image
for i=ii:(ii+63) % To address rows of blocks
for j=jj:(jj+63) % To address columns of block
x{k}=z; k=k+1; % concatinate the total 4096 sub images of 8x8 blocks into cell
z=[]; dr=0; % clear z and dr for next round
% save x in nn it consist of DCT reansformed original image into cell of
% 64 sub images having 64x64 blocks of size each
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%To insert watermark in to blocks%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
i=[]; j=[]; w=1; wmrk=watermark; welem=numel(wmrk); % welem - no. of elements in watermark image
for k=1:64
kx=(x{k}); % Extracting DCT transformed original block of 8x8 size into kx for processing
for i=1:8 % To address row of block
for j=1:8 % To adress column of block
if (i==8) && (j==8) && (w<=welem) % Eligiblity condition to insert watremark
% i=1 and j=1 - means embedding element in first bit of every 8x8 block
if wmrk(w)==0 % if watermark pixel is black
kx(i,j)=kx(i,j)+35; % raise original DCT image pixel by watermark values 35
elseif wmrk(w)==1 % if watermark pixel is white
kx(i,j)=kx(i,j)-35; % down original DCT image pixel by watermark values 35
x{k}=kx; kx=[]; % Watermark value will be replaced in block
%%%%%%%%%%%%%%%%%%%%%%%%%%%%To recombine 64x64x64 cells in to original watermarked image of 512x512 size %%%%%%%%%
i=[]; j=[]; data=[]; count=0;
embimg1={}; % Changing complete row cell of 4096 into 64 row cell
for j=1:8:64
for i=j:(j+7)
% Change 8 row cell in to particular columns to form image
i=[]; j=[]; data=[];
embimg=[]; % final watermarked image
for i=1:8
embimg=[embimg;embimg1{i}]; % Final watermarked image
embimg=(uint8(blkproc(embimg,[8 8],@idct2))); % inverse DCT transform
imwrite(embimg,'out_new.jpg') % save watermarked image

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by