Archive for the 'Algorithms' Category

Jun 07 2007

A Simple De-speckle Algorithm

Published by under Algorithms

This algorithm attempts to find out whether a Pixel is a speckle in the scanned Image. A speckle can be roughly defined as an Impulse noise that has a very high/low value compared to its neighbors.

Normally, a median filter is good in reducing the speckle. But, applying median to remove speckle is not efficient. So an efficient way to do de-speckle is determine whether a pixel is a speckle and then apply Median or some other averaging technique.

Here is a way you can determine whether a pixel is a speckle quite fast. For this method to work you need to analyze the speckle pattern offline to figure out the threshold value.

Void SpeckleDetectAndCorrect ( char * source, int NumPixels )

{

/* We assume that the pixel of inerest is NumPixels/2+1. That is if the NumPixels is 5, then the 3rd pixel is the point of interest.*/

sum = source[0] + source[1] + source[3] + source[4];

Average = sum /4 ;

if (( Average – source[2]) > abs(20) )

{

/*this is a speckle Hence Apply Median*/

ApplyMedian(source, NumPixels )

}

}

Comments Off on A Simple De-speckle Algorithm

May 31 2007

Effecient Sorting Algorithm For Applying Median Filter to a Image

Published by under Algorithms,C Programming

Normally median filters are applied to remove speckle noises in an Image. There are many variations of Median Filters but all these variations are for choosing the kernel dimensions and shape. What i mean by kernel is that it could be a 3X3 kernel or 5X4 kernel or a radius 3 kernel.

A 3×3 kernal will have 9 elements to sort

A 5X5 kernal will have 25 elements to sort

A radius 3 kernel will have 29 elements to be sorted before you can pick the median.

Bottom line is you choose any variations of kernals, it boils down to effeciency of sorting. I have come up a one such algorithm that i think is very effecient for Median Filtering

Assumptions:

  1. RGB Planar data. The bit depth Per pixel is 8 bits.
  2. Median Filter Kernel size is Odd Number. Like 5, 9, 25 etc
  3. The following code is PseuodCode and good for one dimensional data.

A pseudo Code implementation of the Algorithm is shown below:

Continue Reading »

Comments Off on Effecient Sorting Algorithm For Applying Median Filter to a Image