chess - to extract the correct channel, you have to remember that it is the third dimension that indicates colour. So if img is your 1024x1024x3 image, then
red = img(:,:,1);
green = img(:,:,2);
blue = img(:,:,3);
Remember that image is a built-in MATLAB function, and so is not a good name for a local variable.