Re: Image Contrast Enhancement [message #47644] |
Mon, 27 February 2006 15:21  |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
> Anyway, I'm interested in getting famous, since I need a calling
> card to get that Astronomy Post-Doc position I hope someone is
> going to offer me. (Preferably in a Spanish-speaking part of the
> world, if you please. :-)
When can you be in Tucson? I think it qualifies as Spanish speaking.
JD
|
|
|
Re: Image Contrast Enhancement [message #47647 is a reply to message #47644] |
Mon, 27 February 2006 14:42   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
JD Smith writes:
> I haven't looked yet, but I wonder how you implement the cutoff in log
> scaling? Since the log of negative numbers is undefined, you are
> forced to shift things to be positive. The question becomes, what is
> the minimum value to which you shift? If it's too low, you waste all
> of your dynamic range on the low end where there are no data. If it
> is too high, you lose detail in the background. The method DS9 uses
> is really poor (which is why most people think sqrt() scaling is
> better than log() scaling). I've had good luck using 5% of the range
> (max-min) being thresholded as the magic minimum.
One of the advantages of not being an astronomer is that I
am free to to use brute force methods because I don't know
any better. :-)
Following the example of Gonzalez and Woods, I just scale
*everything* into the range 0 to 1 before I get started
doing the real work. I can get away with this, because in
the end I am scaling everything into the range of 0 to 255
anyway.
Now that I've barged into this arena, I'm learning all kinds
of new things about it. Ideas are coming to me faster than
I can work them out, which means, of course, I've got to
rewrite this whole business as an object so it can become
*really* useful to me. :-)
I did find, however, that I had to arbitrarily scale
the data in AsinhScl into the range 0 to 1000, instead
of 0 to 1 to make it work properly with the variety of
images I was testing against. I'm not sure why this is
so, except that -1 to 1 seems to be a strange zone in
the inverse hyperbolic sine equation. I noted this, but
haven't followed up, since it seems to *work* OK, even
if I don't understand it. That is to say, the modification
gave me results that looked right. However, I notice my
results are different than the FITS Liberator, so I am
looking at this again now.
> Regarding histogram equalization, the methods I've seen (and used)
> tend to reduce the dynamic range, creating "comb" effects in the
> histogram, i.e. not using the full range of value available. I feel
> like I've seen other tools which do not do this, but that may reflect
> more about the data than the tool.
Humm. I don't know. All the methods I've tried to use or implement
seem to use the full dynamic range, although it is an inherently
discrete, as opposed to smooth, process. Some bins are not filled
in the new histogram. Perhaps this is what bothers you.
> Now that you've put in all the goodies, if you really want to cause
> astronomers to loose their minds and begin sending you offers to name
> their first born or their computer after you, allow reading FITS files
> into three channels RGB, with truecolor display, and allow separate or
> grouped scaling of each of those channels, using HREBIN/HASTROM as
> needed to put them onto the same scale, with output to a variety of
> image formats. Try "RGB Frame" in DS9 for an example.
This is what I have been working on today. But, I am still
debating whether to write this as a widget program (which will
be harder to maintain over time), or write it as the object
program, which will take more time, but be more robust. As I say,
I have more ideas than I have the time to implement, which always
suggests objects to me.
Anyway, I'm interested in getting famous, since I need a calling
card to get that Astronomy Post-Doc position I hope someone is
going to offer me. (Preferably in a Spanish-speaking part of the
world, if you please. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Image Contrast Enhancement [message #47651 is a reply to message #47647] |
Mon, 27 February 2006 13:55   |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Sat, 25 Feb 2006 16:39:53 -0700, David Fanning wrote:
> Folks,
>
> I've finally completed what I have been doing piecemeal over
> the past week or so: put ALL my new image contrast improvements
> into a single user interface, XSTRETCH.
>
> http://www.dfanning.com/programs/xstretch.zip
>
> Using the image histogram as a guide, you can now threshhold
> your image values and perform a contrast stretch between those
> values using linear, power-law (gamma), log, or an inverse
> hyperbolic sine function as the scaling function. Moreover,
> the code has been re-organized so that I can easily add additional
> scaling functions as needed. This program works great with
> even the worst of the images I have in my perverse collection.
I haven't looked yet, but I wonder how you implement the cutoff in log
scaling? Since the log of negative numbers is undefined, you are
forced to shift things to be positive. The question becomes, what is
the minimum value to which you shift? If it's too low, you waste all
of your dynamic range on the low end where there are no data. If it
is too high, you lose detail in the background. The method DS9 uses
is really poor (which is why most people think sqrt() scaling is
better than log() scaling). I've had good luck using 5% of the range
(max-min) being thresholded as the magic minimum.
Regarding histogram equalization, the methods I've seen (and used)
tend to reduce the dynamic range, creating "comb" effects in the
histogram, i.e. not using the full range of value available. I feel
like I've seen other tools which do not do this, but that may reflect
more about the data than the tool.
Now that you've put in all the goodies, if you really want to cause
astronomers to loose their minds and begin sending you offers to name
their first born or their computer after you, allow reading FITS files
into three channels RGB, with truecolor display, and allow separate or
grouped scaling of each of those channels, using HREBIN/HASTROM as
needed to put them onto the same scale, with output to a variety of
image formats. Try "RGB Frame" in DS9 for an example.
JD
|
|
|
|
Re: Image Contrast Enhancement [message #47660 is a reply to message #47655] |
Mon, 27 February 2006 08:20   |
Patrick Broos
Messages: 27 Registered: December 1996
|
Junior Member |
|
|
David,
In case it helps I'll mention a three little facts (which you probably
already know very well) about the "astronomy market" for constructing
color composite images.
* The HASTROM tool in Landsman's library is useful for aligning
mulitple FITS images.
* Probably most of the color composites made during data analysis are
made by the "ds9" tool.
* Probably most of the color composites made for Education and Public
Outreach purposes are made by Photoshop using the FITS Liberator
plugin: http://www.spacetelescope.org/projects/fits_liberator/
(Photoshop's undocumented magic algorithm for combining images allows
one to "combine" more than three data sets, e.g. you can have red,
blue, green, brown, tangarine, chartreuse, etc. components.)
I'm delighted that you're taking seriously Robert Lupton's excellent
criticism of the embarrassing saturate-to-white color model used
throughout astronomy (including ds9 and Photoshop). A nice GUI to
construct color composites the right way would be a help to astronomy.
I've written a lame version of such a tool but I look forward to your
more professional solution to the problem.
Best of luck,
Patrick
Chandra-ACIS Team at Penn State
|
|
|
|
Re: Image Contrast Enhancement [message #47792 is a reply to message #47644] |
Mon, 27 February 2006 15:47  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
JD Smith writes:
> When can you be in Tucson? I think it qualifies as Spanish speaking.
Uh, sometime before summer, OK. I grew up in Phoenix.
I *know* how hot it is in Tucson. I'm not sure even I
can play tennis at 4AM. :-(
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|