Main Content

Convert Grayscale Image to Binary Image

This example shows you how to convert a grayscale image to a binary image using a global threshold.

Example Model

Open the Simulink® model.

modelname = "ex_blkautothreshold.slx";
open_system(modelname)

This model reads the input image using an Image From File block with the File name parameter set to coins.png.

The model then converts the input image to a binary image by using the Autothreshold block with default parameters. The Autothreshold block performs the thresholding operation using Otsu's method.

Simulate the Model

Run the model. The model displays the input intensity image and the output binary image using Video Viewer blocks.

sim(modelname);