Repository navigation
Refactor scale_image module - #17
Conversation
There was a problem hiding this comment.
Is it really worth using this given that the percentile parameters are only used for this function?
There was a problem hiding this comment.
The percentile parameters are actually used in 3 functions.
There was a problem hiding this comment.
I guess my problem with decorators is that from my experience, unless you use something like the decorator module, they lose the function signature, so that find_cutlevels? doesn't show the right signature anymore. I don't have time to try it out here today, but can you check if the signature is preserved?
|
@ejeschke - I think you have implemented image scaling functions similar or identical to the ones in The idea is that this becomes available in |
|
I plan to review this in more detail and compare some of the results to what I use in APLpy. |
|
@cdeil, I'll take a look at the module and review. The color distribution algorithms in ginga (I prefer this term to "scaling", since image scaling has a long history of referring to resampling in traditional computer graphics) can be found here (https://github.com/ejeschke/ginga/blob/master/ginga/ColorDist.py). The docstring for each of the distributions (linear, log, power, sqrt, squared, asinh, sinh and histeq) describe the distribution function mapping y = f(x) to a range of 0..1. In ginga, this is coupled with mapping the distribution to a table of color entries (the color map), as well as providing an inverse for plotting the values to a color bar, which makes the program logic slightly more complicated than in this module being reviewed (small classes instead of methods). From a cursory glance, it looks as if there are also auto cut levels calculations in this module. In ginga, these are found here (https://github.com/ejeschke/ginga/blob/master/ginga/AutoCuts.py), which implements minmax, histogram, stddev, median filtering, and zscale algorithms. I was never able to get satisfactorily close to IRAFs zscale results for the levels, and finally found a nice implementation by the stsci folks, which I think does a pretty close approximation. |
|
@ejeschke - interesting, it sounds like what you do in ginga is very similar to what we do in APLpy (see e.g. the Normalize class in https://github.com/aplpy/aplpy/blob/master/aplpy/normalize.py). |
|
@astrofrog, yes, this looks similar to what ginga does, although it looks like your class combines the cuts with the distribution. In ginga these are done as separate steps with two different classes (i.e. coming into the distribution the data has already been redistributed to the boundaries of the cuts. But I see the inverse method, which I can guess must be used by matplotlib to create the color bar. Probably the astropy module should provide this same kind of inverse, if possible. |
|
Maybe it would be a good idea to have something similar to ginga and then have a single high-level wrapper function for users who want to use it directly? |
|
I added a command-line script to convert FITS images to bitmap files. |
|
I just noticed @ChrisBeaumont also has code available! https://github.com/glue-viz/ds9norm So... we should merge all this up into a single solution! :) |
|
haha that didn't take long :) +1 on merging these efforts. My approach more-or-less directly wraps the logic I found in ds9 into a Matplotlib normalize class. The main difference with APLpy is (I think) the ability to set bias and contrast in addition to vmin/vmax. |
|
As @larrybradley mentioned in astropy/photutils#132 this is already an improvement over what is currently in |
This PR refactors the
scale_imagemodule, including combining thescale_*functions into a single function (#11 (comment), #16).@astrofrog I have no equivalent to APLpy's
vmidkeyword forlogscaling (logscaling in APLpy is a bit different). Forasinhscaling,noise_levelhere is equivalent tovmid(but the defaults are not the same).Can someone review this?