Enlarging an Image
-
Upload
aleksandarpmau -
Category
Documents
-
view
221 -
download
0
Transcript of Enlarging an Image
-
8/19/2019 Enlarging an Image
1/18
Enlarging an Image
Applying the Seven-step Proces
-
8/19/2019 Enlarging an Image
2/18
Double Size of Image
• Problem: double image size
• Twice width + height
• 7 Steps
-
8/19/2019 Enlarging an Image
3/18
Step 1: Small Instance by Han
• 2x2 ! 4x4
inImage outImage
-
8/19/2019 Enlarging an Image
4/18
Step 2: Write Down Steps
inImage
I started with the image I wanted (inImage)1
-
8/19/2019 Enlarging an Image
5/18
Step 2: Write Down Steps
inImage outImage
I made a blank image (outImage) twice as wideand twice as tall as inImage
2
-
8/19/2019 Enlarging an Image
6/18
Step 2: Write Down Steps
inImage outImage
I made outImage’s 1st pixel red3
-
8/19/2019 Enlarging an Image
7/18
Step 2: Write Down Steps
inImage outImage
I made outImage’s 2nd pixel red4
-
8/19/2019 Enlarging an Image
8/18
Step 2: Write Down Steps
inImage outImage
I made outImage’s 3rd pixel blue5
-
8/19/2019 Enlarging an Image
9/18
Step 2: Write Down Steps
inImage outImage
I made outImage’s 16th pixel purple18
-
8/19/2019 Enlarging an Image
10/18
Step 2: Write Down Steps
I started with the image I wanted (inImage)1
I made a blank image (outImage)twice as wide and twice as tall as inImage
2
I made outImage’s 1st pixel red3
I made outImage’s 2nd pixel red4
I made outImage’s 3rd pixel blue5
I made outImage’s 4th pixel blue6
I made outImage’s 5th pixel red7
I made outImage’s 6th pixel red8
I made outImage’s 7th pixel blue9
I made outImage’s 8th pixel blue10
… 9th pixel green11
…10th pixel green12
…11th pixel purple13
…12th pixel purple14
…13th pixel green15
…14th pixel green16
…15th pixel purple17
…16th pixel purple18
-
8/19/2019 Enlarging an Image
11/18
Step 3: Find Patterns
I made outImage’s 1st pixel red3
I made outImage’s 2nd pixel red4
I made outImage’s 3rd pixel blue5
I made outImage’s 4th pixel blue6
I made outImage’s 5th pixel red7
I made outImage’s 6th pixel red8
I made outImage’s 7th pixel blue9
I made outImage’s 8th pixel blue10
… 9th pixel green11
…10th pixel green12
…11th pixel purple13
…12th pixel purple14
…13th pixel green15
…14th pixel green16
…15th pixel purple17
…16th pixel purple18
Look for repetitions and patterns
-
8/19/2019 Enlarging an Image
12/18
Step 3: Find Patterns
I made outImage’s 1st pixel red3
I made outImage’s 2nd pixel red4
I made outImage’s 3rd pixel blue5
I made outImage’s 4th pixel blue6
I made outImage’s 5th pixel red7
I made outImage’s 6th pixel red8
I made outImage’s 7th pixel blue9
I made outImage’s 8th pixel blue10
… 9th pixel green11
…10th pixel green12
…11th pixel purple13
…12th pixel purple14
…13th pixel green15
…14th pixel green16
…15th pixel purple17
…16th pixel purple18
Look for repetitions and patterns
-
8/19/2019 Enlarging an Image
13/18
Step 3: Find Patterns
I made outImage’s 1st pixel red3
I made outImage’s 2nd pixel red4
I made outImage’s 3rd pixel blue5
I made outImage’s 4th pixel blue6
I made outImage’s 5th pixel red7
I made outImage’s 6th pixel red8
I made outImage’s 7th pixel blue9
I made outImage’s 8th pixel blue10
… 9th pixel green11
…10th pixel green12
…11th pixel purple13
…12th pixel purple14
…13th pixel green15
…14th pixel green16
…15th pixel purple17
…16th pixel purple18
Look for repetitions and patterns
-
8/19/2019 Enlarging an Image
14/18
Step 3: Find Patterns
I made outImage’s 1st pixel red3
I made outImage’s 2nd pixel red4
I made outImage’s 3rd pixel blue5
I made outImage’s 4th pixel blue6
I made outImage’s 5th pixel red7
I made outImage’s 6th pixel red8
I made outImage’s 7th pixel blue9
I made outImage’s 8th pixel blue10
… 9th pixel green11
…10th pixel green12
…11th pixel purple13
…12th pixel purple14
…13th pixel green15
…14th pixel green16
…15th pixel purple17
…16th pixel purple18
Look for repetitions and patterns
d
-
8/19/2019 Enlarging an Image
15/18
Step 3: Find Patterns
• Find pattern in
pixel used
0 1 2 3
0
1
2
3
0 1
0
1
To color pixel
with x = …
Look at pixel
with x = …0
1
2
3
0
0
1
1
S i d
-
8/19/2019 Enlarging an Image
16/18
Step 3: Find Patterns
• Divide by 2 is close
• But only want integer part
• Similar pattern for y’s
To color pixel with x
Look at pixelwith x = …
0 0
1 0
2 1
3 1
x/2
0
0.5
1
1.5
0
0
1
1
floor(x/2)
S 3 Fi d P
-
8/19/2019 Enlarging an Image
17/18
Step 3: Find Patterns
I made a blank image (outImage) twice as wideand twice as tall as inImage
2
I started with the image I wanted (inIMage)1
For each pixel in outImage:3
Computed x=floor(pixel’s x/2)a
Computed y=floor(pixel’s y/2)b
Set pixel to the same color asthe pixel at (x,y) in inImage
c
S 4 T Al i h
-
8/19/2019 Enlarging an Image
18/18
Step 4: Test Algorithm
I started with the image I wanted (inImage)1
I made a blank image (outImage)twice as wide and twice as tall as inImage
2
For each pixel in outImage:3
Computed x=floor(pixel’s x/2)a
Computed y=floor(pixel’s y/2)b
Set to the same color as thepixel at (x,y) in inImage
c
Now it’s your turn.
Think about if your
answer is right
Yes. Answer is right!Now let’s write code