Newsgroups: sci.image.processing
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!godot.cc.duq.edu!newsfeed.pitt.edu!gatech!sdd.hp.com!hp-pcd!hpcvsnz!briand
From: briand@cv.hp.com (Brian Dixon)
Subject: Re: image enhancement
Sender: news@hpcvsnz.cv.hp.com (News )
Message-ID: <D9pyAL.3x5@hpcvsnz.cv.hp.com>
Date: Mon, 5 Jun 1995 21:27:57 GMT
References: <3qhct4$6t7@wimbledon.dcs.hull.ac.uk>
Nntp-Posting-Host: hpcvsgen.cv.hp.com
Organization: Hewlett-Packard
X-Newsreader: TIN [version 1.1 PL9.4]
Lines: 81

T.O.Ozanian@dcs.hull.ac.uk wrote:
:  
: I have some particularly poor X-ray images of hip bones. 
: I would like to apply some available image enhancement techniques 
: and see how they perform on these images. I am aware that there are
: two types of operations that are generally utilised:
: 	- contrast enhancement by some kind of histogram modification
: 	- adaptive smoothing that preserves image features while
: 	  smoothing uniform regions.

: If you have worked in this area I will appreciate some source code of 
: algorithms for image enhancement in order to do some research tests.

The easiest way is to use a lookup-table (LUT) to remap the original pixel
values into new pixel values.  For example, depending on the reason for
the contrast manipulation (not necessarily an expansion), you may utilize
a number of different techniques for producing your LUT.  Here's a list of
the more common techniques to get you started (one of these will most likely
be satisfactory):

Contrast enhancement for human viewing, but not for defect detection or
critical metrology:
-----------------------------------------------------------------------
- Try a histogram equalization (this is *not* the most efficient way of
  coding this up, but it is a clearer way of seeing what's happening):
  1) Produce a histogram from the image's pixel values.  This need not actually
     be normalized to the range 0.0-1.0, e.g. 0% to 100%.  I just use actual
     counts, where each pixel value from MIN_VAL to MAX_VAL (0-255 typically)
     in an array contains the counts of the number of pixels in the image with
     that value.
  2) Produce a new array with MAX_VAL number of elements in it.  Fill each
     element with the sum of the histogram counts ranging from MIN_VAL to
     the current value.  For example, element 0 merely has the number of
     pixels that were absolutely black.  Element 1 has the sum of the count
     in element 0 and element 1 from the histogram array.  Element 2 has
     the sum of the first 3 elements (0-2) in the histogram array etc.
  3) Normalize this array so the values in the array range from MIN_VAL to
     MAX_VAL.  For example, multiply each element in this array by the
     value (1/highest_sum)*MAX_VAL.  Now you have a lookup table that
     expands the contrast in low contrast areas and doesn't expand the
     contrast in the areas that already have high contrast.
  4) Remap the original image using this LUT.

- Note that this is a nonlinear enhancement which will change the 
  distribution of spatial frequencies in the image, resulting in moved
  edges and apparent size changes in some features.  These affects will
  be small enough for a normal viewer to not see them, but will probably
  be great enough to toss out too much accuracy for metrology.

Contrast expansion viewing or template matching:
------------------------------------------------
- Try a linear contrast expansion:
  1) Produce a histogram of the original image as mentioned in #1 above.
  2) Scan the histogram to determine the range of values that contain the
     majority of the information content in the image.  For this example,
     assume a histogram that ranges from 1 to 200 (easy numbers), and
     has a bumpy peak that ranges from 1 to 20, but is flat everywhere above
     20.
  3) Produce a linear LUT as follows (using my example numbers):
     - All values above 20 are set to MAX_VAL, e.g. 20-200 get remapped to 200.
     - All values from 1 to 20 get set to ((VAL-1)/RANGE)*MAX_VAL.  In my
       example, the range is 20 pixels and MAX_VAL is 200.  Element 1 gets
       remapped to 0.  Element 2 gets remapped to (1/20)*200 = 10.  In the
       same way, remapping continues (20, 30, 40, 50, 60, ..., 190).
- Note that this does not increase information content and the resulting
  histogram will have gaps in it, e.g. in my example, gaps exist from 1-9,
  from 11-19, from 21-29 etc.  The increase contrast may help certain
  template matching algorithms, but will make no difference to others.  The
  resulting contrast expansion will look fairly natural to human viewers.

Contrast expansion for highlighting density (for example):
----------------------------------------------------------
- Just like linear contrast expansion, but use a log() or ln() function to
  produce the new LUT values.

Regards,
Brian

--
Brian Dixon, Machine Vision Engineer, Hewlett Packard (Corvallis, Oregon)
503-715-3143 (wk), briand@cv.hp.com (email). "Opinions & attitudes are mine!"
