function [Csize,scoremax,CLabmax]=trysizes(I,Tfilename,M,My_sizes)
%This functions calculates the combined correlation for each of the sizes
%given, and computes which size provides the maximum correlation. The
%result is the correct size, the maximum correlation value and the combined
%correlation itself.

[imx,imy,imz]=size(I);
scores=zeros(11,1);

CLab=zeros(imx,imy,length(My_sizes));

for k=1:length(My_sizes)
    %Calculate combined correlation.
    CLab(:,:,k)=combined_corr(Tfilename,My_sizes(k),I,M);
    %Compute maxima.
    scores(k)=max(max(CLab(:,:,k)));
end

%Choose the correct size as a function of the highest correlation value.

scoremax=max(scores);
Csize=My_sizes(min(find(scores==scoremax)));
CLabmax=CLab(:,:,min(find(scores==scoremax)));
