gauss( sigma, source, target, service ); service.shutdown();
@Override public void compute(final RandomAccessible<T> input, final RandomAccessibleInterval<T> output) { try { SeparableSymmetricConvolution.convolve(Gauss3.halfkernels(sigmas), input, output, threads.getExecutorService()); } catch (final IncompatibleTypeException e) { throw new RuntimeException(e); } }
public static double[][] halfkernels( final double[] sigma ) { final int n = sigma.length; final double[][] halfkernels = new double[ n ][]; final int[] size = halfkernelsizes( sigma ); for ( int i = 0; i < n; ++i ) halfkernels[ i ] = halfkernel( sigma[ i ], size[ i ], true ); return halfkernels; }
public static double[][] halfkernels( final double[] sigma ) { final int n = sigma.length; final double[][] halfkernels = new double[ n ][]; for( int i = 0; i < n; ++i ) { final int size = Math.max( 2, (int) (3 * sigma[ i ] + 0.5) + 1 ); halfkernels[ i ] = halfkernel( sigma[ i ], size, true ); } return halfkernels; }
gauss( sigma, source, target, service ); service.shutdown();
final double[][] halfkernels = halfkernels( sigma ); final int numthreads = Runtime.getRuntime().availableProcessors(); SeparableSymmetricConvolution.convolve( halfkernels, source, target, numthreads );
for ( int d = 0; d < n; ++d ) s[ d ] = sigma; gauss( s, source, target );
@Override public void compute(final RandomAccessibleInterval<T> input, final RandomAccessibleInterval<T> output) { if (outOfBounds == null) { outOfBounds = new OutOfBoundsMirrorFactory<>(Boundary.SINGLE); } final RandomAccessible<FloatType> eIn = // (RandomAccessible) Views.extend(input, outOfBounds); try { SeparableSymmetricConvolution.convolve(Gauss3.halfkernels(sigmas), eIn, output, threads.getExecutorService()); } catch (final IncompatibleTypeException e) { throw new RuntimeException(e); } }
for ( int d = 0; d < n; ++d ) s[ d ] = sigma; gauss( s, source, target );
final double[][] halfkernels = halfkernels( sigma ); final Convolution< NumericType< ? > > convolution = SeparableKernelConvolution.convolution( Kernel1D.symmetric( halfkernels ) ); convolution.setExecutor( service );
@Override public final < R extends RealType< R > > Img< FloatType > evaluate( final Img< R > img, final R alpha ) throws ParseException { RandomAccessibleInterval< FloatType > fimg = ImgLibUtils.copyToFloatTypeImage( img ); try { Gauss3.gauss( alpha.getRealDouble(), Views.extendZero( fimg ), fimg ); } catch ( IncompatibleTypeException e ) { throw new RuntimeException( e ); } return ( Img< FloatType > ) fimg; }
public static double[] computeCenter( final Img< FloatType > i, final double threshold ) throws IncompatibleTypeException { final Img<FloatType> copy = i.copy(); Gauss3.gauss( 2, Views.extendMirrorSingle( copy ), copy ); return centerofmass( copy, threshold ); }
Gauss3.gauss( Util.getArrayFromValue( sigma, psi.numDimensions() ), Views.extendMirrorSingle( psi ), psi, service );
protected Img< FloatType > computeGaussianConvolution( final double[] sigma ) { final FloatType type = new FloatType(); Img< FloatType > target = null; try { target = this.factory.imgFactory( type ).create( image, type ); Gauss3.gauss( sigma, Views.extend( image, outOfBoundsFactory ), target ); } catch ( final IncompatibleTypeException e ) { e.printStackTrace(); } return target; }
Gauss3.gauss( sigma[ 0 ], source, gaussian ); else Gauss3.gauss( sigma, source, gaussian ); return calculateMatrix( Views.extend( gaussian, outOfBounds ), gradient, hessianMatrix, outOfBounds ); Gauss3.gauss( IntStream.range( 0, source.numDimensions() ).mapToDouble( i -> sigma[ 0 ] ).toArray(), source, gaussian, es ); else Gauss3.gauss( sigma, source, gaussian, es ); return calculateMatrix( Views.extend( gaussian, outOfBounds ), gradient, hessianMatrix, outOfBounds, nTasks, es );
public ArrayList< ImagePlus > call() { // Get channel(s) to process ImagePlus[] channels = extractChannels(originalImage); ArrayList<ImagePlus>[] results = new ArrayList[ channels.length ]; for(int ch=0; ch < channels.length; ch++) { results[ ch ] = new ArrayList<ImagePlus>(); final ImagePlus im = channels [ ch ].duplicate(); final Img<FloatType> image2 = ImagePlusAdapter.wrap( im ); // first extend the image with mirror RandomAccessible< FloatType > mirrorImg = Views.extendMirrorSingle( image2 ); // adjust sigma based on voxel size final double[] isoSigma = new double[ mirrorImg.numDimensions() ]; for ( int d = 0; d < isoSigma.length; ++d ) isoSigma[ d ] = sigma * scaleFactor[ d ]; try { Gauss3.gauss( isoSigma, mirrorImg, image2 ); } catch (IncompatibleTypeException e) { IJ.log( "Error when calculating Gaussian feature." ); e.printStackTrace(); return null; } final ImagePlus ip = ImageJFunctions.wrapFloat( image2, availableFeatures[ GAUSSIAN ] +"_" + sigma ); results[ch].add( ip ); } return mergeResultChannels(results); } };
public ArrayList< ImagePlus > call() { // Get channel(s) to process ImagePlus[] channels = extractChannels(originalImage); ArrayList<ImagePlus>[] results = new ArrayList[ channels.length ]; for(int ch=0; ch < channels.length; ch++) { results[ ch ] = new ArrayList<ImagePlus>(); final ImagePlus im = channels [ ch ].duplicate(); final Img<FloatType> image2 = ImagePlusAdapter.wrap( im ); // first extend the image with mirror RandomAccessible< FloatType > mirrorImg = Views.extendMirrorSingle( image2 ); // adjust sigma based on voxel size final double[] isoSigma = new double[ mirrorImg.numDimensions() ]; for ( int d = 0; d < isoSigma.length; ++d ) isoSigma[ d ] = sigma * scaleFactor[ d ]; try { Gauss3.gauss( isoSigma, mirrorImg, image2 ); } catch (IncompatibleTypeException e) { IJ.log( "Error when calculating Gaussian feature." ); e.printStackTrace(); return null; } final ImagePlus ip = ImageJFunctions.wrapFloat( image2, availableFeatures[ GAUSSIAN ] +"_" + sigma ); results[ch].add( ip ); } return mergeResultChannels(results); } };
Gauss3.gauss( new double[]{ 2, 2, 2 }, Views.extendZero( s ), s );
Gauss3.gauss( rad / Math.sqrt( 2 ), source, img ); final ImgPlus< UnsignedShortType > imgplus = new ImgPlus< >( img );