MEDIAN_CUT_CVIP

median_cut_cvip() -Image segmentation using median-cut method.

Contents

SYNTAX

outImage = median_cut_cvip(inImage, numColors, option)

Input Parameters include:

Output Parameter includes :

DESCRIPTION

The function performs the segmentation using median-cut method, originally developed to map 24-bit color images to 8-bit color. It works by finding the maximum spread along the red, green or blue axes, and then dividing the color space with the median value along that axis. This division of the color space continues until the number of desired colors is reached. At this point, all the color vectors in a given subdivision of the color space are used to find an average color for that subdivision. After all the average colors are found, we implemented two methods to assign one of the average colors to each pixel.In method 1, we directly assign the average color of a cube to the pixels that have same colors of the color cube. In method 2, the algorithm goes back and maps each of the original color vectors to the closest one. Euclidean distance method is implemented to find the closeness.

REFERENCE

1. Scott E Umbaugh. DIGITAL IMAGE PROCESSING AND ANALYSIS: Applications with MATLAB and CVIPtools, 3rd Edition.

EXAMPLE

% Read image

 I = imread('butterfly.tif');

% Calling function default numColors = 2, Option = 1

 O1 = median_cut_cvip(I);

% number of colors

 N = 8;

% Calling function with user defined parameters numColors = 8, but option = 1 as default

 O2 = median_cut_cvip(I,N);

 %numColors = 8 and Euclidean distance method is selected

 O3 = median_cut_cvip(I,N,2);

% Display input image

 figure;imshow(I);title('Input image')

% Display output image

 figure;imshow(O1,[]);title('Output image with default parameters');

 figure;imshow(O2,[]);title('Output image with user defined parameters');

 figure;imshow(O3,[]);title('Output image with user defined parameters');

CREDITS

Author:Norsang Lama, March 2017
Copyright © 2017-2018 Scott E Umbaugh
For updates visit CVIP Toolbox Website