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

What's hot

Digital image processing using matlab
Digital image processing using matlab Digital image processing using matlab
Digital image processing using matlab
Amr Rashed
 
Introduction in Image Processing Matlab Toolbox
Introduction in Image Processing Matlab ToolboxIntroduction in Image Processing Matlab Toolbox
Introduction in Image Processing Matlab Toolbox
Shahriar Yazdipour
 
Dital Image Processing (Lab 2+3+4)
Dital Image Processing (Lab 2+3+4)Dital Image Processing (Lab 2+3+4)
Dital Image Processing (Lab 2+3+4)
Moe Moe Myint
 
Image restoration
Image restorationImage restoration
Image restoration
Upendra Pratap Singh
 
Tools-Tools Corel Draw
Tools-Tools Corel DrawTools-Tools Corel Draw
Tools-Tools Corel Draw
Dian Arifin
 
Digital image processing2.pptx
Digital image processing2.pptxDigital image processing2.pptx
Digital image processing2.pptx
DivyanshAgarwal78
 
Image enhancement
Image enhancement Image enhancement
Image enhancement
SimiAttri
 
.bmp image data format
.bmp image data format.bmp image data format
.bmp image data format
Mahesh pawar
 
Image proceesing with matlab
Image proceesing with matlabImage proceesing with matlab
Image proceesing with matlabAshutosh Shahi
 
Image restoration and degradation model
Image restoration and degradation modelImage restoration and degradation model
Image restoration and degradation model
AnupriyaDurai
 
Digital Image restoration
Digital Image restorationDigital Image restoration
Digital Image restoration
Md Shabir Alam
 
CV_1 Introduction of Computer Vision and its Application
CV_1 Introduction of Computer Vision and its ApplicationCV_1 Introduction of Computer Vision and its Application
CV_1 Introduction of Computer Vision and its Application
Khushali Kathiriya
 
Basic image processing techniques
Basic image processing techniquesBasic image processing techniques
Basic image processing techniques
Heikham Anandkumar Singh
 
Lect 02 second portion
Lect 02  second portionLect 02  second portion
Lect 02 second portion
Moe Moe Myint
 
Image processing in MATLAB
Image processing in MATLABImage processing in MATLAB
Image processing in MATLAB
Amarjeetsingh Thakur
 
Chapter 6 Image Processing: Image Enhancement
Chapter 6 Image Processing: Image EnhancementChapter 6 Image Processing: Image Enhancement
Chapter 6 Image Processing: Image Enhancement
Varun Ojha
 
Steganography: LSB technique
Steganography: LSB techniqueSteganography: LSB technique
Steganography: LSB technique
Mikel Solabarrieta
 
DCT image compression
DCT image compressionDCT image compression
DCT image compression
youssef ramzy
 

What's hot (20)

Digital image processing using matlab
Digital image processing using matlab Digital image processing using matlab
Digital image processing using matlab
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Introduction in Image Processing Matlab Toolbox
Introduction in Image Processing Matlab ToolboxIntroduction in Image Processing Matlab Toolbox
Introduction in Image Processing Matlab Toolbox
 
Dital Image Processing (Lab 2+3+4)
Dital Image Processing (Lab 2+3+4)Dital Image Processing (Lab 2+3+4)
Dital Image Processing (Lab 2+3+4)
 
Image restoration
Image restorationImage restoration
Image restoration
 
Tools-Tools Corel Draw
Tools-Tools Corel DrawTools-Tools Corel Draw
Tools-Tools Corel Draw
 
Digital image processing2.pptx
Digital image processing2.pptxDigital image processing2.pptx
Digital image processing2.pptx
 
Image enhancement
Image enhancement Image enhancement
Image enhancement
 
.bmp image data format
.bmp image data format.bmp image data format
.bmp image data format
 
Image proceesing with matlab
Image proceesing with matlabImage proceesing with matlab
Image proceesing with matlab
 
Image restoration and degradation model
Image restoration and degradation modelImage restoration and degradation model
Image restoration and degradation model
 
point operations in image processing
point operations in image processingpoint operations in image processing
point operations in image processing
 
Digital Image restoration
Digital Image restorationDigital Image restoration
Digital Image restoration
 
CV_1 Introduction of Computer Vision and its Application
CV_1 Introduction of Computer Vision and its ApplicationCV_1 Introduction of Computer Vision and its Application
CV_1 Introduction of Computer Vision and its Application
 
Basic image processing techniques
Basic image processing techniquesBasic image processing techniques
Basic image processing techniques
 
Lect 02 second portion
Lect 02  second portionLect 02  second portion
Lect 02 second portion
 
Image processing in MATLAB
Image processing in MATLABImage processing in MATLAB
Image processing in MATLAB
 
Chapter 6 Image Processing: Image Enhancement
Chapter 6 Image Processing: Image EnhancementChapter 6 Image Processing: Image Enhancement
Chapter 6 Image Processing: Image Enhancement
 
Steganography: LSB technique
Steganography: LSB techniqueSteganography: LSB technique
Steganography: LSB technique
 
DCT image compression
DCT image compressionDCT image compression
DCT image compression
 

Similar to Images in matlab

Programming in matlab lesson5
Programming in matlab lesson5Programming in matlab lesson5
Programming in matlab lesson5
najmah17
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
Ankur Nanda
 
Image processing using matlab
Image processing using matlab Image processing using matlab
Image processing using matlab
SangeethaSasi1
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlab
Aman Gupta
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlabneetirajsinh
 
IRJET- 3D Vision System using Calibrated Stereo Camera
IRJET- 3D Vision System using Calibrated Stereo CameraIRJET- 3D Vision System using Calibrated Stereo Camera
IRJET- 3D Vision System using Calibrated Stereo Camera
IRJET Journal
 
Performance Anaysis for Imaging System
Performance Anaysis for Imaging SystemPerformance Anaysis for Imaging System
Performance Anaysis for Imaging System
Vrushali Lanjewar
 
Matlab Working With Images
Matlab Working With ImagesMatlab Working With Images
Matlab Working With Images
matlab Content
 
Image processing
Image processingImage processing
Image processingmaheshpene
 
Working with images in matlab graphics
Working with images in matlab graphicsWorking with images in matlab graphics
Working with images in matlab graphics
mustafa_92
 
image enhancement.pptx
image enhancement.pptximage enhancement.pptx
ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)Hasitha Ediriweera
 
Matlab dip
Matlab dipMatlab dip
Matlab dip
Jeevan Reddy
 
Image processing basics using matlab
Image processing basics using matlabImage processing basics using matlab
Image processing basics using matlabAnkur Tyagi
 
Image processing using matlab
Image processing using matlabImage processing using matlab
Image processing using matlab
dedik dafiyanto
 
Basics of image processing using MATLAB
Basics of image processing using MATLABBasics of image processing using MATLAB
Basics of image processing using MATLAB
Mohsin Siddique
 
imageenhancementtechniques-140316011049-phpapp01 (1).pptx
imageenhancementtechniques-140316011049-phpapp01 (1).pptximageenhancementtechniques-140316011049-phpapp01 (1).pptx
imageenhancementtechniques-140316011049-phpapp01 (1).pptx
salutiontechnology
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlab
minhtaispkt
 
Dip 1
Dip 1Dip 1

Similar to Images in matlab (20)

Programming in matlab lesson5
Programming in matlab lesson5Programming in matlab lesson5
Programming in matlab lesson5
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
 
Image processing using matlab
Image processing using matlab Image processing using matlab
Image processing using matlab
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlab
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlab
 
IRJET- 3D Vision System using Calibrated Stereo Camera
IRJET- 3D Vision System using Calibrated Stereo CameraIRJET- 3D Vision System using Calibrated Stereo Camera
IRJET- 3D Vision System using Calibrated Stereo Camera
 
Performance Anaysis for Imaging System
Performance Anaysis for Imaging SystemPerformance Anaysis for Imaging System
Performance Anaysis for Imaging System
 
Matlab Working With Images
Matlab Working With ImagesMatlab Working With Images
Matlab Working With Images
 
Image processing
Image processingImage processing
Image processing
 
Working with images in matlab graphics
Working with images in matlab graphicsWorking with images in matlab graphics
Working with images in matlab graphics
 
image enhancement.pptx
image enhancement.pptximage enhancement.pptx
image enhancement.pptx
 
ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)
 
Matlab dip
Matlab dipMatlab dip
Matlab dip
 
Image processing basics using matlab
Image processing basics using matlabImage processing basics using matlab
Image processing basics using matlab
 
Image processing using matlab
Image processing using matlabImage processing using matlab
Image processing using matlab
 
Basics of image processing using MATLAB
Basics of image processing using MATLABBasics of image processing using MATLAB
Basics of image processing using MATLAB
 
Report
ReportReport
Report
 
imageenhancementtechniques-140316011049-phpapp01 (1).pptx
imageenhancementtechniques-140316011049-phpapp01 (1).pptximageenhancementtechniques-140316011049-phpapp01 (1).pptx
imageenhancementtechniques-140316011049-phpapp01 (1).pptx
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlab
 
Dip 1
Dip 1Dip 1
Dip 1
 

Recently uploaded

space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 

Recently uploaded (20)

space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 

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