Re: filtering problem [message #22603 is a reply to message #22539] |
Tue, 21 November 2000 00:00   |
John-David T. Smith
Messages: 384 Registered: January 2000
|
Senior Member |
|
|
Dave Brennan wrote:
>
> Once again thanks for the help.
>
> However, life is not quite as simple as I imagined. Previously I said :
>
>> 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.
>
> I have later found that this is not entirely correct.
>
> Although any value below the thershold should not be included in the
> statistics, pixels below the threshold should be corrected by the algorithm.
>
> Therefore is it possible to change the code:
>
> pro thresh, a, n, t
> m = a ge t
> wh = where(m,cnt)
> if cnt eq 0 then return
> a[wh] = a[wh] * mean(a[wh]) * (smooth(float(m),n,/EDGE) / $
> (smooth(a*m,n,/EDGE)+1.e-30))[wh]
> end
You can simply remove the [wh] from everywhere but the mean. By the
way, I rarely use constructs like adding 1.e-30 (I took that from the
previous poster's version to ensure comparable runtime penalties). If
you were ever using this on data arrays which were quite small, you'd be
in trouble. Dealing with overflows is why the !VALUES sysvar was
invented. And, on the other hand, if your sub-threshold pixels
dominated, such that it may be impossible to correct certain locations
(no window mean defined), you should explicitly test for this, and do
something sensible (either relax your threshold, warn the user, etc.)
JD
--
J.D. Smith | WORK: (607) 255-6263
Cornell Dept. of Astronomy | (607) 255-5842
304 Space Sciences Bldg. | FAX: (607) 255-5875
Ithaca, NY 14853 |
|
|
|