Enlarging pictures - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Enlarging pictures

Description:

Scaling Up Last time I taught this class I had a student during Lab 5 with a ... Can you think of a less 'blocky' way to do this? ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 8
Provided by: BenSc
Category:

less

Transcript and Presenter's Notes

Title: Enlarging pictures


1
Session 14
  • Enlarging pictures

2
What can I do when things arent the size I want?
  • Scaling Up Last time I taught this class I had
    a student during Lab 5 with a photo of Paris
    Hilton. She wanted to make it bigger so she could
    put a pigs head on her body.

3
Thinking Through Scaling Up
0
1
2
  • Copy each pixel in the source multiple times to
    the target
  • Source (0,0) Target (0,0)
  • Source (0,0) Target(1,0)
  • Source (1,0) Target(2,0)
  • Source (1,0) Target(3,0)
  • Source (2,0) Target(4,0)
  • Source (2,0) Target(5,0)
  • Source (0,0) Target(0,1)
  • Source (0,0) Target(1,1)

0
1
0
1
2
3
4
5
0
1
2
3
4
  • def scaleUpBlocks(sourcePicture)
  • w getWidth(sourcePicture)2
  • h getHeight(sourcePicture)2
  • newPicture makeEmptyPicture(w,h)
  • for x in range(1,getWidth(sourcePicture)1)
  • for y in range(1,getHeight(sourcePicture)1)
  • source getPixel(x,y)
  • target getPixel(x2,y2)
  • setColor(target,getColor(source))
  • target getPixel(x2-1,y2)
  • setColor(target,getColor(source))
  • target getPixel(x2-1,y2-1)
  • setColor(target,getColor(source))
  • target getPixel(x2,y2-1)
  • setColor(target,getColor(source))
  • return newPicture

5
Can you think of a less blocky way to do this?
  • Average two adjoining Pixels to come up with a
    brand new Pixel between them
  • Has strengths and weaknesses as an overall
    solution

6
Another way to Scale Up
0
1
2
  • Copy each pixel in the source only once.

0
1
2
0
1
3
4
0
1
2
7
Another way to Scale Up
0
1
2
  • Copy each pixel in the source only once.
  • For the remaining empty pixels, insert the
    average of the two neighbor pixels.

0
1
2
0
1
3
4
0
1
2
Write a Comment
User Comments (0)
About PowerShow.com