Chapter 03: IMAGE: Part 1: Key Term Quiz
Chapter 03: IMAGE: Part 1: Key Term Quiz
d. photographs
e. boxes
5. “Unlimited use” of stock photography may actually impose a limitation on:
a. the number of units you can distribute without paying more.
b. the number of changes you can make to the image.
c. converting the image to another file format.
d. the filters you may use to alter the image.
e. the price you can charge for your product.
6. Name the area of memory where data such as text and images is temporarily stored
when you cut or copy within an application.
a. scrapbook
b. notepad
c. junkyard
d. filedump
e. clipboard
7. Perhaps the single most significant advance in computer image processing during the
late 1980s was the development of:
a. digital cameras
b. 3-D modeling programs
c. image-editing programs
d. scanners
e. electronic crayons 2
8. When an image created on a Macintosh is viewed on a PC:
a. it appears darker and richer because the values have changed
b. it appears lighter and less saturated because the values have changed
c. it appears darker and richer even though the values have not changed
d. it appears lighter and less saturated even though the values have not changed
e. it appears exactly the same
9. Graphic artists designing for print media use vector-drawn objects because:
a. they can contain more subtle variations in shading than bitmap graphics
b. printing inks respond better to them
c. they can be converted across platforms more easily
d. they can be scaled to print at any size
e. they can be viewed directly in Web browsers
10. The 3-D process of extending a plane surface some distance, either perpendicular to
the shape’s outline or along a defined path, is called:
a. lathing
b. rendering
c. modeling
d. extruding
e. skinning
11. A GIF image may contain:
a. 8 bits of color information per pixel
1 From PIL import Image # first two lines import the necessary modules from PIL
2 import ImageDraw
3 txt = "Not really a fancy text!"
4 size = (150, 50)
5 color = (0, 100, 0)
6 img = Image.new('RGB', size, color) # creating image using Image.new
7 imgDrawer = ImageDraw.Draw(img) # The function ImageDraw.Draw takes an image
object as an argument to create a Draw instance. This Draw instance enables drawing
various things in the given image.
8 imgDrawer.text((5, 20), txt) # we call the text method of the Draw instance and supply
position (a tuple) and the text (stored in the string txt) as arguments.
9 img.show()
Part 4. Resizing
Download the image from internet.
Write the following code. Replace the inPath and outPath strings with the appropriate
image path on your machine.
1 import Image
2 inPath = "C:\\images\\ImageResizeExample.jpg"
3 img = Image.open(inPath)
4 width , height = (160, 160)
5 size = (width, height)
6 foo = img.resize(size)
7 foo.show()
8 outPath = "C:\\images\\foo.jpg"
9 foo.save(outPath)
#Line 6 in the code snippet does the resizing job and finally we save the new image on
line 9. You can see how the resized image looks by calling foo.show().
Part 5 Rotating
Use your image and write down following code:
1 import Image
2 inPath = "C:\\images\\Rotate.png"
3 img = Image.open(inPath)
4 deg = 45
5 filterOpt = Image.BICUBIC
6 outPath = "C:\\images\\Rotate_out.png"
7 foo = img.rotate(deg, filterOpt)
8 foo.save(outPath)
Part 6 Flipping
Use your image and write down following code:
1 import Image
2 inPath = "C:\\images\\Flip.png"
3 img = Image.open(inPath)
4 outPath= "C:\\images\\Flip_out.png"
5 foo = img.transpose(Image.FLIP_LEFT_RIGHT)
6 foo.save(outPath)
5
# To flip the image vertically, replace line 5 in the code with the following:
foo = img.transpose(Image.FLIP_TOP_BOTTOM)
The same effect can be achieved using the ImageOps module. To flip the image
horizontally, use ImageOps.mirror, and to flip the image vertically, use ImageOps.flip.
import ImageOps
# Flip image horizontally
foo1 = ImageOps.mirror(img)
# Flip image vertically
foo2 = ImageOps.flip(img)
Part 7 Cropping
import Image
img = Image.open("C:\\images\\Crop.png")
left = 0
upper = 0
right = 180
lower = 215
bbox = (left, upper, right, lower)
img = img.crop(bbox)
img.show()
Part 8 Pasting
Use your image and write down following code:
1 import Image
2 img = Image.open("C:\\images\\Crop.png")
3 # Define the elements of a 4-tuple that represents
4 # a bounding box ( region to be cropped)
5 left = 0
6 upper = 25
7 right = 180
8 lower = 210
9 bbox = (left, upper, right, lower)
10 # Crop the smiley face from the image
11 smiley = img.crop(bbox_1)
12 # Flip the image horizontally
13 smiley = smiley.transpose(Image.FLIP_TOP_BOTTOM)
14 # Define the box as a 2-tuple. 6
15 bbox_2 = (0, 210)
16 # Finally paste the 'smiley' on to the image.
17 img.paste(smiley, bbox_2)
18 img.save("C:\\images\\Pasted.png")
19 img.show()