function [ outputImg ] = drawrectangle( image, x, y, width, height, r, g, b ) % This function takes an image along with the coordinates to draw a % rectangle. The last four parameters are the red, green, and blue values % of the rectangle to draw. The image must be a color image. Note that % the x and y coordinates are for the top left corner of the image. % % okay, first let's go ahead and get a copy... tempImg = im2double( image ); % now let's modify the boundaries to the color that we want... % setup the image...remember, we're only drawing a border here... % top horizontal... tempImg( y:y+3, x:x+width, 1 ) = r; tempImg( y:y+3, x:x+width, 2 ) = g; tempImg( y:y+3, x:x+width, 3 ) = b; % bottom horizontal tempImg( y+height-3:y+height, x:x+width, 1 ) = r; tempImg( y+height-3:y+height, x:x+width, 2 ) = g; tempImg( y+height-3:y+height, x:x+width, 3 ) = b; % left & right vertical tempImg( y:y+height, x:x+4, 1 ) = r; tempImg( y:y+height, x:x+4, 2 ) = g; tempImg( y:y+height, x:x+4, 3 ) = b; tempImg( y:y+height, x+width:x+width+4, 1 ) = r; tempImg( y:y+height, x+width:x+width+4, 2 ) = g; tempImg( y:y+height, x+width:x+width+4, 3 ) = b; % now let's return it... outputImg = tempImg; % EOF