Re: hist_2d question [message #64289] |
Tue, 16 December 2008 16:20 |
Jeremy Bailin
Messages: 618 Registered: April 2008
|
Senior Member |
|
|
On Dec 16, 2:19 pm, "Jeff N." <jeffnettles4...@gmail.com> wrote:
> On Dec 16, 12:49 pm, Chris <beaum...@ifa.hawaii.edu> wrote:
>
>
>
>> On Dec 16, 3:45 am, "Jeff N." <jeffnettles4...@gmail.com> wrote:
>
>>> Hi folks,
>
>>> I'm working with 2d histograms for the first time, and have a question
>>> the documentation doesn't seem to answer (or i missed it).
>
>>> Is there a way to construct your bins such that you'll know how many
>>> output DN your image has? I want to put a color table on my image,
>>> and have been constructing color tables to match the number of output
>>> DN, which is fine but i'm wondering if there's a way to ensure 256 DN
>>> in the output. I'm sure the answer to this question is "make your
>>> bins right", but i'm wondering if there's a straightforward way to
>>> calculate how to do that.
>
>>> Thanks for any help,
>>> Jeff
>
>> I don't know of any easy way to do this, but I assume you want the
>> __peak__ number of counts in a bin to be 256 (the total number is just
>> the number of datapoints you feed into the histogram call, unless you
>> clip out the edges). Why not just use bytscl() to scale the result
>> afterwards?
>
> Hi Chris,
>
> Thanks for getting back to me...one of my little issues was that i was
> using some code sent to me by someone else. I finally looked at their
> code and realized what i should've known from the start: they were
> applying a color table using a (1d) histogram of the 2d histogram, so
> all i need to do is make that histogram give me 256 bins, make a color
> table with a color for each bin in the histogram, and i should be all
> set (in theory of course!).
>
> Thanks,
> Jeff
On a marginally related note, I recently wrote code for doing
histogram equalization of images made from 2d histograms (ie. hist_2d
or hist_nd... in fact, the code should work for multi-dimensional
histograms made with hist_nd, but I've never tested it), in case
anyone would find it useful:
http://web.astroconst.org/jbiu/jbiu-doc/plot/histeq.html
The result should have approximately equal numbers of pixels in each
intervals of value.
(not yet in an official JBIU release, but you can grab the code from
the Source link)
-Jeremy.
|
|
|
Re: hist_2d question [message #64291 is a reply to message #64289] |
Tue, 16 December 2008 11:19  |
jeffnettles4870
Messages: 111 Registered: October 2006
|
Senior Member |
|
|
On Dec 16, 12:49 pm, Chris <beaum...@ifa.hawaii.edu> wrote:
> On Dec 16, 3:45 am, "Jeff N." <jeffnettles4...@gmail.com> wrote:
>
>> Hi folks,
>
>> I'm working with 2d histograms for the first time, and have a question
>> the documentation doesn't seem to answer (or i missed it).
>
>> Is there a way to construct your bins such that you'll know how many
>> output DN your image has? I want to put a color table on my image,
>> and have been constructing color tables to match the number of output
>> DN, which is fine but i'm wondering if there's a way to ensure 256 DN
>> in the output. I'm sure the answer to this question is "make your
>> bins right", but i'm wondering if there's a straightforward way to
>> calculate how to do that.
>
>> Thanks for any help,
>> Jeff
>
> I don't know of any easy way to do this, but I assume you want the
> __peak__ number of counts in a bin to be 256 (the total number is just
> the number of datapoints you feed into the histogram call, unless you
> clip out the edges). Why not just use bytscl() to scale the result
> afterwards?
Hi Chris,
Thanks for getting back to me...one of my little issues was that i was
using some code sent to me by someone else. I finally looked at their
code and realized what i should've known from the start: they were
applying a color table using a (1d) histogram of the 2d histogram, so
all i need to do is make that histogram give me 256 bins, make a color
table with a color for each bin in the histogram, and i should be all
set (in theory of course!).
Thanks,
Jeff
|
|
|
Re: hist_2d question [message #64294 is a reply to message #64291] |
Tue, 16 December 2008 09:49  |
Chris[6]
Messages: 84 Registered: July 2008
|
Member |
|
|
On Dec 16, 3:45 am, "Jeff N." <jeffnettles4...@gmail.com> wrote:
> Hi folks,
>
> I'm working with 2d histograms for the first time, and have a question
> the documentation doesn't seem to answer (or i missed it).
>
> Is there a way to construct your bins such that you'll know how many
> output DN your image has? I want to put a color table on my image,
> and have been constructing color tables to match the number of output
> DN, which is fine but i'm wondering if there's a way to ensure 256 DN
> in the output. I'm sure the answer to this question is "make your
> bins right", but i'm wondering if there's a straightforward way to
> calculate how to do that.
>
> Thanks for any help,
> Jeff
I don't know of any easy way to do this, but I assume you want the
__peak__ number of counts in a bin to be 256 (the total number is just
the number of datapoints you feed into the histogram call, unless you
clip out the edges). Why not just use bytscl() to scale the result
afterwards?
|
|
|