PCD Watermark

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

clear all; close all; clc; % Initialize the Strength factor(Inisialisasi faktor Kekuatan) alpha=0.

001; % Get The original Input Image(Dapatkan asli Input Berkas) originalImage=imread('cameraman.tif'); watermarkedImage = zeros(512,512) ; % Resize the Original Image into 512512 matrix(Mengubah ukuran Gambar Asli % menjadi 512 512 matriks) inputImage= im2double(imresize(originalImage,[512 512],'bilinear')); figure,imshow(inputImage),title('BASE IMAGE'); % Get The watermark Input Image(Dapatkan The watermark Input Berkas) % Resize the Watermark Image into 6464 matrix(Mengubah ukuran Watermark % Gambar menjadi 64 64 matrix) xx=imread('iislah.JPG'); %xx=rgb2gray(xx);(xx = rgb2gray (xx);) watermarkImage = im2double(imresize(xx,[64 64],'bilinear')); figure,imshow(watermarkImage),title('WATERMARK IMAGE'); w = watermarkImage(:)'; r1=1;r2=8; % Initialize the watermark Image Sub-Block row values(Menginisialisas i watermark gambar nilai baris Sub-Blok) c1=1;c2=8; % Initialize the watermark Image Sub-Block column values(Menginisiali sasi watermark gambar nilai kolom Sub-Blok) count = 0; for i = 1: 64 for j = 1: 64 count = count +1; % Retrive 8X8 sub-block from original Image(Retrive 8X8 sub-blok dari % aslinya Gambar) block = inputImage(r1:r2,c1:c2); % Aplly DCT to Sub-block(Aplly DCT ke Sub-blok) f = dct2(block); % Apply the Watermark formula f(m,n)*w(x,y)*alpha(Terapkan Watermark rumus % f (m, n) * w (x, y) * alpha) f(8,8) = w(count) * alpha; % Apply Inverse DCT to f(Terapkan Inverse DCT untuk f) out = idct2(f); % disp(out);(disp (out);) watermarkedImage(r1:r2,c1:c2) = out; c1=c1+8; c2=c2+8; % disp(count);(disp (count);) end r1=r1+8; r2=r2+8; c1=1;c2=8; end res = im2uint8(watermarkedImage); imwrite(res,'DCTwatermarkedImage.tif','tif');

figure,imshow(res),title('IMAGE AFTER WATERMARKING'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Simple DCT Based Watermark Extracting(DCT Sederhana Berbasis Watermark % Extracting) % Initialize the Strength factor(Inisialisasi faktor Kekuatan) alpha=0.001; w1 = zeros(64,64); inputImage = watermarkedImage; r1=1;r2=8; % Initialize the watermark Image Sub-Block row values(Menginisialisas i watermark gambar nilai baris Sub-Blok) c1=1;c2=8; % Initialize the watermark Image Sub-Block column values(Menginisiali sasi watermark gambar nilai kolom Sub-Blok) count = 0; for i = 1: 64 for j = 1: 64 count = count +1; % Retrieve 8X8 sub-block from original Image(Ambil 8X8 sub-blok dari % aslinya Gambar) block = inputImage(r1:r2,c1:c2); % Apply DCT to Sub-block(Terapkan DCT ke Sub-blok) f = dct2(block); % Apply the Watermark formula f(m,n)*w(x,y)*alpha(Terapkan Watermark rumus % f (m, n) * w (x, y) * alpha) w1(count) = f(8,8) / alpha; c1=c1+8; c2=c2+8; end r1=r1+8; r2=r2+8; c1=1;c2=8; end op = vec2mat(w1,64); imshow(op,[]),title('Extracted Watermark Image');

You might also like