/** * Constructs a map for specified values. * @param f array of values; by reference, not by copy. */ public FloatByteMap(float[][] f) { _clips = new Clips(f); }
private void update() { if (_dirty) { _fmin = _clips.getClipMin(); _fmax = _clips.getClipMax(); _fscale = 256.0f/(_fmax-_fmin); _flower = _fmin; _fupper = _flower+255.5f/_fscale; _dirty = false; } }
/** * Sets the percentiles used to compute clips for this mapping. The * default percentiles are 0 and 100, which correspond to the minimum * and maximum array values. * <p> * Calling this method enables the computation of clips from percentiles. * Any clip values specified or computed previously will be forgotten. * @param percMin the percentile corresponding to clipMin. * @param percMax the percentile corresponding to clipMax. */ public void setPercentiles(double percMin, double percMax) { _clips.setPercentiles(percMin,percMax); }
/** * Sets the percentiles used to compute clips for this group. The default * percentiles are 0 and 100, which correspond to the minimum and maximum * array values. * <p> * Calling this method enables the computation of clips from percentiles. * Any clip values specified or computed previously will be forgotten. * @param percMin the percentile corresponding to clipMin. * @param percMax the percentile corresponding to clipMax. */ public void setPercentiles(double percMin, double percMax) { _clips.setPercentiles(percMin,percMax); double clipMin = _clips.getClipMin(); double clipMax = _clips.getClipMax(); //System.out.println("clip min="+clipMin+" max="+clipMax); for (ImagePanel ip:_ipList) ip.setClips(clipMin,clipMax); _colorMap.setValueRange(clipMin,clipMax); }
public void testPercentiles() { double tiny = 10.0f*FLT_EPSILON; int n = 101; //float[][][] f = rampfloat(0.0f,1.0f,0.0f,0.0f,n,n,n); //SimpleFloat3 f3 = new SimpleFloat3(f); //Clips clips = new Clips(f3); float[] f = rampfloat(0.0f,1.0f,n); Clips clips = new Clips(f); for (int imin=0,imax=n-1; imin<imax; ++imin,--imax) { double pmin = 100.0*imin/(n-1); double pmax = 100.0*imax/(n-1); clips.setPercentiles(pmin,pmax); float cmin = clips.getClipMin(); float cmax = clips.getClipMax(); assertEquals(imin,cmin,tiny); assertEquals(imax,cmax,tiny); } } }
/** * Sets the clips for this group. Image panels in this group map array * values to bytes, which are then used as indices into a specified color * model. This mapping from array values to byte indices is linear, and * so depends on only these two clip values. The clip minimum value * corresponds to byte index 0, and the clip maximum value corresponds to * byte index 255. Sample values outside of the range [clipMin,clipMax] * are clipped to lie inside this range. * <p> * Calling this method disables the computation of clips from percentiles. * Any clip values computed or specified previously will be forgotten. * @param clipMin the sample value corresponding to color model index 0. * @param clipMax the sample value corresponding to color model index 255. */ public void setClips(double clipMin, double clipMax) { _clips.setClips(clipMin,clipMax); clipMin = _clips.getClipMin(); clipMax = _clips.getClipMax(); for (ImagePanel ip:_ipList) ip.setClips(clipMin,clipMax); _colorMap.setValueRange(clipMin,clipMax); }
/** * Gets the maximum clip value for 2nd image panels. * @return the maximum clip value. */ public float getClip2Max() { return _clips2.getClipMax(); }
/** * Gets the minimum clip value. * @return the minimum clip value. */ public float getClipMin() { return _clips.getClipMin(); }
/** * Gets the minimum percentile for 2nd image panels. * @return the minimum percentile. */ public float getPercentile2Min() { return _clips2.getPercentileMin(); }
/** * Gets the maximum percentile. * @return the maximum percentile. */ public float getPercentileMax() { return _clips.getPercentileMax(); }
/** * Sets the clips for this mapping. * <p> * Calling this method disables the computation of clips from percentiles. * Any clip values computed or specified previously will be forgotten. * @param clipMin the sample value corresponding to byte value 0. * @param clipMax the sample value corresponding to color model index 255. */ public void setClips(double clipMin, double clipMax) { _clips.setClips(clipMin,clipMax); }
/** * Gets the minimum clip value. * @return the minimum clip value. */ public float getClipMin() { updateClips(); return _clipMin; }
makeClipsValid(); _clipsDirty = false;
/** * Sets the percentiles used to compute clips for 1st image panels in * this group. The default percentiles are 0 and 100, which correspond * to the minimum and maximum array values. * <p> * Calling this method enables the computation of clips from percentiles. * Any clip values specified or computed previously will be forgotten. * @param percMin the percentile corresponding to clipMin. * @param percMax the percentile corresponding to clipMax. */ public void setPercentiles1(double percMin, double percMax) { _clips1.setPercentiles(percMin,percMax); double clipMin = _clips1.getClipMin(); double clipMax = _clips1.getClipMax(); //System.out.println("clip min="+clipMin+" max="+clipMax); for (ImagePanel ip:_ip1List) ip.setClips(clipMin,clipMax); _colorMap1.setValueRange(clipMin,clipMax); }
/** * Sets the clips for 2nd image panels in this group. Image panels in * this group map array values to bytes, which are then used as indices * into a specified color model. This mapping from array values to byte * indices is linear, and so depends on only these two clip values. The * clip minimum value corresponds to byte index 0, and the clip maximum * value corresponds to byte index 255. Sample values outside of the * range [clipMin,clipMax] are clipped to lie inside this range. * <p> * Calling this method disables the computation of clips from percentiles. * Any clip values computed or specified previously will be forgotten. * @param clipMin the sample value corresponding to color model index 0. * @param clipMax the sample value corresponding to color model index 255. */ public void setClips2(double clipMin, double clipMax) { _clips2.setClips(clipMin,clipMax); clipMin = _clips2.getClipMin(); clipMax = _clips2.getClipMax(); for (ImagePanel ip:_ip2List) ip.setClips(clipMin,clipMax); _colorMap2.setValueRange(clipMin,clipMax); }
/** * Gets the maximum clip value for the specified color component. * @param ic the index (0, 1, 2, or 3) of the color component. * @return the maximum clip value. */ public float getClipMax(int ic) { return _clips[ic].getClipMax(); }
/** * Gets the minimum clip value. * @return the minimum clip value. */ public float getClipMin() { return _clips.getClipMin(); }
/** * Gets the minimum percentile. * @return the minimum percentile. */ public float getPercentileMin() { return _clips[0].getPercentileMin(); }
/** * Gets the maximum percentile. * @return the maximum percentile. */ public float getPercentileMax() { return _clips.getPercentileMax(); }