Code covered by the BSD License  

Highlights from
GETCLIM: Suggest appropriate values for colormap limits

Be the first to rate this file! 5 Downloads (last 30 days) File Size: 1.81 KB File ID: #40102
image thumbnail

GETCLIM: Suggest appropriate values for colormap limits

by

 

31 Jan 2013 (Updated )

Determines thresholds such that 2% of data values will be mapped to the extremes of the colormap

| Watch this File

File Information
Description

 getclim determines threshold values such that 2% (by default) of
   values at the top and bottom of the data range will be mapped
   to the extremes of the colormap.

 For datasets with a few outliers that influence the range, getclim
   is superior to the default behaviour of using the min and max
   of the dataset.

 Usage: threshVals = getclim(imdata, dataFraction)

          imdata: numeric array representing an image to be displayed
    dataFraction: fraction of voxels to clip at each end (default 0.02)

    threshVals: column vector of values to use for clims in imshow

 Example:
   I = peaks(200);
   min(I(:)), max(I(:)) % -6.5487, 8.1059
   threshVals = getclim(I) % -4.2936, 5.8228
   I2 = I;
   I2(153,106) = 3*I(153,106);
   min(I2(:)), max(I2(:)) % -6.5487, 23.5936
   threshVals = getclim(I2) % -4.2936, 5.8228
   figure
   subplot(2,2,1), imshow(I, []), title('I')
   subplot(2,2,2), imshow(I, threshVals), title('I+getclim')
   subplot(2,2,3), imshow(I2, []), title('I2')
   subplot(2,2,4), imshow(I2, threshVals), title('I2+getclim')

 See also STRECHLIM, IMADJUST

Required Products MATLAB
MATLAB release MATLAB 7.14 (R2012a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
06 Feb 2013 Andrew Davis

Thanks for the comment, Jurgen. I agree that a single output vector makes more sense -- I've updated the file accordingly.

01 Feb 2013 Jurgen

A better version of matlabs stretchlim.
Better because:
- Stretchlim returns 0-1 normalized thresholds, regardless of input class.
- Stretchlim fails with int16 even though the help says it can be used
- Any data from single or double class must be in the 0-1 range.

That said, I personally prefer 1 output vector containing both values, like with stretchlim.

Updates
04 Feb 2013

Output a single vector as per Jurgen's suggestion

Contact us