matlab infinity,Can PSNR be infinity

[i11,i12]=uigetfile('*.jpg;*.png;*.tif;*bmp');

i12=strcat(i12,i11);%String Concatenation

i1=imread(i12);%Image is read and stored in the variable i1

i1= imresize(i1,[256 256]);%resizing the image with new dimensions as 512*512

[l,m,n]=size(i1);%displaying the dimensions of Image

P1=im2double(i1);%Convert the integer image into double image as it gives more Precised value

%Did 3 level DWT

[F1,F2]= wfilters('haar','d');

[LL,LH,HL,HH] = dwt2(P1,'haar','d');%One Level DWT

[LL1,LH1,HL1,HH1] = dwt2(LL,'haar','d');%Two Level DWT

[LL2,LH2,HL2,HH2] = dwt2(LL1,'haar','d')%Three Level DWT

[a,b]= uigetfile('*.jpg;*.png;*.tif;*bmp');%Fetching the Image to be watermarkedXXXXXXXXXX%

b= strcat(b,a);%String Concatenation

c=imread(b);%Image is read and stored in the variable c

c= imresize(c,[64 64]);%resizing the image with new dimensions as 64*64

[p,q,r]=size(c);%displaying the dimensions of Image

%%%%%%%%%Cipher watermark%%%%%%%%%%%%%%%%%%%%%

scrambleOrder = randperm(p*q);

redChannel = c(:, :, 1);

greenChannel = c(:, :, 2);

blueChannel = c(:, :, 3);

redChannel = redChannel(scrambleOrder);

greenChannel = greenChannel(scrambleOrder);

blueChannel = blueChannel(scrambleOrder);

redChannel = reshape(redChannel, [p,q]);

greenChannel = reshape(greenChannel, [p,q]);

blueChannel = reshape(blueChannel, [p,q]);

s = cat(3, redChannel, greenChannel, blueChannel);

%converting the encrypted image into one level dwt

f= im2double(s);

[F1,F2]= wfilters('haar','d');

[LL11,LH11,HL11,HH11] = dwt2(f,'haar','d');%one level dwt of the encrypted image

%LL11 = imresize(LL11,[64 64]);

k = LL2 + 0.001*LL11.*LL2;

Watermarkedimage_level1= idwt2(k,LH2,HL2,HH2,'haar');%reconstruction of the watermark level3

Watermarkedimage_level2=idwt2(Watermarkedimage_level1,LH1,HL1,HH1,'haar');%reconstruction of the watermark level2

Watermarkedimage_final=idwt2(Watermarkedimage_level2,LH,HL,HH,'haar');%reconstruction of the watermark level1

%%%%%%%%%%%%%%%rotation attack%%%%%%%%%%%%%%%%%%%%%%%

%data = clipboard('pastespecial')

J = imresize(Watermarkedimage_final,[220 140]);

[N1 L1 B1] = size(J);

%axis tight;

%%%%%%%PSNR and MSE between Host Image and Watermarked

%%%%%%%Image%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%Recovery of watermark fromm attacked image%%%%%%%%%%%%%%%%%%%%%%%%%%

[a b c1 d]=dwt2(J,'haar','d');

[aa bb cc dd]=dwt2(a,'haar','d');

[aaa bbb ccc ddd]=dwt2(aa,'haar','d');

aaa = imresize(aaa,[N1/3 L1/3]);

LL2 = imresize(LL2,[N1/3 L1/3]);

Recovered_watermark = [(aaa ./LL2)-1]./0.001;

%imshow(Recovered_watermark);

Recovered_watermark1 = imresize(Recovered_watermark,[32 32]);

Wavelet_reconstruction=idwt2(Recovered_watermark1,LH11,HL11,HH11,'haar');

[u v z] = size(Wavelet_reconstruction);

%scrambleOrder1 = randperm(u*v);

%%%%%%%%%%Decryption of Watermark%%%%%%%%%%%

recoverOrder = zeros([u*v], 2);

recoverOrder(:, 1) = 1 : (u*v);

recoverOrder(:, 2) = scrambleOrder;

newOrder1 = sortrows(recoverOrder, 2);

newOrder = newOrder1(:,1);

redChannel = redChannel(newOrder);

greenChannel = greenChannel(newOrder);

blueChannel = blueChannel(newOrder);

redChannel = reshape(redChannel, [u, v]);

greenChannel = reshape(greenChannel, [u, v]);

blueChannel = reshape(blueChannel, [u, v]);

D = cat(3, redChannel, greenChannel, blueChannel);

s= im2double(s);

squaredErrorImage = (c-D).^ 2;

MSE=sum(sum(squaredErrorImage)) / (p* q)

MaxI=1;%maX INDICATES THE Maximum Value of the Pixles

PSNR=10*log10((MaxI^2)/MSE)

channelToCorrelate = 1;% Use the red channel.

correlationOutput = normxcorr2(D(:,:,1), c(:,:, channelToCorrelate));

[rows, columns, numberOfColorBands] = size(correlationOutput);

[maxCorrValue, maxIndex] = max(abs(correlationOutput(:)))

channelToCorrelate = 2;% Use the green channel.

correlationOutput = normxcorr2(D(:,:,1), c(:,:, channelToCorrelate));

[rows, columns, numberOfColorBands] = size(correlationOutput);

[maxCorrValue, maxIndex] = max(abs(correlationOutput(:)))

channelToCorrelate = 3;% Use the green channel.

correlationOutput = normxcorr2(D(:,:,1), c(:,:, channelToCorrelate));

[rows, columns, numberOfColorBands] = size(correlationOutput);

[maxCorrValue, maxIndex] = max(abs(correlationOutput(:)))

subplot(3, 3, 1);imshow(i1);title('Message Image');

subplot(3, 3, 2);imshow(c);title('Watermark image');

subplot(3, 3, 3);imshow(s);title('Encrypted Watermark');

subplot(3,3,4);imshow(Watermarkedimage_final);title('Watermarked Final');

subplot(3, 3, 5);imshow(J);title('Scaled Watermarked Image');

subplot(3, 3, 6);imshow(D);title('Decrypted Watermark');

figure;surf(correlationOutput);title('correlationOutput');

%%%%%%%PSNR and MSE between Host Image and Watermarked

%%%%%%%Image%%%%%%%%%%%%%%%%%%%%

%squaredErrorImage = (P1 - J) .^ 2;

%%MSE=sum(sum(squaredErrorImage)) / (l * m)

%MaxI=1; %maX INDICATES THE Maximum Value of the Pixles

%PSNR=10*log10((MaxI^2)/MSE)

%%%%%%%%%%%%%PSNR and MSE between Encrypted and Extracted

%%%%%%%%%%%%%Image%%%%%%%%%%%%%%%%%%%%

%i3= im2double(i3);

%squaredErrorImage = (s - Wavelet_reconstruction).^ 2;

%MSE=sum(sum(squaredErrorImage)) / (p* q)

%MaxI=1; %maX INDICATES THE Maximum Value of the Pixles

%PSNR=10*log10((MaxI^2)/MSE)

%%%%%%%PSNR and MSE between watermark and Decrypted

%%%%%%%Image%%%%%%%%%%%%%%%%%%%%%%%%

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值