/OtsuSegmentation

An algorithm to highlight the different regions in an image.

Primary LanguageMATLAB

OtsuSegmentation

An algorithm to highlight the different regions in an image using an extended version of Otsu's statistical thresholding. The different regions in an image are grouped into a greyscale value, depending on how many regions were found, the output shows the number of regions and corresponding greyscale value of each region.

Explanation

The underlying logic is to create a histogram of the greyscale values in the image and find threshold(s) in this histogram that splits the image into some groups and minimizes the weighted sum of within group variances.

Dependencies

  1. MATLAB Parallel Computing Toolbox, depeding on your systems bounds the default profile for the parallel pool can be 'Threads' or 'Processes'
  2. Image Processing Toolbox for 'imwrite' and 'imread'

Usage

  1. To run the program, add folder containing “Segmentation_code.m” and the image files into the MATLAB path.
  2. Run the program in MATLAB
  3. Enter the input image name in the MATLAB command line, no need to add the “.bmp”
  4. The command line will output number of regions, and thresholds found
  5. Wait for the script to display all the relevant graphs and image outputs in order
  6. If the name of the file was entered incorrectly, re-run the program

Example outputs

Original image:

image

Segmented image:

image

Original image:

image

Segmented image:

image

Original image:

image

Segmented image:

image