L23. Working with Image Files imread, imwrite, imshow, uint8, rgb2gray.

Slides:



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

Web Design Vocab 3 PNG, JPG, GIF, MP3, MPEG.
Information Representation
L.Ghadah R. Hadba CT1514-L1.  Computer Graphics :refers to processing of creating a new image from Geometry, Lighting parameters, Materials and Textures.Using.
The Binary Numbering Systems
DIGITAL IMAGE PROCESSING CMSC 150: Lecture 14. Conventional Cameras  Entirely chemical and mechanical processes  Film: records a chemical record of.
Multimedia for the Web: Creating Digital Excitement Multimedia Element -- Graphics.
Insight Through Computing 22. Working with Image Files imread, imwrite, imshow, uint8, rgb2gray.
Connecting with Computer Science, 2e
Insight Through Computing 18. Two-Dimensional Arrays Set-Up Rows and Columns Subscripting Operations Examples.
CS430 © 2006 Ray S. Babcock CS430 – Image Processing Image Representation.
Insight Through Computing 23. Working with Image Files Cont’d Filtering Noise Edge Detection.
Introduction to Computer Graphics
01/31/02 (C) 2002, UNiversity of Wisconsin, CS 559 Last Time Color and Color Spaces.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
CS559-Computer Graphics Copyright Stephen Chenney Image File Formats How big is the image? –All files in some way store width and height How is the image.
WEB GRAPHICS. The Pixel Computer displays are comprised of rows and columns of pixels. Pixels are indivisible. Some common screen resolutions are:, 600.
Department of Physics and Astronomy DIGITAL IMAGE PROCESSING
1 Ethics of Computing MONT 113G, Spring 2012 Session 11 Graphics on the Web Limits of Computer Science.
Image processing Second lecture. Image Image Representation We have seen that the human visual system (HVS) receives an input image as a collection of.
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.
THE COLORS OF LIGHT RED, GREEN and BLUE
Image Storage Bitmapped Graphics – in which an image is represented as a collection of dots Vector Graphics – in which an image is represented as a set.
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.
Lecture 18 Chapter 12 Matrices continued. Outline from Chapter Matrix Operations Matrix Multiplication Matrix Division
Web Image Basics Comp 140 December 2. Vector Graphics Can be repositioned or resized – Will not diminish output quality Typically stored in AI, EPS, PICT.
Common file formats  Lesson Objective: Understanding common file formats and their differences.  Learning Outcome:  Describe the type of files which.
1 Ethics of Computing MONT 113G, Spring 2012 Session 10 HTML Tables Graphics on the Web.
Two –Dimensional Arrays Mrs. C. Furman Java Programming November 19, 2008.
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.
+ 5 Things you need to know about images* *Images for the web.
Computer Images Can store color info about each pixel, but makes file BIG Compression for Web 15.
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.
Image Representation. Digital Cameras Scanned Film & Photographs Digitized TV Signals Computer Graphics Radar & Sonar Medical Imaging Devices (X-Ray,
Web Graphics. Colours and Display Graphics and Modems 28.8kbps = 3.6 KB per second 36 KB takes 10 seconds to load. Pixels and color.
Digital Image Processing Lecture4: Fundamentals. Digital Image Representation An image can be defined as a two- dimensional function, f(x,y), where x.
Module 4- Build a Game Look at Me Mod 4 Lesson 3 Graphics.
1 COMS 161 Introduction to Computing Title: The Digital Domain Date: September 6, 2004 Lecture Number: 6.
Color and Images. Color The natural colors we see and the colors we see on computer monitors are different. CMYK -natural RGB -monitor.
Mirjana Devetakovic, M.Sc. CAAD - Images Beograd, 2011.
 By Bob “The Bird” Fiske & Anita “The Snail” Cost.
POWERPOINT PLUS 11/17/07 Class Notes. WHAT IS A PIXEL A pixel is a number that represents the intensity of light at a square spot in the picture. Pixels.
CMPS1371 Introduction to Computing for Engineers IMAGES.
Digital Image Editing Presented by John Hohn. File Formats JPEG – Joint Photographic Experts Group PNP – Portable Network Graphics GIF – Graphic Interchange.
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
Computer Science 121 Scientific Computing Winter 2014 Chapter 14 Images.
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.
Image Representation Last update st March Heejune Ahn, SeoulTech.
Scanner Scanner Introduction: Scanner is an input device. It reads the graphical images or line art or text from the source and converts.
Graphics and Image Data Representations 1. Q1 How images are represented in a computer system? 2.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 5.
Information in Computers. Remember Computers Execute algorithms Need to be told what to do And to whom to do it.
Module 4- Build a Game Look at Me Mod 4 Lesson 3 Graphics.
8th Lecture – Intro to Bitmap or Raster Images
Computer Application in Engineering Design
(Project) by:- ROHAN HIMANSHU ANUP 70282
L24. More on Image File Processing
Everything is a number Everything in a computer memory and on storages is a number. Number  Number Characters  Number by ASCII code Sounds  Number.
Computer Science Higher
Images In Matlab.
Image File Size and File Compression
Representing Images 2.6 – Data Representation.
COMS 161 Introduction to Computing
Colors Computers build colors from Red, Green, and Blue; not Red, Blue, and Yellow. RGB = Red Green Blue Creating Colors Red + Blue = Purple No Red, No.
Multimedia System Image
Intro Math Problem Solving October 31
Intro Math Problem Solving November 2
Creating Digital Graphics
Presentation transcript:

L23. Working with Image Files imread, imwrite, imshow, uint8, rgb2gray

Pictures as Arrays A black and white picture can be encoded as a 2D Array Typical: 0 <= A(i,j) <= 255 (black) (white) Values in between correspond to different levels of grayness.

318-by Just a Bunch of Numbers

A Color Picture is 3 Arrays Stack them in a 3D array. Typical: 0 <= A(i,j,1) <= 255 (red) 0 <= A(i,j,2) <= 255 (green) 0 <= A(i,j,3) <= 255 (blue) Note 3 rd Subscript

Encoding Images There are a number of file formats for images. Some common ones: JPEG (Joint Photographic Experts Group) GIF (Graphics Interchange Format) Behind the scenes: compressing data

A Compression Idea Store the array (81 num’s) or the purple vectors (18 num’s)?

More Dramatic Suppose A is a 1000-by 2000 times table. Do I store A (2,000,000 numbers) or Do I store the two 1-dimensional multiplier arrays (3000 numbers) and “reconstruct” A

Images can be written as a sum of a relatively small number of times tables 1000-by-2000 picture might be well approximated by the sum of 100 times tables. 2,000,000 vs (100 x 3000)

Operations on Images They amount to operations on 2D Arrays. A good place to practice “array” thinking.

Two Problems We have: LawSchool.jpg

Problem 1 Want: LawSchoolMirror.jpg

Problem 2 Want: LawSchoolUpDown.jpg

Solution Framework Read LawSchool.jpg from memory and convert it into an array. Manipulate the Array. Convert the array to a jpg file and write it to memory.

imread % Read image and convert to % a 3D array… A = imread('LawSchool.jpg');

The 3D Array >> [m,n,p] = size(A) m = 1458 n = 2084 p = 3 rows columns layers

The Layers 1458-by-2084 A(:,:,1) A(:,:,3) A(:,:,2)

Left-Right Mirror Image A = imread(’LawSchool.jpg’) [m,n,p] = size(A); for j=1:n B(:,j,1) = A(:,n+1-j,1) B(:,j,2) = A(:,n+1-j,2) B(:,j,3) = A(:,n+1-j,3) end imwrite(B,'LawSchoolMirror.jpg')

Equivalent for j=1:n B(:,j,1) = A(:,n+1-j,1) B(:,j,2) = A(:,n+1-j,2) B(:,j,3) = A(:,n+1-j,3) end B = A(:,n:-1:1,:);

The Upside Down Image A = imread(’LawSchool.jpg’) [m,n,p] = size(A); for i=1:m C(i,:,1) = A(m+1-i,:,1) C(i,:,2) = A(m+1-i,:,2) C(i,:,3) = A(m+1-I,:,3) end imwrite(C,'LawSchoolUpDown.jpg')

Equivalent for j=1:n C(i,:,1) = A(m+1-i,:,1) C(i,:,2) = A(m+1-i,:,2) C(i,:,3) = A(m+1-i,:,3) end C = A(m:-1:1,:,:);

New Problem Color  Black and White Have:

New Problem Color  Black and White Want:

rgb2gray A = imread('LawSchool.jpg'); bwA = rgb2gray(A); imwrite(bwA,‘LawSchoolBW.jpg')

How Does the Conversion Work? r g b gray It’s a complicated mapping

Why not take Average? bwA = uint8(zeros(m,n)) for i=1:m for j = 1:n bwA(i,j) = ( A(i,j,1) +… + A(i,j,2) + A(i,j,3))/3; end imwrite(bwA,‘LawSchoolBW.jpg') uint8 : unsigned 8-bit integer

Why not take Max? bwA = uint8(zeros(m,n)) for i=1:m for j = 1:n bwA(i,j) = max([A(i,j,1) … A(i,j,2) A(i,j,3)]); end imwrite(bwA,‘LawSchoolBW.jpg') uint8 : unsigned 8-bit integer

Max:

Matlab:

Problem: Produce a Negative

Idea If matrix A represents the image and B(i,j) = 255 – A(i,j) for all i and j, then B will represent the negative.

Finding Edges

Idea Suppose matrix A represents the image and is m-by-n. |A(i,j+1) – A(i,j)| is big if there is a “jump” in the grayness value as we go from pixel (i,j) to pixel (i,j+1).

Idea (Cont’d) Form a new matrix B that is m-by-(n-1): B(i,j) = abs(A(i,j+1) – A(i,j))

A = imread(‘ClockTower.jpg’) [m,n] = size(A); % Compute the difference image… for j=1:n-1 B(:,j) = A(:,j+1)-A(:,j); end imwrite(B,’ClockTowerEdges.jpg’) Overall

If A(i,j) is very different from the average of its four neighbors, set B(i,j) to be that average. std = sqrt((N-ave)^2 + … (E-ave)^2 + … (S-ave)^2 + … (W-ave)^2)); if abs(A(i,j) – ave)> std B(i,j) = ave; else B(i,j) = A(i,j) end