Insight Through Computing 22. Working with Image Files imread, imwrite, imshow, uint8, rgb2gray.

Slides:



Advertisements
Similar presentations
Pixels and Digital Images Yrd. Doc. Dr. Ahmet Sayar Kocaeli Universitesi Bilgisayar Muhendisligi Ileri Bilgisayar Grafikleri.
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
Chapter 14 Landsat 7 image of the retreating Malaspina Glacier, Alaska.
Connecting with Computer Science, 2e
Insight Through Computing 18. Two-Dimensional Arrays Set-Up Rows and Columns Subscripting Operations Examples.
Insight Through Computing 23. Working with Image Files Cont’d Filtering Noise Edge Detection.
First Bytes - LabVIEW. Today’s Session Introduction to LabVIEW Colors and computers Lab to create a color picker Lab to manipulate an image Visual ProgrammingImage.
Graphics in the web Digital Media: Communication and Design
Introduction to Computer Graphics
5. 1 JPEG “ JPEG ” is Joint Photographic Experts Group. compresses pictures which don't have sharp changes e.g. landscape pictures. May lose some of the.
Roger Cheng (JPEG slides courtesy of Brian Bailey) Spring 2007
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.
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.
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.
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.
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.
Chapter 1. Introduction. Goals of Image Processing “One picture is worth more than a thousand words” 1.Improvement of pictorial information for human.
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,
Digital Image Processing Lecture4: Fundamentals. Digital Image Representation An image can be defined as a two- dimensional function, f(x,y), where x.
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.
CMPS1371 Introduction to Computing for Engineers IMAGES.
L23. Working with Image Files imread, imwrite, imshow, uint8, rgb2gray.
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.
Intelligent Vision Systems Image Geometry and Acquisition ENT 496 Ms. HEMA C.R. Lecture 2.
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.
Lecture 27: Image Processing
Image Representation Last update st March Heejune Ahn, SeoulTech.
Image Editing Vocabulary Words Pioneer Library System Norman Public Library Nancy Rimassa, Trainer Thanks to Wikipedia ( help.
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.
Computer Application in Engineering Design
(Project) by:- ROHAN HIMANSHU ANUP 70282
L24. More on Image File Processing
Image Processing Objectives To understand pixel based image 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
Image File Size and File Compression
Digital Image Processing using MATLAB
Сабақтың тақырыбы: Компьютерлік графика негіздері
EP375 Computational Physics
CSC 381/481 Quarter: Fall 03/04 Daniela Stan Raicu
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.
Digital Image Processing
Multimedia System Image
Fundamentals of Image Processing Digital Image Representation
Intro Math Problem Solving October 31
Intro Math Problem Solving November 2
Presentation transcript:

Insight Through Computing 22. Working with Image Files imread, imwrite, imshow, uint8, rgb2gray

Insight Through Computing 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.

Insight Through Computing 318-by Just a Bunch of Numbers

Insight Through Computing 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

Insight Through Computing

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

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

Insight Through Computing 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

Insight Through Computing 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)

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

Insight Through Computing Two Problems We have: LawSchool.jpg

Insight Through Computing Problem 1 Want: LawSchoolMirror.jpg

Insight Through Computing Problem 2 Want: LawSchoolUpDown.jpg

Insight Through Computing 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.

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

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

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

Insight Through Computing % Store left-right mirror of A % in array B [nr,nc,np]= size(A); for r= 1:nr for c= 1:nc B(r,c )= A(r,nc-c+1 ); end A B

Insight Through Computing % Store left-right mirror of A % in array B [nr,nc,np]= size(A); for r= 1:nr for c= 1:nc for p= 1:np B(r,c,p)= A(r,nc-c+1,p); end

Insight Through Computing Left-Right Mirror Image (vectorized) 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')

Insight Through Computing Even more vectorized 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,:);

Insight Through Computing 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')

Insight Through Computing 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,:,:);

Insight Through Computing New Problem Color  Black and White Have:

Insight Through Computing New Problem Color  Black and White Want:

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

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

Insight Through Computing 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') Type uint8 : unsigned 8-bit integers (0,1,2,…,255)

Insight Through Computing

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')

Insight Through Computing Max:

Insight Through Computing Matlab:

Insight Through Computing Weighted average of the RGB values.3R+.59G+.11B for i= 1:m for j= 1:n M(i,j)=.3*R(i,j) +.59*G(i,j) +.11*B(i,j) end scalar operation R G B

Insight Through Computing Weighted average of the RGB values.3R+.59G+.11B M=.3*R +.59*G +.11*B vectorized operation R G B

Insight Through Computing Problem: Produce a Negative

Insight Through Computing 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.

Insight Through Computing function newIm = toNegative(im) % newIm is the negative of image im % im, newIm are 3-d arrays; each component is uint8 [nr,nc,np]= size(im); % dimensions of im newIm= zeros(nr,nc,np); % initialize newIm newIm= uint8(newIm); % Type for image color values for r= 1:nr for c= 1:nc for p= 1:np newIm(r,c,p)= im(r,c,p); end