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

Re: Sorting and image rescaling

Martin Schultz <martin.schultz@dkrz.de> writes:

> Bill <wclodius@lanl.gov> writes:
> > I work on some of the software for an imaging sensor. One of the codes I
> > wrote was to generate JPEGS. In order to generate prettier JPEGS I wrote
> > my own bytescaling routine that crudely takes into account the
> > distribution of values within a band image. This routine relies on a
> > single line equivalent to
> > 
> >      sorted_values = SORT(band_image)
> > 
> > where SORT is the IDL intrinsic, and band image is a floating point two
> > dimensional array.  I basically use this line to find a set percentage
> > of minum and maximum outliers , and use the maximum and minimum of the
> > remaining inliers to do a linear rescaling to values from 0 to 255.
... Clodius text deleted by CM ...
> This sounds like a prime time application for histogram ;-) Just
> don't ask me how to use this magical hat ;-(

I agree with Martin here, but you can probably make it as simple or
complicated as you want.

The simplest way to do it would be to construct a histogram and then
use a FOR loop to nibble x% from the edges, where x is selectable.  In
newer versions of IDL you can use the CUMULATIVE option to the TOTAL
function to simplify life a little further, since it avoids the FOR

I don't think the REVERSE_INDICES keyword of HISTOGRAM helps a whole
lot in this case (whew, some people say).  The only benefit is that
the REVERSE_INDICES keyword returns some information on the cumulative
distribution which you might use to your advantage (ie, avoid the FOR
loop again).  This appears to be overkill though, and has the
potential to use a lot of memory like the SORT solution does.


Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response