X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



3225 Rate this article:
No rating

Why are there differences between stretches applied to the display and those applied to the file?

This Help Article discusses why there are differences in the pixel values when you apply a stretch to a display and when you apply a stretch to a file in ENVI.

The results from using the ENVI routine, stretch_doit, are different than if the stretch is applied to a displayed band and saved to a file. The example used is ENVI's sample dataset, bhtmref.img. If you display band 1 of this file, there is a default 2% stretch applied to the display window. The resulting pixel values are different than if you run the following routine, which performs the same 2% stretch:
----------------------------------------------
pro example_stretch_doit
envi, /restore_base_save_files
envi_batch_init, log_file='batch.txt'
envi_open_file, 'c:\rsi\idl61\products\envi41\data\bhtmref.img',
r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif

envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = 'test_stretch'

envi_doit, 'stretch_doit', $
fid=fid, pos=pos, dims=dims, $
method=1, out_name=out_name, $
i_min=2.0, i_max=98.0, range_by=0, $
out_min=0, out_max=255, out_dt=1, $
r_fid=r_fid
envi_batch_exit
end
----------------------------------------------
So, what is different about saving from the display here?

For percent stretches, ENVI does a special stretch for the display case, which really can't be reproduced. ENVI's default 2% stretch, if the histogram is "normal" looking (i.e. more than three bins), will calculate the left hand percent stretch on hist[1:*] and the right hand percent stretch on hist[0:n_elements(hist)-2]. If the histogram is a normal gaussian shaped curve, then the difference between this and the "full" histogram is negligible. However, if there is a large saturation of min or max values (such as an image with a lot of background), then ENVI's default stretch will ignore the spike and calculate the percent stretch based on the rest of the "real" histogram. This allows ENVI to display, by default, many images which otherwise would not stretch well with a 2% linear stretch since they contain more than 2% background.

This is the difference observed in the pixel values and there is not a way for ENVI_STRETCH_DOIT to reproduce the exact same results.


Review on 12/31/2013 MM

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »