SlideShare a Scribd company logo
1 of 25
Multimedia Technology in
MATLAB
By:
Mustafa N. Jaafar
Lecture 2:
Representation Images In MATLAB Graphics
OUTLINE
• What Is Image Data?
• Data Types in MATLAB
• Supported Image Formats
• Read image from graphics file
• Information about graphics file
• Write image to graphics file
• Convert RGB image or colormap to grayscale
• Image Histogram in MATLAB
• Resize image in MATLAB
• Image representation, sampling and quantization
• Sampling image in MATLAB
• quantization image in MATLAB
WHAT IS IMAGE DATA?
• The basic MATLAB data structure is the array, an ordered set of real or complex elements. An array is
naturally suited to the representation of images, real-valued, ordered sets of color or intensity data. (An
array is suited for complex-valued images.)
• In the MATLAB workspace, most images are represented as two-dimensional arrays (matrices), in which
each element of the matrix corresponds to a single pixel in the displayed image. For example, an image
composed of 200 rows and 300 columns of different colored dots stored as a 200-by-300 matrix. Some
images, such as RGB, require a three-dimensional array, where the first plane in the third dimension
represents the red pixel intensities, the second plane represents the green pixel intensities, and the third
plane represents the blue pixel intensities.
DATA TYPES IN MATLAB
• MATLAB math supports three different numeric classes for image display:
• double-precision floating-point (double)
• 16-bit unsigned integer (uint16)
• 8-bit unsigned integer (uint8)
SUPPORTED IMAGE FORMATS
• MATLAB commands read, write, and display several types of graphics file formats for images. As
with MATLAB generated images, once a graphics file format image is displayed, it becomes an
image object. MATLAB supports the following graphics file formats, along with others:
• BMP (Microsoft® Windows® Bitmap)
• GIF (Graphics Interchange Files)
• HDF (Hierarchical Data Format)
• JPEG (Joint Photographic Experts Group)
• PCX (Paintbrush)
• PNG (Portable Network Graphics)
• TIFF (Tagged Image File Format)
• XWD (X Window Dump)
READ IMAGE FROM GRAPHICS FILE
• Syntax
• A = imread(filename)
• Example 1 from Matlab :
• A = imread('ngc6543a.jpg');
• imshow(A)% Display the image.
• Example 2 by using File in a folder
• A = imread(C:myFoldermyImage.ext’)
• Example 3 by using File in a folder
• A = imread(C:myFoldermyImage.ext')
BIT DEPTH
• Bit depth is the number of bits used to represent each image pixel. Bit depth is
calculated by multiplying the bits-per-sample with the samples-per-pixel. Thus, a
format that uses 8 bits for each color component (or sample) and three samples
per pixel has a bit depth of 24. Sometimes the sample size associated with a bit
depth can be ambiguous. For example, does a 48-bit bit depth represent six 8-bit
samples, four 12-bit samples, or three 16-bit samples? See Algorithms for sample
size information to avoid this ambiguity.
INFORMATION ABOUT GRAPHICS FILE
• Syntax
• info = imfinfo(filename)
• Description imfinfo(filename) returns a structure whose fields contain
information about an image in a graphics file
• Example :
• info = imfinfo('ngc6543a.jpg');
WRITE IMAGE TO GRAPHICS FILE
• Syntax
• imwrite(A,filename)
• Description: imwrite(A,filename) writes image data A to the file specified by
filename, inferring the file format from the extension. imwrite creates the new file
in your current folder. The bit depth of the output image depends on the data
type of A and the file format.
• Example
• A = rand(50);
• imwrite(A,'myGray.png')
CONVERT RGB IMAGE OR COLORMAP TO GRAYSCALE
• Syntax
• I = rgb2gray(RGB)
• Description rgb2gray(RGB) converts the truecolor image RGB to the grayscale image
I. The rgb2gray function converts
• Examples
• RGB = imread('peppers.png’);
• subplot(121); imshow(RGB) ; title (‘color image’)
• gray = rgb2gray(RGB);
• subplot(122); imshow(gray) ; title(‘Gray image’)
CONVERT RGB IMAGE OR COLORMAP TO GRAYSCALE
IMAGE HISTOGRAM
• Description : the imhist function creates a histogram plot by defining n equally
spaced bins, each representing a range of data values, and then calculating the
number of pixels within each range
• Example
• I = imread('rice.png’);
• subplot(121) ; imshow(I) ; title (‘ Orginal image’)
• subplot(122) ; imhist(I) ; title (‘ histogram image’)
IMAGE HISTOGRAM
RESIZE IMAGE IN MATLAB
• Syntax
• B = imresize(A,scale)
• Description imresize(A,scale) returns image B that is scale times the size of image A. The input
image A can be a grayscale, RGB, binary, or categorical image.
• Example1
• I = imread('ngc6543a.jpg’);
• J = imresize(I, 0.5);
• Example2
• RGB = imread('peppers.png’);
• RGB2 = imresize(RGB,[64 64]);
IMAGE REPRESENTATION, SAMPLING AND
QUANTIZATION
• To create an image which is digital, we need to covert continuous data into digital form. there are two steps in which it is done: (sampling , quantization )
• Sampling : related to coordinates values (nyquist frequency)
• Quantization : related to intensity values
• Sampling is done on the x-axis while quantization is done on the y-axis
SAMPLING
• Sampling corresponds to a discretization of the space. That is, of the domain of
the function, into f : [1, . . . ,N] × [1, . . . , M] → R
SAMPLING
• clc;clear all;close all; n=2;
• img = rgb2gray( imread('Lenna.png’))
• for i=1:n:size(img,1)
• for j=1:n:size(img,2)
• for k=0:n-1
• for l=0:n-1
• im(i+k,j+l)=img(i,j);
• end end end end
• subplot(1,2,1);imshow(uint8(img));title('Original Image');
• subplot(1,2,2);imshow(uint8(im));title('Sampled Image');
SAMPLING
QUANTIZATION IMAGE
• Syntax
• quant_A = imquantize(A,levels)
• Description example quant_A = imquantize(A,levels) quantizes image A using
specified quantization values contained in the N element vector levels.
QUANTIZATION IMAGE
QUANTIZATION IMAGE
• clc;clear all; close all
• Image = imread('peppers.png');
• grayImage= rgb2gray(Image);
• subplot(2, 4, 1);imshow(grayImage, []); title('Original Gray Scale Image')
• for level =2:8
• thresh = multithresh(grayImage,level)
• quantizedImage = imquantize(grayImage, thresh);
• subplot(2, 4, level);imshow((quantizedImage),[]); title(['quantized with level '
num2str(level) ]);
• end
QUANTIZATION IMAGE
SUMMERY
Matalb function :
• imread() – reading an image with different postfixes
• imresize() – resizing an image to any given size
• figure – opening a new graphical window
• subplot(#of row, # of col, location) – showing different plots/images in one graphical window
• imshow() – displaying an image
• Imquantize- (A,levels) quantizes image
 We have looked at:
 What is sampling?
 What is spatial resolution?
 What is quantization?
 What is grey-level resolution
Thank you
For Listen

More Related Content

What's hot

Introduction to Flash
Introduction to FlashIntroduction to Flash
Introduction to FlashIzatul Akma
 
Basic Introduction To Graphic File Formats
Basic Introduction To Graphic File FormatsBasic Introduction To Graphic File Formats
Basic Introduction To Graphic File FormatsAnkit Mishra
 
Multimedia color in image and video
Multimedia color in image and videoMultimedia color in image and video
Multimedia color in image and videoMazin Alwaaly
 
Features image processing and Extaction
Features image processing and ExtactionFeatures image processing and Extaction
Features image processing and ExtactionAli A Jalil
 
Animation in Computer Graphics
Animation in Computer GraphicsAnimation in Computer Graphics
Animation in Computer GraphicsRinkuNahar
 
Number plate recognition using matlab
Number plate recognition using matlabNumber plate recognition using matlab
Number plate recognition using matlabAbhishek Sainkar
 
Mpeg video compression
Mpeg video compressionMpeg video compression
Mpeg video compressionGem WeBlog
 
Image processing SaltPepper Noise
Image processing SaltPepper NoiseImage processing SaltPepper Noise
Image processing SaltPepper NoiseAnkush Srivastava
 
Semantic Segmentation on Satellite Imagery
Semantic Segmentation on Satellite ImagerySemantic Segmentation on Satellite Imagery
Semantic Segmentation on Satellite ImageryRAHUL BHOJWANI
 
Chapter 5 : ANIMATION
Chapter 5 : ANIMATIONChapter 5 : ANIMATION
Chapter 5 : ANIMATIONazira96
 
Threshold Selection for Image segmentation
Threshold Selection for Image segmentationThreshold Selection for Image segmentation
Threshold Selection for Image segmentationParijat Sinha
 
Chapter 8 Video
Chapter 8 VideoChapter 8 Video
Chapter 8 Videoshelly3160
 

What's hot (20)

Introduction to Flash
Introduction to FlashIntroduction to Flash
Introduction to Flash
 
Basic Introduction To Graphic File Formats
Basic Introduction To Graphic File FormatsBasic Introduction To Graphic File Formats
Basic Introduction To Graphic File Formats
 
Color model
Color modelColor model
Color model
 
Multimedia color in image and video
Multimedia color in image and videoMultimedia color in image and video
Multimedia color in image and video
 
YUV, Y CB CR and Subsampling
YUV, Y CB CR and SubsamplingYUV, Y CB CR and Subsampling
YUV, Y CB CR and Subsampling
 
Types of images
Types of imagesTypes of images
Types of images
 
Gamma and Colour Space
Gamma and Colour SpaceGamma and Colour Space
Gamma and Colour Space
 
Features image processing and Extaction
Features image processing and ExtactionFeatures image processing and Extaction
Features image processing and Extaction
 
Bit plane coding
Bit plane codingBit plane coding
Bit plane coding
 
Animation in Computer Graphics
Animation in Computer GraphicsAnimation in Computer Graphics
Animation in Computer Graphics
 
Number plate recognition using matlab
Number plate recognition using matlabNumber plate recognition using matlab
Number plate recognition using matlab
 
Mpeg video compression
Mpeg video compressionMpeg video compression
Mpeg video compression
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Image processing SaltPepper Noise
Image processing SaltPepper NoiseImage processing SaltPepper Noise
Image processing SaltPepper Noise
 
Semantic Segmentation on Satellite Imagery
Semantic Segmentation on Satellite ImagerySemantic Segmentation on Satellite Imagery
Semantic Segmentation on Satellite Imagery
 
Module 31
Module 31Module 31
Module 31
 
Unit3 dip
Unit3 dipUnit3 dip
Unit3 dip
 
Chapter 5 : ANIMATION
Chapter 5 : ANIMATIONChapter 5 : ANIMATION
Chapter 5 : ANIMATION
 
Threshold Selection for Image segmentation
Threshold Selection for Image segmentationThreshold Selection for Image segmentation
Threshold Selection for Image segmentation
 
Chapter 8 Video
Chapter 8 VideoChapter 8 Video
Chapter 8 Video
 

Similar to Working with images in matlab graphics

Image processing tool box.pptx
Image processing tool box.pptxImage processing tool box.pptx
Image processing tool box.pptxAvinashJain66
 
ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)Hasitha Ediriweera
 
Dip digital image 3
Dip digital image 3Dip digital image 3
Dip digital image 3Shajun Nisha
 
Matlab intro
Matlab introMatlab intro
Matlab introfvijayami
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image ProcessingAnkur Nanda
 
Introduction to Image Processing with MATLAB
Introduction to Image Processing with MATLABIntroduction to Image Processing with MATLAB
Introduction to Image Processing with MATLABSriram Emarose
 
Image processing basics using matlab
Image processing basics using matlabImage processing basics using matlab
Image processing basics using matlabAnkur Tyagi
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlabminhtaispkt
 
Images in matlab
Images in matlabImages in matlab
Images in matlabAli Alvi
 
Digital Image Processing (Lab 07)
Digital Image Processing (Lab 07)Digital Image Processing (Lab 07)
Digital Image Processing (Lab 07)Moe Moe Myint
 

Similar to Working with images in matlab graphics (20)

Image processing tool box.pptx
Image processing tool box.pptxImage processing tool box.pptx
Image processing tool box.pptx
 
ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)
 
Dip digital image 3
Dip digital image 3Dip digital image 3
Dip digital image 3
 
Image processing in MATLAB
Image processing in MATLABImage processing in MATLAB
Image processing in MATLAB
 
Image Processing Using MATLAB
Image Processing Using MATLABImage Processing Using MATLAB
Image Processing Using MATLAB
 
Matlab intro
Matlab introMatlab intro
Matlab intro
 
Ec section
Ec section Ec section
Ec section
 
Image processing
Image processingImage processing
Image processing
 
Image processing
Image processingImage processing
Image processing
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
 
Introduction to Image Processing with MATLAB
Introduction to Image Processing with MATLABIntroduction to Image Processing with MATLAB
Introduction to Image Processing with MATLAB
 
Image processing basics using matlab
Image processing basics using matlabImage processing basics using matlab
Image processing basics using matlab
 
MATLAB & Image Processing
MATLAB & Image ProcessingMATLAB & Image Processing
MATLAB & Image Processing
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlab
 
Report
ReportReport
Report
 
Images in matlab
Images in matlabImages in matlab
Images in matlab
 
4 image enhancement in spatial domain
4 image enhancement in spatial domain4 image enhancement in spatial domain
4 image enhancement in spatial domain
 
Dip day1&2
Dip day1&2Dip day1&2
Dip day1&2
 
Digital Image Processing (Lab 07)
Digital Image Processing (Lab 07)Digital Image Processing (Lab 07)
Digital Image Processing (Lab 07)
 
Dip syntax 4
Dip syntax 4Dip syntax 4
Dip syntax 4
 

Recently uploaded

Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 

Recently uploaded (20)

Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 

Working with images in matlab graphics

  • 1. Multimedia Technology in MATLAB By: Mustafa N. Jaafar Lecture 2: Representation Images In MATLAB Graphics
  • 2. OUTLINE • What Is Image Data? • Data Types in MATLAB • Supported Image Formats • Read image from graphics file • Information about graphics file • Write image to graphics file • Convert RGB image or colormap to grayscale • Image Histogram in MATLAB • Resize image in MATLAB • Image representation, sampling and quantization • Sampling image in MATLAB • quantization image in MATLAB
  • 3. WHAT IS IMAGE DATA? • The basic MATLAB data structure is the array, an ordered set of real or complex elements. An array is naturally suited to the representation of images, real-valued, ordered sets of color or intensity data. (An array is suited for complex-valued images.) • In the MATLAB workspace, most images are represented as two-dimensional arrays (matrices), in which each element of the matrix corresponds to a single pixel in the displayed image. For example, an image composed of 200 rows and 300 columns of different colored dots stored as a 200-by-300 matrix. Some images, such as RGB, require a three-dimensional array, where the first plane in the third dimension represents the red pixel intensities, the second plane represents the green pixel intensities, and the third plane represents the blue pixel intensities.
  • 4. DATA TYPES IN MATLAB • MATLAB math supports three different numeric classes for image display: • double-precision floating-point (double) • 16-bit unsigned integer (uint16) • 8-bit unsigned integer (uint8)
  • 5. SUPPORTED IMAGE FORMATS • MATLAB commands read, write, and display several types of graphics file formats for images. As with MATLAB generated images, once a graphics file format image is displayed, it becomes an image object. MATLAB supports the following graphics file formats, along with others: • BMP (Microsoft® Windows® Bitmap) • GIF (Graphics Interchange Files) • HDF (Hierarchical Data Format) • JPEG (Joint Photographic Experts Group) • PCX (Paintbrush) • PNG (Portable Network Graphics) • TIFF (Tagged Image File Format) • XWD (X Window Dump)
  • 6. READ IMAGE FROM GRAPHICS FILE • Syntax • A = imread(filename) • Example 1 from Matlab : • A = imread('ngc6543a.jpg'); • imshow(A)% Display the image. • Example 2 by using File in a folder • A = imread(C:myFoldermyImage.ext’) • Example 3 by using File in a folder • A = imread(C:myFoldermyImage.ext')
  • 7. BIT DEPTH • Bit depth is the number of bits used to represent each image pixel. Bit depth is calculated by multiplying the bits-per-sample with the samples-per-pixel. Thus, a format that uses 8 bits for each color component (or sample) and three samples per pixel has a bit depth of 24. Sometimes the sample size associated with a bit depth can be ambiguous. For example, does a 48-bit bit depth represent six 8-bit samples, four 12-bit samples, or three 16-bit samples? See Algorithms for sample size information to avoid this ambiguity.
  • 8. INFORMATION ABOUT GRAPHICS FILE • Syntax • info = imfinfo(filename) • Description imfinfo(filename) returns a structure whose fields contain information about an image in a graphics file • Example : • info = imfinfo('ngc6543a.jpg');
  • 9. WRITE IMAGE TO GRAPHICS FILE • Syntax • imwrite(A,filename) • Description: imwrite(A,filename) writes image data A to the file specified by filename, inferring the file format from the extension. imwrite creates the new file in your current folder. The bit depth of the output image depends on the data type of A and the file format. • Example • A = rand(50); • imwrite(A,'myGray.png')
  • 10. CONVERT RGB IMAGE OR COLORMAP TO GRAYSCALE • Syntax • I = rgb2gray(RGB) • Description rgb2gray(RGB) converts the truecolor image RGB to the grayscale image I. The rgb2gray function converts • Examples • RGB = imread('peppers.png’); • subplot(121); imshow(RGB) ; title (‘color image’) • gray = rgb2gray(RGB); • subplot(122); imshow(gray) ; title(‘Gray image’)
  • 11. CONVERT RGB IMAGE OR COLORMAP TO GRAYSCALE
  • 12. IMAGE HISTOGRAM • Description : the imhist function creates a histogram plot by defining n equally spaced bins, each representing a range of data values, and then calculating the number of pixels within each range • Example • I = imread('rice.png’); • subplot(121) ; imshow(I) ; title (‘ Orginal image’) • subplot(122) ; imhist(I) ; title (‘ histogram image’)
  • 14. RESIZE IMAGE IN MATLAB • Syntax • B = imresize(A,scale) • Description imresize(A,scale) returns image B that is scale times the size of image A. The input image A can be a grayscale, RGB, binary, or categorical image. • Example1 • I = imread('ngc6543a.jpg’); • J = imresize(I, 0.5); • Example2 • RGB = imread('peppers.png’); • RGB2 = imresize(RGB,[64 64]);
  • 15. IMAGE REPRESENTATION, SAMPLING AND QUANTIZATION • To create an image which is digital, we need to covert continuous data into digital form. there are two steps in which it is done: (sampling , quantization ) • Sampling : related to coordinates values (nyquist frequency) • Quantization : related to intensity values • Sampling is done on the x-axis while quantization is done on the y-axis
  • 16. SAMPLING • Sampling corresponds to a discretization of the space. That is, of the domain of the function, into f : [1, . . . ,N] × [1, . . . , M] → R
  • 17. SAMPLING • clc;clear all;close all; n=2; • img = rgb2gray( imread('Lenna.png’)) • for i=1:n:size(img,1) • for j=1:n:size(img,2) • for k=0:n-1 • for l=0:n-1 • im(i+k,j+l)=img(i,j); • end end end end • subplot(1,2,1);imshow(uint8(img));title('Original Image'); • subplot(1,2,2);imshow(uint8(im));title('Sampled Image');
  • 19.
  • 20. QUANTIZATION IMAGE • Syntax • quant_A = imquantize(A,levels) • Description example quant_A = imquantize(A,levels) quantizes image A using specified quantization values contained in the N element vector levels.
  • 22. QUANTIZATION IMAGE • clc;clear all; close all • Image = imread('peppers.png'); • grayImage= rgb2gray(Image); • subplot(2, 4, 1);imshow(grayImage, []); title('Original Gray Scale Image') • for level =2:8 • thresh = multithresh(grayImage,level) • quantizedImage = imquantize(grayImage, thresh); • subplot(2, 4, level);imshow((quantizedImage),[]); title(['quantized with level ' num2str(level) ]); • end
  • 24. SUMMERY Matalb function : • imread() – reading an image with different postfixes • imresize() – resizing an image to any given size • figure – opening a new graphical window • subplot(#of row, # of col, location) – showing different plots/images in one graphical window • imshow() – displaying an image • Imquantize- (A,levels) quantizes image  We have looked at:  What is sampling?  What is spatial resolution?  What is quantization?  What is grey-level resolution