DivImg - %gets the left half of the image out2 = img,halfcols 1:end%gets the right half of the image out3 = false out4 = false case'q Return all 4

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function [out1 out2 out3 out4] = divImg(img,mode) f % Find the size [rows cols clr] = size(img); % Find halfway halfrows = ceil(rows./2); halfcols = ceil(cols./2); switch mode %must use switch, because mode is a string that needs to be compared to %multiple cases case 'tb' % Return the top and bottom halves out1 = img(1:halfrows,:,:); %gets the top half of the image out2 = img(halfrows+1:end,:,:); %gets the bottom half of the image out3 = false; out4 = false; case 'lr' % Return the left and right halves out1 = img(:,1:halfcols,:);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %gets the left half of the image out2 = img(:,halfcols+1:end,:); %gets the right half of the image out3 = false; out4 = false; case 'q' % Return all 4 quadrants out1 = img(1:halfrows,1:halfcols,:); %gets the top left corner of the image out2 = img(1:halfrows,halfcols+1:end,:); %gets the top right corner of the image out3 = img(halfrows+1:end,1:halfcols,:); %gets the bottom left corner of the image out4 = img(halfrows+1:end,halfcols+1:end,:); %gets the bottom right corner of the image end end...
View Full Document

This note was uploaded on 10/21/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Institute of Technology.

Ask a homework question - tutors are online