Borrar filtros
Borrar filtros

How to get file (video) from PSNR on the video compression?

3 visualizaciones (últimos 30 días)
Joni Afria
Joni Afria el 10 de Jul. de 2019
Comentada: Joni Afria el 12 de Jul. de 2019
I am a student
I have a project fro my lecturer to analyze video compression. I don't know how to get file (video) from the variable video compression (PSNR).
can anyone help me?
thank you

Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Jul. de 2019
You cannot do that. Psnr is a statistical measure. You cannot recover the image from it.
  6 comentarios
Joni Afria
Joni Afria el 11 de Jul. de 2019
% *************************************************************************
%% H.264/AVC DECODER
% It works on YUV sequence
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This script/function was created by
% Abdullah Al Muhit
% contact - Almuhit [At] Gmail.com
% website - https://sites.google.com/site/almuhit/
% Please use it at your own risk. Also, Please cite the following paper:
% A A Muhit, M R Pickering, M R Frater and J F Arnold, “Video Coding using Elastic Motion Model and Larger Blocks,” IEEE Trans. Circ. And Syst. for Video Technology, vol. 20, no. 5, pp. 661-672, 2010. [Impact factor – 3.18] [PDF]
% A A Muhit, M R Pickering, M R Frater and J F Arnold, “Video Coding using Geometry Partitioning and an Elastic Motion Model,” accepted for publication in Journal of Visual Communication and Image Representation. [Impact factor – 1.33] [PDF]
% Modification is done by Ali Radmehr
% Feel free to contact us: Radmehr.Telecom [AT] Gmail.Com
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Initialization
clear all;
clc;
close all;
tic
system_dependent('DirChangeHandleWarn', 'Never');
addpath(genpath('.'));
%% Input - load the encoded file
load ./bitstream_enc.mat; % correct packets
global h w QP block_size
%%%%%%%%%%%%%%%%%%%%
Frame_start = 20; % I frame
Frame_end = 25; % Following P frames
FrameNo = 1+(Frame_end-Frame_start);
%%%%%%%%%%%%%%%%%%%%
width = 176;
height = 144;
[mov,imgRgb] = loadFileYuv('suzie_qcif.yuv',width,height,Frame_start:Frame_end); % loading yuv file
mov_yuv = zeros(height,width,3,FrameNo); % (h,w,y/u/v,number of frames!!
% Deviding yuv components.
% Just y component is needed!
mov_y = zeros(height,width,FrameNo);
for i =1:FrameNo
mov_yuv(:,:,:,i) = double(mov(i).cdata);
mov_y(:,:,i) = mov_yuv(:,:,1,i);
end
%-------------------------
idx = 1;
block_size = 16; % change blocksize if needed!
%---------------------------------------------------------
% Decode header
[h,w,QP,Frame_start,Frame_end,m] = dec_header(bitstream);
idx = idx + m - 1;
N = 1 + (Frame_end - Frame_start);
if (strcmp(bitstream(idx:idx+3),'1111'))
disp('Decoding I Frame')
idx = idx + 4;
[Ceq_r(:,:,1),idx]=decode_i_frame(idx,bitstream);
Ceq(:,:,1) = mov_y(:,:,1);
PSNR_rec(1)=find_psnr(Ceq(:,:,1),Ceq_r(:,:,1));
PSNR_rec_ec(1)=find_psnr(Ceq(:,:,1),Ceq_r(:,:,1));
end
Ceq_r_ec(:,:,1) = Ceq_r(:,:,1);
figure(1)
pause(1)
image(Ceq_r_ec(:,:,1))
title(['Frame No. ' num2str(Frame_start)]);
colormap(gray(256))
truesize([2*h 2*w])
drawnow
for k = 2:N
if (strcmp(bitstream(idx:idx+3),'0000'))
disp('Decoding P Frame')
idx = idx + 4;
%-----------PERFORMING EC ON THE ERRONEOUS FRAME---------------
B=0; %1.4; % Average Burst Length
PLR=0; %5/100; % Packet Loss Rate
[Ceq_r_ec(:,:,k),idx,ErrorMat]= decode_p_frame(idx,bitstream,Ceq_r_ec(:,:,k-1),B,PLR); % decoding using ec
if isempty(ErrorMat) == 0 % if there is any error, EC would be applied.
Ceq_r_ec(:,:,k) = EC(Ceq_r_ec(:,:,k),Ceq_r_ec(:,:,k-1),ErrorMat,1,block_size); %mode 1 is frame-copy method.
end
% visualizing the decoded frame with error concealment
figure(1)
image(Ceq_r_ec(:,:,k))
title(['Frame No. ' num2str(Frame_start+k-1)]);
colormap(gray(256))
truesize([2*h 2*w])
drawnow
pause(1)
%--------------------------------------------------------------
Ceq(:,:,k) = mov_y(:,:,k);
%PSNR_rec(k) = find_psnr(Ceq(:,:,k),Ceq_r(:,:,k));
PSNR_rec_ec(k) = find_psnr(Ceq(:,:,k),Ceq_r_ec(:,:,k));
end
end
% disp(['average PSNR without any error concealment is: ', num2str(mean(PSNR_rec))])
disp([ 'average PSNR with frame-copy error concealment is: ', num2str(mean(PSNR_rec_ec))])
toc
Joni Afria
Joni Afria el 12 de Jul. de 2019
Mr @walter roberson
but, now i have new problem, the video just play one frame for 5 second. Can you help me Mr?

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by