public static double fraction( GrowQueue_F64 list , double fraction ) { int k = (int)((list.size-1)*fraction+0.5); return QuickSelect.select(list.data,k,list.size); } }
public static double fraction( GrowQueue_F64 list , double fraction ) { int k = (int)((list.size-1)*fraction+0.5); return QuickSelect.select(list.data,k,list.size); } }
/** * <p> * Robust median estimator of the noise standard deviation. Typically applied to the HH<sub>1</sub> subband. * </p> * * <p> * σ = Median(|Y<sub>ij</sub>|)/0.6745<br> * where σ is the estimated noise standard deviation, and Median(|Y<sub>ij</sub>|) * is the median absolute value of all the pixels in the subband. * </p> * * <p> * D. L. Donoho and I. M. Johnstone, "Ideal spatial adaption via wavelet shrinkage." * Biometrika, vol 81, pp. 425-455, 1994 * </p> * * @param subband The subband the image is being computed from. Not modified. * @param storage Used to temporarily store the absolute value of each element in the subband. * @return estimated noise variance. */ public static float estimateNoiseStdDev(GrayF32 subband , float storage[] ) { storage = subbandAbsVal(subband, storage ); int N = subband.width*subband.height; return QuickSelect.select(storage, N / 2, N)/0.6745f; }
int median = QuickSelect.select(storage, index / 2, index); output.set(x,y, median );
float median = QuickSelect.select(storage,index/2,index); output.set(x,y, median );
errorMetric.computeDistance(_dataSet,errors); double median = QuickSelect.select(errors, (int)(N*errorFraction+0.5), N);
errorMetric.computeDistance(_dataSet,errors); double median = QuickSelect.select(errors, (int)(N*errorFraction+0.5), N);
float median = QuickSelect.select(storage, index / 2, index); output.set(x,y, median ); float median = QuickSelect.select(storage,index/2,index); output.set(x,y, median ); float median = QuickSelect.select(storage,index/2,index); output.set(x,y, median ); float median = QuickSelect.select(storage,index/2,index); output.set(x,y, median );
int median = QuickSelect.select(storage,index/2,index); output.set(x,y, median ); int median = QuickSelect.select(storage,index/2,index); output.set(x,y, median ); int median = QuickSelect.select(storage,index/2,index); output.set(x,y, median ); int median = QuickSelect.select(storage,index/2,index); output.set(x,y, median );
/** * Creates a random array then sorts it. It then requests that the specified element be found * and compares it against the sorted array. */ @Test public void testWithQuickSort() { Comparable orig[] = new Comparable[100]; Comparable copy[] = new Comparable[orig.length]; Comparable sorted[] = new Comparable[orig.length]; for( int i = 0; i < orig.length; i++ ) { orig[i] = rand.nextDouble(); sorted[i] = orig[i]; } Arrays.sort(sorted); for( int i = 0; i < orig.length; i++ ) { System.arraycopy(orig,0,copy,0,orig.length); QuickSelect.select(copy,i,copy.length); assertEquals(sorted[i],copy[i]); } }
@Test public void testWithQuickSortIndex() { Comparable orig[] = new Comparable[100]; Comparable copy[] = new Comparable[orig.length]; Comparable sorted[] = new Comparable[orig.length]; int indexes[] = new int[ orig.length ]; for( int i = 0; i < orig.length; i++ ) { orig[i] = rand.nextDouble(); sorted[i] = orig[i]; } Arrays.sort(sorted); for( int i = 0; i < orig.length; i++ ) { System.arraycopy(orig,0,copy,0,orig.length); QuickSelect.select(copy,i,copy.length,indexes); assertEquals(orig[i],copy[i]); assertEquals(sorted[i],copy[indexes[i]]); } }
double threshold = QuickSelect.select(workArray.data, (int) (chisqs.size * fraction), chisqs.size);
@Test public void testWithQuickSort_I64() { long orig[] = new long[100]; long copy[] = new long[orig.length]; long sorted[] = new long[orig.length]; for( int i = 0; i < orig.length; i++ ) { orig[i] = rand.nextInt(5000); sorted[i] = orig[i]; } Arrays.sort(sorted); for( int i = 0; i < orig.length; i++ ) { System.arraycopy(orig,0,copy,0,orig.length); double val = QuickSelect.select(copy,i,copy.length); assertEquals(sorted[i],copy[i],1e-6); // make sure everything earlier in the list is less than the selected one for( int j = 0; j < i; j++ ) { assertTrue(copy[j]<=val); } // everything after it should be greater for( int j = i+1; j < copy.length; j++ ) { assertTrue(copy[j]>val); } } }
@Test public void testWithQuickSort_I32() { int orig[] = new int[100]; int copy[] = new int[orig.length]; int sorted[] = new int[orig.length]; for( int i = 0; i < orig.length; i++ ) { orig[i] = rand.nextInt(5000); sorted[i] = orig[i]; } Arrays.sort(sorted); for( int i = 0; i < orig.length; i++ ) { System.arraycopy(orig,0,copy,0,orig.length); double val = QuickSelect.select(copy,i,copy.length); assertEquals(sorted[i],copy[i],1e-6); // make sure everything earlier in the list is less than the selected one for( int j = 0; j < i; j++ ) { assertTrue(copy[j]<=val); } // everything after it should be greater for( int j = i+1; j < copy.length; j++ ) { assertTrue(copy[j]>val); } } }
/** * Creates a random array then sorts it. It then requests that the specified element be found * and compares it against the sorted array. */ @Test public void testWithQuickSort_F64() { double orig[] = new double[100]; double copy[] = new double[orig.length]; double sorted[] = new double[orig.length]; for( int i = 0; i < orig.length; i++ ) { orig[i] = rand.nextDouble(); sorted[i] = orig[i]; } Arrays.sort(sorted); for( int i = 0; i < orig.length; i++ ) { System.arraycopy(orig,0,copy,0,orig.length); double val = QuickSelect.select(copy,i,copy.length); assertEquals(sorted[i],copy[i],1e-6); // make sure everything earlier in the list is less than the selected one for( int j = 0; j < i; j++ ) { assertTrue(copy[j]<=val); } // everything after it should be greater for( int j = i+1; j < copy.length; j++ ) { assertTrue(copy[j]>val); } } }
/** * Extracts local max and/or min from the intensity image. If more than the maximum features are found then * only the most intense ones will be returned * @param intensity Feature image intensity */ public void process(GrayF32 intensity ) { originalMin.reset(); originalMax.reset(); nonmax.process(intensity,null,null,originalMin,originalMax); localExtreme.reset(); for (int i = 0; i < originalMin.size; i++) { Point2D_I16 p = originalMin.get(i); float val = intensity.unsafe_get(p.x,p.y); localExtreme.grow().set(-val,false,p); } for (int i = 0; i < originalMax.size; i++) { Point2D_I16 p = originalMax.get(i); float val = intensity.unsafe_get(p.x, p.y); localExtreme.grow().set(val,true,p); } if( localExtreme.size > maxTotalFeatures ) { QuickSelect.select(localExtreme.data, maxTotalFeatures, localExtreme.size); localExtreme.size = maxTotalFeatures; } }
double medianFB = QuickSelect.select(errorsFB,numTracksFB/2,numTracksFB);