Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 5fef6fe0 authored by DIB Elian's avatar DIB Elian
Browse files

Changed padding parameter

parent 5c3dfa48
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,7 @@ p.addParameter('subSamp' , subSamp , @ischar);
p.addParameter('bitDepth' , bitDepth , @isnumeric);
p.addParameter('inColSpace' , 'rgb' , @ischar);
p.addParameter('outColSpace', 'ycbcr' , @ischar);
p.addParameter('padding' , true , @islogical);
p.addParameter('padding' , 8 , @isnumeric);
p.addParameter('encode' , true , @islogical);
p.addParameter('decode' , true , @islogical);
......@@ -65,11 +65,11 @@ end
% Write input yuv file
if LFParams.encode
[imgSize,imgRes] = LF.write(LFRef,LFParams,'filename',LFParams.refFilename);
[imgSize,imgRes,imgSizePad] = LF.write(LFRef,LFParams,'filename',LFParams.refFilename);
end
% Convert inputs for HEVC
LFHEVCParams = LF.LFtoHEVC(imgSize,imgRes,LFParams,HEVCParams);
LFHEVCParams = LF.LFtoHEVC(imgSizePad,imgRes,LFParams,HEVCParams);
% Encode frames using HEVC
[nbBits,peaksnr] = HEVC.codec(LFHEVCParams,HEVCParams);
......
function [LFRef,LFSizePad] = pad(LFRef,blockSize)
function [LFRef,imgSizePad] = pad(LFRef,padding)
%PAD Pad lightfield data
% [LFRef,LFSizePad] = pad(LFRef,blockSize)
LFSize = size(LFRef);
LFSize(3) = 0;
imgSize = LFSize(1:3);
imgRes = LFSize(4:end);
imgSizePad = ceil(imgSize./blockSize).*blockSize;
imgSizePad = ceil(imgSize./padding).*padding;
imgSizePad(3) = imgSize(3);
LFSizePad = [imgSizePad,imgRes];
padSize = LFSizePad-LFSize;
padSize = [imgSizePad-imgSize,zeros(1,numel(imgRes))];
padSizePre = floor(padSize/2);
padSizePost = padSize - padSizePre;
......
......@@ -7,7 +7,7 @@ filename = fullfile(pwd,'sequence');
% Create input parser scheme
p = inputParser; p.StructExpand = true; p.KeepUnmatched = true;
p.addParameter('filename', filename, @ischar);
p.addParameter('padding' , false , @islogical);
p.addParameter('padding' , 1 , @isnumeric);
% Parse arguments
p.parse(varargin{:});
......@@ -15,13 +15,14 @@ p.parse(varargin{:});
padding = p.Results.padding;
% Recover frames
frames = yuv.read(imgSize,imgRes,varargin{:});
imgSizePad = ceil(imgSize./padding).*padding;
imgSizePad(3) = imgSize(3);
frames = yuv.read(imgSizePad,imgRes,varargin{:});
% Recover LF
LFRec = LF.fromSlices(frames);
if padding
LFRec = LF.unpad(LFRec,[imgSize,imgRes]);
end
% Undo padding
LFRec = LF.unpad(LFRec,imgSize);
end
\ No newline at end of file
function LFRef = unpad(LFRef,LFSize)
function LFRef = unpad(LFRef,imgSize)
%UNPAD Remove padding from lightfield data
% LFRef = unpad(LFRef,LFSize)
LFSizePad = size(LFRef);
imgSizePad = LFSizePad(1:3);
imgRes = LFSizePad(4:end);
padSize = LFSizePad-LFSize;
padSize = [imgSizePad-imgSize,zeros(1,numel(imgRes))];
padSizePre = floor(padSize/2);
padSizePost = padSize - padSizePre;
......
function [imgSize,imgRes] = write(LFRef,varargin)
function [imgSize,imgRes,imgSizePad] = write(LFRef,varargin)
%WRITE Write lightfield 4D(u,v,x,y) data to yuv file
% [LFSize,yuvSize] = WRITE(LFRef,varargin)
......@@ -7,7 +7,7 @@ filename = fullfile(pwd,'sequence');
% Create input parser scheme
p = inputParser; p.StructExpand = true; p.KeepUnmatched = true;
p.addParameter('filename', filename, @ischar);
p.addParameter('padding' , false , @islogical);
p.addParameter('padding' , 1 , @isnumeric);
% Parse arguments
p.parse(varargin{:});
......@@ -22,9 +22,8 @@ m = utils.getMat(filename,true);
m.imgSize = imgSize;
m.imgRes = imgRes;
if padding
LFRef = LF.pad(LFRef,8);
end
% Do padding
[LFRef,imgSizePad] = LF.pad(LFRef,padding);
% Change 5D LF to a collection of 2D frames
frames = LF.toSlices(LFRef);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment