%% Fuzzy_Paper Implementation : 
%  IEEE TRANSACTIONS ON FUZZY SYSTEMS, VOL. 20, NO. 4, AUGUST 2012
%  ---------------------------------------------------------------
clear all;

%% Synthetic Data Generation 
%  -------------------------

param.dict_size  = 50;            % dictionary size
param.patch_size  = 5;            % image patch size
param.num_patch   = 10000;            % number of Document to sample
param.upscale      = 1.6;            % upscaling factor
param.ovrlap       = 3;

param.lDim = 4*param.patch_size^2; 
param.hDim = param.patch_size^2; 
sig = 7.5;                          % paretres of the sinthesized data 

cntr = ceil(sig)*(1:param.lDim);            % Data center

X = [];
for i = 1:param.dict_size
    X = [X; repmat(circshift(cntr, [1, i]), param.num_patch/param.dict_size, 1) + ...
        sig*randn([param.num_patch/param.dict_size, param.lDim])]; % Class i
end

X = X./repmat(sqrt(sum(X.^2, 2))+eps, 1, param.lDim);

cl_lv = [];
for i = 1:param.dict_size
    cl_lv = [cl_lv; i*ones(param.num_patch/param.dict_size, 1)];
end

%% Cluster each of the classes into smaller sub-clusters

W = RandOrthMat(param.lDim); 
Y = X*W(:, 1:param.hDim); 

XY = [X, Y]; 

[IDX, C] = kmeans(XY, param.dict_size); 

C = C(:, 1:param.lDim); 
% clear('CC', 'X1', 'X2', 'idx', 'cntr', 'i', 'c', 'c1', 'c2', 'ft', 'cnt', 'perm', 'id', 'cl_lv'); 

