%% Convert Grayscale Image to Binary Image Using Dithering
% Read the grayscale image from the corn.tif file into the MATLAB® workspace. The grayscale version of the image is the third image in the file.

corn_gray = imread('corn.tif',3);

% Display the grayscale image using imshow.

imshow(corn_gray)

% Convert the image to binary by using the dither function.

corn_bw = dither(corn_gray);

% Display the binary image. Although pixels in the binary image only have the value 0 or 1, the image appears to have shades of gray because of dithering.

imshow(corn_bw)

% Copyright 2018 The MathWorks, Inc.