function effectOfSnr(inputfile,uploadfile,m,min,step,NumberOfFrames, filename)
%The first function to be called in this slide
%this function shows the effect of SNRb on a picture for a fixed value of m
%(the number of repeated elements of a vector when encoding this vector using 
%the repetition code as an error-correcting code)
%Inputs defined by the user from the webdemo page:
%inputfile is a file to be chosen
%uploadfile is a file to be uploaded
%m is the fixed value of m to be chosen
%min is the minimal value of SNRb
%step is the step between the values of SNRb 
%NumberOfFrames is the number of pictures to be shown
if(  strcmp(inputfile,'OwnFile'))
    Im = imread (uploadfile);
    
else
    Im=imread(inputfile);
end

imageDimensions = size(Im);
B=dec2bin(Im,8);
strBinaryVector=reshape(B.',1,[]);
w1=repmat(strBinaryVector,m,1);
strRepeated=w1(:);
strRepeated=strRepeated';
intRepeated =strVecToIntVec(strRepeated);
ModulatedVector=modulation(intRepeated);



EbN0=min:step: min + (step * (NumberOfFrames-1));


SNR=EbN0+10*log10(1/m);
laenge = length(SNR);


for     k = 1:laenge
    
    
    sigma_ch=1/sqrt(2*power(10,SNR(k)/10));
    
    VerrauschtesSignal = awgn_channel(ModulatedVector,sigma_ch) ;
    
    DemodulatedSignal=demodulation(VerrauschtesSignal);
    
    K = correction(DemodulatedSignal,m);
   
    R = reshape (K', 8, [])';
    S2 = bin2dec(int2str(R));
    S4 = uint8(reshape(S2,imageDimensions));
      new_filename = [filename '_' num2str(k-1)];
title(['E_b/N_0 = ' num2str(EbN0)]);
    imwrite (S4,new_filename,'png');
      
    
end

end

