Borrar filtros
Borrar filtros

imshow() black image

2 visualizaciones (últimos 30 días)
Mostfa Abd El-Aziz
Mostfa Abd El-Aziz el 26 de Ag. de 2020
Editada: Mostfa Abd El-Aziz el 26 de Ag. de 2020
%%%%% Complete Code %%%%%%%%%%%
clc
close all
clear
%% Input images
I=imread('gl1.jpg');
I=imresize(I,[512,512]);
logo=imread('watermark.jpg');
logo=imresize(logo,[64,64]);
figure
subplot(1,4,1)
imshow(I)
title('Host Image')
subplot(1,4,2)
B=I(:,:,3); % Blue Channel
imshow(logo)
xlabel('Logo (Watermark Image)')
gf=100; % Watermark Strength
n_dct=60; % <=64
zigzag=[1 9 2 3 10 17 25 18 11 4 5 12 19 26 33 41 34 27 20 13 6 7 14 21 28 35 42 49 57 ...
50 43 36 29 22 15 8 16 23 30 37 44 51 58 59 52 45 38 31 24 32 39 46 53 60 61 54 47 40 48 55 62 63 56 64];
dct_idx=zigzag(1:n_dct);
%% key generation:
key=randperm(512*512,64*64);
%% Block Selection (Embedding Step):
c=0;
Watermarked_B=B;
for i=1:64:64*64-63
c=c+1;
block_index=key(i:i+63);
blockB=double(reshape(B(block_index),[8,8]));
% discrete cosine transform:
dct_blockB=dct2(blockB);
% Singular Value Decomposition:
[U,S,V]=svd(dct_blockB(dct_idx));
sigmaB=S(1); % Biggest Singular Value
% embedding watermark image:
if logo(c)==1
S(1)=sigmaB+gf;
else
S(1)=sigmaB-gf;
end
reference{i}=S;
coeffs=U*S*V; % inverse svd
rec_dct_block=zeros(8);
rec_dct_block(dct_idx)=coeffs;
rec_block=idct2(rec_dct_block); % inverse dct
row_block=reshape(rec_block,1,64);
Watermarked_B(block_index)=row_block;
end
Watermarked_image=I;
Watermarked_image(:,:,3)=Watermarked_B;
subplot(1,4,3),
imshow(Watermarked_image);
title('Watermarked Image')
%% Extraction Step
Ex_watermark=zeros(8);
Watermarked_B=Watermarked_image(:,:,3);
c=0;
for i=1:64:64*64-63
c=c+1;
block_index=key(i:i+63);
blockB=double(reshape(B(block_index),[8,8]));
% discrete cosine transform:
dct_blockB=dct2(blockB);
% Singular Value Decomposition:
[Ub,Sb,Vb]=svd(dct_blockB(dct_idx));
Sbw=reference{i};
sigmaB=Sb(1); % Biggest Singular Value - Host
sigmaBW=Sbw(1); % Biggest Singular Value - Watermarked
% Extracting watermark image:
if sigmaBW>sigmaB
Ex_watermark(c)=1;
end
end
subplot(1,4,4),
imshow(double(Ex_watermark))
xlabel('Extracted Watermark');
  2 comentarios
KSSV
KSSV el 26 de Ag. de 2020
Try:
imshow((Ex_watermark))
Mostfa Abd El-Aziz
Mostfa Abd El-Aziz el 26 de Ag. de 2020
Dear,KSSV i use your recommended suggested code bit the problem still not solved

Iniciar sesión para comentar.

Respuestas (1)

Ezgi Aslan
Ezgi Aslan el 26 de Ag. de 2020
if sigmaBW>sigmaB
Ex_watermark(c)=1;
end
this code doesn't run so Ex_watermark always include zeros (8x8). And shows black image
  4 comentarios
Image Analyst
Image Analyst el 26 de Ag. de 2020
Mostfa, please attach gl1.jpg and watermark.jpg if you need more help.
I'm attaching my own watermarking demo, for what its worth.
Mostfa Abd El-Aziz
Mostfa Abd El-Aziz el 26 de Ag. de 2020
Editada: Mostfa Abd El-Aziz el 26 de Ag. de 2020
Dear , Image Analysy This is my attached images

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by