1 % =================================================================
2 % Sparse Feature Fidelity (SFF) Version 2.0
3 % Copyright(c) 2013 Hua-wen Chang
5 % ----------------------------------------------------------------
6 % Please refer to the following paper
8 % Hua-wen Chang, Hua Yang, Yong Gan, and Ming-hui Wang, "Sparse Feature Fidelity
9 % for Perceptual Image Quality Assessment", IEEE Transactions on Image Processing,
10 % vol. 22, no. 10, pp. 4007-4018, October 2013
11 % ----------------------------------------------------------------------
12 % GET SAMPLE PATCHES FROM NATURAL IMAGES
15 % samples total number of patches to take
16 % patchSize patch width in pixels
19 % X the image patches as column vectors
21 % There are two sets of images for sampling and training data1 and data2
22 % =================================================================
23 function X = sampleimages(samples, patchSize)
26 getsample = floor(samples/dataNum);
27 patchDim = (patchSize^2)*3;
28 X = zeros(patchDim,samples);
32 if i==dataNum, getsample = samples-sampleNum+1; end
34 I = imread(['data1/' num2str(i) '.ppm']);
37 % Sample patches in random locations
40 posx = floor(rand(1,getsample)*(sizex-patchSize-2))+1;
41 posy = floor(rand(1,getsample)*(sizey-patchSize-1))+1;
43 X(:,sampleNum) = reshape( I(posy(1,j):posy(1,j)+patchSize-1, posx(1,j):posx(1,j)+patchSize-1, 1:3),[patchDim 1]);
44 sampleNum=sampleNum+1;