Computer Science 111 Fundamentals of Programming I Introduction to Digital Image Processing.

Slides:



Advertisements
Similar presentations
Introduction to Colour Management
Advertisements

Computer Science 111 Fundamentals of Programming I More Digital Image Processing.
Objectives Define photo editing software
HISTOGRAM TRANSFORMATION IN IMAGE PROCESSING AND ITS APPLICATIONS Attila Kuba University of Szeged.
Capturing and optimising digital images for research Gilles Couzin.
School of Computing Science Simon Fraser University
IAT 3551 Computer Graphics Overview Color Displays Drawing Pipeline.
Digital Audio, Image and Video Hao Jiang Computer Science Department Sept. 6, 2007.
Fundamentals of Python: From First Programs Through Data Structures
Computer Vision Lecture 3: Digital Images
Digital Images. Scanned or digitally captured image Image created on computer using graphics software.
Trevor McCasland Arch Kelley.  Goal: reduce the size of stored files and data while retaining all necessary perceptual information  Used to create an.
Image Processing.  a typical image is simply a 2D array of color or gray values  i.e., a texture  image processing takes as input an image and outputs.
Fundamentals of Photoshop
Image processing Second lecture. Image Image Representation We have seen that the human visual system (HVS) receives an input image as a collection of.
© 1999 Rochester Institute of Technology Color. Imaging Science Workshop for Teachers ©Chester F. Carlson Center for Imaging Science at RIT Color Images.
Lab #5-6 Follow-Up: More Python; Images Images ● A signal (e.g. sound, temperature infrared sensor reading) is a single (one- dimensional) quantity that.
TOPIC 4 INTRODUCTION TO MEDIA COMPUTATION: DIGITAL PICTURES Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach.
Image Processing & Perception Sec 9-11 Web Design.
2/3/04© University of Wisconsin, CS559 Spring 2004 Last Time Color –Transforming between two color spaces –A gamut is the set of displayable colors in.
Objective Understand concepts used to create digital graphics. Course Weight : 15% Part Three : Concepts of Digital Graphics.
Chapter 5 Using Classes and Objects in Media Computing
I-1 Steps of Image Generation –Create a model of the objects –Create a model for the illumination of the objects –Create an image (render) the result I.
COSC 1P02 Intro. to Computer Science 6.1 Cosc 1P02 Week 6 Lecture slides "To succeed, jump as quickly at opportunities as you do at conclusions." --Benjamin.
© 1999 Rochester Institute of Technology Introduction to Digital Imaging.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
Computer Science 111 Fundamentals of Programming I Introduction to Graphics.
Computer Science 112 Fundamentals of Programming II Graphics Programming.
COSC 1P02 Introduction to Computer Science 7.1 Cosc 1P02 Week 7 Lecture slides "There are two ways of constructing a software design; one way is to make.
Digital Cameras And Digital Information. How a Camera works Light passes through the lens Shutter opens for an instant Film is exposed to light Film is.
September 5, 2013Computer Vision Lecture 2: Digital Images 1 Computer Vision A simple two-stage model of computer vision: Image processing Scene analysis.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Intelligent Vision Systems Image Geometry and Acquisition ENT 496 Ms. HEMA C.R. Lecture 2.
infinity-project.org Engineering education for today’s classroom 2 Outline How Can We Use Digital Images? A Digital Image is a Matrix Manipulating Images.
Image Representation. Digital Cameras Scanned Film & Photographs Digitized TV Signals Computer Graphics Radar & Sonar Medical Imaging Devices (X-Ray,
Digital Image Processing Part 1 Introduction. The eye.
ADOBE PHOTOSHOP VECTOR VS RASTER. Pixel A pixel is the fundamental unit of an image in Photoshop. It is a small square block of color. An image often.
Computer Science 111 Fundamentals of Programming I Introduction to Digital Image Processing.
Introduction to Image processing using processing.
Digital Image Processing Lecture4: Fundamentals. Digital Image Representation An image can be defined as a two- dimensional function, f(x,y), where x.
Computer Vision Introduction to Digital Images.
How digital cameras work The Exposure The big difference between traditional film cameras and digital cameras is how they capture the image. Instead of.
Adobe Photoshop CS5 – Illustrated Unit A: Getting Started with Photoshop CS5.
DIGITAL IMAGE. Basic Image Concepts An image is a spatial representation of an object An image can be thought of as a function with resulting values of.
Digital Imaging Fundamentals Ms. Hema C.R. School of Mechatronic Engineering.
Python Programming in Context Chapter 6. Objectives To understand pixel based image processing To use nested iteration To use and understand tuples To.
Visual Computing Computer Vision 2 INFO410 & INFO350 S2 2015
PART 2 – Size, Display, Color Modes. Image Size Courtesy of Digital images are made up of pixels (picture elements),
Computer Science 121 Scientific Computing Winter 2014 Chapter 14 Images.
Intelligent Vision Systems Image Geometry and Acquisition ENT 496 Ms. HEMA C.R. Lecture 2.
TOPIC 4 INTRODUCTION TO MEDIA COMPUTATION: DIGITAL PICTURES Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach.
Digital Image Processing
HOW SCANNERS WORK A scanner is a device that uses a light source to electronically convert an image into binary data (0s and 1s). This binary data can.
Scanner Scanner Introduction: Scanner is an input device. It reads the graphical images or line art or text from the source and converts.
Adobe Photoshop CS4 – Illustrated Unit A: Getting Started with Photoshop CS4.
1 Sections 5.1 – 5.2 Digital Image Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Image Processing Intro2CS – week 6 1. Image Processing Many devices now have cameras on them Lots of image data recorded for computers to process. But.
Digital Cameras in the Classroom Day One Basics Ann Howden UEN Professional Development
Photoshop CS6 – Nelson Unit 3: Photoshop CS6. Objectives Define photo editing software Start Photoshop and view the workspace Use the Zoom tool and the.
Fundamentals of Programming I Introduction to Graphics
Image Processing Objectives To understand pixel based image processing
Adjusting Image Colors Lasso & Marquee Tools
DIP 9 65 Original 210 Eye Zoomed.
Fundamentals of Programming I Introduction to Digital Image Processing
Fundamentals of Programming I Introduction to Graphics
Fundamentals of Programming I Introduction to Digital Image Processing
COMS 161 Introduction to Computing
Digital Image Processing
Non-numeric Data Representation
Fundamentals of Python: First Programs Second Edition
Presentation transcript:

Computer Science 111 Fundamentals of Programming I Introduction to Digital Image Processing

Digital Images Input devices: –scanners –cameras –camcorders Output devices: –display screens –printers Processing: –file compression –various transformations

Transformations Convert from color to grayscale Adjust the brightness Adjust the contrast Adjust the size Rotate Morph into another image

Morph of the Day 1

Morph of the Day 2

Representing Images An image can be represented as a two-dimensional grid of RGB values (pixels) To capture an image (via camera or scanner), a continuous range of color info is sampled as a set of discrete color values All processing works with the grid of RGB values Output maps the grid to a file, display, or printer

The images Module A non-standard, open source module that includes a set of classes and methods for processing images Can edit scripts in IDLE, then run them from the shell or a terminal prompt python3 myprogram.py

The Image Class Image(fileName) Image(width, height) draw() clone() getWidth() getHeight() getPixel(x, y) setPixel(x, y, (r, g, b)) save(filename = "") Represents a grid of pixels Methods for display, examining the dimensions, examining or resetting pixels, and saving changes to a file A pixel is just a tuple of 3 integers Works with GIF image files

A Simple Session >>> from images import Image

A Simple Session The image file must be in the current working directory >>> from images import Image >>> image = Image('smokey.gif')

A Simple Session draw must be run to display the image >>> from images import Image >>> image = Image('smokey.gif') >>> image.draw()

A Simple Session >>> from images import Image >>> image = Image('smokey.gif') >>> image.draw() >>> image.getWidth(), image.getHeight() (300, 225) The comma creates a tuple of results

A Simple Session >>> from images import Image >>> image = Image('smokey.gif') >>> image.draw() >>> image.getWidth(), image.getHeight() (300, 225) >>> image.getPixel(0, 0) (206, 224, 122) Screen coordinates: the origin (0, 0) is the upper left corner y-values increase as you move down

Transformations: Black and White Compute the average of the three color components in a pixel If the average is less than 128, then set the pixel ’ s three color components to 0s (black) Otherwise, set them to 255s (white)

blackPixel = (0, 0, 0) whitePixel = (255, 255, 255) for y in range(image.getHeight()): for x in range(image.getWidth()): (r, g, b) = image.getPixel(x, y) average = (r + g + b) // 3 if average < 128: image.setPixel(x, y, blackPixel) else: image.setPixel(x, y, whitePixel) Transformations: Black and White

for y in range(3): for x in range(4): print((y, x), end = ' ') print() Processing a Grid (0, 0) (0, 1) (0, 2) (0, 3) (1, 0) (1, 1) (1, 2) (1, 3) (2, 0) (2, 1) (2, 2) (2, 3) 3 rows, 4 columns

Transformations: Inversion Should turn black into white or white into black Reset each color component of a pixel to 255 minus that component ’ s value

for each pixel in the image: subtract each color component from 255 Transformations: Inversion

Transformations: Grayscale Compute the average of the three color components in a pixel Reset each color component of the pixel to this average value

Transformations: Grayscale for y in range(image.getHeight ()) for x in range(image.getWidth()): (r, g, b) = image.getPixel(x, y) ave = (r + g + b) // 3 image.setPixel(x, y, (ave, ave, ave))

A Better Grayscale Algorithm The simple average of the RGB values does not take account of the human retina ’ s different sensitivities to the luminance of those values The human eye is most sensitive to green, then red, then blue Psychologists have determined the exact sensitivities Multiply each value by a weight factor and then add them up

A Better Grayscale Algorithm red = int(red * 0.299) green = int(green * 0.587) blue = int(blue * 0.114) gray = red + green + blue image.setPixel(x, y, (gray, gray, gray)) Old New

Package Code in a Function def grayScale(image): for y in range(image.getHeight ()): for x in range(image.getWidth()): (r, g, b) = image.getPixel(x, y) ave = (r + g + b) // 3 image.setPixel(x, y, (ave, ave, ave)) Note that this function does not return a new image, but modifies its argument Until now, functions did not modify arguments This is the most efficient way of modifying large data objects

For Monday More Image Transformations