Main Content

Implement Histogram Equalization and Median Filtering on Images Using Android Device

This example shows how to use the Simulink® Support Package for Android® Devices to implement histogram equalization and median filtering on images using an Android device.

Using histogram equalization, you can adjust the intensity values of the pixels of an input image. This example shows how to use histogram equalization to adjust the contrast of a grayscale image. The input image to the Simulink model has a low contrast, while the output image has its pixel values evenly distributed throughout the range.

Using median filtering, you can apply median filter to each pixel of an input image. It removes the impulse noise from an input image without significantly reducing the sharpness of the image. This example shows how to use median filtering on a grayscale image.

Prerequisites

Required Hardware

  • Android device such as a phone or tablet

  • USB cable

Hardware Setup

Connect your Android device to the host computer using the USB cable. Set up your Android device using the Hardware Setup. For more information, see Hardware Setup.

Configure Simulink Model and Calibrate Parameters

Open the androidVisionGettingStarted2 Simulink model.

For more information on Simulation Sources, Android Inputs, Display and Visualization, and Android Outputs area, see Get Started with Computer Vision Applications Using Android Device.

Algorithm

The im2gray function inside the Image to Gray MATLAB Function block converts the input RGB image to grayscale.

The Histogram Equalization (Computer Vision Toolbox) block enhances the contrast of the input grayscale image. The Median Filter (Computer Vision Toolbox) block removes the impulse noise from the input grayscale image.

Run Simulink Model

1. In the Algorithm area of the Simulink model, position the Manual Switch to receive output from the Simulation Sources area.

2. On the Simulation tab of the Simulink model, click Run. Toggle the Rocker Switch in the dashboard panel to observe the simulation output for histogram equalization.

3. Toggle the Rocker Switch in the dashboard panel to observe the simulation output for median filtering.

Deploy Simulink Model on Android Device

1. In the Algorithm area of the Simulink model, position the Manual Switch to receive output from the Simulation Sources area.

2. On the Hardware tab of the Simulink model, in the Mode section, click Run on board. In the Deploy section, click Build, Deploy & Start. The androidVisionGettingStarted2 application launches automatically on your Android device.

3. In the Dashboard tab of the application, toggle the rocker switch towards histogram equalization.

Go to the App tab and observe the output.

4. In the Dashboard tab of the application, toggle the rocker switch towards median filter. Go to the App tab and observe the output.

5. In the Algorithm area of the Simulink model, position the Manual Switch to receive output from the Android Inputs area.

6. Redeploy the Simulink model on your Android device. On the App tab of the application, observe the live camera feed output on your Android device.

4. In the Dashboard tab of the application, toggle the rocker switch towards median filter. Go to the App tab and observe the output.

See Also