Comparing 2 frames from video
3 次查看(过去 30 天)
显示 更早的评论
I want to compare first video frames from original video and edited video, when i'm comparing r and r2 it always show error :
Error in psnr (line 3)
original_img=double(original_img);
Output argument "MSE" (and maybe others) not assigned during call to "psnr".
Error in videoStego (line 186)
[P,MSE]=psnr(r,r2);
But if i'm comparing other variables like r and b2, g and r2, etc it just run smoothly. Here is my code:
ori = VideoReader('Ori.avi');
frame = read(ori,1);
img=frame(:,:,:,1);
r=img(:,:,1);
g=img(:,:,2);
b=img(:,:,3);
edited = VideoReader('Edited.avi');
frame2 = read(v,1);
img2=frame2(:,:,:,1);
r2=img2(:,:,1);
g2=img2(:,:,2);
b2=img2(:,:,3);
[P,MSE]=psnr(r,r2);
And here is the psnr code:
function [P,MSE]=psnr(original_img,stego_img)
original_img=double(original_img);
stego_img=double(stego_img);
if (original_img==stego_img)
PSNR=100;
else
m = size(original_img,1);
n = size(stego_img,2);
d = 0 ;
for i = 1:m-1
for j = 1:n-1
d = d + (original_img(i,j) - stego_img(i,j)).^2 ;
end
end
MSE=d/(m*n);
MAX = max( abs(original_img(:)) );
PSNR= 10*log10(MAX^2/MSE);
end
P=PSNR;
0 个评论
采纳的回答
Stephan
2021-6-17
Try:
function [P,MSE]=Untitled(original_img,stego_img)
original_img=double(original_img);
stego_img=double(stego_img);
if (original_img==stego_img)
PSNR=100;
MSE=0; % Added this line
else
m = size(original_img,1);
n = size(stego_img,2);
d = 0 ;
for i = 1:m-1
for j = 1:n-1
d = d + (original_img(i,j) - stego_img(i,j)).^2 ;
end
end
MSE=d/(m*n);
MAX = max( abs(original_img(:)) );
PSNR= 10*log10(MAX^2/MSE);
end
P=PSNR;
end
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!