//************************************************** // Author : Asmita Bhar //************************************************** function [out] = cvMedian(image,varargin) // Finds median values in an input // // Calling Sequence // val = cvMedian(image) // val = cvMedian(image, name, value, .....) // // Parameters // image : Input image matrix // SortMethod (Optional) : The sort method to calculate the median - Quick sort or Insertion Sort. Default : Quick sort // Dimension (Optional) : Dimension along which the function operates - Row, Column, All or Custom. Default : All // CustomDimension (Optional) : The integer dimension over which the function calculates the median. This value cannot exceed the number of dimensions in input. It applies only when 'Dimension' property is set to 'Custom'. Default : 1 // // Description // The function calculates the median values in a given input image matrix. // // Examples // //Load an image // I = imread('peppers.png'); // val1 = cvMedian(I); // calculates the median value considering dimension as 'All' // val2 = cvMedian(I,'Dimension','Row'); //calculates the median value in 'Row' dimension // // Authors // Asmita Bhar // [lhs,rhs] = argn(0); if rhs<1 then error(msprintf("Not enough input arguments")); end if rhs>7 then error(msprintf("Too many input arguments")); end [iRows iCols]=size(image(1)) iChannels = size(image) sortMethod = 'Quick sort'; dimension = 'All'; customDimension = 1; flag=0; i=1; while(i