Wednesday, May 28, 2008



Assignment 5. ( commands for octave 3.0.1)

Question 1. Octave commands for constructing a 256 by 256 matrix with entries of 0 everywhere except inside a circle with a radius of 50 where the values are 1.

function val = circle(x,y)
> val=zeros(256);
> for i=1:256; for j=1:256;
> if (i-x)^2+(j-y)^2 <=2500; > val(i,j)=1;
> end
> end
> end
> end
> imshow(circle(128,128))

Question 2. Give octave commands to draw the top part of figure 6.4
> P(:,:,1)=circle(156,103);
> P(:,:,2)=circle(113,128);
> P(:,:,3)=circle(156,153);
>imshow(255*P)

Question 3.
Skewing bigT with s=2.

> bigT = 255*ones(256);
octave-3.0.1.exe:68> bigT(30:79,64:191)=zeros(50,128);
octave-3.0.1.exe:69> bigT(50:199,111:146)= zeros(150,36);
octave-3.0.1.exe:70> Ts = zeros(256);
octave-3.0.1.exe:71> for i=1:256; for j=1:256;
> Ts(i,round(mod(j+2*i,256)+1))=bigT(i,j); end; end;
octave-3.0.1.exe:72> imshow(Ts)


rotating the skewed Ts by 7pi/6

Trot=128*ones(256);
c=cos(7*pi/6)
s=sin(7*pi/6)
for i=1:256; for j=1:256;
Trot(round(mod(i*c-j*s,256)+1),round(mod(i*s+j*c,256)+1))=Ts(i,j);
end
end
imshow(Trot)

Saturday, May 24, 2008

On Octave 3.0.0 commands to:

(1) make a matrix of 256 by 1 ones: ones(256,1)

(2) make a matrix of the integers 0 through 255 in a single row: [0:1:255]

(3) make a column of the integers 0 through 255: [0:1:255]'

(4) make a 256 by 256 matrix with the rows, all the same,

equal to the numbers 0 to 255: C=ones(256,1)*[0:1:255]

(5) make a 256 by 256 matrix with the columns, all the same,

equal to the numbers 0 to 255: C'

(6) make a 256 by 256 matrix of all zeros: zeros(256)

(7) make a 256 by 256 matrix of all ones: ones(256)

(8) make a 256 by 256 matrix of the value 128: 128*ones(256)

(9) make a 256 by 256 matrix of all zeros: zeros(256)

(10) display a fading greyscale image

imshow((1/255)*ones(256,1)*[0:1:255])

For questions 11-16: Define

l=(1/255)*ones(256,1)*[255:-1:0]
r=(1/255)*ones(256,1)*[0:1:255]
u=l'
d=r'
z=zeros(256)
f=ones(256)

(11) display the RB face of the color cube

RB(:,:,1) = r;
RB(:,:,2) = z;
RB(:,:,3) = u;
imshow(RB)

(12) display the RG face of the color cube

RG(:,:,1) = u;
RG(:,:,2) = r;
RG(:,:,3) = z;
imshow(RG)

(13) display the GB face of the color cube

GB(:,:,1) = z;
GB(:,:,2) = r;
GB(:,:,3) = d;
imshow(GB)

(14) display the MY face of the color cube

MY(:,:,1) = f;
MY(:,:,2) = r;
MY(:,:,3) = u;
imshow(MY)

(15) display the CM face of the color cube

CM(:,:,1) = d;
CM(:,:,2) = r;
CM(:,:,3) = f;
imshow(CM)

(16) display the GM face of the color cube

YC(:,:,1) = l;
YC(:,:,2) = f;
YC(:,:,3) = u;
imshow(YC)

(17) display the whole color cube in a cross with white regions where there doesn't need
to be anything

r1=[f,d,f]
r2=[r,f,l]
r3=[f,u,f]
r4=[f,z,f]

R = [r1;r2;r3;r4]

g1=[f,r,f]
g2=[z,r,f]
g3=[f,r,f]
g4=[f,r,f]

G = [g1;g2;g3;g4]

b1=[f,f,f]
b2=[u,u,u]
b3=[f,z,f]
b4=[f,d,f]

B = [b1;b2;b3;b4]

C(:,:,1)=R;
C(:,:,2)=G;
C(:,:,3)=B;

imshow(RGB)

(18) display something similar to the rainbow image that appears on the Math 5300
facebook page

f=ones(100,50);
d=(1/50)*ones(100,1)*[50:-1:1];
u=(1/50)*ones(100,1)*[1:1:50];
dh =(1/100)*ones(100,1)*[100:-1:51];
uh=(1/100)*ones(100,1)*[1:1:50];
qd=(1/100)*ones(100,1)*[50,-1,1]
qu=(1/100)*ones(100,1)*[51,1,100]
z=zeros(100,50);

R=[f,f,d,z,z,u,dh];
G=[z,u,f,dh,qd,z,z];
B=[z,z,z,uh,uh,qu,f];

M(:,:,1)=R;
M(:,:,2)=G;
M(:,:,3)=B;

imshow(M);

(19) shift the entries of a matrix A one place left (wrapping around left ! right)

A= circshift(A,[0,-1]);

(20) shift the entries of a matrix A one place down (wrapping around bottom)

A = circshift(A,1);

(21) shift the entries of a matrix A one place left (dropping values on the left edge)
A= circshift(A,[0,-1]);
for i=1:rows(A);
A(i,1)=0;
endfor;


(22) shift the entries of a matrix A one place down (dropping values on the bottom edge)
A = circshift(A,1);
for i=1:columns(A);
A(rows(A),i)=0;
endfor;

Wednesday, May 21, 2008

Assignment #3



Question 1. "Why does color space look like a shark fin?"


The Chromaticity diagram represents the visible color spectrum. We can think about taking the

visible spectrum wich makes a long rectangle and bending it to bring the two ends together. We will get something that looks like the shark fin.



Above is the graph for wavelength versus x/y. It represents the wavelength for red to green ratio, which is also the tristimulus ratio X/Y.






Above is the graph for wavelength versus y. It represents the wavelengths for different saturations of green.

Above is the graph for wavelength versus z/y. It represents the wavelengths for blue to green ration or tristimulus ration Y/Z.



Question 2.


If c1 has coordinates (x1, y1), c2 has coordinates (x2, y2) and c3 is the color on the line then the general expression for computing the relative percentages of colors c1 and c2 composing a given color that is known to lie on the straight line joining the two colors is



P1c1 + P2c2 = (x3,y3)





P1 = (x3-x2)/(x1-x2) , where P2 = 1 - P1




if x1-x2 =0 then use P1 = (y3-y2)/(y1-y2)



Question 3.




Given color c1(x1,y1), c2(x2,y2) and c3(x3,y3) the expression for computing the relative percentages of c1, c2 and c3 composing a given color that is known to liehe within the triangle whose vertices are at the coordinates of c1, c2, c3 is





P1c1+ P2c2+P3c3 = (x4, y4)



P1(x1-x3) = x4 -x3 -P2(x2-x3) <= if x1 = x3 solve directly for P2




otherwise P1 = (x4-x3 -P2(x2-x3))/(x1-x3)





P2 = ((y4-y3)(x1-x3)-(x4-x3)(y1-y3))/((y2-y3)(x1-x3)-(x2-x3)(y1-y3))




P3 = 1- P1-P2




Question 4.





Yellow component of the image in problem 6.6 as it would appear on monochrome monitor.
Magenta component of the image in problem 6.6 as it would appear on monochrome monitor.







Cyan component of the image in problem 6.6 as it would appear on monochrome monitor.






b) The image would have the colors inverted.






Question 5. Transformation from RGB to CMY= [1 1 1] -[R G B] that is fed into RGB inverts the colors of the image. The effect on HSI would be to add 180 degrees to H mod 360.


new I = 1-I

new S = 1 - (3/(1-3I+2(2-I(1-S)-I(1+Scos(H)/cos(60-H))))*min(1-I(1-S),1-I(1+ScosH/cos(60-H)),1-3I+2-I(1-S)-I(1+Scos(H)/cos(60-H))))


Question 6.

If a transformation switches the red and blue components.

S and I values of HSI coordinates do not change. To get the new H = -oldH+240 mod 360



b) If blue and red channels of the image 6.5 are exchanged thed we get

Sunday, May 11, 2008

Assignment 2


first four digits 2064

2064 = 0(mod 8)
2064 = 0(mod 3)
2064 = 6(mod 7)

Question 1.

x - 0011
y- 0101

Possible ways of getting 16 binary functions using AND/OR and NOT
(not x) and x - 0000
x and y - 0001
x and (not y) - 0010
x and x - 0011
(not x) and y - 0100
y and y - 0101
(x or y) and [(not x) or (not y)] - 0110
x or y -0111
not(x or y) -1000
not[(x or y) and {(not x) or (not y)}] - 1001
not y - 1010
not[(not x) and y ] - 1011
not x -1100
not [ x and (not y)] -1101
(not x) or (not y) - 1110
x or (not x) -1111

Question 2. (0) All 16 binary functions can be represented using {AND,NOT}

Question 3 (0)

Commutative functions are

0000

0001

0110

0111

1000

1001

1110

1111

Question 4. When working in trinary with two input arguments and one output argument there are 19,683 possible binary operations.


Question 5. I think that only 2 binary operations are necessary to express every possible two argument function on trinary operations. I also think that in http://www.aymara.org/ternary/ternary.pdf the author is not getting the right
truth table for impl(x,y).

Question 6-6 Setting Black = 1 and White = 0
It seems that both images are the same.
(pic1 AND pic 2) and (pic1 OR pic2) is the same as
pic1 AND (pic1 IMPL pic2)




Question 7.

A - Poison caused the victims death

B- There was a change in victim's blood chemistry

C- There was a residue of poison in the stomach

D-There were puncture marks on the body

E- Poison was injected by a needle

IFF - if and only if

IF - only if

A IFF (B OR C)

NOT(B OR C)

D

E IF D

A OR (NOT D)

Orders of Magnitude

Question 1.

The computer with 1GB of memory has 16384 times more memory than a computer with 64K.

Question 2.

6160.4 floppy disks with 800K are equivalent to a 4.7GB DVD.

Question 3.






The first mass marketed PC cpu was Intel 8080 with a clock speed of 2MHZ



Computers now have clock speeds of up to 4GHZ. This has an increase factor of 2000, although



it is actually much higher than this due to more work done in todays processors per every cycle.



Wednesday, May 7, 2008




"A lot has changed with respect to computers in the last 25 years"-would be an understatement. The rise of the Internet age and affordable home computing has made computers part of almost every one's everyday life and a huge part of the economy. It has changed the way people work, communicate, do business, enjoy entertainment and live. This has put pressure on R&D companies and manufacturers to battle out for new competitive technologies and has made computers a great deal more affordable. There is an ongoing integration between computers and other technologies such as television, telephones and wireless communications. Computers are also assuming bigger roles in the industry, taking over certain tasks that have been performed by humans and at the same time creating new jobs that did not exist previously.

Using the computers and internet for communicating, banking, researching, reading news, gaming, digital imaging, data mining, multimedia design are just some of the applications available at home today that were not available a couple of decades ago. It is both a technological and software evolution that has permitted these things to exist. As is shown in this Intel presentation
http://www.intel.com/technology/timeline.pdf the number of transistors available to the average home consumer has grown from 134,000 in 1982 to about 1,000,000,000 today. Moore's Law states that the number of transistors will double roughly every two years. Then, by Moore's Law we should have about 134,000(2)^13 = 1,097,728,000 transistors available today, an amazingly accurate prediction made in 1965. At the same time we have to realize that even the most powerful computer is useless without the right software. I believe that many of new developments that will come in the future will be possible not simply because of even faster computer speeds, but because of new innovative ideas and good programming.


So what awaits us in this brave new world of super-computing, and how much longer can we expect this kind of growth to last? The problem with making transistors smaller is that there is a physical limit to how small they can be, and it seems that the chip companies are already struggling with the shrinking. To continue the increase in transistors, they are now placing multiple cores on a single chip, but this has its limits too http://blog.elisehuard.be/2007/12/moores-law/. The real progress is going to be made when something like quantum computing becomes feasible, but this is highly unlikely to happen within the next twenty years
http://en.wikipedia.org/wiki/Quantum_computer.
I think that for now the computers are already fast enough for many things. Even if from now on computers did not get faster for many years, the applications would still keep on getting better and better regardless of the speed. Of course other parts of computers like memory, bandwidth and displays will keep on improving. Some things that I think would be nice to see in the next 20 years are the connection to the Internet of the poorer regions of the world where the penetration of the Internet at present time is very low, much higher bandwidth speeds, much more reliable glitch free software and movie quality real-time graphics.