[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: filtering problem



This should do the trick.
Allan Wienecke
Visual Numerics, Inc.
Celebrating 30 Years as an Independent Software Vendor

; a is the array
; n is the kernel size
; t is the threshold

function dave, a, n, t

  m = a gt t
  k = replicate( 1.0, n, n )

  return, a * avg(a) * convol(m,k) / (convol(m*a,k)+1e-30)

end


Dave Brennan wrote:

> Hi,
>
> i don't know if anyone can help but it's worth a try!
>
> I am trying to filter an array say (256x256) with a window of size 65x65
> which scans across the array pixel by pixel. It should compare the
> statistics of the area within the kernal with the global statistics of
> the image to produce a correction image. (This is a particular type of
> inhomogeneity correction)
>
> In detail: 'the algorithm should correct the pixel value by a
> multiplicative factor found by dividing the global mean by the window
> mean'
> A further problem is I want the ability to set a threshold where data
> below the threshold are not included in the statistics and not corrected
> by the algorithm.
>
> At first I though I could just use convol to produce a correction map
> but this does not allow me to set a threshold.
>
> Does anyone have any ideas? It needs to be as fast as possible as it
> will work on 128 images at a time.
>
> Cheers
>
> Dave Brennan