% color2gray.m
% Takes in a color image (usually in JPG data format) and returns grayscale
% value.
% Probably not the most efficient way to do this, but I am just a young
% padouin in the world of Matlab

function grayscale = color2gray(color_image);

image_dimensions = size(color_image);
image_height = image_dimensions(1);
image_width = image_dimensions(2);
image_colorspace = image_dimensions(3);

red_channel = color_image(1:image_height,1:image_width,1);
blue_channel = color_image(1:image_height,1:image_width,2);
green_channel = color_image(1:image_height,1:image_width,3);

grayscale = (red_channel/3 + blue_channel/3 + green_channel/3);