School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Images and 2D Graphics COMP 112 2014 # 16.

Slides:



Advertisements
Similar presentations
Md. Monjur –ul-Hasan Department of Computer Science & Engineering Chittagong University of Engineering & Technology Chittagong 4349
Advertisements

Digital Color 24-bit Color Indexed Color Image file compression
Madeleine Wright Peter Wentworth. » On your screen, or with light beams, colours are additive. » Each pixel is a mixture of Red, Green and Blue, the additive.
Numbers in Images GCNU 1025 Numbers Save the Day.
Fundamentals of Digital Imaging
School of Computing Science Simon Fraser University
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae & david streader, VUW Images and 2D Graphics COMP.
Colour Theory and Application B.Sc. (Hons) Multimedia ComputingMedia Technologies.
1 Lecture 6 Attributes of graphical primitives Colors Colors in OpenGL Algorithms for scan-conversion.
Graphics File Formats. 2 Graphics Data n Vector data –Lines –Polygons –Curves n Bitmap data –Array of pixels –Numerical values corresponding to gray-
Images and colour Colour - colours - colour spaces - colour models Raster data - image representations - single and multi-band (multi-channel) images -
Image Representation.
Graphics in the web Digital Media: Communication and Design
1 Perception. 2 “The consciousness or awareness of objects or other data through the medium of the senses.”
Graphics and Images September 28, Unit 3.
How Images are Represented Bitmap images (Dots used to draw the image) Monochrome images 8 bit grey scale images 24 bit colour Colour lookup tables Vector.
Color Model AbdelRahman Abu_absah Teacher: Dr. Sana'a Alsayegh.
CS110: Computers and the Internet Color and Image Representation.
1 Internet Graphics. 2 Representing Images  Raster Image: Images consist of “dots” of color, not lines  Pixel: Picture element-tiny rectangle  Resolution:
Graphical images Bit-mapped (or raster-based) image: Matrix describing the individual dots that are the smallest elements (pixels) of resolution on a computer.
Data starts with width and height of image Then an array of pixel values (colors) The number of elements in this array is width times height Colors can.
Primaries: magenta, yellow, and cyan This color system is called subtractive because: each primary color absorbs (subtracts) a certain part of the color.
Colour Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman
Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 6 This presentation © 2004, MacAvon Media Productions Colour.
Prepared by George Holt Digital Photography BITMAP GRAPHIC ESSENTIALS.
Digital Images The digital representation of visual information.
Color Names All standards-compliant browsers should handle these color names These color names can be used with the CSS properties of color and background-color.
Dean Pentcheff NHMLAC MBPC/Crustacea 17 April 2006.
COMP Bitmapped and Vector Graphics Pages Using Qwizdom.
Computer Graphics Using “ Adobe Photoshop ” Introduction to E-Learning Center, DAD presents Workshop on Instructor: Mazhar.
Digital Images Chapter 8, Exploring the Digital Domain.
TOPIC 4 INTRODUCTION TO MEDIA COMPUTATION: DIGITAL PICTURES Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach.
Foundations of Web Design I Photoshop CS5 Michael Daniel
CS1315: Introduction to Media Computation Picture encoding and manipulation.
THE THEORY & CONCEPTS Lesson 1 – Part 1. What is Graphic Design It’s a CREATIVE PROCESS Undertaken in order to convey a specific message/s I can’t teach.
Image Representation. Objectives  Bitmaps: resolution, colour depth and simple bitmap file calculations.  Vector graphics: drawing list – objects and.
CSC Computing with Images
CS- 375 Graphics and Human Computer Interaction Lecture 1: 12/4/1435 Fundamental Techniques in Graphics Lecturer: Kawther Abas.
CS112 Scientific Computation Department of Computer Science Wellesley College Numb3rs Number and image types.
Graphics workshop Library and Information Services University of St Andrews.
Image Representation. Digital Cameras Scanned Film & Photographs Digitized TV Signals Computer Graphics Radar & Sonar Medical Imaging Devices (X-Ray,
3461 Output Model A picture is worth a thousand words.
Ch 6 Color Image processing CS446 Instructor: Nada ALZaben.
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.
Mirjana Devetakovic, M.Sc. CAAD - Images Beograd, 2011.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Images and 2D Graphics COMP # 17.
Intro to Color Theory. Objectives Identify and discuss various color models including RGB, CMYK, Black/white and spot color. Investigate color mixing.
Image File Formats By Dr. Rajeev Srivastava 1. Image File Formats Header and Image data. A typical image file format contains two fields namely Dr. Rajeev.
TOPIC 4 INTRODUCTION TO MEDIA COMPUTATION: DIGITAL PICTURES Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach.
Image Editing Vocabulary Words Pioneer Library System Norman Public Library Nancy Rimassa, Trainer Thanks to Wikipedia ( help.
Graphics and Image Data Representations 1. Q1 How images are represented in a computer system? 2.
Information Systems Design and Development Media Types Computing Science.
Computer Graphics: Achromatic and Coloured Light.
Colour CPSC Colour ● Models ● RGB ● CMY(K) ● HSB (or HSV) ● RYB ● Harmonies ● Monochrome ● Complementary ● Analogous ● Triadic.
DIGITAL MEDIA FOUNDATIONS
Introduction to Computational Art
Images and 2D Graphics COMP
Sampling, Quantization, Color Models & Indexed Color
Design Concepts: Module A: The Science of Color
Binary Representation in Audio and Images
Adjusting Image Colors Lasso & Marquee Tools
Week 13 - Monday CS 121.
Raster Images CPSC 1030.
EEE3112 Introduction to Multimedia Application & Technology Chapter 1: Image Development by Muhazam Mustapha, September 2012.
Computer Graphics Using “Adobe Photoshop”
Representing Images 2.6 – Data Representation.
MED 2001 Advanced Media Production
Light Light has wave-like properties
Multimedia System Image
Basic Concepts of Digital Imaging
Presentation transcript:

School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Images and 2D Graphics COMP # 16

COMP112 16: 2 Menu Graphics Understanding and Representing Colours Images and image manipulation Admin Test: 15 th April, 4-5pm, HMLT104, HULT323

COMP112 16: 3 Images An image is a 2D array of pixels Colors how do you represent the colour of a pixel? How do you represent images size, resolution, many different formats Lots of things you want to do to images crop, rotate, zoom, change resolution, change the brightness or colour blur, sharpen, refocus,…. compress, decompress,… join up, morphing,…. photoshop effects,………………………………………………….. image recognition,……………………………

COMP112 16: 4 Pixels and Colours Pixels: sample of the image, typically representing the colour at or over a small region Colours: Black and white:1 Bit Grey scale: 1 integer, 8 bit, 16, 32 bit,…. Colour Palette:eg, 1 byte (8 bits) specifying a colour from a palette of 256 colours Colour:3 numbers: RGB, HSL, HSV, CMY,… 18 bits, 24 bits, 30 bits, 48 bit” Color + transparency: 4 numbers Why three numbers? What is a colour?

COMP112 16: 5 Colour Light is made of waves of many different frequencies spectrum. Single frequency light: “pure” color. Different combinations of frequencies are different colors. red violet red violet red violet

COMP112 16: 6 Why only three color components? Human eye has only three different color detectors: Lots of different combinations of pure colours give rise to the same perceived color We can’t distinguish as many different colours as an eye with (say) five different color detectors. Three degrees of freedom ⇒ three numbers are sufficient. red violet

COMP112 16: 7 Side track: Displays and Printing Different display technologies will generate different combinations of “pure” colours, and will look different. ⇒ reproducing true colours on digital displays is very hard. ⇒ calibrating displays is challenging Printing uses subtractive colours: adding colours makes it darker colors behave differently, and are very well specified may not match what’s on the screen. If building software, hardware, or websites where colour matters, you need to learn more about it!

COMP112 16: 8 Colours: Which three numbers? RGB: red green blue, additive model 0,0,0 = black, 1.0, 1.0, 1.0 = white typically 24 bits per pixel, 8 bits per component simple, but non-linear correspondence to our perception HSV, HSL hue, saturation, value/lightness can translate to/from RGB better correspondence to perception CMY Cyan, magenta, yellow subtractive for printing. Run ColourPicker

COMP112 16: 9 Transparency (“alpha”) Can use a 4 th number to represent transparency: (  ) Governs how this color combines with another color. result =   colour + (1 -  )  old-color Colour choosers: Java: javax.swing.JColorChooser Powerpoint Inkscape multiple visualisations of a 3D space. challenging HCI design issue.

COMP112 16: 10 Color in Java Color is represented by 32 bit color = 4 bytes = 4  8 bits,  1 byte each for red, green, blue, alpha Has constructors that take 3 or 4 integers (0-255) new Color(20, 172, 230); new Color(20, 172, 230, 128); a single integer: new Color( ) ; new Color(0x14ACE6); new Color( , true);new Color(0x8014ACE6, true); 3 or 4 floats (0.0 … 1.0) new Color (0.0781f, f, f); new Color (0.0781f, f, f, 0.5f); Static “factory” method: Color.getHSBColor(0.7656f, f, f) hexadecimal literals (ints) float. literals

COMP112 16: 11 Java Program import ecs100.*; import java.awt.Color; import javax.swing.JColorChooser; public class ColourPicker{ private Color color = new Color(20, 172, 230, 128); private int radius = 20; public ColourPicker(){ UI.setColor(color); UI.setMouseListener(new UIMouseListener(){ public void mousePerformed(String action, double x, double y){ if (action.equals("released")){ UI.fillOval(x-radius, y-radius, radius*2, radius*2); } }}); UI.addButton("Colour", new UIButtonListener(){ public void buttonPerformed(String b){ color = JColorChooser.showDialog(null, "pick a color", color); UI.setColor(color); }}); UI.addSlider("Size", 0, 100, radius, new UISliderListener(){ public void sliderPerformed(String s, double value){ radius = (int)value; }}); } public static void main(String[] arguments){ new ColourPicker(); } } Anonymous inner classes

COMP112 16: 12 Images what do I want to say? images vs compressed images image files: header information vs pixel values talk about compression? image arrays: 2D array of Color, easy, but problem: Color is immutable 2D array of int (rgb) easier, problem: harder to manipulate components 2D array of array of int[3] mutable, so easy to access and change components separately reading files in Java

COMP112 16: 13 Images: file formats Files: Why so many image formats? (raster based formats) JPEG, (lossy compression) TIFF, (allows high quality 48 bit colour) GIF, (palette of bit colour, lossless compression) PNG, (palette and 24-bit, lossless compression) BMP, (range of formats, usually large) PNM, (very simple, no compression, large) WebP, (recent replacement for PNG, 45% better on av ….. What is in an image file? header: information about the image (format, size, ….) pixel values (compressed and encoded)

COMP112 16: 14 Images: internal data structures Good data structure for Java programs working with images? 2D array of Color + - 2D array of int: alpha red green blue + - 2D array of int [3], float [3], int [4], float [4]: {red,green,blue,  } + -

COMP112 16: 15 Load image file to int [ ][ ][ ] import javax.imageio.ImageIO; import java.awt.image.BufferedImage; private int [ ][ ][ ] image; public void loadImage() { String imageName = UIFileChooser.open(); if (imageName==null) return; try { BufferedImage img = ImageIO.read(new File(imageName)); UI.printMessage("loaded image " + imageName); image = new int [img.getHeight()] [img.getWidth()] [3]; for (int row = 0; row < img.getHeight(); row++){ for (int col = 0; col < img.getWidth(); col++){ int rgb = img.getRGB(col, row); image[row] [col] [0] = (rgb>>16) & 255; image[row] [col] [1] = (rgb>>8) & 255; image[row] [col] [2] = rgb & 255; } } catch(IOException e){UI.println("Image reading failed: "+e);} } Use a library!! Don’t parse the formats yourself! Bitwise shift operators

COMP112 16: 16 Save int [ ] [ ] [ ] to image file public void saveImage() { if (image==null) { return; } int height = this.image.length; int width = this.image[0].length; BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); for (int row = 0; row < height; row++) { for (int col = 0; col < width; col++) { int rgb = (((image[row][col][0] << 8) + image[row][col][1]) << 8) + image[row][col][2]; img.setRGB(col, row, rgb); } try { String fname = UIFileChooser.save("save to png image file"); if (fname==null) { return; } ImageIO.write(img, "png", new File(fname)); } catch(IOException e){UI.println("Image reading failed: "+e);} }