SlideShare a Scribd company logo
IMAGES IN MATLAB
Group Members: 
 Muhammad Raheel Ali (12-EE-131) 
 Rana Tassuvar (12-EE-123) 
 Muhib ullah (12-EE-214)
What is Image Data??? 
 In Matlab, an image is a set of color or intensity 
data. 
 Each image is formed by combination of pixels. 
 Each pixel is a matrix element. 
 Each pixel has its own intensity of red, blue and 
green color. 
 A high level image is represented by a 3 
dimensional array. 
 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.
Popular Matlab functions associated 
with Images: 
In Matlab, there are a lot of useful functions. Some 
of these are: 
 imread 
 imshow 
 rgb2gray 
 imhist 
 imadjust 
 imb2w 
And many more….
Loading an image in Matlab: 
 For loading an image in Matlab, we use use 
“imread” function. 
Following is an example of loading an image: 
a=imread('skardu.jpeg');
Showing an image in Matlab: 
 “imshow” function shows the loaded image in 
Matlab window. 
Following is an example: 
 a=imread('skardu.jpg'); 
 imshow(a);
Output:
Getting image info using Matlab: 
 We mainly have two types of images that we use 
to deal in Matlab. These are 
1- RGB images 
2- Indexed images 
 RGB images are stored in 3 matrices. 1st for red, 
2nd for green and 3rd for blue. 
 Each element in matrix stores intensity value of 
red, green or blue color for a particular pixel. 
 In indexed images, each pixel is given an index. 
 Each index is mapped to RGB value in colormap.
Pixel info of RGB image: 
 For obtaining pixels info of an rgb image, we have 
a built in function “impixelinfo”. 
Following syntax is used: 
 a=imread('rgb.jpg'); 
 imshow(a); 
 impixelinfo; 
 On the output screen, we can see the particular 
row and column of pixel with its corresponding 
rgb value.
Output: 
In the bottom left corner, we can see the pixel info.
 We can also find the size of image by using given 
command: 
>> a=imread('rgb.jpg'); 
>> impixelinfo 
>> size(a) 
Output is: 
ans = 
768 1024 3 
 Output shows that it is a 768x1024 image with 3 
planes.
Converting image from one format to 
other: 
 Matlab can be used to change the format of 
image. 
Following table gives information about image 
conversion: 
As an example we will change format of image.
Converting image to grayscale 
image: 
 “rgb2gray” function converts the image to 
grayscale image. 
Example is: 
 a=imread('skardu.jpg'); 
 b=rgb2gray(a); 
 imshow(b);
Output 
:
Histogram of Image: 
 “imhist” function is used to obtain histogram of 
image. 
 This function plots a graph that shows how many 
pixels are in a specific intensity in grayscale 
image. 
An example is: 
 a=imread('skardu.jpg'); 
 b=rgb2gray(a); 
 imhist(b)
Output:
Adjusting the contrast ratio: 
 “imadjust” function adjusts the contrast ratio in image. 
Example is: 
 a=imread('skardu.jpg'); 
 b=rgb2gray(a); 
 c=imadjust(b); 
 subplot(1,2,1); 
 imshow(b); 
 title('Not Adjusted'); 
 subplot(1,2,2); 
 imshow(c); 
 title('Adjusted');
Output:
Using Matlab to obtain black and 
white image: 
 “im2bw” is a function in Matlab that turns the 
image into black and white image. 
Example: 
 a=imread('skardu.jpg'); 
 b=im2bw(a); 
 imshow(b);
Output:
Resizing the image: 
 Matlab can also be used to resize the image. 
 By resizing, we mean that we can increase or 
decrease pixels of image. 
Following code is an example: 
 a=imread('skardu.jpg'); 
 subplot(1,2,1); 
 imshow(a); 
 title('original image'); 
 c=imresize(a,1/5); 
 subplot(1,2,2); 
 imshow(c); 
 title('Resized');
Output: 
Image is blurred showing decrease in number of pixels.
Performance issues in Matlab 
images: 
 Matlab is very fast on vector and matrix 
operations but 
Correspondingly slow with loops. 
So, 
• Try to avoid loops 
• Try to vectorize your code
Thank You!
Any 
Question???

More Related Content

PPTX
Introduction to Image Processing with MATLAB
PDF
Basics of image processing using MATLAB
PPTX
Image enhancement techniques
PDF
Basics of Image Processing using MATLAB
PPSX
Color Image Processing: Basics
PPTX
MATLAB & Image Processing
PDF
PDF
Image compression
Introduction to Image Processing with MATLAB
Basics of image processing using MATLAB
Image enhancement techniques
Basics of Image Processing using MATLAB
Color Image Processing: Basics
MATLAB & Image Processing
Image compression

What's hot (20)

PPTX
Mathematical operations in image processing
PPTX
Image processing second unit Notes
PPTX
Lect 02 second portion
PPSX
Image processing on matlab presentation
PPTX
Dip review
PPTX
Image Restoration (Order Statistics Filters)
PPTX
Image Processing Using MATLAB
PDF
Image Restoration (Digital Image Processing)
PPTX
Unit3 dip
PDF
Introduction to OpenCV
PPTX
Image Enhancement in Spatial Domain
PDF
Lecture 4 Relationship between pixels
PPT
Discrete cosine transform
PPTX
Matlab Working With Images
PPTX
digital image processing
PPTX
Histogram Processing
PDF
Digital Image Processing: An Introduction
PPTX
Image Restoration And Reconstruction
Mathematical operations in image processing
Image processing second unit Notes
Lect 02 second portion
Image processing on matlab presentation
Dip review
Image Restoration (Order Statistics Filters)
Image Processing Using MATLAB
Image Restoration (Digital Image Processing)
Unit3 dip
Introduction to OpenCV
Image Enhancement in Spatial Domain
Lecture 4 Relationship between pixels
Discrete cosine transform
Matlab Working With Images
digital image processing
Histogram Processing
Digital Image Processing: An Introduction
Image Restoration And Reconstruction
Ad

Similar to Images in matlab (20)

PPTX
Working with images in matlab graphics
PDF
Image processing using matlab
PDF
Programming in matlab lesson5
PDF
Matlab dip
PDF
PPTX
Image processing in MATLAB
PDF
Image processing with matlab
PDF
PDF
Image processing basics using matlab
PDF
Sec 2.pdf
PDF
Image processing with matlab
PDF
Matlab intro
PPT
Image Processing using Matlab . Useful for beginners to learn Image Processing
PDF
Introduction to Digital Image Processing Using MATLAB
PPT
Matlab
PDF
Digital Image Processing
PPT
Image processing for robotics
PDF
BMVA summer school MATLAB programming tutorial
PPT
Image processing using matlab
PPTX
ImageProcessingWithMatlab(HasithaEdiriweera)
Working with images in matlab graphics
Image processing using matlab
Programming in matlab lesson5
Matlab dip
Image processing in MATLAB
Image processing with matlab
Image processing basics using matlab
Sec 2.pdf
Image processing with matlab
Matlab intro
Image Processing using Matlab . Useful for beginners to learn Image Processing
Introduction to Digital Image Processing Using MATLAB
Matlab
Digital Image Processing
Image processing for robotics
BMVA summer school MATLAB programming tutorial
Image processing using matlab
ImageProcessingWithMatlab(HasithaEdiriweera)
Ad

Recently uploaded (20)

PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
composite construction of structures.pdf
PPTX
Sustainable Sites - Green Building Construction
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPT
Project quality management in manufacturing
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
PPT on Performance Review to get promotions
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPT
Mechanical Engineering MATERIALS Selection
PDF
Digital Logic Computer Design lecture notes
PPTX
Welding lecture in detail for understanding
bas. eng. economics group 4 presentation 1.pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
composite construction of structures.pdf
Sustainable Sites - Green Building Construction
CH1 Production IntroductoryConcepts.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
Lecture Notes Electrical Wiring System Components
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Project quality management in manufacturing
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPT on Performance Review to get promotions
R24 SURVEYING LAB MANUAL for civil enggi
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Mechanical Engineering MATERIALS Selection
Digital Logic Computer Design lecture notes
Welding lecture in detail for understanding

Images in matlab

  • 2. Group Members:  Muhammad Raheel Ali (12-EE-131)  Rana Tassuvar (12-EE-123)  Muhib ullah (12-EE-214)
  • 3. What is Image Data???  In Matlab, an image is a set of color or intensity data.  Each image is formed by combination of pixels.  Each pixel is a matrix element.  Each pixel has its own intensity of red, blue and green color.  A high level image is represented by a 3 dimensional array.  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. Popular Matlab functions associated with Images: In Matlab, there are a lot of useful functions. Some of these are:  imread  imshow  rgb2gray  imhist  imadjust  imb2w And many more….
  • 5. Loading an image in Matlab:  For loading an image in Matlab, we use use “imread” function. Following is an example of loading an image: a=imread('skardu.jpeg');
  • 6. Showing an image in Matlab:  “imshow” function shows the loaded image in Matlab window. Following is an example:  a=imread('skardu.jpg');  imshow(a);
  • 8. Getting image info using Matlab:  We mainly have two types of images that we use to deal in Matlab. These are 1- RGB images 2- Indexed images  RGB images are stored in 3 matrices. 1st for red, 2nd for green and 3rd for blue.  Each element in matrix stores intensity value of red, green or blue color for a particular pixel.  In indexed images, each pixel is given an index.  Each index is mapped to RGB value in colormap.
  • 9. Pixel info of RGB image:  For obtaining pixels info of an rgb image, we have a built in function “impixelinfo”. Following syntax is used:  a=imread('rgb.jpg');  imshow(a);  impixelinfo;  On the output screen, we can see the particular row and column of pixel with its corresponding rgb value.
  • 10. Output: In the bottom left corner, we can see the pixel info.
  • 11.  We can also find the size of image by using given command: >> a=imread('rgb.jpg'); >> impixelinfo >> size(a) Output is: ans = 768 1024 3  Output shows that it is a 768x1024 image with 3 planes.
  • 12. Converting image from one format to other:  Matlab can be used to change the format of image. Following table gives information about image conversion: As an example we will change format of image.
  • 13. Converting image to grayscale image:  “rgb2gray” function converts the image to grayscale image. Example is:  a=imread('skardu.jpg');  b=rgb2gray(a);  imshow(b);
  • 15. Histogram of Image:  “imhist” function is used to obtain histogram of image.  This function plots a graph that shows how many pixels are in a specific intensity in grayscale image. An example is:  a=imread('skardu.jpg');  b=rgb2gray(a);  imhist(b)
  • 17. Adjusting the contrast ratio:  “imadjust” function adjusts the contrast ratio in image. Example is:  a=imread('skardu.jpg');  b=rgb2gray(a);  c=imadjust(b);  subplot(1,2,1);  imshow(b);  title('Not Adjusted');  subplot(1,2,2);  imshow(c);  title('Adjusted');
  • 19. Using Matlab to obtain black and white image:  “im2bw” is a function in Matlab that turns the image into black and white image. Example:  a=imread('skardu.jpg');  b=im2bw(a);  imshow(b);
  • 21. Resizing the image:  Matlab can also be used to resize the image.  By resizing, we mean that we can increase or decrease pixels of image. Following code is an example:  a=imread('skardu.jpg');  subplot(1,2,1);  imshow(a);  title('original image');  c=imresize(a,1/5);  subplot(1,2,2);  imshow(c);  title('Resized');
  • 22. Output: Image is blurred showing decrease in number of pixels.
  • 23. Performance issues in Matlab images:  Matlab is very fast on vector and matrix operations but Correspondingly slow with loops. So, • Try to avoid loops • Try to vectorize your code