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

Home » Public Forums » archive » Inexplicable tvrd() behavior
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Inexplicable tvrd() behavior [message #52811] Fri, 02 March 2007 12:42
BillG is currently offline  BillG
Messages: 6
Registered: March 2007
Junior Member
Can some one explain this behavior and offer a solution?

In direct graphics, indexed color mode,
1. I create a color plot in a window,
2. read in back in with image1=tvrd()
3. plot it again in another window.

I would expect (want) that the two windows would be identical but they
appear quite different: the image in the second window appears to be
(image1*4 < 255). The following program illustrates the problem.

(Why indexed color? I want to create an color indexed png of the image
but the resulting png looks like the image in window2)
(Usual disclaimer: there is an explanation and solution obvious to
anyone with any idl experience but its Friday, I have a
headache , .... Also, I have read Fanning's Chapter 3 'Working with
Color' to no avail)

------------------------------------------------------------ -----------
;;A program to examine the behavior of tvrd
;;Set the graphics environment: indexed color
set_plot, 'win' ;set the device to 'win'
device, decom = 0 ;indexed color
loadct, 39 ;load the color table

;;Create some data
pnts = 400
data = dist(pnts, pnts)

;;Scale the data
image1 = bytscl(data)

;;Plot the image
window, 0, xsize = pnts, ysize = pnts
tv, image1

;;Now read it back in
image2 = tvrd()

;;Open a new window and plot the image read in from window 0 to window
2: shouldn't
;;it appear exactly as window 0?
window, 2, xsize = pnts, ysize = pnts
tv, image2

;;Instead, image2 looks like image1*4 < 255
window, 3, xsize = pnts, ysize = pnts
tv, (image1*4 < 255)

;;plot the values of a diagonal slice through the image: it suggests
the source of the
;;problem but not the solution
window, 1, xsize = pnts, ysize = pnts
!p.multi = [0, 1, 2]
ii = indgen(pnts)
plot, image1[ii, ii], title='image1'
plot, image2[ii, ii], title='image2'

end
-------------------------------------------

Windows XP, idl6.3,


Cheers,
Bill Gallery
[Message index]
 
Read Message
Previous Topic: Re: How do I visualize images .tiff stored in an array of pointers?
Next Topic: Re: Inexplicable tvrd() behavior

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

Current Time: Fri Oct 10 14:09:19 PDT 2025

Total time taken to generate the page: 0.08316 seconds