Play with image files 2-dimensional array matrix

Similar documents
Previous Lecture: Today s Lecture: Announcements: 2-d array examples. Image processing

Previous Lecture: Today s Lecture: Announcements: 2-d array examples. Working with images

MATLAB Image Processing Toolbox

Image processing in MATLAB. Linguaggio Programmazione Matlab-Simulink (2017/2018)

Digital Image processing Lab

Images and Graphics. 4. Images and Graphics - Copyright Denis Hamelin - Ryerson University

Introduction to Color Theory

6.098/6.882 Computational Photography 1. Problem Set 1. Assigned: Feb 9, 2006 Due: Feb 23, 2006

L2. Image processing in MATLAB

(ans: Five rows and five columns accommodate 25 switch locations. )

(ans: Five rows require a 3-bit code and ten columns a 4-bit code. Hence, each key has a 7 bit address.

DSP First Lab 06: Digital Images: A/D and D/A

Mech 296: Vision for Robotic Applications. Vision for Robotic Applications

Matlab for CS6320 Beginners

Brief Introduction to Vision and Images

Computer Science 121. Scientific Computing Chapter 12 Images

EELE 5110 Digital Image Processing Lab 02: Image Processing with MATLAB

Lab P-8: Digital Images: A/D and D/A

A PROPOSED ALGORITHM FOR DIGITAL WATERMARKING

COURSE ECE-411 IMAGE PROCESSING. Er. DEEPAK SHARMA Asstt. Prof., ECE department. MMEC, MM University, Mullana.

5.1 Image Files and Formats

RGB COLORS. Connecting with Computer Science cs.ubc.ca/~hoos/cpsc101

Lab 1. Basic Image Processing Algorithms Fall 2017

Getting Started With The MATLAB Image Processing Toolbox

Lecture 1: Introduction to Matlab Programming

CS 445 HW#2 Solutions

Vector VS Pixels Introduction to Adobe Photoshop

EP375 Computational Physics

We are IntechOpen, the world s leading publisher of Open Access books Built by scientists, for scientists. International authors and editors

Image Processing - License Plate Localization and Letters Extraction *

GUIDELINES & INFORMATION

Bitmap Vs Vector Graphics Web-safe Colours Image compression Web graphics formats Anti-aliasing Dithering & Banding Image issues for the Web

LECTURE 03 BITMAP IMAGE FORMATS

Computer Programming

Image representation, sampling and quantization

UNIT 7C Data Representation: Images and Sound

ANALYSIS OF IMAGE ENHANCEMENT TECHNIQUES USING MATLAB

Waitlist. We ll let you know as soon as we can. Biggest issue is TAs

CIS581: Computer Vision and Computational Photography Homework: Cameras and Convolution Due: Sept. 14, 2017 at 3:00 pm

EGR 111 Image Processing

Applying mathematics to digital image processing using a spreadsheet

INTRODUCTION TO IMAGE PROCESSING

Introduction to DSP ECE-S352 Fall Quarter 2000 Matlab Project 1

UNIT 7C Data Representation: Images and Sound Principles of Computing, Carnegie Mellon University CORTINA/GUNA

Image Compression Using SVD ON Labview With Vision Module

>>> from numpy import random as r >>> I = r.rand(256,256);

CS 484, Fall 2018 Homework Assignment 1: Binary Image Analysis

Digital Photographs and Matrices

Computer Vision & Digital Image Processing

Image Representation and Processing

IMAGE PROCESSING: POINT PROCESSES

Bitmap Image Formats

Oversubscription. Sorry, not fixed yet. We ll let you know as soon as we can.

4/9/2015. Simple Graphics and Image Processing. Simple Graphics. Overview of Turtle Graphics (continued) Overview of Turtle Graphics

Visual Cryptography. Frederik Vercauteren. University of Bristol, Merchant Venturers Building, Woodland Road, Bristol BS8 1UB.

15110 Principles of Computing, Carnegie Mellon University

Sponsored by IBM. 6. The input to all problems will consist of multiple test cases unless otherwise noted.

Image Forgery. Forgery Detection Using Wavelets

Fundamentals of Multimedia

15110 Principles of Computing, Carnegie Mellon University

2. Color spaces Introduction The RGB color space

ITP 140 Mobile App Technologies. Images

UNIT 7B Data Representa1on: Images and Sound. Pixels. An image is stored in a computer as a sequence of pixels, picture elements.

Stamp Colors. Towards a Stamp-Oriented Color Guide: Objectifying Classification by Color. John M. Cibulskis, Ph.D. November 18-19, 2015

CMPSC 390 Visual Computing Spring 2014 Bob Roos Review Notes Introduction and PixelMath

How is Information Stored

What is a digital image?

Ch. 3: Image Compression Multimedia Systems

Lecture 9: Digital Images

MATLAB 6.5 Image Processing Toolbox Tutorial

Lane Detection in Automotive

Performance Evaluation of H.264 AVC Using CABAC Entropy Coding For Image Compression

Image Extraction using Image Mining Technique

Picture Encoding and Manipulation. We perceive light different from how it actually is

Digital Image Processing. Lecture # 3 Image Enhancement

Introduction. Prof. Lina Karam School of Electrical, Computer, & Energy Engineering Arizona State University

Convert images and non-vector PDFs

>>> from numpy import random as r >>> I = r.rand(256,256);

Block Truncation Coding (BTC) Technique for Regions Image Encryption

II. Basic Concepts in Display Systems

Introduction to More Advanced Steganography. John Ortiz. Crucial Security Inc. San Antonio

Lec. 26, Thursday, April 15 Chapter 14: Holography. Hologram

Permutations. = f 1 f = I A

ECC419 IMAGE PROCESSING

Photoshop 01. Introduction to Computer Graphics UIC / AA/ AD / AD 205 / F05/ Sauter.../documents/photoshop_01.pdf

The Use of Non-Local Means to Reduce Image Noise

Photoshop CS6. Table of Contents. Image Formats! 3. GIF (Graphics Interchange Format)! 3. JPEG or JPG (Joint Photographic Experts Group)!

Computer system This distribution of pd is executable under the cygwin system ( on a Windows XP system running on an I86 PC.

International Journal of Digital Application & Contemporary research Website: (Volume 1, Issue 7, February 2013)

Color, graphics and hardware Monitors and Display

Digital Image Processing. Digital Image Fundamentals II 12 th June, 2017

Computer Graphics. Rendering. Rendering 3D. Images & Color. Scena 3D rendering image. Human Visual System: the retina. Human Visual System

Digital Image Processing 3/e

Artifacts and Antiforensic Noise Removal in JPEG Compression Bismitha N 1 Anup Chandrahasan 2 Prof. Ramayan Pratap Singh 3

V Grech. Publishing on the WWW. Part 1 - Static graphics. Images Paediatr Cardiol Oct-Dec; 2(4):

Finger print Recognization. By M R Rahul Raj K Muralidhar A Papi Reddy

Lane Detection in Automotive

Histogram Equalization

Comparing Multiresolution SVD with Other Methods for Image Compression

Developing Multimedia Assets using Fireworks and Flash

Transcription:

Previous class: Play with sound files Practice working with vectors Now: Play with image files 2-dimensional array matrix A picture as a matrix 2-dimensional array 1458-by-2084 150 149 152 153 152 155 151 150 153 154 153 156 153 151 155 156 155 158 154 153 156 157 156 159 156 154 158 159 158 161 157 156 159 160 159 162 1 2 2-d array: matrix An array is a named collection of like data organized into rows and columns A 2-d array is a table, called a matrix Two indices identify the position of a value in a matrix, e.g., mat(r,c) refers to component in row r, column c of matrix mat Array index starts at 1 ectangular: all rows have the same #of columns r c Creating a matrix uilt-in functions: ones, zeros, rand E.g., zeros(2,3) gives a 2-by-3 matrix of 0s uild a matrix using square brackets, [ ], but the dimension must match up: [x y] puts y to the right of x [x; y] puts y below x 4 0 3 [4 0 3; 5 1 9] creates the matrix 5 1 9 [4 0 3; ones(1,3)] gives 4 0 3 [4 0 3; ones(3,1)] doesn t work 1 1 1 4 5 % What will M be? M = [ones(1,3); 1:4] A 1 1 1 0 1 2 3 4 1 1 1 1 2 3 What will A be? A= [1 1] A= [A ones(2,1)] A= [1 1 1 1; A A] Aa. 3-by-4 matrix b. 4-by-3 matrix Cc. vector of length 12 Dd. Error C Error M not created 6 8 1

Working with a matrix: size and individual components [nr, nc]= size(m) M(2,4)= 1; disp(m(3,1)) M(1,nc)= 4; iven a matrix M 2-1.5 0-3 3 8 6 7 7 5-3 8.5 9 10 52 81.5 7 2 % nr is #of rows, % nc is #of columns Images can be encoded in different ways Common formats include JPE: Joint Photographic Experts roup IF: raphics Interchange Format Data are compressed We will work with jpeg files: imread: read a.jpg file and convert it to a normal numeric array that we can work with imwrite: write an array into a.jpg file (compressed data) 9 10 rayness: a value in [0..255] 0 = black 255 = white These are integer values Type: uint8 Let s put a picture in a frame ead a grayscale jpeg file into a matrix P P = imread( <filename>.jpg ); See the image represented by P imshow(p) 150 149 152 153 152 155 151 150 153 154 153 156 153 151 155 156 155 158 154 153 156 157 156 159 156 154 158 159 158 161 157 156 159 160 159 162 Change the edge pixels into the frame color (grayscale) you want 11 12 Problem: produce a negative Problem: produce a negative Negative is what we say, but all color values are positive numbers! Think in terms of the extremes, 0 and 255. Then the negative just means the opposite side. So 0 is the opposite of 255; 1 254; 5 250; 30 225; x 255-x 13 14 2

function newim = tonegative(im) % newim is the negative of image im % im, newim are 3-d arrays; each component is uint8 A color picture is made up of matrices [nr,nc,np]= size(im); % dimensions of im Color image 3-d Array newim= zeros(nr,nc); newim= uint8(newim); % initialize newim % Type for image color values 0 A(i,j,1) 255 newim(r,c,p)= ; 0 A(i,j,2) 255 0 A(i,j,3) 255 Operations on images amount to operations on matrices good way to practice matrix manipulation! 15 18 Extracting subarrays and tiling Accessing a submatrix: M( _:_, _:_ ) Accessing a subarray (3-d): P( _:_, _:_, : ) Concatenate horizontally: [ PL P ] Concatenate vertically: [ PT; P ] Your multi-media project Create a Matlab program that involves image and sound manipulation You get to Make your own design Set the level of difficulty Finish by 11:30am and submit in CMS Mirror image Sub-array Set color conditionally Manipulate sound vector and playback Photo negative tiling 19 20 Example: Mirror Image Solution Framework 1. ead LawSchool.jpg from memory and convert it into an array. 2. Manipulate the Array. 3. Convert the array to a jpg file and write it to memory. LawSchool.jpg LawSchoolMirror.jpg 21 22 3

eading and writing jpg files % ead jpg image and convert to % a 3D array A A = imread('lawschool.jpg'); A 3-d array as 3 matrices [nr, nc, np] = size(a) % dimensions of 3-d array A #rows #layers (pages) #columns % Write 3D array to memory as % a jpg image imwrite(,'lawschoolmirror.jpg') M1= A(:,:,1) M2= A(:,:,2) M3= A(:,:,3) 23 24 % Make mirror image of A [nr,nc,np]= size(a); (r,c,p)= A(r,nc-c+1,p); % Make mirror image of A - the whole thing A= imread( LawSchool.jpg ); [nr,nc,np]= size(a); = zeros(nr,nc,np); = uint8(); % Type for image color values (r,c,p)= A(r,nc-c+1,p); image() % Show 3-d array data as an image imwrite(, LawSchoolMirror.jpg ) 26 30 Vectorized code simplifies things Work with a whole column at a time A 1 2 3 4 5 6 1 2 3 4 5 6 Column c in is column nc-c+1 in A Vectorized code to create a mirror image A = imread( LawSchool.jpg ) [nr,nc,np] = size(a); (:,c,1) = A(:,nc+1-c,1) (:,c,2) = A(:,nc+1-c,2) (:,c,3) = A(:,nc+1-c,3) imwrite(,'lawschoolmirror.jpg') 41 45 4

Example: color black and white Averaging the values to get a gray value.3+.59+.11 /3+/3+/3 Can average the three color values to get one gray value. 47 48 Averaging the values to get a gray value Averaging the values to get a gray value.3+.59+.11.3+.59+.11 for i= 1:m for j= 1:n M(i,j)=.3*(i,j) +.59*(i,j) +.11*(i,j) scalar operation M=.3* +.59* +.11* vectorized operation 49 50 Here are 2 ways to calculate the average. Are gray value matrices g and h the same given image data A? g(r,c)= A(r,c,1)/3 + A(r,c,2)/3... A(r,c,3)/3; h(r,c)=... ( A(r,c,1)+A(r,c,2)+A(r,c,3) )/3; A: yes : no Turn the white duck yellow! The duck s body and the image s background show some contrast. However, neither the duck s body nor the background has a uniform color Are the values different enough for us to write a rule in the program to tell between the duck and the background? Check out the values! 52 53 5