-
Notifications
You must be signed in to change notification settings - Fork 1
/
Unpack.m
27 lines (19 loc) · 961 Bytes
/
Unpack.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function unpackedImage = Unpack(image,marginRatio, marginParam)
%UNPACK Summary of this function goes here
% Detailed explanation goes here
imageSize = size(image);
marginSize = round(imageSize(1,1) * marginRatio);
rMarginWidth = round(imageSize(1,2) / 2);
realMarginRatio = 1 - cos(pi*marginRatio);
rMarginHeight = round(imageSize(1,1) * realMarginRatio * marginParam);
topR = image(1:rMarginHeight,1:rMarginWidth,:);
top = Resize(topR, [marginSize,imageSize(1,2)]);
bottomR = image(1:rMarginHeight,(rMarginWidth+1):imageSize(1,2),:);
bottom = Resize(bottomR,[marginSize,imageSize(1,2)]);
middleR = image((rMarginHeight+1):imageSize(1,1),:,:);
mid = Resize(middleR, [imageSize(1,1) - (2*marginSize), imageSize(1,2)]);
unpackedImage = zeros(imageSize, 'uint8');
unpackedImage(1:marginSize,:,:) = top;
unpackedImage((imageSize(1,1) - marginSize+1):imageSize(1,1),:,:) = bottom;
unpackedImage((marginSize+1):(imageSize(1,1) - marginSize),:,:)= mid;
end