New Image Processing Routines [message #47726] |
Wed, 22 February 2006 12:47  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Folks,
I've been boning up on astronomy lately (Stars and their Spectra
by James Kaler just arrived in today's mail) because I want to
build an astronomy image viewer. I've had some tools to work
with images, but they haven't worked terribly well with the
perverse images generated by astronomers and saved in FITS files.
At least, that has been my experience with them. Maybe I only
get sent the worst of the lot, I don't know.
And I don't know if it is my imagination or whether FITS
images are just FULL of values close to zero, but I generate
so many &%$@# floating underflow messages when I deal with
them that it just depresses me. Frankly, if I never see
another floating underflow message in my life it will be
too soon.
All this prelude to saying that I spent the past couple
of days with my nose in that extraordinary book, Digital
Image Processing, 2nd Edition, by Gonzalez and Woods, and
it's even more useful (to me, anyway) companion, Digital
Image Processing with Matlab. Damn, these are two good books!
I got excited about Chapter 3, Intensity Transformation
Functions, and decided to replicate the programs described
in that chapter in IDL. Intensity transformations allow you
to manipulate contrast in images, which is important not
only in astronomy, but in many other image processing fields.
The programs below, for example, have already been helpful
to me in preprocessing medical images prior to snaking
with active contours.
Here are brief descriptions of the new programs I've
written and downloaded to my web page:
http://www.dfanning.com/documents/programs.html
IMGSCL -- I think of this as BYTSCL on steroids. It
scales your data into 0 to 255, but you can choose
a power law (gamma) scaling in addition to
a linear scaling. Moreover, you can choose the
output values directly, and you can get a negative
image as well as the normal positive image just by
setting the Negative keyword.
LOGSCL -- Similar to IMGSCL, except instead of a
power-law log transformation, it uses a log transformation.
The advantage of this is that you can compress values at either
end of a data range, and stretch the data centered about
a specified value, called the MEAN in the program.
XSTRETCH -- This old program has been completely rewritten to
serve as a graphical user interface to IMGSCL. It now works
perfectly with all the gnarly FITS and DICOM images I have laying
around here, in addition to the old standards in the IDL examples/data
directory. If contrast is your problem, I feel confident saying
you can use this to solve it. The program displays the image
histogram as an aid to selecting the proper contrast stretch.
I have also improved the way this program works with your
own programs or objects. So, it is possible to just use the
control panel and have the image displayed when and where
you like.
I have also beefed up SCALE_VECTOR, a program that I rely
on more and more to do all sorts of data scaling tasks, and
I have added a routine called CONVERT_TO_TYPE which can
convert its input to various data types at run-time. All
of these programs now fix the problems that cause data
underflow, or turn the damn messages OFF when I can't do
a damn thing about it. (For example, just taking the MIN
or MAX of an array containing values close to zero cause
these warnings.)
Even as I am writing this note, I can think of new things
to do with some of these programs, so check back often.
And, as always, I'm interested in errors you might find.
(I found another as I was downloading the "final" version. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|