EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Matlab Tutorial Matlab Image Processing
 

Matlab Image Processing

Updated March 13, 2023

Matlab Image Processing

 

 

Introduction to Matlab Image Processing

Image Processing apps are provided by MATLAB in the form of a toolbox that helps us in automating commonly used image processing techniques and workflows by enabling interactive segmentation of image data, comparison of image registration methods, and batch processing of large datasets.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Image processing in MATLAB lets us explore any image or video and make changes like adjusting the contrast, manipulating ROI (regions of interest) and create histograms to understand the definition of the image.

Here is the list of some of the most commonly used functions for processing images in MATLAB:

Syntax & Description

  1. imread (): This function is used to read or load the image which we want to process
  2. imshow (): This function is used to display the image that we have loaded
  3. imagesc (): This function is used to display the image by utilizing the full set of colors present in the colormap. A color scale can also be used after calling this function to get a better idea of the colors present
  4. imhist (): Using This function, we can check how the pixel intensity of the image is distributed
  5. histeq (): Using this function, we can edit the contrast of our image
  6. imwrite (): This function is used to insert our edited image into a file
  7. iminfo (): This function is used to confirm if our edited file is loaded into a disk file

Functions of Matlab Image Processing

Let us now understand the use of all the functions in MATLAB. First, we will use an image stored in MATLAB’s image processing app and execute all the functions in steps for that image.

Step #1

In the first step, we Load or Read the image into our workspace.

Code:

imageInput = imread (‘kids.tif');

[‘imread’ will read the image and will store it in the array ‘imageInput’]

Step #2

In this step, we will display our image in the workspace.

Code:

imshow (imageInput)

[‘imshow’ will display the image as output in the workspace]

Output:

Matlab Image Processing output 1

As we can see in the output, the image is loaded in our workspace.

Step #3

In this step, we will display our image with the colors from the colormap. We will also use a colorbar to check the intensity of the colors.

Code:

imagesc (imageInput)

[‘imagesc’ will display the image with a full range of colors from the colormap]

colorbar

[‘colorbar’ is used to display a scale next to the image to check the intensity of the colors]

Output:

Matlab Image Processing output 2

As we can see in the output, the image is displayed and has a full range of colors in the colormap, and we also have a colorbar next to it.

Step #4

In this step, we will check the intensity of pixels in our image. We will be using the figure function to display the intensity in the form of a histogram.

Code:

figure

[Used to display the histogram for intensity]

imhist (imageInput)

[‘imhist’ will create the distribution of the pixel intensities]

Output:

Matlab Image Processing output 3

As we can see in the output, the range of pixel intensity for our image is very narrow, i.e. the values are concentrated in a small range.

Step #5

In this step, we will edit the contrast of our image. This is done because we found in the above step that our image has a very narrow pixel intensity.

Code:

newImage = histeq (imageInput);

[‘histeq function will improve the pixel intensity, or we can say that it will improve the contrast of our image]

figure
imshow (newImage)

[Displaying our new image (with improved contrast]

Output:

output 4

As we can see in the output, the contrast of our image has improved drastically.

Step #6

In this step, let us call the ‘imhist’ function again with ‘newImage’ as the input. This will confirm that contrast or pixel intensities of the new image created are now uniformly distributed.

Code:

figure
imhist (newImage)

Output:

output 5

As we can see in the histogram above, the pixel intensities of the new image created are now uniformly distributed.

Step #7

In this step, we will insert the new image into the disk file.

Code:

imwrite (newImage, 'kids2.png');

[Using ‘imwrite’ to save the image in disk file]

Step #8

Finally, we will confirm if our image is saved in the disk file or not using the ‘iminfo’ function. This will also give us all other details like file size, format, width, height, etc.

Code:

imfinfo ('kids2.png')

[Getting the information of the saved file]

Output:

output 6

As we can see in the output, the file is saved as expected by us. We also have all other information related to the image.

Conclusion

  1. Image processing app can be used in MATLAB to perform various operations on an image, ranging from loading the image, editing it and saving it in the disk file.
  2. The image processing can be used to process both 2D& 3D images

Recommended Articles

This is a guide to Matlab Image Processing. Here we discuss the Functions of Matlab Image Processing and will execute all the functions in steps. You may also have a look at the following articles to learn more –

  1. xlsread Matlab
  2. Matlab Images
  3. MATLAB Unique
  4. Matlab trapz()

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW