m=480; n=480;
fin=fopen('arrayR.raw','r');
X=fread(fin,m*n,'uint8=>uint8'); fclose(fin);
Y=reshape(X,m,n);
Y=Y';
for i=1:m
    for j=1:n
        if(Y(i,j)<=30)
            Y(i,j) = uint8(double(Y(i,j))/double(30)*10.0);
        elseif(Y(i,j)<=60)
            Y(i,j) = uint8(30+double(Y(i,j)-30)/double(30)*10.0);
        elseif(Y(i,j)<=100)
            Y(i,j) = uint8(60+double(Y(i,j)-60)/double(60)*200.0);
        end
    end
end
figure;
subplot(1,2,1);imshow(Y);title('arrayR.raw');
subplot(1,2,2);histogram(Y);

m=512; n=512;
fin=fopen('Whorl.raw','r');
X=fread(fin,m*n,'uint8=>uint8'); fclose(fin);
Y=reshape(X,m,n);
Y=Y';
figure;
for i=1:n
    for j=1:m
        if(Y(i,j)<=125)
            Y(i,j) = uint8(double(Y(i,j))/double(125)*40.0);
        elseif(Y(i,j)<=200)
            Y(i,j) = uint8(125+double(Y(i,j)-125)/double(75)*50.0);
        else
            Y(i,j) = uint8(200+double(Y(i,j)-200)/double(max(Y(:))-200)*55.0);
        end
    end
end
subplot(1,2,1);
imshow(Y);
title('Whorl.raw');
subplot(1,2,2);
histogram(Y);

m=480; n=640;
fin=fopen('gelm1.raw','r');
X=fread(fin,m*n,'uint8=>uint8'); fclose(fin);
Y=reshape(X,m,n);
Y=Y';
figure;
for i=1:n
    for j=1:m
        if(Y(i,j)<=60)
            Y(i,j) = uint8(double(Y(i,j))/double(60)*20.0);
        elseif(Y(i,j)<=100)
            Y(i,j) = uint8(60+double(Y(i,j)-60)/double(40)*20.0);
        else
            Y(i,j) = uint8(100+double(Y(i,j)-100)/double(max(Y(:))-100)*200.0);
        end
    end
end
subplot(1,2,1);
imshow(Y);
title('gelm1.raw');
subplot(1,2,2);
histogram(Y);
