Biosciences: Image Processing

This is an interactive courseware module that teaches the basics of image processing using biologically motivated examples.
Updated 16 Apr 2024

Biological Sciences: Image Processing

View Module on File Exchange or Open in MATLAB Online

In this module, we will learn how to import, preprocess, and segment biologically relevant images using MATLAB®. Make sure you're familiar with the basics of using MATLAB by going through the MATLAB Onramp before continuing. You'll need to utilize the Image Processing Toolbox for this module. You may want to consider going through the Image Processing Onramp for further practice.

Table of Contents


  Notes on the use of live scripts

  Various icons will be used throughout these scripts to identify different types of interactivity.


Stained cells in a cow blood vessel

Cells taken from the inner walls of a cow blood vessel, stained fluorescent, and viewed under a microscope.


As biologists, we study the living world and how the species that comprise it evolve, interact, and function. You can imagine many ways in which images might be useful in biology. Images of a species of animal or plant might be used to identify various features of those organisms. Image processing can be used to monitor the health of crops, to measure the movement of humans, and can be used with machine learning techniques to diagnose different conditions such as skin cancer. An iPhone will tell you what species of plant you're looking at if you take a photo of it. If you're walking in the woods, you can instantly know if you can eat a plant or should avoid touching it altogether! We'll start this module by exploring such a plant image.

Within organisms, we may want to look deeper than can be seen with the naked eye, which is enabled by the various types of microscopy currently used in the field. You can imagine using basic microscopy methods to look at the cells in a patient's blood, or even using more complicated microscopic imaging methods to look at the activity of cells in an alive mouse's brain!

As techniques in biology have gotten more and more complex, biologists have begun collecting more and more data. It can be challenging to analyze all of this data by hand, but luckily MATLAB can help! For example, imagine you collect a sample of a patient's blood, and you want to count the number of cells so you can figure out if the cell count is too low, too high, etc. People used to have to painstakingly count cells by hand, but now the process can be easily automated in MATLAB by importing and segmenting an image of the slide. We'll explore how to do this at the end of this module.

Notes on the use of live scripts

  • These scripts can all be run independently, though we recommend going through these live scripts in order.
  • These live scripts are intended to be used with output inline. To change the output, go to the View tab of the toolstrip, and select image_1.png Output Inline.
  • If you haven't spent much time with live scripts, and need a refresher on interacting with them before you begin, click [here](matlab: edit starting_tips.mlx).

Various icons will be used throughout these scripts to identify different types of interactivity.

          Try icon Students to interact with the code .

         Exercise icon Exercises exist in most scripts and the answers will be provided at the end.

A problem set for students to practice these concepts is also included here.

         Reflect icon Students reflect on what they've learned or on what the data means.

         Application icon Particularly interesting examples of how these concepts are used in "real-world" biology


  • Learning objective: Students will import, manipulate, and segment a plant image in MATLAB, and learn how images are stored.
  • Learning objective: Students will learn to segment images by shape and count the number of cells on a microscope slide image of red blood cells.

Cite As

Emma Smith Zbarsky (2024). Biosciences: Image Processing (, GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2023a
Compatible with R2023a and later releases
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Versions that use the GitHub default branch cannot be downloaded

Version Published Release Notes

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.