comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Philosophical Scaling Question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Philosophical Scaling Question [message #51593] Mon, 04 December 2006 10:24 Go to next message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
> LoadCT, 33
> image = LoadData(7)
> TVLCT, r, g, b, /GET
> data = Scale_Vector(image, 1, 1000) ; Data in log scale.
> pos = [0.1, 0.1, 0.9, 0.7]
> TVImage, LogScl(data), Position=pos, /Keep, /Erase
> index = Bindgen(256)
>
> TVLCT, r[LogScl(index)], g[LogScl(index)], b[LogScl(index)]
> Colorbar, Range=[1,1000], XLOG=1, Divisions=3, $
> Position=[pos[0], 0.87, pos[2], 0.93], Minor=5
>

Ah ha, this exactly what I wanted colorbar to do!! The reason I had
never been able to get it done is that was a lot of work (and work I
didn't know how to do), it seems like a flag to colorbar or tvlct or
something that was /logscl would do the trick. Really the issue was my
unfamiliarity with logscl, tvlct, and tvimage and how to put it all
together.

Cheers,
Brian
Re: Philosophical Scaling Question [message #51595 is a reply to message #51593] Mon, 04 December 2006 10:00 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Brian Larsen writes:

> I think I agree with this statement but for most all of (making an
> assumption there I guess) just having it plot in decades as opposed to
> linear is good enough. In that case I think this thread may have
> solved this.
>
> maybe give the user some options to pass onto logscl but have the
> defaults just as were used here...

Well, *exactly*. I've thought all along the request
for a "logarithmic color bar" didn't make much sense.
Because if this is all you want, COLORBAR already does
this.

LoadCT, 33
image = LoadData(7)
TVLCT, r, g, b, /GET
data = Scale_Vector(image, 1, 1000) ; Data in log scale.
pos = [0.1, 0.1, 0.9, 0.7]
TVImage, LogScl(data), Position=pos, /Keep, /Erase
index = Bindgen(256)

TVLCT, r[LogScl(index)], g[LogScl(index)], b[LogScl(index)]
Colorbar, Range=[1,1000], XLOG=1, Divisions=3, $
Position=[pos[0], 0.87, pos[2], 0.93], Minor=5

You can choose the logarithmic scale to use. Use LOGSCL
for a true log scaling. Choose GMASCL for a power-law
scaling. Or, even choose an inverse hyperbolic sine scaling
with with ASINHSCL:

http://www.dfanning.com/ip_tips/xstretch.html

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Philosophical Scaling Question [message #51596 is a reply to message #51595] Mon, 04 December 2006 09:12 Go to previous messageGo to next message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
> Now the question remains: How would you make a
> logarithmic color bar in a general way that would
> accommodate various log scalings? I believe I could
> do it if I were also displaying the image, but I
> have grave doubts about it being possible to do it
> generally.

I think I agree with this statement but for most all of (making an
assumption there I guess) just having it plot in decades as opposed to
linear is good enough. In that case I think this thread may have
solved this.

maybe give the user some options to pass onto logscl but have the
defaults just as were used here...

-Brian
Re: Philosophical Scaling Question [message #51597 is a reply to message #51596] Mon, 04 December 2006 09:04 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Actually, I think they are slightly different. I checked
> this, too. It is easier to see if you set the EXPONENT
> keyword to 8 in the LOGSCL function. There just aren't
> enough "bins" in a 256 element vector to see great variety
> unless the log scaling is pretty drastic.

By the way, I checked this with CINDEX, which gives
you a more detailed look at the current color table
than COLORBAR.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Philosophical Scaling Question [message #51599 is a reply to message #51597] Mon, 04 December 2006 09:02 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Brian Larsen writes:

> to ask another question... why when you add colobar after each of the
> tvimage calls the colorbar is the same in windows 1 and 2?

Actually, I think they are slightly different. I checked
this, too. It is easier to see if you set the EXPONENT
keyword to 8 in the LOGSCL function. There just aren't
enough "bins" in a 256 element vector to see great variety
unless the log scaling is pretty drastic.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Philosophical Scaling Question [message #51600 is a reply to message #51599] Mon, 04 December 2006 08:58 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Paolo Grigis writes:

> Well, as I see it, you are scaling the wrong quantity:
> it is not the *values* of r,g,b that should be scaled,
> but their *indices*... try:
>
> ind=bindgen(256)
> TVLCT, r[LogScl(ind)], g[LogScl(ind)], b[LogScl(ind)]

Yes, I just came to that conclusion myself. This works
as expected. Thank you!

Now the question remains: How would you make a
logarithmic color bar in a general way that would
accommodate various log scalings? I believe I could
do it if I were also displaying the image, but I
have grave doubts about it being possible to do it
generally.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Philosophical Scaling Question [message #51601 is a reply to message #51600] Mon, 04 December 2006 08:51 Go to previous messageGo to next message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
This is a good question.

to ask another question... why when you add colobar after each of the
tvimage calls the colorbar is the same in windows 1 and 2?

Maybe this is my lack of understanding of what logscl does.


Brian


Loadct, 33, /Silent
TVLCT, r, g, b, /Get
pmm, r
pmm, g
pmm, b

image = Loaddata(7)
pmm, image

Window, XSize=400, YSize=350, 0
Loadct, 33, /Silent
TVImage, image
colorbar

Window, XSize=400, YSize=350, 1
Loadct, 33, /Silent
TVImage, LogScl(image)
colorbar

Window, XSize=400, YSize=350, 2
Loadct, 33, /Silent
TVLCT, r, g, b, /Get
TVLCT, logscl(r), logscl(g), logscl(b)
tvimage, image
colorbar



David Fanning wrote:
> Folks,
>
> With no answers to my weekend questions about logarithmic
> color bars I'm flying blind this morning. And I seem to be
> running into theoretical difficulties. Can anyone help?
>
> Suppose I had a color table (color table 33 comes to mind)
> where each color vector had a min of 0 and a max 0f 255.
>
> IDL> Loadct, 33, /Silent
> IDL> TVLCT, r, g, b, /Get
> IDL> MinMax, r
> 0 255
> IDL> MinMax, g
> 0 255
> IDL> MinMax, b
> 0 255
>
> And suppose I also have an image that is scaled in
> the same way:
>
> IDL> image = Loaddata(7)
> IDL> MinMax, image
> 0 255
>
> And finally, suppose I have a way to scale such data
> sets in a logametric way, say a function LOGSCL.
>
> IDL> .compile LOGSCL
> Compiled module: LOGSCL.
>
> My hypothesis is that there are two ways to display this
> data "logarithmically". I can leave the color table vectors
> alone, and scale the image data. Or, I can leave the image
> alone and scale the color vectors. Either way should result
> in exactly the same display.
>
> The problem is, it doesn't. :-(
>
> Window, XSize=400, YSize=350, 0
> Loadct, 33, /Silent
> TVImage, image
>
> Window, XSize=400, YSize=350, 1
> Loadct, 33, /Silent
> TVImage, LogScl(image)
>
> Window, XSize=400, YSize=350, 2
> Loadct, 33, /Silent
> TVLCT, r, g, b, /Get
> TVLCT, LogScl(r), LogScl(g), LogScl(b)
> TVImage, image
>
> Does anyone have a good idea for why not?
>
> Cheers,
>
> David
>
> P.S. And please don't tell me there is something wrong
> with LOGSCL, as this is *not* the answer I want to
> hear. :-(
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Philosophical Scaling Question [message #51602 is a reply to message #51601] Mon, 04 December 2006 08:48 Go to previous messageGo to next message
Paolo Grigis is currently offline  Paolo Grigis
Messages: 171
Registered: December 2003
Senior Member
Well, as I see it, you are scaling the wrong quantity:
it is not the *values* of r,g,b that should be scaled,
but their *indices*... try:

ind=bindgen(256)
TVLCT, r[LogScl(ind)], g[LogScl(ind)], b[LogScl(ind)]

instead.

Ciao,
Paolo

David Fanning wrote:
> Folks,
>
> With no answers to my weekend questions about logarithmic
> color bars I'm flying blind this morning. And I seem to be
> running into theoretical difficulties. Can anyone help?
>
> Suppose I had a color table (color table 33 comes to mind)
> where each color vector had a min of 0 and a max 0f 255.
>
> IDL> Loadct, 33, /Silent
> IDL> TVLCT, r, g, b, /Get
> IDL> MinMax, r
> 0 255
> IDL> MinMax, g
> 0 255
> IDL> MinMax, b
> 0 255
>
> And suppose I also have an image that is scaled in
> the same way:
>
> IDL> image = Loaddata(7)
> IDL> MinMax, image
> 0 255
>
> And finally, suppose I have a way to scale such data
> sets in a logametric way, say a function LOGSCL.
>
> IDL> .compile LOGSCL
> Compiled module: LOGSCL.
>
> My hypothesis is that there are two ways to display this
> data "logarithmically". I can leave the color table vectors
> alone, and scale the image data. Or, I can leave the image
> alone and scale the color vectors. Either way should result
> in exactly the same display.
>
> The problem is, it doesn't. :-(
>
> Window, XSize=400, YSize=350, 0
> Loadct, 33, /Silent
> TVImage, image
>
> Window, XSize=400, YSize=350, 1
> Loadct, 33, /Silent
> TVImage, LogScl(image)
>
> Window, XSize=400, YSize=350, 2
> Loadct, 33, /Silent
> TVLCT, r, g, b, /Get
> TVLCT, LogScl(r), LogScl(g), LogScl(b)
> TVImage, image
>
> Does anyone have a good idea for why not?
>
> Cheers,
>
> David
>
> P.S. And please don't tell me there is something wrong
> with LOGSCL, as this is *not* the answer I want to
> hear. :-(
>
Re: Philosophical Scaling Question [message #51603 is a reply to message #51602] Mon, 04 December 2006 08:29 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Lojos writes:

> Probably log(0)=-inf plays a role in your experiment.
> Does LOGSCL handle it?

Yes, LogScl handles this properly.

I'm still very confused.

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Philosophical Scaling Question [message #51604 is a reply to message #51603] Mon, 04 December 2006 08:25 Go to previous messageGo to next message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Mon, 4 Dec 2006, David Fanning wrote:

> Folks,
>
> With no answers to my weekend questions about logarithmic
> color bars I'm flying blind this morning. And I seem to be
> running into theoretical difficulties. Can anyone help?
>
> Suppose I had a color table (color table 33 comes to mind)
> where each color vector had a min of 0 and a max 0f 255.
>
> IDL> Loadct, 33, /Silent
> IDL> TVLCT, r, g, b, /Get
> IDL> MinMax, r
> 0 255
> IDL> MinMax, g
> 0 255
> IDL> MinMax, b
> 0 255
>
> And suppose I also have an image that is scaled in
> the same way:
>
> IDL> image = Loaddata(7)
> IDL> MinMax, image
> 0 255
>
> And finally, suppose I have a way to scale such data
> sets in a logametric way, say a function LOGSCL.
>
> IDL> .compile LOGSCL
> Compiled module: LOGSCL.
>
> My hypothesis is that there are two ways to display this
> data "logarithmically". I can leave the color table vectors
> alone, and scale the image data. Or, I can leave the image
> alone and scale the color vectors. Either way should result
> in exactly the same display.
>
> The problem is, it doesn't. :-(
>
> Window, XSize=400, YSize=350, 0
> Loadct, 33, /Silent
> TVImage, image
>
> Window, XSize=400, YSize=350, 1
> Loadct, 33, /Silent
> TVImage, LogScl(image)
>
> Window, XSize=400, YSize=350, 2
> Loadct, 33, /Silent
> TVLCT, r, g, b, /Get
> TVLCT, LogScl(r), LogScl(g), LogScl(b)
> TVImage, image
>
> Does anyone have a good idea for why not?
>
> Cheers,
>
> David
>
> P.S. And please don't tell me there is something wrong
> with LOGSCL, as this is *not* the answer I want to
> hear. :-(
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>


Probably log(0)=-inf plays a role in your experiment.
Does LOGSCL handle it?

regards,
lajos
Re: Philosophical Scaling Question [message #51732 is a reply to message #51593] Mon, 04 December 2006 12:43 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Brian Larsen writes:

>> LoadCT, 33
>> image = LoadData(7)
>> TVLCT, r, g, b, /GET
>> data = Scale_Vector(image, 1, 1000) ; Data in log scale.
>> pos = [0.1, 0.1, 0.9, 0.7]
>> TVImage, LogScl(data), Position=pos, /Keep, /Erase
>> index = Bindgen(256)
>>
>> TVLCT, r[LogScl(index)], g[LogScl(index)], b[LogScl(index)]
>> Colorbar, Range=[1,1000], XLOG=1, Divisions=3, $
>> Position=[pos[0], 0.87, pos[2], 0.93], Minor=5
>>
>
> Ah ha, this exactly what I wanted colorbar to do!! The reason I had
> never been able to get it done is that was a lot of work (and work I
> didn't know how to do), it seems like a flag to colorbar or tvlct or
> something that was /logscl would do the trick. Really the issue was my
> unfamiliarity with logscl, tvlct, and tvimage and how to put it all
> together.

Don't get too excited about this yet. It looks beautiful.
I'm just not sure it is correct. :-)

I'm trying to write an article about this, and I keep
running into complications. It is a lot more difficult
than I expected it to be.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Philosophical Scaling Question [message #51739 is a reply to message #51593] Mon, 04 December 2006 10:39 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Brian Larsen writes:

> Ah ha, this exactly what I wanted colorbar to do!! The reason I had
> never been able to get it done is that was a lot of work (and work I
> didn't know how to do), it seems like a flag to colorbar or tvlct or
> something that was /logscl would do the trick. Really the issue was my
> unfamiliarity with logscl, tvlct, and tvimage and how to put it all
> together.

Alas, the problem is for every simple case, there are an infinite
number of more complex cases. And as soon as someone like me
distributes software, I hear from EVERYONE who wants to
do something complex. :-(

I can't keep up. So I try to provide tools that do simple
things (which I can support), and which can be combined in
complex ways (which I can't support, generally).

Note the difference between this philosophy and the
thinking behind iTools, for example. Using my tools
an "ah ha" moment can be experienced in less than 10
lines of code (as you just discovered). Using iTools,
your "ah ha" moment can be a long way off (as I discover
just about every time I try to use one of those darn things).

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Philosophical Scaling Question [message #51741 is a reply to message #51593] Mon, 04 December 2006 10:27 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Brian Larsen writes:

> Ah ha, this exactly what I wanted colorbar to do!! The reason I had
> never been able to get it done is that was a lot of work (and work I
> didn't know how to do), it seems like a flag to colorbar or tvlct or
> something that was /logscl would do the trick. Really the issue was my
> unfamiliarity with logscl, tvlct, and tvimage and how to put it all
> together.

I'll put you on the list of people who want to buy the new book. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Mapping countries
Next Topic: Help with numerical integration

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:50:21 PDT 2025

Total time taken to generate the page: 0.00558 seconds