Title: PROJECT 2
1PROJECT 2
2What is a pixel
- Lots of little dots
- Impressionism
- Pointilism
- The CRT color TV
3Seurat Old Faithful
4RGB
- Subpixels
- How its arranged
- Where the numbers come from
5Things to do with arrays
- Reduced row echelon form
- Addition
- Linear function operation
- Subtraction
- Determinant
Rref
6Things to do with images
- Basics
- Adjust brightness
- Invert colors
- Convert to black and white
7- Jenn effect
- Draw contour lines
8- Blur image
- Stretch image
- Impose drawing onto image
9Which effect would you like to see explained?
Draw contour lines
Stretch image
Blur image
Stack images
Next
10Draw contour lines
- A drawing is only lines that represent changes in
value from one region to another.
Example
11function draw(percent,imin) Rowi2 Rowfmaxrow-1
Coli2 Colfmaxcol-1 Ibwdouble(Ibw) while
(RowiltRowf) while (ColiltColf)
AAIbw(Rowi-1,Coli-1,1) ABIbw(Rowi-1,Coli,
1) ACIbw(Rowi-1,Coli1,1)
BAIbw(Rowi,Coli-1,1) BBIbw(Rowi,Coli,1)
BCIbw(Rowi,Coli1,1)
CAIbw(Rowi1,Coli-1,1)
CBIbw(Rowi1,Coli,1) CCIbw(Rowi1,Coli1,
1) AAabs(BB-AA)
ABabs(BB-AB) ACabs(BB-AC)
BAabs(BB-BA) BCabs(BB-BC)
CAabs(BB-CA) CBabs(BB-CB)
CCabs(BB-CC) if AAgtper BB0
elseif ABgtper BB0
elseif ACgtper BB0 elseif
BAgtper BB0 elseif BCgtper
BB0 elseif CAgtper
BB0 elseif CBgtper BB0
elseif CCgtper BB0 else
BB255 end
Id(Rowi,Coli,1)BB Id(Rowi,Coli,2)BB
Id(Rowi,Coli,3)BB conditions
ColiColi1 end Coli2
RowiRowi1 end Id(maxrow,,1)255
Id(maxrow,,2)255 Id(maxrow,,3)255
Id(,maxcol,1)255 Id(,maxcol,2)255
Id(,maxcol,3)255 Iduint8(Id) imwrite(Id,'Id
.jpg') image(Id)
Assign the values for the surrounding pixels
Find the difference from the current pixel
Determine whether the difference is greater than
the user defined percent
Color the new matrix with the appropriate value
Because we had to frame in the original matrix to
avoid location reference errors, this set resizes
so that the drawn image is the same size as the
original
Back
Output the image
12Stretch images
Original image
Take our existing values and reassign their
location per our supplied stretch value
This will result in a bigger or smaller image
with some holes in the matrix, so we have to fill
the holes with the average value of the cells
around the hole.
Stretched image
Back
13Code
function stretch(percent,imin) Iimread(imin) Id
ouble(I) ssize(I) size of
image maxrows(1) maxcols(2) perpercent/100 m
axrowNround(maxrowper) VERTICAL
STRETCH, ONLY WORKS FROM 50 PERCENT TO 249
PERCENT Rowi1 Coli1 while (Rowiltmaxrow)
while (Coliltmaxcol) conditions
Ni(round(Rowiper),Coli,1)I(Rowi,Coli,1)1
Ni(round(Rowiper),Coli,2)I(Rowi,Coli,2)1
Ni(round(Rowiper),Coli,3)I(Rowi,Coli,3)1
ColiColi1 end Coli1
RowiRowi1 end Rowi2 Coli1 while
(RowiltmaxrowN-1) while (Coliltmaxcol)
if Ni(Rowi,Coli,1)0 AboveI(round((Rowi
1)/per),Coli,1) BelowI(round((Rowi-1)/
per),Coli,1) Avg(AboveBelow)/2
Ni(Rowi,Coli,1)Avg end if
Ni(Rowi,Coli,2)0 AboveI(round((Rowi
1)/per),Coli,2) BelowI(round((Rowi-1)/
per),Coli,2) Avg(AboveBelow)/2
Ni(Rowi,Coli,2)Avg end if
Ni(Rowi,Coli,3)0 AboveI(round((Rowi
1)/per),Coli,3) BelowI(round((Rowi-1)/
per),Coli,3) Avg(AboveBelow)/2
Ni(Rowi,Coli,3)Avg end
ColiColi1 end Coli2
RowiRowi1 end Niuint8(Ni)
imwrite(Ni,'Ni.jpg') image(Ni)
Set size of function, And percent value
Reassign the positions For the new matrix
Search each location for a hole, Then fill the
hole with the average Above and below.
Output the image
14Blur image
Time for HANDOUTS!!!!
Back
15Potential
- Where we can go from here
- Blur image more extensively
- Sharpen images
- Impose smaller images into a larger image
- Cryptography
Questions?