% Description:
%
%       choose7.m returns an index of which image the chosen blocks come
%       from.
%       For scenes with less than 7 exposures, repeat an image used
%       earlier.
%       
% Input:
%
%       d - side of a block
%       image* - image at a given exposure
%
% Output:
%
%       index - index of which image the chosen blocks come from
%

function [index] = choose7(d,image1,image2,image3,image4,image5,image6,image7)

[row, col, rgb] = size(image1);
index = zeros(row/d, col/d);

for j = 1:1:row/d;
    for k = 1:1:col/d;
        
        E = -1;
        
        Ecur = entropyC(image1((j-1)*d+1:j*d,(k-1)*d+1:k*d,:));
        if Ecur > E
            E = Ecur;
            ntemp = 1;
        end
        
        Ecur = entropyC(image2((j-1)*d+1:j*d,(k-1)*d+1:k*d,:));
        if Ecur > E
            E = Ecur;
            ntemp = 2;
        end
        
        Ecur = entropyC(image3((j-1)*d+1:j*d,(k-1)*d+1:k*d,:));
        if Ecur > E
            E = Ecur;
            ntemp = 3;
        end
        
        Ecur = entropyC(image4((j-1)*d+1:j*d,(k-1)*d+1:k*d,:));
        if Ecur > E
            E = Ecur;
            ntemp = 4;
        end
        
        Ecur = entropyC(image5((j-1)*d+1:j*d,(k-1)*d+1:k*d,:));
        if Ecur > E
            E = Ecur;
            ntemp = 5;
        end
        
        Ecur = entropyC(image6((j-1)*d+1:j*d,(k-1)*d+1:k*d,:));
        if Ecur > E
            E = Ecur;
            ntemp = 6;
        end
        
        Ecur = entropyC(image7((j-1)*d+1:j*d,(k-1)*d+1:k*d,:));
        if Ecur > E
            E = Ecur;
            ntemp = 7;
        end
        
        index(j,k) = ntemp;
        
    end
end