%%MATH3360 tutorial1 Introduction on basic programming about imaging
%Input the image called 'pokemon_go.png' to Matlab, 
%pay attention that the data type is now 'uint8'
I=imread('pokemon_go.png'); 

I_R=I(:,:,1); %Red channel of image I
I_G=I(:,:,2); %Green channel of image I
I_B=I(:,:,3); %Blue channel of image I
%Save the red channel image and call it 'Red.jpg'
imwrite(I_R,'Red.jpg'); 
%Save the green channel image and call it 'Green.jpg'
imwrite(I_G,'Green.jpg'); 
%Save the blue channel image and call it 'Blue.jpg'
imwrite(I_B,'Blue.jpg'); 
I=I./2; %Make the intensity lower
imwrite(uint8(I),'darker.jpg');
%Visualize blue channel only in RGB format
I(:,:,1)=0;
I(:,:,2)=0;
imwrite(uint8(I),'blue_rgb.jpg');
%Make the image have maximum contrast among all three color channels
I=imread('bad_contrast.jpg');
I=double(I);
%First make the image intensity in the range of [0,1], 
%then multiply them by 255, i.e. the 8-bit color
I_contrast=(I-min(min(min(I))))./(max(max(max(I)))-min(min(min(I)))).*255;
imwrite(uint8(I_contrast),'contrast.jpg');

