Thursday, June 5, 2008

Assign #5, Q3a




Skewing with a factor of s pixels horizontally can done using at least 2 different octave commands; namely, "rem" (return remainder) or "mod" (modulo). The difference between these two functions as outined in octave-help is the manner in which they evaluate negative numbers. In the case of this assignment question either will do.

I will show both.

First take s=1 and use rem(x,y) command.

Octave commands:

bigT=255*ones(256);
bigT(30:79,64:191)=zeros(50,128);
bigT(50:199,111:146)=zeros(150,36);

# as given from assignment question...

for x=1:256
for y=1:256
xnew=x;
ynew=rem(y+x,256)+1;

# rem function returns remainder of (y+x)/256...

newbigT(xnew,ynew)=bigT(x,y);
endfor
endfor

imshow(newbigT)



Next take s=2 and mod(x,y) command.

Octave commands:

bigT=255*ones(256);
bigT(30:79,64:191)=zeros(50,128);
bigT(50:199,111:146)=zeros(150,36);

# as given from assignment question...

for x=1:256
for y=1:256
xnew=x;
ynew=mod((2*x+y),256)+1;
newbigT(xnew,ynew)=bigT(x,y);
endfor
endfor

imshow(newbigT)

No comments: