resizeImage - [r c clr = size(imarr if ischar(nw Ştermines...

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

View Full Document Right Arrow Icon
function reimarr = resizeImage(imarr,nw,nh) %Write a function resizeImage that will use the round(linspace()) method %of resizing to resize an image. The new width and height may be input %in one of three ways: %- As a double representing the new size in pixels (50) %- As a string representing the new size in pixels ('42') %- As a string representing a percentage of the old size ('50%') %Thus, if you have an image that is 240x320, the following are valid %methods of resizing it to 420x240: %newimg = resizeImage(img,420,'240'); %newimg = resizeImage('200%',240); %newimg = resizeImage('200%','75%'); %Hint: %If you write a helper function that deals with your width, you can %reuse it for your height and save yourself some code.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: [r c clr] = size(imarr); if ischar(nw) %determines whether the new width is a string if strcmp(nw(end),'%') %determines if the number is a percentage a = str2num(nw(1:end-1)); %converts the actual numbers of the string into double num = (a./100).*c; %figures out the correct number of columns if the input is a %percent else num = str2num(nw); %if not a percent, then convert to double end else num = nw; end if ischar(nh) if strcmp(nh(end),'%') b = str2num(nh(1:end-1)); num2 = (b./100).*r; else num2 = str2num(nh); end else num2 = nh; end rind = round(linspace(1,r,num2)); cind = round(linspace(1,c,num)); reimarr = imarr(rind,cind,:);...
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 Tech.

Ask a homework question - tutors are online