;+
; H+
;	TITLE	: aim_uncomp_img
;
; 	Author	: Pamme Crandall
; 	Date	: 02/06/06
;
;	$Date: 2006/06/28 01:43:51 $
;	$Source: /users/crandall/aim/idl_cvs/src/tdp/aim_uncomp_img.pro,v $
;  @(#)	$Revision: 1.1 $
;	$Name:  $
;	$Locker:  $
;
;	PURPOSE:
;          undo cips on-board compression for image data
;
;	CATEGORY:
;	<Category of routine here>
;
;	CALLING SEQUENCE:
;	<How routine is called with parameters, optional ones in brackets>
;
;	INPUT PARAMETERS:
;          cmprsd_data - image data to be uncompressed       
;
;	OPTIONAL KEYWORD PARAMETERS:
;
;	OUTPUT PARAMETERS:
;          uncompressed image
;
;	COMMON BLOCKS:
;	<Describe any common blocks used>
;
;	PROCEDURE:
;	<describe procedure for processing>
;
;-
;	MODIFICATIONS/REVISION LEVEL:
;	MM/DD/YY WHO	WHAT (most recent change first)
;       06/24/05 PC	first revision
;
; H-
;------------------------------------------------------------------------------

function aim_uncomp_img, cmprsd_data


    ;uncompress all data
    uncmprsd_data = ((((long(cmprsd_data)) - 511)^2)/2)

    ;for data elements that were originally less than
    ;or equal to 543, return them to their initial value

     no_change_index = where(cmprsd_data le 543)
   if n_elements(no_change_index) gt 0 then begin
        if no_change_index[0] ne -1 then begin
            no_change_data = cmprsd_data[no_change_index]
            uncmprsd_data[no_change_index] = no_change_data
        endif
    endif

    return, uncmprsd_data

end
