Sunday, June 8, 2008

Sunday, June 1, 2008

Assignment 6







Assignment 6


(1) Rotation of bigT from Assignment 5 by using linear interpolation

T=255*ones(256);
T(30:79,64:191)=zeros(50,128);
T(50:199,111:146)=zeros(150,36);
T1=ones(256);
for x=1:256
for y=1:256
u=x*cos(2*pi/3)+y*sin(2*pi/3);
v=-x*sin(2*pi/3)+y*cos(2*pi/3);
a=u; b=mod(v-u,256)+1;
r=floor(a); s=floor(b);
if ((r>0)&(r<256)&(s>0)&(s<256))
T1(x,y)=[1-(a-r),a-r]*[T(r,s),T(r,s+1);T(r+1,s),T(r+1,s+1)]*[1-(b-s);b-s];
endif
endfor
endfor
imshow(T1)



Comparing with the picture obtained in assessment 5, using interpolation Q3 we have now obtained a nice, smooth image.

(2) Creating a 256x256 square matrix such that each element (i,i+1) is 1 and the rest of the elements are 0 (0<=i<=255).

tril(ones(256),1)-tril(ones(256))

or:

A=zeros(256);
for i=1:256
for j=1:256
if (j==i+1) A(i,j)=1;
end
end
end

(3) Determining the average color of a picture
a)

A(:,:,1)=ones(100);
A(:,:,2)=tril(ones(100));
A(:,:,3)=zeros(100);
B=255*A;
imshow(B)


size(B)
ans =

100 100 3
sum(sum(B))
ans =

ans(:,:,1) = 2550000
ans(:,:,2) = 1287750
ans(:,:,3) = 0


C=sum(sum(B))/size(A,1)/size(A,2)
C =

ans(:,:,1) = 255
ans(:,:,2) = 128.78
ans(:,:,3) = 0

for i=1:3
average(:,:,i)=C(i)*ones(100);
end
imshow(average)

Note:
If I do imshow(double(average)/255) I obtain a black screen


b) Rainbow image Math 5300:
Picture from the Assignment 4:


pkg load image
cd C:\
A=imread("Rainbow.jpg");
imshow(A)

Note: If I do:
imshow(double(A)/255) I get a black screen

size(A)
ans =

89 129 3

sum(sum(A))
ans =

ans(:,:,1) = 2076422
ans(:,:,2) = 1669866
ans(:,:,3) = 1580322

B=sum(sum(A))/size(A,1)/size(A,2)
B =

ans(:,:,1) = 180.86
ans(:,:,2) = 145.45
ans(:,:,3) = 137.65

for i=1:3
average(:,:,i)=B(i)*ones(100);
end
imshow(average)

Average color = white screen

Note: If I do imshow(double(average)/255) I get a black screen.

c)
1st Picture: “Peas”



pkg load image
cd C:\
A=imread("Peas.jpg");
imshow(A)


Note: If I do imshow(double(A)/255) I get a black screen.



size(A)
ans =

113 160 3

sum(sum(A))
ans =

ans(:,:,1) = 590114
ans(:,:,2) = 1866276
ans(:,:,3) = 273125

B=sum(sum(A))/size(A,1)/size(A,2)
B =

ans(:,:,1) = 32.639
ans(:,:,2) = 103.22
ans(:,:,3) = 15.106

for i=1:3
average(:,:,i)=B(i)*ones(100);
end
imshow(average)

2nd Picture: “Lit Tree”




pkg load image
cd C:\
A=imread("LitTree.jpg");
imshow(A)

size(A)
ans =

625 444 3

sum(sum(A))
ans =

ans(:,:,1) = 14070613
ans(:,:,2) = 19127011
ans(:,:,3) = 9894485


B=sum(sum(A))/size(A,1)/size(A,2);
B =

ans(:,:,1) = 50.705
ans(:,:,2) = 68.926
ans(:,:,3) = 35.656

for i=1:3
average(:,:,i)=B(i)*ones(100);
end
imshow(average)

Note: If I do imshow(double(average)/255) I get a black screen.


Monday, May 26, 2008

Saturday, May 24, 2008

Sunday, May 18, 2008

Assignment 3

(1)
























I used the Chromaticity Diagram to determine the corresponding values (x,y,z=1-x-y) for the values of the wavelengths W=380, 420, 460,...,700.
(2)
P1(x1,y1) - coordinates of color 1
P2(x2,y2) - coordinates of color 2
P(x,y) - coordinates of a color C on the segment determined by the two points
c1-percentace of color 1 in C; c2 - percentage of color 2 in C
We know that: c1*(x1,y1) + c2*(x2,y2) = (x,y) therefore we obtain:
c1*x1 + c2*x2 = x
c1*y1 + c2*y2 = y
We know that between two colors there can't be a third one, so c2=1-c1 which gives us
c1*(x1-x2) = x-x2
c1*(y1-y2)=y-y2
We obtain the formula for finding the concentration of color 1 in color C: c1 = (x-x2)/(x1-x2) = (y-y2)/(y1-y2) and c2 = 1- c1.
Notes:
We know that (x1,y1) different from (x2,y2), therefore either x1 is different from x2 or y1 is different from y2, so we do have a valid formula in all cases.
In the double equality above, the last equality is equivalent with the fact that P lies on P1P2.
(3)
P1(x1,y1), P(x2,y2), P(x3,y3) - coordinates of the three given colors
P(x,y) point interior to the triangle P1P2P3
Similarly, c1*(x1,y1) + c2*(x2,y2) + c3*(x3,y3) = (x,y)
We obtain a linear system with three unknowns, c1, c2, c3:
c1*x1 + c2*x2 + c3*x3 = x
c1*y1 + c2*y2 +c3 *y3 = y
We can substitute c3 = 1-c1-c2 and obtain:
c1*(x1-x3) + c2*(x2-x3) =x-x3
c1*(y1-y3) +c2*(y2-y3) =y-y3
The discriminant of the system is delta = (x1-x3)(y2-y3)-(x2-x3)(y1-y3)
delta1=(x-x3)(y2-y3)-(x2-x3)(y-y3)
delta2=(x1-x3)(y-y3)-(x-x3)(y1-y3)
c1=delta1/delta and c2=delta2/delta
(used Cramer formulas)
(4)
In the RGB model R(red) corresponds to the x axis, G(green) to the y axis and B (blue) to the z axis. The normalized coordinates are in the following table. The CMY components are determined by the formula: (C,M,Y)=(1,1,1)-(R,G,B) which means each color will transform into its complement.Complement colors: b and W, R and C, G and M, Y and B. The gray border will remain gray.

From the table, the components are:
C=(1,0,1,1,1,0,0,0), M=(1,1,0,0,0,1,1,0) and Y=(1,1,1,1,0,0,0,0).




b)
The resulted components will be the complements of the first ones: white, Cyan, Blue, Magenta, Red, Yellow, Green, black (in this order). The gray border will remain gray.

(5)
Inverts color means it turns each color into its complement: R-C, B-Y, G-M, b-W. This would then be equivalent with converting from RGB to CMY, so the transformation is given by the four equations presented in class (6.2-2, 6.2-3, 6.2-4).
If we apply this transformations to CMY, we'' have to substitute R, G, B in the formulas with their complements: 1-C, 1-M, and 1-Y respectively. We obtain:
"teta"= cos^-1*{(1/2[(M-C)+(Y-C)]/sqrt[(M-C)^2+(Y-C)(Y-M)]}
H="teta" for Y<=M and 2*pi-"teta" for Y>M
S=(C+M+Y)/(C+M+Y-3)*(1-max(M,Y,C))
I=1-1/3*(C+Y+M)
(6)
a)
The saturation (S) and intensity (I) will remain the same as they are symetrical formulas in Red and Blue. The Hue (H) may change.
b) Swapping the Red and Blue channels in GIMP.

Monday, May 12, 2008

Assignment 2

(1)
0000=xAND(NOTx)
1000=NOT(xORy)
0100=yAND(NOTx)
0010=xAND(NOTy)
0001=xANDy
1100=NOTx
1010=NOTy
1001=((NOTx)ORy)AND((NOTy)ORx)
0110=(xAND(NOTy))OR(yAND(NOTx))
0101=y
0011=x
1110=NOT(xANDy)
1101=(NOTx)ORy
1011=(NOTy)ORx
0111=xORy
1111=xOR(NOTx)
(2)
0000=xXORx
1000=xXOR(yIMPLx)
0100=xXOR(yXOR((xIMPLy)XOR((xXORx)IMPL(xXORy))))
0010=(xIMPLy)XOR((xXORx)IMPL(xXORy))
0001=xXOR((xIMPLy)XOR((xXORx)IMPL(xXORy)))
1100=xIMPL(xXORx)
1010=yIMPL(xXORx)
1001=(xXORy)IMPL(xXORx)
0110=xXORy
0101=y
0011=x
1110=xIMPL(xXORy)
1101=xIMPLy
1011=yIMPLx
0111=yXOR((xIMPLy)XOR((xXORx)IMPL(xXORy)))
1111=(xXORx)IMPL(xXORy)
Therefore all 16 functions can be written using only complositions of XOR and IMPL.
(3)
(a) Comutative functions: 0000, 1000, 0001, 1001, 0110, 1110, 0111, 1111

(4)
Working in ternary we have 3x3=9 possible combinations (x,y). Our functions will then be columns of 9 digits 0-2, which means 3^9=19683 possibilities. Therefore, there are possible 19,683 bynary operations.
(5)
For binary inputs , there are necessary three operations: AND, OR, NOT to represent all the possible functions.
From my research through the internet, I found out that for ternary inputs, in order to represent all 19,683 possible functions there are necessary four operations: AND, OR, NOT, IMPL .
(6)
(b)

pic1ANDpic2 pic1ORpic2 pic1IMPLpic2


pic1IMPLpic2=(NOTpic1)OR(pic2)
black=1, white=0
black or black =black
white or white =white
black or white =black
white or black =black
For finding pic1IMPLpic2 we imagine overlaping the two original pictures. In the area where the first picture was black and the second one white we will obtain white. The rest of the picture will be black.
(7)
Let:
a=Poison caused the victim's death.
b=There was a change in the 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.
a IFF (b OR c)
(NOT b) AND (NOTc) AND d
e IMPL d
a XOR (NOT d)
(8)
1)
64K=2^6K
1GB=2^10MB=2^20K
2^20/2^6=2^14 times more memory
2)
1floppy=800K
1DVD=4.7GB=(4.7)x (2^20)KB.
(4.7)x(2^20)/800=6160.384
Therefore we would need 6161 floppy disks to save all the data on a single DVD.
3)
Processor clock rates of early computers:
The clock rate is the fundamental rate in cycles per second (measured in hertz) at which a computer performs its most basic operations such as adding two numbers or transferring a value from one processor register to another. Usually when referring to a computer, the term "clock rate" is used to refer to the speed of the CPU.
The first commercial PC, the Altair 8800 (by MITS), used an Intel 8080 CPU with a clock rate of 2 MHz (2 million cycles/second). The original IBM PC (c. 1981) had a clock rate of 4.77 MHz. In 1995, Intel's Pentium chip ran at 100 MHz , and in 2002, an Intel Pentium 4 model was introduced as the first CPU with a clock rate of 3 GHz.

Assignment 1

(b) "Copying from the internet is not cheating"

As a teacher I personally would not be worried about students copying from the internet or other resources when doing homework. I state that because in my opinion, grades should have two main components: homework assignments and exams. Researching materials available on the internet in doing homework assignments is the same as going to the library, researching and using everything available. The internet just makes research and exchanging ideas easier and faster. When assigning homework, as teachers, we have to be aware that our students have available numerous printed and not printed resources, share ideas with their peers, or even have the professional "help" of a hired tutor. I believe homework is an important part of the grading scheme because it shows how much effort a student is willing to put into that course. Therefore, when I mark homework, I grade the corectness of the methods and answers and the amount of effort that the student has put into that piece of work, creativity, etc.
Even if I decided to assign different homework questions to all my students, I do not believe I can be 100% sure that they did it without anybody else's help. I think it is more important for me to know how well the student has mastered the tought concepts. Therefore I would use another big component as part of the grade: class participation and exams done without any available materials.