-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDCTNet_Blockwise_Histogram.m
23 lines (18 loc) · 1.01 KB
/
DCTNet_Blockwise_Histogram.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
% Author : Cong Jie, Ng
% Paper : Ng, C. J., and Teoh, A. B. J. "DCTNet: A Simple Learning-Free Approach for Face Recognition." In 2015 Asia-Pacific Signal and Information Processing Association Annual Summit and Conference (APSIPA), 761-68, 2015.
function OutHists = DCTNet_Blockwise_Histogram(InHashedImgs, Params)
OutHists = {};
blkSize = Params.HistBlockSize;
for i = 1:length(InHashedImgs)
hashedImg = InHashedImgs{i};
% Crop HashedImg to center, in case HashedImg size is not divisible by BlockSize
[h, w] = size(hashedImg);
margin = [h w] - blkSize .* floor([h w] ./ blkSize);
margin1 = round(margin / 2);
margin2 = margin - margin1;
hashedImg = hashedImg((margin1(1) + 1):(end - margin2(1)),(margin1(2) + 1):(end - margin2(2)));
% Block-Wise Histogramming
blockwiseHist = histc(im2col(hashedImg, blkSize, 'distinct'),(0:2^Params.NumFilters(end)-1)');
OutHists = cat(1, OutHists, blockwiseHist);
end
end