Saturday, May 31, 2008

Assignment #6 3a

Code:
















Original Image











Average Image

Assignment 6 #2

Code:

two=triu(two,1)-triu(two,2);
imshow(two)

Image:

Assignment 6 #1 again

I went back to my notes and remembered the 'double' command. My image looks better now.
















Assignment 6 #1

I am not sure if I have done this correctly as there are no black lines in it. I have compared the code to that done in class and I can't find any errors.














Assignment 5 #3

This question took me quite a bit of time. I took a fair bit of time to understand how the rotate commands worked. I hope that I have correct answers now that I have finished.

I started by skewing the 'BigT'. At first I skewed it the wrong way but, after some advice in class, I was able to do this part. My skew factor (s) was 2.

Here is the code:





Here is the image:













I then did the rotation. This took me the longest amount of time. I started with a grey background so my image looks different than most. My angle of rotation was pi/6.
























Here is the combo - skew and then rotate. I have included the code and the image. I started with a grey background so my image looks different than most.


































































Tuesday, May 27, 2008

Assignment 5 #2

#2
circler=255*zeros(256);
circleg=255*zeros(256);
circleb=255*zeros(256);

for x=1:256;
for y = 1:256;
if (x-150)^2+(y-150)^2<=2500;
circleb(x,y)=1;
end;
end;
end;

for x=1:256;
for y = 1:256;
if (x-150)^2+(y-100)^2<=2500;
circler(x,y)=1;
end;
end;
end;

for x=1:256;
for y = 1:256;
if (x-100)^2+(y-120)^2<=2500;
circleg(x,y)=1;
end;
end;
end;

A(:,:,1)=circler;
A(:,:,2)=circleg;
A(:,:,3)=circleb;

imshow(A)


Monday, May 26, 2008

Assignment 5 #1

circlew=zeros(256);
for x = 1:256;
for y = 1:256;
if (x-128)^2 +(y-128)^2 <=2500;
circlew(x,y)=1;
end;
end;
end;
imshow(circlew)



Assignment 4 #18

#18

The original picture in Facebook looks like this:










My image in Octave looks like this:












My code in Octave is:
c(:,:,1)=[1,1,1,0,0,0,1,0.5];
c(:,:,2)=[0,0.5,1,1,1,0,0,0];
c(:,:,3)=[0,0,0,0,1,1,1,0.5];
imshow(c)

Assignment 4 #21,22

In order to construct the matrix used in class:

0 0 0
1 0 0
0 1 0

I used the tril (triangle lower) command. It will take the lower triangular part of a matrix and convert all other values to zero. The second argument is optional and specifies how many diagonals above or below the main diagonal should also be set to zero.

A=[1,2,3;4,5,6;7,8,9];
P=tril(ones(3),-1);
Q=tril(ones(30,-2);
B=P-Q;
Shiftdown=B*A
Shiftright=A*B

Matrix P:
0 0 0
1 0 0
1 1 0

Matrix Q:
0 0 0
0 0 0
1 0 0

The matrix, Shiftright, which is the result of A*B is the answer to 21.

The matrix, Shiftdown, which is the result of B*A is the answer to 22.

Wednesday, May 21, 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. z(:,:,1)=[ones(256,1)*[0:1:255]/255]’;
z(:,:,2)=zeros(256);
z(:,:,3)=[ones(256,1)*[0:1:255]/255];
imshow(z)
12. z(:,:,1)=[ones(256,1)*[0:1:255]/255]’;
z(:,:,2)= [ones(256,1)*[0:1:255]/255];
z(:,:,3)= zeros(256);
imshow(z)
13. z(:,:,1)=zeros(256);
z(:,:,2)=[ones(256,1)*[0:1:255]/255];
z(:,:,3)= [ones(256,1)*[255:-1:0]/255]’;
imshow(z)
14. magenta to cyan
z(:,:,1)=[ones(256,1)*[0:1:255]/255]’;
z(:,:,2)= [ones(256,1)*[0:1:255]/255];
z(:,:,3)=ones(256);
imshow(z)
15. magenta to yellow
z(:,:,1)=ones(256);
z(:,:,2)=[ones(256,1)*[0:1:255]/255];
z(:,:,3)=[ones(256,1)*[0:1:255]/255]’;
imshow(z)
16. yellow to cyan
z(:,:,1)=[ones(256,1)*[0:1:255]/255]’;
z(:,:,2)=ones(256);
z(:,:,3)=[ones(256,1)*[0:1:255]/255];
imshow(z)


17. Here is the original output from Octave. The images in Octave are not displayed as squares, they are shown as rectangles. I did a print screen to capture this image and it got a bit distorted in the middle. The original picture didn't have this.
















I stretched the image to make it more like a square. Again, the image looks much nicer but when I put it into paint to save it as a JPEG, dark lines were added to the image.









18.


19. a=[1,3,0;2,3,6]
circshift(a,[0,-1])

20. a=[1,3,0;2,3,6]
shift(a,1)
21.
22.

Assignment 3

1.
The outline of the fin shows the various wavelengths – the pure colours shown in the spectrum.

wavelength versus x/y





wavelength vs y









wavelength vs z/y









wavelength vs x









wavelength vs z









x represents the percentage of red in the wavelength
y represents the percentage of green in the wavelength
z represents the percentage of blue in the wavelength

2.
Given C1(x1,y1), C2(x2,y2) and C(x,y) are ordered pairs within the chromaticity diagram. C1 and C2 form a line segment and C is a point on this line segment.

Length of C1C=SQRT( (x1-x)^2 + (y1 – y)^2)

Length of C1C2 = SQRT( (x1-x2)^2 + (y1 – y2)^2)

%C2 = (length of C1C)/(length of C1C2)*100%
%C1=100-%C2

I did this question using ratios before I saw Mike’s message on Facebook. I was not able to do #3 using this strategy.

Using Mike’s strategy, I got

My equations are
a + b = 1
x = ax1 + bx2
y = ay1 + by2

My solutions for a and b are:

a = (xy2-x2y)/(x1y2-x2y1)
b = (xy1-x1y)/(x2y1-y1x2)

3.
Using Mike’s strategy again,
My equations are:
a + b + c = 1
x = ax1 + bx2 + cx3
y = ay1 + by2 + cy3

My solutions for a, b and c are:

a = [x(y3-y2)+x2(y-y1)+x3(y1-y)]/[y1(x1-x2) +y2(x3-x1)+y3(x2-x3)]
b = [x(y3-y2)+x2(y-y1)+x3(y1-y)]/[y1(x3-x2)+y2(x1-x3)+y3(x2-x1)]
c = [x(y2-y1)+x1(y-y2)+x2(y1-y)]/[y1(x2-x3)+y2(x2-x1)+y3(x1-x2)]

I did this manually so I hope I didn’t make any mistakes as I don’t feel like doing it again (enjoyable though it was)!

4.
a) I started with the RGB components of the image.

Red Component







Green Component







Blue Component







Black: (C,M,Y)=(1,1,1)-(R,B,G)
(C,M,Y)=(1,1,1)-(0,0,0)
(C,M,Y)=(1,1,1)

Similarly,

Red: (C,M,Y)=(0,1,1)
Yellow: (C,M,Y)=(0,0,1)
Green: (C,M,Y)=(1,0,1)
Cyan: (C,M,Y)=(1,0,0)
Blue: (C,M,Y)=(1,1,0)
Magenta: (C,M,Y)=(0,1,0)
White: (C,M,Y)=(0,0,0)

Cyan Component







Magenta Component







Yellow Component








6.
b) In GIMP, choose
Colours
Components
Channel mixer
Switch the percentages on the red and blue channels.

















































































The above image looks good to me as there is still white in the middle. If there is a problem, please let me know.

I am tired and can’t think about HSI right now. I will finish other questions after sleep.

Wednesday, May 14, 2008

Assignment 2

To Make the Assignment Unique

(1) According to my student number, I will be doing 2(0), 3(2) and 6(0).

Bit Strings and Logic

(1)

0 = Y AND (NOT Y)
1 = X AND Y
2 = X AND (NOT Y)
3 = X
4 = Y AND (NOT X)
5 = Y
6 = [Y AND (NOT X)] OR [X AND (NOT Y)]
7 = X OR Y
8 = (NOT X) AND (NOT Y)
9 = [NOT X AND NOT Y)] OR [X AND Y]
10 = NOT Y
11 = X OR [NOT (X AND Y)]
12 = NOT X
13 = Y OR (NOT X)
14 = NOT (X AND Y)
15 = X OR (NOT X)

(2)

While working on #1, I discovered that some of the expressions could be written equivalently with AND or OR in combination with NOT. In class we discussed DeMorgan’s Law that shows that any AND or OR can be replaced with the other in combination with NOT, as shown below:


NOT (A AND B) = (NOT A) OR (NOT B)
NOT (A OR B) = (NOT A) AND (NOT B)

Therefore, all or the binary functions can be written in terms of AND and NOT using the above rules to replace the OR function.

(3)

According to my student number with mod 16, I will be doing the binary operation of OR.

I found that OR is commutative, associative and idempotent.

The following chart, with f = OR, illustrates that OR is associative. (I have been unable to import the table from WORD, I will scan it and post it ASAP.)


(4) When working in trinary, things grow exponentially with a base of 3, instead of exponentially with a base of 2 as in binary. Therefore, with 2 binary input arguments, there are 9 different arrangements of the input arguments. For the output operations, there are 3 possible output values for each of these 9 arrangements. This means that there are output operations.

(5)






(6) Using pic1 and pic2 as given in class, here are the images that I created in GIMP.


pic1 AND pic2









pic1 OR pic2








pic1 XOR pic2





(7)

A – Poison caused the victim’s death.
B - There was a change in blood pressure.
C – There is a residue of poison in his stomach.
D – There were puncture marks on the body.
E – Poison was injected by a needle.

A IFF (B OR C)
B NOR C BUT D
E IFF D
A OR (NOT D)

Order of Magnitude

(1)
Commodore 64: 64KB
1GB = 1024 MB
= 1024 x 1024 KB
= 2^20 KB
2^20 divided by 64 (2^6) equals 2^14 (16384)
Therefore, a computer with 1GB has 16384 times the memory of a Commodore 64.

(2)

Double sided floppy disk: 800KB
DVD: 4.7GB = 4.7 x 1024 MB
= 4.7 x 1024 x 1024 KB
= 4.7 x 2^20 KB
(4.7 x 2^20) divided by 800 = 6160.384

Therefore, the DVD is equivalent to about 6160 floppy disks.

(3)

The first commercial PC, the Altair 8800 (1975) had a clock rate of 2MHz (2 million cycles per second).

Modern computers (2002) with an Intel Pentium 4 have a clock rate of 3GHz (3 billion cycles per second).
(3 x 10^9) / (2 x 10^6) = 1.5 x 10^3 (1500)
Therefore, a modern computer is about 1500 times as fast as a computer from 1975.

My sources for information on clock rates:

http://en.wikipedia.org/wiki/Clock_rate

http://www.islandnet.com/~KPOLSSON/comphist/comp2006.htm

Most new computers sold are in the 2 to 3 gigahertz (2,000 to 3,000 Mhz) range.

http://mindprod.com/bgloss/cpu.html








Monday, May 12, 2008

“Copying from the internet is not cheating.”

With the prevalence of computers and internet access, it is becoming increasingly simple for students to acquire information from each other and from sources on the internet. Students also seem to value a high mark over knowledge gained.

Educators are aware of the possibility that assignments will be copied or shared. However, is seems almost impossible to keep up with the new and innovative ways that students discover to avoid actually doing assigned work!

It is reasonable for students to discuss and share solutions to homework problems. This does not reduce their motivation as they know that they will have to write a test on the content and they will be evaluated on the test results. I try to devise assignments where each student gets a different problem or a bank of problems and each student is randomly assigned two or three of the problems. When this is not possible, I try to give the assignments during class time individually.

When there are larger assignments, it is difficult to avoid the possibility of cheating. A Data Management teacher at my school recently determined that several of her students were submitting power point presentations that they had not created but found or been given.

From the website, http://middlehighschool.suite101.com/blogs.cfm#electronic_cheating,
a recent article by Kellie Hayden, states that cheating using electronics is starting in middle school. She said that recently in a rural middle school, a teacher caught three different students copying during a one week period. One copied another’s homework during class, one used another student’s identification number and took an on-line quiz for that student. The third copied and pasted information for an essay directly from an online book.

An article by Stacey Conradson & Pedro Hernández-Ramos, http://pareonline.net/getvn.asp?v=9&n=9, states that statistics show that cheating is on the rise amongst students and it is starting as early as elementary school. The article states that websites that sell essays are amongst the most popular on the internet. Cheaters.com received 80 to 100 new members daily in the late 1990’s.

As teachers, the challenge is to educate students – sharing information on a regular basis is fine but work that is submitted for evaluation needs to be created by the individual. Also, we need to help students learn to value the acquisition of knowledge and skills. In time, this will result in higher grades. Conversely, cheating that results in higher marks in the short term, will eventually result in lower grades. This is because the prerequisite skills have not been learned.

An article by Rob Taylor, http://www.schoolfinder.com/news/plagiari.asp, supports my idea. He says that students need to realize that, in the long run, they are hurting themselves.