function output=threshold(input,level)

%This function applies a simple threshold to an image
%on being given a specific threshold value
%-----------------------------------------------------

input=double(input);
[rows,cols]=size(input);
output=zeros([rows,cols]);


for i=1:1:rows
    for j=1:1:cols
                
        if (input(i,j)<level))
                output(i,j)=0;
                        
            else
                output(i,j)=255;
        end
    end;
end;             
output=uint8(output);
