Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/check_imscaled.pro'
pro check_imscaled, image_struct, xbw, ybw, imscaled

;check the scaled image if just central subset of image is to be displayed,
;	(so unsmoothed borders are not displayed when image is smoothed).
;Frank Varosi NASA/GSFC 1991.

	if N_struct( image_struct ) NE 1 then return

	xsiz = image_struct.Xmax - image_struct.Xmin
	ysiz = image_struct.Ymax - image_struct.Ymin

	tags = tag_names( image_struct )
	w = where( tags EQ "IMSCALED", tag_ims )

	if (tag_ims) then begin

		s = size( image_struct.imscaled )-1
		if N_params() GT 3 then imscaled = image_struct.imscaled

	  endif else begin

		w = where( tags EQ "SIZE_IMSCALED", tag_size )

		if (NOT tag_size) then begin
			message,"scaled image size info not found",/INF,/CON
			return
		    endif

		s = image_struct.size_imscaled -1
	   endelse

	xbw = (s(1)-xsiz)/2
	ybw = (s(2)-ysiz)/2

	if ((xbw GT 0) OR (ybw GT 0)) AND $
	   (N_params() GT 3) AND (N_elements( imscaled ) GT 8) then begin
		Lx = s(1)-xbw
		Ly = s(2)-ybw
		imscaled = imscaled( xbw:Lx, ybw:Ly )
	   endif
return
end