|
This utility routine is a pop-up dialog widget that allows the user to select one
or more "names" from a string array of names. I use it to give the user a list of scientific
data sets inside an HDF file. This program is similar to
Name_Selector, but I find it easier to use and
make selections when you have a large number of selections.

|
|
|
This utility routine is a pop-up dialog widget that allows the user to select one
or more "names" from a string array of names. I use it to give the user a list of scientific
data sets inside an HDF file. I will read and display the selected scientific data sets from
the file. This program is similar to
List_Selector.
|

|
|
|
This utility routine converts a number to a string. I use it primarily to convert numbers
I wish to display in a text widget. It allows you to specify how many decimal places you would
like to have in the output. This is much more flexible than IDL's normal string formatting functions,
and it works with all types of numerical values. |

|
|
|
This simple utility just copies the contents of an IDL direct graphics window
and sends it directly to the default printer, represented by the PRINTER device.
Care is taken to preserve the aspect ratio of the window and to create as large
an image as possible on the output page.
|

|
|
|
This is a utility routine that allows you to distribute IDL program libraries and find
application sub-directories relative to the directory containing the program that is currently
running. In other words, your end-users need only include directories relative to the
main program directory. You won't care where on their hard drive they place them!
If your directory structure looks like this:
.../myapp
.../myapp/data/resources
You can find your icon resources file, myicon.icn, like this:
filename = Filepath(Root_Dir=ProgramRootDir(), Subdirectory=['data','resources'], 'myicon.icn)
This program is a must if you distribute IDL program libraries.
|

|
|
|
This simple object implements a "progress bar". If you compile the program manually,
you will find an example program
at the bottom of the file that will show you how to operate the ProgressBar object.
This program requires
several programs from the Coyote Library, which you can
download
as a zip file if you like.
|

|
|
|
This utility program returns the range ([minimum, maximum]) of a vector or array.
|

|
|
|
This utility program replicates or tiles a 2D matrix or array by an integer number
of colums and rows. It is similar to the MatLab RepMat command.
|

|
|
|
This utility program allows the user to save or export a variable to the main IDL level (normally
where IDL commands are typed) from within a procedure or function. I use it when debugging code
and I want to save an image to the main IDL level for further inspection with other interactive
programming tools.
|

|
|
|
This simple utility routine allows you to scale all the points in a vector
between a minimum and maximun value. The minimum value of
the vector (or array) is set equal to the minimun data range. And
the maximun value of the vector (or array) is set equal to the
maximun data range. The program is useful for scaling latitude and
longitude vectors for contour plots on map projections, for example. |

|
|
|
This program is
more or less a drop-in replacement for the Window command in IDL, with this significant
difference: if the requested graphics window size is larger than the display size, the
graphics window is returned in a scrollable base widget so the user can scroll around
in the larger graphics window. I find this program useful when I need to create
large windows on my desktop machine, but still want to be able to see the full-resolution
output on my laptop, which has a lower resolution display. |

|
|
|
This utility program sets the default values for positional and
keyword arguments to IDL commands.
|

|
|
|
The purpose of this program is to allow the user to browse a very narrow
selection of shapefiles. Namely, those containing geographical shapes
in latitude and longitude coordinates. In other words, shapefiles
containing maps. File attributes are listed in the left-hand list
widget. Clicking on a file attribute, will list all the entity
attributes for that file attribute in the right-hand list. Clicking
an entity attribute with list the type of entity, and the X and Y
bounds of that entity (shown as LON and LAT, respectively), in the
statusbar at the bottom of the display.
Knowing the attribute and entity names of a shapefile will give
you insight into how to read and display the information in the file.
For examples, see the Coyote Library programs DrawCounties and DrawStates.
|

|
|
|
The purpose of this program is to provide an efficient algorithm for sorting an array by individual
rows. The program, described by JD Smith, the author, “as a friend to HIST_ND”, was the result of a
long discussion on this topic on the IDL newsgroup. This was the most efficient algorithm of several
that were offered and discussed. It is offered here with JD's permission.
|

|
|
|
This function allows you to calculate a character size for a particular
string, so that the string width is close to a specified target width
in the current graphics window. The function is particularly useful
with respect to sizing strings in resizeable graphics windows. The target
width is specified in normalized units.
|

|
|
|
This function provides a way of specifying 44 different plotting symbols
for use with graphics commands such as PLOT and OPLOT. The return value of the
function is used as input to the PSYM keyword. For example, to display a plot with
hourglass symbols (symbol number 19), you would type this:
Plot, findgen(11), SymSize=2, PSym=SYMCAT(19)
|

|
|
|
This small utility program can take a long line of text and break it into a string array at
some arbitrary maximum length. I find it useful for breaking up a long error message produced
with MESSAGE into a string array suitable for display in DIALOG_MESSAGE.
|

|
|
|
This utility routine simply returns the names of the months in various formats. It is useful for
labeling graphics displays and so forth. The user can ask for a specific month by giving a month index.
Formats, in addition to the normal months, include all capital letters, three-letter abbreviations, and single letters. |

|
|
|
There has been extensive discussion lately on the IDL newsgroup about the most efficient
method for rotating volumetric data. Several algorithms were tried and discussed. This algorithm,
by Martin Downing in the UK, is the current favorite. It processes the volume in "chunks", which
could, in theory, make it suitable for parallelization.
|

|
|
|
This program works together with TVIMAGE and TVSCALE to allow the user to
interactively determine image location and values for the displayed image.
Further information is contained in this
article on my web page. |

|
|
|
This program is a device independent replacement for the IDL TVRD program. It returns an 8-bit image when called on 8-bit displays and a 24-bit pixel interleaved image when called on 24-bit displays. Optional keywords can produce BMP, GIF, JPEG, PICT, PNG, and TIFF file output automatically. |

|
|
|
This is a simple utility program
to delete or undefine a variable from within an IDL program. It is a more powerful
version of DelVar, which can only be used at the main IDL level.
|

|
|
|
This small utility program can determine if a specified IDL graphics window is currently open
and available to receive graphics commands.
|

|
|
|
This simple utility routine for changing directories is written
by Paul Sorenson and included here with his permission. It works on VMS and Windows
machines only. This is one of those incredibly useful programs that make you think:
"Now how come I didn't think of that!" It is an
excellent example of how to write a widget program with an object-oriented design.
All the programs you need are available in this zip file.
|
[Return to Table of Contents]

|
|
|
This is an image processing utility routine similar to GMASCL in that
it scales input data into the range of 0 to 255. But it uses an inverse hyperbolic sine scaling algorithm, rather than
a power-law (gamma) scaling algorithm. This is extremely useful when you have an image with a low
signal to noise ratio. It can compress the noise, which simulataneously expanding the signal.
You can specify both the minimum and maximun scaling
output values, and you can obtain a negative image by simply setting the Negative keyword.
The shape of the hyperbolic sine curve can be modified with a “softening” parameter, named beta. The input is scaled with the following equation before the
final output is scaled into the range 0 to 255:
scaled = ASINH(beta*image)
Here is a picture of what the output looks like when the input is INDGEN(256). Although the output
resembles a gamma function with the default beta parameter, the function can
be “tuned” to work with even those very difficult FITS images. The XSTRETCH
program can be used as an interactive front end to this program.
|

|
|
|
This is an extremely simple program that will "blend" or "fuse" two 24-bit true-color
images using alpha blending. You set the alpha value to a number between 0 and 1 to select
the percentage of background image pixels to use in the blended image. For example, ALPHA=0.8
will use 80% of the background pixel values and 20% of the foreground pixel values in the
blended image. The program is a wrapper to the TVImage
command and can use all the features and keywords of that command. The figure below shows
two MODIS images on the left (MOD02) and middle (MOD29), and the blended image on the right. An ALPHA value
of 0.75 was used to create the blended image.
|

|
|
|
This function returns a checkerboard image containing a user-specified number
of alternating colored boxes (default of 8 as in a real checkerboard). The default
image output size is 400 by 400, but can be specified by the user.
|

|
|
|
This is an image processing utility routine similar to BYTSCL in that
it scales input data into the range of 0 to 255. But it differs in that a user-specified
percentage of pixels can be clipped from either end of the image histogram. The default it
to use a two percent clip. (What ENVI calls a linear 2% stretch.) Clipping is approximate,
and depends entirely on the image histogram. To clip 5 percent of the pixels from both ends
of the image histogram before stretching, type this command. The XSTRETCH
program can be used as an interactive front end to this program.
IDL> TVImage, ClipScl(image, 5)
|

|
|
|
This is an image processing utility routine similar to GMASCL in that
it scales input data into the range of 0 to 255. But it uses an Gaussian (normal) scaling algorithm, rather than
a power-law (gamma) scaling algorithm. Interactive Gaussian stretching can be accomplished with
XSTRETCH.
Here is a picture of what the output looks like with various Gaussian values when the input is INDGEN(256).
|

|
|
|
I think of this program as “BYTSCL on steroids!” It scales
image data in the manner of BYTSCL, but it also allows gamma log scaling in addition to
the standard linear scaling. Moreover, you can specify both the minimum and maximun scaling
output values, and you can obtain a negative image by simply setting the Negative keyword.
I wrote the program primarily to deal with gnarly FITS images with their often complex image
contrast requirements. For exploring image contrast, see XSTRETCH, which is
an interactive graphical front end
for this program.
Here is a picture of what the output looks like with various gamma values when the input is INDGEN(256).
|

|
|
|
The purpose of this program is to calculate an N-dimensional histogram. Please don't ask me any questions
about it. I didn't write it, and I'm not even totally sure I understand it. It was written by J.D. Smith and made
available to the IDL community via the IDL newsgroup. I do know this: anything JD does is impressive. And the
amount of code in this program (well, to be more exact, the lack of code in this program) is tremendously
impressive. There is no one in the entire IDL community who understands histograms or vectorization better than JD.
|

|
|
|
The purpose of this program is to perform "histogram matching" on an image.
Histogram matching is a process whereby the image pixel distribution is manipulated
to conform to the pixel distribution or histogram of another image. The final
pixel distribution of the image will approximate that of the input histogram.
For a more complete explanation of this process, see
Histogram Matching.
|

|
|
|
This is an image processing utility routine similar to GMASCL in that
it scales input data into the range of 0 to 255. But it uses a log scaling algorithm, rather than
a linear or gamma (power-law) scaling algorithm. This is extremely useful when you want to
compress information in
the upper and lower data values, while stretching the area around a mean value.
You can specify both the minimum and maximun scaling
output values, and you can obtain a negative image by simply setting the Negative keyword.
The center of the scaling curve can be set with a Mean keyword, and the slope of the curve can be
set by selecting higher values of Exponent. The input is scaled with this equation before the
final output is scaled into the range 0 to 255:
scaled = 1 / ( 1 + (mean/input)^exponent)
Here is a picture of what the output looks like when the input is INDGEN(256). The XSTRETCH
program can be used as an interactive front end to this program.
|

|
|
|
The purpose of this program is to sharpen an image with a Laplacian filter. Laplacian filters identify
edges in images. In sharpening, these edges are added back to the image to produce a "sharpening" effect.
For a more complete description of the method use, see the article
Image Sharpening with a Laplacian Kernel.
|

|
|
|
This widget program has been completely revised as a general purpose
contrast enhancer for 2D images. It allows the user to interactively apply
linear, gamma, log, or inverse hyperbolic sine stretches to an image. The user moves two threshold
bars over the histogram plot of an image and the specified stretch is applied
to the image data between the two threshold lines. For the log stretches, a third
line shows the general shape of the scaling function. The program has
been updated to allow both windows to be interactively resized, printed, as saved in a variety of file
output types. The
stretched image can be saved to the main IDL level. This program requires
a number of programs from the Coyote Library, which you can
download
as a single zip file. The program was updated on 6 September 2007 to
include four new stretches: (1) a linear 2 percent stretch, (2) a square root (log) stretch,
(3) a histogram equalization stretch, and (4) a Gaussian normal stretch.
|
[Return to Table of Contents]

|
|
|
A "smart", resizeable
graphics window. If you want resizeable graphics windows for direct
graphics programs in IDL 5.2 and higher, then this is the program for you.
Each graphics window can use and load its own color tables and
send its content to PostScript, BMP, GIF, JPEG, PICT, PNG, and TIFF files. These windows "protect" their colors from corruption from
other programs and they work on 24-bit displays almost exactly
the way they work on 8-bit displays. The program can reproduce virtually
any IDL graphics procedure command you wish to write if you
follow just three simple rules, outlined in the program documentation.
FSC_Window requires a number of programs from the Coyote program library.
See the program documentation for details.
This program replaces an older program named XWindow. Note that the
names of some keywords have changed from that older program.
This program requires
several programs from the Coyote Library, which you can
download
as a zip file if you like.
|

|
|
|
A program for drawing a histogram plot that actually looks like a histogram plot.
The histogram bars can be filled with lines (for black and white printing) or with
colors. By setting an OPLOT keyword, you can overplot histograms on already exisiting
axes. This program requires
FSC_COLOR and
ERROR_MESSAGE from the Coyote Library, which you can
download
as a zip file if you like.
|

|
|
|
Some people prefer the higher precision of the
Global Self-consistent, Hierarchical, High-resolution, Shoreline (GSHHS) database for drawing continental outlines and other shorelines to the built-in CIA
database that comes with IDL. This program works in way analogous to MAP_CONTINENTS, in that it allows
the user to draw shoreline boundaries into a map projection space set up with either MAP_SET or
MAP_PROJ_INIT. You see example output below from running the program with the highest resolution
GSHHS file. Detailed instructions for using this program are
described in an accompanying article.
|

|
|
|
This program is a wrapper program for the Plot and OPlot
commands. Its purpose is to make it easy for the user
to modify Plot keywords and parameters through interactive
dialogs. Changes are implemented immediately, allowing the user to
quickly make a plot ready for publication-quality applications,
web output, etc. Users can save the plot in PostScript format,
as well as JPEG, TIFF, PNG, BMP, etc. outputs. Users can make changes
to program colors, fonts, character sizes, line styles,
and plot symbols, among many other parameters. The program window
is completely resizable.
Using the program is as simple as using the Plot and OPlot
commands.
IDL> MPI_Plot, data, Color='Saddle Brown', DataColor='Navy', Background='Ivory'
IDL> MPI_Plot, moredata, Color='Red', LineStyle=2, /Overplot
Below, you can see the MPI_Plot program and the dialog (at reduced size)
that gives you access to plot and axis keywords and parameters.

|

|
|
|
This program is strictly a demonstration program to illustrate how to create a
map coordinate system on top of an image that is already gridded into a map projection.
It uses a precipitation image that is gridded into a polar stereographic map projection.
|

|
|
|
This program is strictly a demonstration program to illustrate how to overlay
satellite data onto an IDL map projection in a device-independent way. That is to say,
the output of the program should look identical (as much as is reasonably possible)
on the display and in PostScript output. The program is discussed in detail in
this tutorial article. Output
of the program looks similar to the image below.
|

|
|
|
This program allows you to plot meteorological "stations" on a map
project or other plot. See the WINDBARB program below
for a picture of what station plots look like. This was written primarily to
be used by the WINDBARB program.
|

|
|
|
This program allows you to display and position an image in a output
display window with the Position keyword, just like other IDL graphics output.
The advantage of this is that output looks the same in PostScript windows
as well as display windows and it is trivial to use images along with
other IDL graphics commands in the same window. The aspect ratio of the
image can be preserved in the output window if desired. The program has
been updated to honor the !P.Multi setting, so you can position images in
windows exactly the way you do plots.
This is a replacement program for the TV command.
The program automatically determines
if an 8-bit or 24-bit image is being
displayed and sets the Decomposition and True keywords appropriately.
This is a true device-, image-, and display-independent program.
This is far and away the most useful program in my library!
The program has been updated on 18 March 2008 to accept a SCALE keyword that
will allow the image argument to be byte scaled before display. An AXES keyword has
also been added, which will add a set of axes to the image.
|

|
|
|
This program allows you to display and position an image in a output
display window with the Position keyword, just like other IDL graphics output.
The advantage of this is that output looks the same in PostScript windows
as well as display windows and it is trivial to use images along with
other IDL graphics commands in the same window. The aspect ratio of the
image can be preserved in the output window if desired. The program has
been updated to honor the !P.Multi setting.
This means you can display multiple images in a window just like you can
display multiple plots. This is a replacement program for the TVSCL command,
although unlike that command, TVScale allows you to use both a Top and Bottom
keyword to specify the range of the scaled data. The data is scaled between the
values of the Bottom
and Top keywords. The program automatically determines
if an 8-bit or 24-bit image is being
displayed and sets the Decomposition and True keywords appropriately.
This is a true device-, image-, and display-independent program.
|

|
|
|
This program allows you to plot meteorological wind barbs on a map or
other graphical display. Wind barbs show the direction and speed of the wind
at a particular location. The figure below shows wind barbs plotted along with
station plots on a map projection. To plot stations, you will require the
StationPlot program, too.
|

|
|
|
This program demonstrates how to write a program to interactively change the
contrast and brightness of an image. This is sometimes called the window level and window
width. This kind of interaction is often required when working with 16-bit medical images.
Details of the algorithm used in this program can be found in
this article. This program requires TVImage and
Colorbar__Define from the Coyote program library.
|
[Return to Table of Contents]

|
|
|
This simple function creates a true-color bitmap that can be used to create a colored widget button.
I used the following code to create the figure below.
tlb = Widget_Base(/Row, /Exclusive)
button1 = Widget_Button(tlb, Value=ColorButtonBitmap('Button 1'))
button2 = Widget_Button(tlb, Value=ColorButtonBitmap('Button 2', $
FGCOLOR='YELLOW', BGCOLOR='NAVY'))
button3 = Widget_Button(tlb, Value=ColorButtonBitmap('Button 3', $
BGCOLOR='YELLOW', FGCOLOR='INDIAN RED'))
Widget_Control, tlb, /Realize
|

|
|
|
The purpose of this compound widget object is to provide an alternative
to the droplist widget (Widget_Droplist) offered in the IDL distribution. What has
always annoyed me about a droplist is that you can’t get the current
“value” of a droplist easily. This compound widget makes this and
other tasks much easier.
|

|
|
|
This compound widget is designed as a more-or-less drop-in replacement
for the RSI-supplied CW_Field program. It is an ill-conceived precursor (which I have tried desperately not to support) to FSC_INPUTFIELD. If you aren't really sure
about objects, use this program instead of FSC_INPUTFIELD. If you are ready to go
for it, use FSC_INPUTFIELD, the officially supported version of these
two similar programs.
|

|
|
|
This compound widget is a file selection tool I find I use over and over
in my own programming. I wanted a way for the user to be able to select
either a directory name or a file name. Writing the program as an object
gave me a great deal of power over how I handle absolute or relative file
names. Here is what the program looks like in a top-level base by itself:
|

|
|
|
This compound widget is designed as a more-or-less drop-in replacement
for the RSI-supplied CW_Field program. There are several things I have never
liked about CW_Field, but the the foremost thing is that on Windows machines
the text widget input box is grayed out and does not look as if it is editable.
Without this visual clue, users are confused about how CW_Field works.
This program is more flexible and powerful than CW_Field. One of the ways it is more powerful is that it is possible
to set the fields up so that users can tab from one field to the next and have the
text in the fields automatically selected for editing. An example program at the
end of the code shows you how this is done. Compile the program file first to run the example.
|

|
|
|
A simple example of the proper way to write a pop-up dialog widget program that returns
information to the caller. The program can be used to return a single piece of information from
the user. For example, to ask the user for the name of a variable to store a processed image
at the main IDL level, you might type something like this:
varname = TextBox(Title='Provide Main-Level Variable Name...', Group_Leader=event.top, $
Label='Variable Name: ', Cancel=cancelled, XSize=200, Value='stretched_image')
IF NOT cancelled THEN BEGIN
displayImage = BytScl(*info.image, Top=info.top, $
Max=info.maxThresh, Min=info.minThresh)
dummy = Routine_Names(varname, displayImage, Store=1)
ENDIF
See Writing Pop-Up Dialog Widgets for a discussion
of this program.
|

|
|
|
A simplified XInterAnimate program that shows
you the correct way to implement an animation loop in a widget program
with a Widget_Timer event.
|

|
|
|
This program shows you how to "zoom" into a line plot. Similar to
ZImage, the program allows you to designate a
zoom area with a rubberband box. The program also demonstrates a
device independent way to work with drawing colors. The program
requires GetColor from the
Coyote Library.
|
[Return to Table of Contents]
Object Graphics Programs

|
|
|
This is an object graphics program that I set as a programming exercise for
myself. I had several ideas I wanted to work out in object graphics. First, I wanted
to know how to work with several graphical representations of data in the same graphics
window. I wanted each view to work independently of the others, and I wanted to know
how to gather user interaction from each view. Second, I wanted to know how to do an
"in place" zoom into an image, and do it in such a way that I could preserve the
aspect ratio of the portion of the image I was zooming into. Third, I wanted to show
how to "window" and "level" an image. This is also known as setting the "contrast" and
"brightness" of the image. I wanted to do this in conjunction with a color bar that
reflected the window and level in a way that was intuitive and gave me a sense that I
knew what I was doing. :-)
I spent nearly 10 days working on this. Not exclusively, but steadily. I was
surprised at how difficult it was to get what I wanted. The IDL documentation does
not offer much in the way of how to do things easily. For example, I tried
several different ways of drawing the rubberband box in the zoom image until I found
a method that reliably gave me the proper image coordinates. It took me a long time
to figure out how to maintain the proper aspect ratio of the image in a resizeable graphics window. At the end, I got fairly good at knowing what to do. But I spent
hours staring at my computer screen, too.
You can see a picture of the program in the figure below. The left image
is a zoomable image. Click and drag a rubberband box around the portion of the
image you wish to "zoom" into. The image is not necessarily zoomed. Rather, this
portion of the image is shown in the graphics view in a way that preserves its
aspect ratio. The effect is to have it appear that you are zooming into the data.
To "zoom out" to the entire image, just click and release anywhere
in the left window.
The center window is the contrast/brightness image. Click and drag the
cursor horizontally in this window to adjust the "brightness" or "level" of the image data.
Click and drag the cursor vertically in this window to adjust the "contrast" or "window"
into the image data. Click and release the cursor in this window to return to the starting
values of 25% contrast and 75% brightness.
|

|
|
|
I find the scaling factors that have to be passed to the
[XYZ]Coord_Convert keyword to get graphics primitives
arranged properly in my graphic views impossible to understand. Here
is a program that allows me to specify the primitive's data range
(obtained from the primitive itself) and a position in my arbitrary
coordinate system and it calculates the proper scaling factor automatically.
I could not write object graphics programs without it. This is a program
that is used in all of my object graphics programs. |
|