SlideShare a Scribd company logo
1 of 27
DIGITAL IMAGE PROCESSING
• Basic image processing functions:
• imread()
• imshow()
• imwrite()
• rgb2gray()
• imhist()
• imadjust()
• im2bw()
• imtool()
• iminfo()
• imagesc()
• Title()
• Size()
• Subplot()
• Colormap()
• Whos()
Reading Image
• >>F = imread(Penguins_grey.jpg);
>>G = imread(Penguins_RGB.jpg);
RGB image of penguinsGrayscale image of penguins
• To get the size of a 2D image,
[M,N] = size(f)
This syntax returns the number of rows (M) and
columns (N) in the image.
Find additional information about the array using
‘whos’ command.
• Syntax
whos filename
‘whos f’ gives name, size, bytes, class and attributes of
the array ‘f.’
Syntax:
whos filename
As an example, ‘whos F’gives:
Name F
Size 768×1024×3
Bytes 2359296
Class Attributes uint8
‘whos G’ gives:
Name G
Size 768×1024
Bytes 786432
• To start the image tool, use the imtool function.
• >>B = imread(Penguins_grey.jpg);
>>imtool(B)
• The above window that appears when using the image tool. The
status text at the bottom of the main window shows the column/row
location and the value of the pixel lying under the mouse cursor.
Measure Distance tool
The Measure Distance tool under Tools tab is used to show the
distance between the two selected points
Pixel Region tool
The Pixel Region tool shows individual pixels from the small
square region on the upper right tip, zoomed large enough to see
the actual pixel values.
• Quality
The quality parameter is used as a trade-off between the
resulting image’s subjective quality and file size.
• Syntax:
imwrite(f, ‘filename.jpg’, ‘quality’, q)
where ‘q’ is an integer between 0 and 100.
It can be used to reduce the image size.
• image Penguins_grey.jpg is read
• JPG format with three different quality parameters: 75 (default), 10
(poor quality and small size) and 90 (high quality and large size)
are applied
• F = imread(‘Penguins_grey.jpg’);
imwrite(F,’Penguins_grey_75.
jpg’,’quality’,75);
imwrite(F,’Penguins_grey_10.
jpg’,’quality’,10);
imwrite(F,’Penguins_grey_90.
jpg’,’quality’,90);
• From the following images, quality factors of 75, 10 and 90
seen. Note that that a low-quality image has a smaller size than
a higher-quality image.
Image for quality factor of 90Image for quality factor of 10Image for quality factor of 75
• Image information
File details including file name, data, size,
format, height and width can be obtained.
• Syntax:
imfinfo’filename’
imfinfo(‘Penguins_grey.jpg’)
ans=
Filename: [1×50 char]
FileModDate: ’02-Aug-2016 09:24:12′
FileSize: 100978
Format: ‘jpg’
FormatVersion: ”
Width: 1024
Height: 768
BitDepth: 8
ColorType: ‘grayscale’
FormatSignature: ”
NumberOfSamples: 1
CodingMethod: ‘Huffman’
CodingProcess: ‘Sequential’
Comment: {}
• The following example stores all the information into variable
‘K’:
• K = imfinfo(‘Penguins_grey.jpg’)
• The information generated by ‘imfinfo’ is appended to the
structure variable by means of fields, separated from ‘K’ by a
dot. As an example, the image height and width are stored in
structure fields K.height and K.weight.
• imread()
The imread() command will read an image into a matrix:
img = imread('ImageProcessing_1/BerkeleyTower.png');
>> size(img)
ans =
499 748 3
• It's a 499x748 matrix with 3 RGB channels. The matrix looks like this:
24 40 73 108 129 108 96 100 109 114 108 109 62
29 56 97 107 110 104 103 105 106 110 110 111 105
...
3 2 2 1 0 0 1 1 0 1 2 4 2
1 0 1 3 2 0 0 0 1 1 2 1 0
...
• imshow()
To show our image use ,
The imshow() command shows an image in
standard 8-bit format, like it would appear in a
web browser.
The imagesc()command displays the image on
scaled axes with the min value as black and the
max value as white.
Using imshow():
Using imagesc():
• We can check the RGB values with (x,y) coordinates of a pixel:
• Select "Data Cursor" icon from the top menu
• Click the mouse on the image
• Notice each pixel is a 3-dimensional vector with values in the range [0,255].
The 3 numbers displayed is the amount of RGB.
• Actually, a color image is a combined image of 3 grayscale images. So, we can
display the individual RGB components of the image using the following
script:
subplot(131);
imagesc(img(:,:,1));
title('Red');
subplot(132);
imagesc(img(:,:,2));
title('Green');
subplot(133);
imagesc(img(:,:,3));
title('Blue');
• Using a command colormap gray, the picture turns into a
grayscale:
• >> colormap gray
• imwrite()
To save new blue image, use the imwrite() command:
imwrite(blue_img, 'Blue4_BerkeleyTower.png', 'png');
• rgb2gray()
img = imread('ImageProcessing_1/BerkeleyTower.png');
gray = rgb2gray(img);
imshow(gray);
• >> size(gray)
ans =
499 748
• imhist()
Display a histogram of image data.
img = imread('ImageProcessing_1/BerkeleyTower.png');
gray = rgb2gray(img);
imhist(gray);
• imadjust()
imadjust() adjust image intensity values. It maps the values in intensity image of an
input to new values in output image. This increases the contrast of the output image.
img = imread('ImageProcessing_1/Rachmaninoff.jpg');
gray = rgb2gray(img);
adj_img = imadjust(gray, [0.3,0.7],[]);
subplot(121);
imshow(gray);
title('input');
subplot(122);
imshow(adj_img);
title('adjusted');
• im2bw()
im2bw() converts the grayscale image to a binary image.
img = imread('ImageProcessing_1/Rachmaninoff.jpg');
gray = rgb2gray(img);
adj_img = imadjust(gray, [0.3,0.7],[]);
bw_img = im2bw(adj_img);
subplot(121);
imshow(adj_img);
title('input image');
subplot(122);
imshow(bw_img);
title('binary image');

More Related Content

What's hot

Let’s Talk About Ruby
Let’s Talk About RubyLet’s Talk About Ruby
Let’s Talk About Ruby
Ian Bishop
 
Python simplecv
Python simplecvPython simplecv
Python simplecv
UFPA
 

What's hot (18)

Ggplot
GgplotGgplot
Ggplot
 
Advanced Concepts in Python
Advanced Concepts in PythonAdvanced Concepts in Python
Advanced Concepts in Python
 
Let’s Talk About Ruby
Let’s Talk About RubyLet’s Talk About Ruby
Let’s Talk About Ruby
 
3
33
3
 
SD & D Bitmapped Graphics
SD & D Bitmapped GraphicsSD & D Bitmapped Graphics
SD & D Bitmapped Graphics
 
HTML 5_Canvas
HTML 5_CanvasHTML 5_Canvas
HTML 5_Canvas
 
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)
 
Python simplecv
Python simplecvPython simplecv
Python simplecv
 
How big-is-your-graph
How big-is-your-graphHow big-is-your-graph
How big-is-your-graph
 
Seg code
Seg codeSeg code
Seg code
 
CLUSTERGRAM
CLUSTERGRAMCLUSTERGRAM
CLUSTERGRAM
 
Lec2
Lec2Lec2
Lec2
 
Big Data LDN 2017: From Zero to AI in 30 Minutes
Big Data LDN 2017: From Zero to AI in 30 MinutesBig Data LDN 2017: From Zero to AI in 30 Minutes
Big Data LDN 2017: From Zero to AI in 30 Minutes
 
Ggplot2 cheatsheet-2.1
Ggplot2 cheatsheet-2.1Ggplot2 cheatsheet-2.1
Ggplot2 cheatsheet-2.1
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvas
 
Multimedia
MultimediaMultimedia
Multimedia
 
全民优化
全民优化全民优化
全民优化
 
Intro to HTML5 Canvas
Intro to HTML5 CanvasIntro to HTML5 Canvas
Intro to HTML5 Canvas
 

Similar to Dip syntax 4

Image processing basics using matlab
Image processing basics using matlabImage processing basics using matlab
Image processing basics using matlab
Ankur Tyagi
 
Image processing tool box.pptx
Image processing tool box.pptxImage processing tool box.pptx
Image processing tool box.pptx
AvinashJain66
 
Random And Dynamic Images Using Python Cgi
Random And Dynamic Images Using Python CgiRandom And Dynamic Images Using Python Cgi
Random And Dynamic Images Using Python Cgi
AkramWaseem
 
Can you please separate the code into imagespy sharpenpy.pdf
Can you please separate the code into imagespy sharpenpy.pdfCan you please separate the code into imagespy sharpenpy.pdf
Can you please separate the code into imagespy sharpenpy.pdf
agmbro1
 
Image Processing using Matlab . Useful for beginners to learn Image Processing
Image Processing using Matlab . Useful for beginners to learn Image ProcessingImage Processing using Matlab . Useful for beginners to learn Image Processing
Image Processing using Matlab . Useful for beginners to learn Image Processing
Ashok Kumar
 

Similar to Dip syntax 4 (20)

Simple Matlab tutorial using matlab inbuilt commands
Simple Matlab tutorial using matlab inbuilt commandsSimple Matlab tutorial using matlab inbuilt commands
Simple Matlab tutorial using matlab inbuilt commands
 
Working with images in matlab graphics
Working with images in matlab graphicsWorking with images in matlab graphics
Working with images in matlab graphics
 
Dip 2
Dip 2Dip 2
Dip 2
 
Image processing basics using matlab
Image processing basics using matlabImage processing basics using matlab
Image processing basics using matlab
 
Dip 1
Dip 1Dip 1
Dip 1
 
CE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfCE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdf
 
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
 
Image processing tool box.pptx
Image processing tool box.pptxImage processing tool box.pptx
Image processing tool box.pptx
 
Image processing for robotics
Image processing for roboticsImage processing for robotics
Image processing for robotics
 
الوسائط المتعددة Multimedia تاج
الوسائط المتعددة  Multimedia تاجالوسائط المتعددة  Multimedia تاج
الوسائط المتعددة Multimedia تاج
 
Random And Dynamic Images Using Python Cgi
Random And Dynamic Images Using Python CgiRandom And Dynamic Images Using Python Cgi
Random And Dynamic Images Using Python Cgi
 
Resize image vb.net
Resize image vb.netResize image vb.net
Resize image vb.net
 
Image_Processing_LECTURE_c#_programming.ppt
Image_Processing_LECTURE_c#_programming.pptImage_Processing_LECTURE_c#_programming.ppt
Image_Processing_LECTURE_c#_programming.ppt
 
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
 
Image enhancement lecture
Image enhancement lectureImage enhancement lecture
Image enhancement lecture
 
Can you please separate the code into imagespy sharpenpy.pdf
Can you please separate the code into imagespy sharpenpy.pdfCan you please separate the code into imagespy sharpenpy.pdf
Can you please separate the code into imagespy sharpenpy.pdf
 
Php gd library
Php gd libraryPhp gd library
Php gd library
 
Digital Image Processing (Lab 07)
Digital Image Processing (Lab 07)Digital Image Processing (Lab 07)
Digital Image Processing (Lab 07)
 
Image Processing using Matlab . Useful for beginners to learn Image Processing
Image Processing using Matlab . Useful for beginners to learn Image ProcessingImage Processing using Matlab . Useful for beginners to learn Image Processing
Image Processing using Matlab . Useful for beginners to learn Image Processing
 

More from Shajun Nisha

ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
Shajun Nisha
 

More from Shajun Nisha (18)

Google meet and its extensions sac
Google meet and its extensions sacGoogle meet and its extensions sac
Google meet and its extensions sac
 
Dip fundamentals 2
Dip fundamentals 2Dip fundamentals 2
Dip fundamentals 2
 
Dip application 1
Dip application 1Dip application 1
Dip application 1
 
Dip digital image 3
Dip digital image 3Dip digital image 3
Dip digital image 3
 
ICT tools
ICT  toolsICT  tools
ICT tools
 
25 environmental ethics intellectual property rights
25 environmental ethics intellectual property rights25 environmental ethics intellectual property rights
25 environmental ethics intellectual property rights
 
Linear regression in machine learning
Linear regression in machine learningLinear regression in machine learning
Linear regression in machine learning
 
Basics of research in research methodology
Basics of research in research methodologyBasics of research in research methodology
Basics of research in research methodology
 
Auto encoders in Deep Learning
Auto encoders in Deep LearningAuto encoders in Deep Learning
Auto encoders in Deep Learning
 
Teaching Aptitude in Research Methodology
Teaching Aptitude in Research MethodologyTeaching Aptitude in Research Methodology
Teaching Aptitude in Research Methodology
 
Perceptron and Sigmoid Neurons
Perceptron and Sigmoid NeuronsPerceptron and Sigmoid Neurons
Perceptron and Sigmoid Neurons
 
Mc Culloch Pitts Neuron
Mc Culloch Pitts NeuronMc Culloch Pitts Neuron
Mc Culloch Pitts Neuron
 
Intensity Transformation and Spatial filtering
Intensity Transformation and Spatial filteringIntensity Transformation and Spatial filtering
Intensity Transformation and Spatial filtering
 
Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)
 
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
ESTIMATING NOISE PARAMETER & FILTERING (Digital Image Processing)
 
Image processing lab work
Image processing lab workImage processing lab work
Image processing lab work
 
introduction to cloud computing
 introduction to cloud computing introduction to cloud computing
introduction to cloud computing
 
online learning NPTEL
online learning NPTELonline learning NPTEL
online learning NPTEL
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 

Dip syntax 4

  • 2. • Basic image processing functions: • imread() • imshow() • imwrite() • rgb2gray() • imhist() • imadjust() • im2bw() • imtool() • iminfo() • imagesc() • Title() • Size() • Subplot() • Colormap() • Whos()
  • 3. Reading Image • >>F = imread(Penguins_grey.jpg); >>G = imread(Penguins_RGB.jpg); RGB image of penguinsGrayscale image of penguins
  • 4. • To get the size of a 2D image, [M,N] = size(f) This syntax returns the number of rows (M) and columns (N) in the image. Find additional information about the array using ‘whos’ command. • Syntax whos filename ‘whos f’ gives name, size, bytes, class and attributes of the array ‘f.’
  • 5. Syntax: whos filename As an example, ‘whos F’gives: Name F Size 768×1024×3 Bytes 2359296 Class Attributes uint8 ‘whos G’ gives: Name G Size 768×1024 Bytes 786432
  • 6.
  • 7. • To start the image tool, use the imtool function. • >>B = imread(Penguins_grey.jpg); >>imtool(B) • The above window that appears when using the image tool. The status text at the bottom of the main window shows the column/row location and the value of the pixel lying under the mouse cursor.
  • 8. Measure Distance tool The Measure Distance tool under Tools tab is used to show the distance between the two selected points
  • 9. Pixel Region tool The Pixel Region tool shows individual pixels from the small square region on the upper right tip, zoomed large enough to see the actual pixel values.
  • 10. • Quality The quality parameter is used as a trade-off between the resulting image’s subjective quality and file size. • Syntax: imwrite(f, ‘filename.jpg’, ‘quality’, q) where ‘q’ is an integer between 0 and 100. It can be used to reduce the image size. • image Penguins_grey.jpg is read • JPG format with three different quality parameters: 75 (default), 10 (poor quality and small size) and 90 (high quality and large size) are applied
  • 11. • F = imread(‘Penguins_grey.jpg’); imwrite(F,’Penguins_grey_75. jpg’,’quality’,75); imwrite(F,’Penguins_grey_10. jpg’,’quality’,10); imwrite(F,’Penguins_grey_90. jpg’,’quality’,90); • From the following images, quality factors of 75, 10 and 90 seen. Note that that a low-quality image has a smaller size than a higher-quality image.
  • 12. Image for quality factor of 90Image for quality factor of 10Image for quality factor of 75
  • 13. • Image information File details including file name, data, size, format, height and width can be obtained. • Syntax: imfinfo’filename’ imfinfo(‘Penguins_grey.jpg’)
  • 14. ans= Filename: [1×50 char] FileModDate: ’02-Aug-2016 09:24:12′ FileSize: 100978 Format: ‘jpg’ FormatVersion: ” Width: 1024 Height: 768 BitDepth: 8 ColorType: ‘grayscale’ FormatSignature: ” NumberOfSamples: 1 CodingMethod: ‘Huffman’ CodingProcess: ‘Sequential’ Comment: {}
  • 15. • The following example stores all the information into variable ‘K’: • K = imfinfo(‘Penguins_grey.jpg’) • The information generated by ‘imfinfo’ is appended to the structure variable by means of fields, separated from ‘K’ by a dot. As an example, the image height and width are stored in structure fields K.height and K.weight.
  • 16. • imread() The imread() command will read an image into a matrix: img = imread('ImageProcessing_1/BerkeleyTower.png'); >> size(img) ans = 499 748 3 • It's a 499x748 matrix with 3 RGB channels. The matrix looks like this: 24 40 73 108 129 108 96 100 109 114 108 109 62 29 56 97 107 110 104 103 105 106 110 110 111 105 ... 3 2 2 1 0 0 1 1 0 1 2 4 2 1 0 1 3 2 0 0 0 1 1 2 1 0 ...
  • 17. • imshow() To show our image use , The imshow() command shows an image in standard 8-bit format, like it would appear in a web browser. The imagesc()command displays the image on scaled axes with the min value as black and the max value as white.
  • 20. • We can check the RGB values with (x,y) coordinates of a pixel: • Select "Data Cursor" icon from the top menu • Click the mouse on the image • Notice each pixel is a 3-dimensional vector with values in the range [0,255]. The 3 numbers displayed is the amount of RGB.
  • 21. • Actually, a color image is a combined image of 3 grayscale images. So, we can display the individual RGB components of the image using the following script: subplot(131); imagesc(img(:,:,1)); title('Red'); subplot(132); imagesc(img(:,:,2)); title('Green'); subplot(133); imagesc(img(:,:,3)); title('Blue');
  • 22.
  • 23. • Using a command colormap gray, the picture turns into a grayscale: • >> colormap gray
  • 24. • imwrite() To save new blue image, use the imwrite() command: imwrite(blue_img, 'Blue4_BerkeleyTower.png', 'png'); • rgb2gray() img = imread('ImageProcessing_1/BerkeleyTower.png'); gray = rgb2gray(img); imshow(gray);
  • 25. • >> size(gray) ans = 499 748 • imhist() Display a histogram of image data. img = imread('ImageProcessing_1/BerkeleyTower.png'); gray = rgb2gray(img); imhist(gray);
  • 26. • imadjust() imadjust() adjust image intensity values. It maps the values in intensity image of an input to new values in output image. This increases the contrast of the output image. img = imread('ImageProcessing_1/Rachmaninoff.jpg'); gray = rgb2gray(img); adj_img = imadjust(gray, [0.3,0.7],[]); subplot(121); imshow(gray); title('input'); subplot(122); imshow(adj_img); title('adjusted');
  • 27. • im2bw() im2bw() converts the grayscale image to a binary image. img = imread('ImageProcessing_1/Rachmaninoff.jpg'); gray = rgb2gray(img); adj_img = imadjust(gray, [0.3,0.7],[]); bw_img = im2bw(adj_img); subplot(121); imshow(adj_img); title('input image'); subplot(122); imshow(bw_img); title('binary image');