Thursday, May 29, 2008

Assignment #5

1. The command that creates a white circle which has a 50 unit radius found within a black square is:

C=zeros(256);
for x = 1:256;
for y = 1:256;
if (x-100)^2+(y-100)^2<=50^2;
C(x,y) = 1 ;
endif;
endfor;
endfor;
imshow(C*255) ;





2.The commands to draw the top part of figure 6.4 in the book is:
topcircle = zeros(256);
for x = 1:256;
for y = 1:256;
if (x-90)^2 + (y-125)^2 <= 50^2;
topcircle(x, y) = 1;
endif;
endfor;
endfor;
leftcircle = zeros(256);
for x = 1:256;
for y = 1:256;
if (x-150)^2 + (y-90)^2 <= 50^2;
leftcircle(x, y) = 1;
endif;
endfor;
endfor;
rightcircle = zeros(256);
for x = 1:256;
for y = 1:256;
if (x-150)^2 + (y-150)^2 <= 50^2;
rightcircle(x, y) = 1;
endif;
endfor;
endfor;
Final(:,:,1) = topcircle;
Final(:,:,2) = leftcircle;
Final(:,:,3) = rightcircle;
imshow(Final*255);






3.a) 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;
imshow(bigTskew);



b) rotate image by 3pi/4 degrees.
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(3*pi/4)-y*sin(3*pi/4)),256)+1, mod(round(x*sin(3*pi/4)+y*cos(3*pi/4)),256)+1);
end;
end;
imshow(bigTskewrotate);

Tuesday, May 27, 2008

Assignment #4

1. ones(256, 1)
2. [0:1:255]
3. [0:1:255]'
4. ones(256, 1)*[0:1:255]
5. [ones(256, 1)*[0:1:255]]'
6. zeros(256)
7. ones(256)
8. 128*ones(256)
9. zeros(256)
10. imshow(ones(256, 1)*[0:1:255]/255)


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

RB Face


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

RG Face


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

GB Face

14. A(;,;,1) = [ones(256, 1)*[0:1:255]/255]';
A(;,;,2) = ones(256, 1)*[0:1:255]/255;
A(;,;,3) = ones(256);
imshow(A);

MC Face

15. A(;,;,1) = ones(256, 1)*[0:1:255]/255;
A(;,;,2) = ones(256);
A(;,;,3) = [ones(256, 1)*[0:1:255]/255]';
imshow(A);

CY Face

16. A(;,;,1) = ones(256);
A(;,;,2) = [ones(256, 1)*[0:1:255]/255]';
A(;,;,3) = ones(256, 1)*[0:1:255]/255;
imshow(A);

YM Face

More answers to follow.

Tuesday, May 13, 2008

Assignment #2

The first digits of my student number are 2007.
2007mod8 = 7 (Q. 2h.)
2007mod3 = 0 (Q. 3a)
2007mod7 = 5 (Q. 6f)

1. The 16 binary functions can be expressed as a composition of the binary operations AND/OR and NOT.
0. Y and not Y
1. X and Y
2. X and not Y
3. X
4. Y and not X
5. Y
6. (X and not Y) and (Y and not X)
7. X or Y
8. Not X or Y
9. Not (X or Y) and not(X and Y)
10. Not Y
11. X and not (X or Y)
12. Not X
13. Y and (X and not (X or Y))
14. Not (X and Y)
15. Not (Y and not Y)

2. I cannot find any combinations of (NOT,IMPL) for the following binary functions 1,2,3,5,6,7,9,10,11.

3.a) 2007mod16 = 7
Is (X or Y) commutative?

x 0 0 1 1
y 0 1 0 1
f(x,y) o 1 1 1
f(y,x) 0 1 1 1 Therefore, (X or Y) is commutative because f(x,y) = f(y,x).

4. As there are 3 possible outputs and 9 possible binary arguments, there are 3^9 = 19683 possible binary operations.

5. Since the operations IMPL, OR, AND, and NOT can generate all 16 binary functions, these same four can generate every possible two argument function on trinary operations.

6. Downloading GIMP has been a nightmare. What would happen if I threw my laptop out the window?

7. Death caused by poison - D
Change in blood chemistry - C
Residue of poison - R
Puncture marks on body - M
Poison injection - I
Poison - P
[P AND (C OR R)] OR [NOT P AND NOT C AND NOT R]
NOT C AND NOT R AND M
NOT [I AND NOT M]
P OR NOT M


Orders of Magnitude

1. A computer with 1 GB of memory has [ 1024 MB x 1024 KB / 64 KB] 16,384 more memory than a Commodore 64 with 64 KB of memory.

2. [4.7 GB x 1024 MB x 1024 KB / 800 KB] 6160 floppy disks that hold 800 KB of storage is equivalent to one DVD which has 4.7 GB of storage.

3. The Mac Plus has a Motorola 68000 CPU which runs at a speed of 8MHz. The AMD has an Athlon 64 X2 4800+ with two cores, each running at 2.4GHz. When measuring and comparing speed, AMD's combined 4.8GHz is 600 times faster than the Motorola. However, the AMD is a far more advanced processor, thus performing much faster than the old 68000 per Mhz. So it's very safe to say that the AMD is at least 1,000 times faster than the Mac Plus. (http://hubpages.com/hub/_86_Mac_Plus_Vs_07_AMD_DualCore_You_Wont_Believe_Who_Wins)

Sunday, May 11, 2008

Comparing Yesterday's Computers to Today's

Hi!

A while back, I came across a very interesting fact about yesterday's computers. One of the first computers used to keep track of and run the complete payroll, monthly billing, and customer records for a fairly decent-sized small business was an IBM System/3 model 10. At this time (1969), this machine rented for approx. $1000/month. In today's world of gigabytes and terabytes, the amazing thing about this computer was that it ran with 8k of memory. It is common to compare an old computer to a modern digital watch. In fact, the System/3 is even more comparable to a musical greeting card that can cost one dollar these days at a neighbourhood dollar store. The question I ask is... if a computerized greeting card can run a small business then why does a modern business computer still cost thousands of dollars?

Why is this the case? One reason nay be because the computer companies can get away with it. Another reason may be that software gets slower, faster than hardware gets faster.

I welcome any other thoughts and/or opinions.

What may the future hold? I have a couple ideas. One... according to Moore's Law (http://en.wikipedia.org/wiki/Moore's_law), computer power doubles every 18 months, meaning that computers will be a million times more powerful by the year 2030. Imagine having a computer that has a 5PHz CPU speed, has a petabyte (a thousand terabytes) of memory, and half an exabyte (a billion gigabytes) of hard disk-equivalent storage. Wow. It would be safe to say that I could burn a couple of music CD's fairly quickly.

Another aspect of computer functionality which I believe will improve tremendously is the computer's ability to defend our online interests more vigorously rather than just sit and wait for commands. Also, what if your computer can chronicle everything and anything that you have seen or done online? I mean, keep a complete record of every hour, minute and second that you have spent online throughout your whole entire life. What would make the computer even more amazing would be that it can do all this monitoring only using up less than 5 percent of your hard drive!