Wednesday, June 11, 2008

Q#3(ii) Picture



Q#3(b)
Average Colour of second image

Octave Commands
octave-3.0.0.exe:47> a=imread("pic2.jpg");
octave-3.0.0.exe:48> b=double(a)/255;
octave-3.0.0.exe:49> size(b)
ans =

541 500 3

octave-3.0.0.exe:50> c=sum(sum(b))/(541*500)
c =

ans(:,:,1) = 0.56223
ans(:,:,2) = 0.62916
ans(:,:,3) = 0.65633


octave-3.0.0.exe:51> d=ones(256);
octave-3.0.0.exe:52> d(:,:,1)=0.56223*ones(256);
octave-3.0.0.exe:53> d(:,:,2)=0.62916*ones(256);
octave-3.0.0.exe:54> d(:,:,3)=0.65633*ones(256);
octave-3.0.0.exe:55> imshow(d);

Assignment#6 Q3



Q#3(c)

Average colour of two assigned pictures
For this assignment Paul helped me alot in downloading assigned pictures.
pkg load image
a=imread("pic1.jpg");
b=double(a)/255;

avgb=sum(sum(b))/(650*780)

c=ones(256);
c(:,:,1)=0.95854*ones(256);
c(:,:,2)=0.95091*ones(256);
c(:,:,3)=0.94792*ones(256);
imshow(c)

Monday, June 9, 2008

Q#3a continued..


Average of colours
octave-3.0.0.exe:14> sum(sum(A))/100/100,
ans =

ans(:,:,1) = 1
ans(:,:,2) = 0.50500
ans(:,:,3) = 0


octave-3.0.0.exe:15> imshow(sum(A));

Assignment #6 Q3


Q#3 Detrmine the average color
a) R=ones(100); G=tril(ones(100));, B=zeros(100);
Ans:
octave-3.0.0.exe:5> A(:,:,1)=ones(100);
octave-3.0.0.exe:6> A(:,:,2)=tril(ones(100));
octave-3.0.0.exe:7> A(:,:,3)=zeros(100);
octave-3.0.0.exe:8> imshow(A);

Assignment #6 Q2


Q#2 create a 256 X 256 matrix with in (i,i+1) position and zeros elsewhere
Octave Commands:
A= zeros(256);
for i=1:256;
A(i,i+1)=1;
end;
imshow(A);
or
octave-3.0.0.exe:8> A=tril(ones(256),1);
octave-3.0.0.exe:9> B=tril(ones(256),0);
octave-3.0.0.exe:10> imshow(A-B);

Question#3c


Big T 7pi/4
Octave Command
bigT=255*ones(256);
bigT(30:79,64:191)=zeros(50,128);
bigT(50:199,111:146)=zeros(150, 36);
for x = 1:256
for y = 1:256
newy=rem(2*x+y,256)+1;
bigTskew(x,y)=bigT(x,newy);
end;
end;
for x=1:256;
for y=1:256;
bigTskewrotate(x,y)=bigTskew(mod(round(x*cos(7*pi/4)-y*sin(7*pi/4)),256)+1, mod(round(x*sin(7*pi/4)+y*cos(7*pi/4)),256)+1);
end;
end;
imshow(bigTskewrotate);

Question #3 b











BigT for S=1
Octave commandoctave-3.0.0.exe:5>
octave-3.0.0.exe:5> bigT=255*ones(256);
octave-3.0.0.exe:6> bigT(30:79,64:191)=zeros(50,128);
octave-3.0.0.exe:7> bigT(50:199,111:146)=zeros(150,36);
octave-3.0.0.exe:8>
octave-3.0.0.exe:8> # as given from assignment question...
octave-3.0.0.exe:8>
octave-3.0.0.exe:8> 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
octave-3.0.0.exe:9>
octave-3.0.0.exe:9> imshow(newbigT)
octave-3.0.0.exe:10>

Wednesday, June 4, 2008

Q#3


Q#3
Image of Big T
Part a)

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

Assignment #5 Q#2

Q#2:Give octave commands to draw the top part of figure 6.4 in the book
Ans:


Octave commands:

octave-3.0.0.exe:34> C=zeros(256);
octave-3.0.0.exe:35> functionC=circle(x,y)
error: `circle' undefined near line 35 column 11
error: evaluating assignment expression near line 35, column 10
octave-3.0.0.exe:35> function C=circle(x,y)
> for i=1:256
> for j=1:256
> if (i-x)^2+(j-y)^2 <=2500
> C(i,j)=1;
> else
> C(i,j)=0;
> endif
> endfor
> endfor
> endfunction
octave-3.0.0.exe:36> C(:,:,1)=circle(142,103);
octave-3.0.0.exe:37> C(:,:,2)=circle(99,128);
octave-3.0.0.exe:38> C(:,:,3)=circle(142,153);
octave-3.0.0.exe:39> imshow(C)
octave-3.0.0.exe:40> imshow(C);

Q#16


Q#16 Display the YM face of the colour cube


Octave command are
YM(:,:,1)=ones(256);
YM(:,:,2)=[ones(256,1)*[0:1:255]/255];
YM(:,:,3)=[ones(256,1)*[255:-1:0]/255]';
Imshow(YM);

Question # 15,


Q #15 Display the CM face of the colour cube
Octave Command
CM(:,:,1)=[ones(256,1)*[0:1:255]/255];
CM(:,:,3)=ones(256);
CM(:,:,2)=[ones(256,1)*[0:1:255]/255]';
imshow(CM)

Monday, June 2, 2008

Q#13, 14



Display the GB face of the colour cube
GB(:,:,1) = Zeros(256);
GB(:,:,2)=[ones(256,1)*[256:-1:0]/255];
GB(:,;,3)=[ones(256,1)*[255:-1:0]/255]';
imshow(GB)



Q#14 Show the CY face of colour cube
Octave Commands:
CY(:,:,1)=[ones(256,1)*[255:-1:0]/255]';
CY(:,:,2)=ones(256);
CY(:,:,3)=[ones(256,1)*[0:1:255]/255];
imshow(CY);

Q#12


Display the RG face of the colour cube
Octave Commands are RG(:,:,1)=[ones(256,1)*[0:1:255]/255];
RG(:,:,2)=[ones(256,1)*[0:1:255]/255];'
RG(:,:,3)= zeros(256);
imshow(RG)

Assignment#4 Q11

RB(:,:,1)=[ones(256,1)*[0:1:255]/255]';
RB(:,:,2)=zeros(256);
RB(:,:,3)=[ones(256,1)*[0:1:255]/255];
imshow(RB)

Assignment #4Q11

Tuesday, May 27, 2008

Assignment #5


Q# 1 Give octave command forconstructing a 256 X 256 matrix with entries of 0 everywhere except inside a circle with radius 50 where the values are 1
Ans:octave-3.0.0.exe:30> X=zeros(256);
octave-3.0.0.exe:31> for A =1:256;
> for B=1:256;
> if(A-128)^2+(B-128)^2 <=2500;
> X(A,B)=1;
> endif;
> endfor;
> endfor;
octave-3.0.0.exe:32> Y=255*X
octave-3.0.0.exe:33> imshow(Y)

Monday, May 26, 2008

assignment #4

19) shift the entries of a matrix A one place left
A = [1,1,0;0,1,0;1,0,0;1,1,1];
for i=1:3
temp(i)=A(i,1)
endfor;
31 for i=1:3
for j=2:3
A(i,j-1)= A(i,j)
endfor;
32 for i=1:3
A(i,3)=temp(i)
endfor;
the matrix A will be 1 0 1
1 0 1
0 0 1
1 1 0
20) shift the entries of a matrix A one place down(wrapping around bottom to top)
consider a matrix A = [2,3,4;5,6,7;8,9,0]
by octave command matrix A= 2 3 4
5 6 7
8 9 0
octave command shift(a,1)
and answer will be A= 8 9 0
2 3 4
5 6 7
21) Shift the entries of a matrix A one place left
let matrix A= [2,3,4;5,6,7;8,9,0]
and matrix B= [0,0,1;1,0,0;0,1,0]
third octave command A*B
3 4 2
6 7 5
9 8 0

22) shift the entries of matrix A one place down
let matrix a=[2,3,4;5,6,7;8,9,0]
and matrix b=[0,0,0;1,0,0;0,1;0]
b*a = [0,0,0;2,3,4;5,6,7] all these are octave command

assignment # 4

Assignment #4

On Octave/Matlab find the command to
1) make a matrix of 256 X 1
the octave command is Ones(256,1)
2) make a matrix of the integers 0 through 255 in a single row
Octave command [0:1:255]
3) make a column of the intergers 0 through 255
Octave command:[0:1:255]'
4) make a 256 X 256 matrix with the rows all the same equal to the numbers 0 to 255
Ones[256,1]*[0:1:255]
5) make a 256 X 256 matrix with the column, all the same, equal to the numbers 0 to 255
ones(256,1)*[0:1:255]'
6)make a 256 X 256 matrix of all zeros
zeros[256,256]
7)make a 256 x 256 matrix of all ones
ones[256,256]
8) make a 256 x 256 matrix of all values 128
128*ones(256)
9) make a 256 x 256 matrix of all zeros
same as 6)
10)display a greyscale image
Octave command: imshow(ones(256,1)*[0:1:255]/255)

Tuesday, May 13, 2008

Assignment #2 continued...

Q: #5
For the ternary inputs we need five basic binary operators. NOT, AND, OR, IMPL and Equivalence. In the binary inputs we can get equivalence with the help of four operators. But we can’t get in case of ternary.
Also check http://www.fw.uri.br/~arpasi/artigos/ternary.pdf

Q: #7
D = death
P = poison
B = Blood chemistry
S = poison in stomach
M = Puncture marks on the body
D IFF B OR S
P IMP D AND M
NOT (B XOR S) AND M

B) Orders of magnitude
1) A commodore computer had memory 64 K B . how many times more in 1GB.
1 KB = 1024 bytes = 2^10 bytes
1GB = 2 ^30 bytes
Today’s computer of 1GB is 16384 more powerful than 64K commodore computer.
2) A doubled sided floppy disc memory is 800KB and storage of DVD is 4.7 GB
4.7 * 2^ 30 / 800* 2^10 = 6160
Approximately 6160 floppy disks can be stored in 4.7 GB DVD

3)The clock rate of first microcomputer processor was approximately 108kHZ but todays pentium iv is running with a speed of 2.5GHz.These are almost 12833 mip more faster than the first generation microcomputer.
http://www.trillian.randomstuff.org

Assignment #2

First four digits of student # is 2059
mod 8, 3 and 7 will be 3, 1 and 1 and for question #3 column 11

16 binary functions in the form of operations AND/OR and NOT
Let X = 0011 and Y = 0101

0000 = Y AND NOT Y
0001 = X AND Y
0010 = X AND NOT Y
0011 = X
0100 = Y AND NOT X
0101 = Y
0110 = (YNOTX) AND (XNOTY)
0111 = X OR Y / NOT X NAND NOT Y
1000 = NOT(NOT X NAND NOT Y)
1001 = X XNOR Y / NOT((X OR Y)AND(NOT(X AND Y))
1010 = NOT Y
1100 = NOT X
1011 = NOT X OR Y
1101 = X OR NOT Y
1110 = NOT(X AND Y)
1111 = X AND NOT X
According to DeMorgan's law we can can switch between AND and OR to describe all 16 combinations.

#2 { NOT, XOR}
The binary functions which can't be represented by using NOT and XOR operators
Binary functions which can be expressed by these two operations are
0110
1100
1010
1001
Thus only four binary combinations can be represented and rest 14 can't be done.

Q: #3 Associative column 11
From the table NOT Y = 1010
Associative Properties is
f(f(x,y),z) = f(x,f(y,z))

x = 00001111
y = 00110011
z = 01010101
f(x,y) = 11001100
f(f(x,y),z) = 00110011
f(y,z) = 10101010
f(x,f(y,z) = 00110011
thus it is associative.



#4
In trinary oprators where values are 0,1 and 2 i.e three valued logic. So three nullary operators, 9 unary,.. but if we put two input and one output then it is a case of binary operators which is equal to 3^(3)^2
outputs for trinary inputs. 3^3^2 = 19683
For more information go to http://en.wikipedia.org/wiki/Logical_operator

Q: #5

Tuesday, May 6, 2008

Coping from the internet

"Coping from the Internet is not cheating." It gives the possibility of sharing information over the Internet or knowing the answers from fellow students is still give some sort of learning and motivation to the student. I think at least student is interacting and bouncing ideas. We don't know which pressure forcing a student to do so. As a mathematics teacher, I can give a big assignment into chunk and provide proper guideline to assess that assignment. Also, I prefer to monitor student progress on regular basis. Moreover, student can do journal entry about the progress of a given assignment. I can setup math forum posting and ask to form and represent own question(similar to the given assignment) to the class.


Examples of cheating and plagiarism over the Internet are


  • copy and paste contents

  • different format used on same page

  • Not answering the assignment properly

  • having website information on the top or bottom of page

  • Not thorough understanding of submitted assignment

This can be preventing


  • with collaboration

  • splitting assignment into parts

  • assigning different due dates

  • monitoring student work regularly...

Computers in next two decades

Computer power continues to double roughly two years. Today's computer can rival a rat brain which was not done past two decades. Within the next two decades computer will match the human brain. Computing is woven into the fabric of our modern society and next two decades everything will be monitored by the computer. Majority of unsolved problems in mathematics or scientific problems are going to solve in coming 20-25 years. Artificial intelligence would be on par with human intellect in next coming years. In 2000, Computer had defeated best human player in chess. With the help of computer we can find out the profile of a person living in Canada in a blink of eye which was not possible 20years ago. In next 20 years, the movie "I terminator" will be the real because of advancement in the technology of computer science.