Saturday, August 3, 2013

MATLAB Code to convert the Image to Bayer Format(BGGR)

Img = imread('Input.jpg');
ImgBayer = Img;

ImgBayer(:, 2 : 2 : end, 3) = 0;
ImgBayer(2 : 2 : end, :, 3) = 0;
ImgBayer(1 : 2 : end, :, 1) = 0;
ImgBayer(:, 1 : 2 : end, 1) = 0;
ImgBayer(1 : 2 : end, 1 : 2 : end, 2) = 0;
ImgBayer(2 : 2 : end, 2 : 2 : end, 2) = 0;
imshow(ImgBayer)
imwrite(ImgBayer, 'IMG_Bayer.jpg');