Images and 2D Graphics COMP

Slides:



Advertisements
Similar presentations
Digital Color 24-bit Color Indexed Color Image file compression
Advertisements

Numbers in Images GCNU 1025 Numbers Save the Day.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae & david streader, VUW Images and 2D Graphics COMP.
Graphics in the web Digital Media: Communication and Design
An Introduction to Scanning and Storing Photographs and Graphics Bryn Jones Aug 2002
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Images and 2D Graphics COMP # 16.
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.
Digital Images Chapter 8, Exploring the Digital Domain.
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.
Chapter 11 Fluency with Information Technology 4 th edition by Lawrence Snyder (slides by Deborah Woodall : 1.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 14 Introduction to Computer Graphics.
Image Representation. Objectives  Bitmaps: resolution, colour depth and simple bitmap file calculations.  Vector graphics: drawing list – objects and.
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.
Communicating Quantitative Information Is a picture worth 1000 words? Digital images. Number bases Standards, Compression Will [your] images last? Homework:
Image Representation. Digital Cameras Scanned Film & Photographs Digitized TV Signals Computer Graphics Radar & Sonar Medical Imaging Devices (X-Ray,
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.
Raster Graphics 2.01 Investigate graphic image design.
 By Bob “The Bird” Fiske & Anita “The Snail” Cost.
Image File Formats. What is an Image File Format? Image file formats are standard way of organizing and storing of image files. Image files are composed.
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.
Images and Graphics.
BITMAPPED IMAGES & VECTOR DRAWN GRAPHICS
DIGITAL MEDIA FOUNDATIONS
Introduction to Computational Art
Graphics and image data representation
Data Representation.
Everything is a number Everything in a computer memory and on storages is a number. Number  Number Characters  Number by ASCII code Sounds  Number.
Binary Notation and Intro to Computer Graphics
Sampling, Quantization, Color Models & Indexed Color
Digital imaging.
Binary Representation in Audio and Images
Computer Science Higher
How to Convert Pictures into Numbers
Chapter 3 Graphics and Image Data Representations
Images, Display, Perception
Compression (of this 8-bit 397,000 pixel image):
Week 13 - Monday CS 121.
2.01 Investigate graphic image design.
Raster Images CPSC 1030.
Chapter III, Desktop Imaging Systems and Issues: Lesson IV Working With Images
A computer display is made up of small squares, called pixels.
CS Computer Graphics Valdosta State University, Spring 2018
GRAPHICS Source:
1.01 Investigate graphic types and file formats.
Introduction to Computer Graphics
An Introduction to Scanning and Storing Photographs and Graphics
EEE3112 Introduction to Multimedia Application & Technology Chapter 1: Image Development by Muhazam Mustapha, September 2012.
Data Representation.
Computer Graphics Using “Adobe Photoshop”
Representing Images 2.6 – Data Representation.
MED 2001 Advanced Media Production
2.01 Investigate graphic image design.
Introduction to Media Computation
COMS 161 Introduction to Computing
Web Programming– UFCFB Lecture 7
Multimedia System Image
Visuals are analog signals...
2.01 Investigate graphic image design.
Lecture 4 - Introduction to Computer Graphics
WJEC GCSE Computer Science
2.01 Investigate graphic image design.
Presentation transcript:

Images and 2D Graphics COMP 112 2017

Menu Graphics Understanding and Representing Colours Images and image manipulation Using Google and the Java API Arrays Reference type Immuteable Objects – and compact colored images

Immutable Objects An object is immutable if it can not be changed How do you make immutable objects All instance variables are private final Only constructors write to instance variables What common Java objects are immutable String Color ….. Why make an object immutable? Why make an object mutable?

Images Images can be built from objects using: Color, transparancy, reflexivity, texture,…. But an image is no more than a 2D array of colored pixels How do you represent the colour of a pixel? Lots of things you want to do to images crop, rotate, zoom, change resolution, change the brightness or colour blur, sharpen, refocus, join up, morphing,…. compress, decompress,… image recognition,……………………………

Pixels and Colours Pixels: Colours: Stored in sample of the image, typically representing the colour at or over a small region Colours: Stored in 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 Color: 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?

Color 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

Why only three color components? Human eye has only three different color detectors: Lots of different combinations of pure colors give rise to the same perceived color We can’t distinguish all different colors. Screens are designed for the human eye hence only need three numbers each recording the intensity of one of the colors we can detect. red violet

Side track: Displays and Printing Different display technologies will generate different combinations of “pure” colors, and will look different. ⇒ reproducing true colors on digital displays is very hard. ⇒ calibrating displays is challenging Printing uses subtractive colors: adding colors 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 color matters, you need to learn more about it!

Colors: 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 poor correspondence to how we describe color mechanical specification related to how devices generate it color HSV, HSL hue, saturation, value/lightness a way to define color based on how we describe color can translate to/from RGB Try ColorPickerSample.java On comp112 www. Run ColourPicker

Transparency (“alpha”) Can use a 4th number to represent transparency: ( : [0,1]) Pixels on a screen only have color RGB Transparency defines how to compute a color from two layers that may have different color. result =   color + (1 - )  old-color Transparency is useful for Layers and for Paints. Colour choosers: Java: javax.swing.JColorChooser Powerpoint

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(1354982) ; new Color(0x14ACE6); new Color(2148838630, true); new Color(0x8014ACE6, true); 3 or 4 floats (0.0 … 1.0) new Color (0.0781f, 0.6718f, 0.8984f); new Color (0.0781f, 0.6718f, 0.8984f, 0.5f); Note: the different range of int and float parameters can result in out of range errors especially given auto type casting. hexadecimal literals (ints) float . literals

Java Application Java program from ColorPickerSample.java code on course home pages. final ColorPicker colorPicker = new ColorPicker(); colorPicker.setValue(Color.CORAL); final Text text = new Text("Try the color picker!"); text.setFont(Font.font ("Verdana", 20)); text.setFill(colorPicker.getValue()); colorPicker.setOnAction(new EventHandler() { public void handle(Event t) { } }); Build object Return chosen color

Images: file formats Why so many image formats? (raster based formats) JPEG, (lossy compression) TIFF, (allows high quality 48 bit colour) GIF, (palette of 256 24-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) ….. What is in an image file? header: information about the image (format, size, ….) pixel values (compressed and encoded) Use Libraries to read and write standard file formats

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,} All that you need in this course is the 2D array of Color

Use libraries when programming! Use library to read standard file formats Google java read image from file How do I build Colors from image? Read Color api Read BufferedImage api

Save Color [ ] [ ] to image file How do I build an image from Colors Look up BufferedImage api and Color api

Pot Holes to fall into: When you are in a Pot Hole ask yourself if you need to: look up an object api Google for a java fragment An image is a 2D array of pixels Array variables are reference Color is an Object hence reference type but is immutable Color can be built by three variables red, green and blue they can either be three ints or three floats. But the range of the int and float is different. + java can convert an int to a float when used in a computation.

Pothole An image is a 2D array of pixels Image A point to an array of rows. A row points to an array of pixels A pixel points to a Color object Rows 0,1,.. i i A Color Cols 0,1,.. j

Pothole An image is a 2D array of pixels Rows 0,1,.. i i Cols 0,1,.. j Will changing A change B when B = A; B = for(int i = 0; i< A.length; i++) { B[i] = A[i] } Color Rows 0,1,.. i A i Cols 0,1,.. j B B i

Pothole An image is a 2 D array of pixels Will changing A change B? B = for(int i = 0; i< A.length; i++) { for(int j = 0; j< A[0].length; j++) { B[i][j] = A[i][j] }} Is this a problem? Color Rows 0,1,.. i A i Cols 0,1,.. j B i

Immutable & repeated images If Color was mutable changing A[i][j] would change B[i][j]. But Color is immutable so can be replaced but not changed. Hence it is safe for A and B to share Color objects. Color Rows 0,1,.. i A i Cols 0,1,.. j A[i][j] B i

Immutable & indexed color Color is an immutable object hence multile pixels that have the same color can share the same Color object. Store an image with a color palette. Each pixel contains the index into the palette and not the color itself. Indexed color is used to save memory and file storage while speeding up display refresh and file transfer rates Rows 0,1,.. i A i Color Cols 0,1,.. j

Quick Overview Java Colors are: Objects are of reference type. Immutable objects Have different representations Objects are of reference type. Arrays of objects are references to references Cloning an array requires deep coping. Immutable objects allows sharing both: Within an array Between arrays