當前位置: 首頁>>代碼示例>>Java>>正文


Java SIFT類代碼示例

本文整理匯總了Java中mpicbg.ij.SIFT的典型用法代碼示例。如果您正苦於以下問題:Java SIFT類的具體用法?Java SIFT怎麽用?Java SIFT使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SIFT類屬於mpicbg.ij包,在下文中一共展示了SIFT類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fetchFeatures

import mpicbg.ij.SIFT; //導入依賴的package包/類
final static protected Collection< Feature > fetchFeatures(
		final Param p,
		final AbstractAffineTile2D< ? > t )
{
	Collection< Feature > features = deserializeFeatures( p, t );
	if ( features == null )
	{
		final FloatArray2DSIFT sift = new FloatArray2DSIFT( p.sift );
		final SIFT ijSIFT = new SIFT( sift );
		features = new ArrayList< Feature >();
		final long s = System.currentTimeMillis();
		ijSIFT.extractFeatures( t.createMaskedByteImage(), features );
		Utils.log( features.size() + " features extracted in tile \"" + t.getPatch().getTitle() + "\" (took " + ( System.currentTimeMillis() - s ) + " ms)." );
		if ( !serializeFeatures( p, t, features ) )
			Utils.log( "Saving features failed for tile: " + t.getPatch() );
	}
	return features;
}
 
開發者ID:trakem2,項目名稱:TrakEM2,代碼行數:19,代碼來源:Align.java

示例2: call

import mpicbg.ij.SIFT; //導入依賴的package包/類
@Override
public ArrayList<Feature> call() throws Exception
{
    final String layerName = layerName( layer );

    //IJ.showProgress( counter.getAndIncrement(), layerRange.size() - 1 );

    final List< Patch > patches = filterPatches( layer, filter );

    ArrayList< Feature > fs = null;
    if ( !clearCache )
        fs = mpicbg.trakem2.align.Util.deserializeFeatures( layer.getProject(), siftParam, "layer", layer.getId() );

    if ( null == fs )
    {
        /* free memory */
        layer.getProject().getLoader().releaseAll();

        final FloatArray2DSIFT sift = new FloatArray2DSIFT( siftParam );
        final SIFT ijSIFT = new SIFT( sift );
        fs = new ArrayList< Feature >();
        ijSIFT.extractFeatures( Patch.makeFlatGrayImage( patches, finalBox, 0, scale ), fs );
        Utils.log( fs.size() + " features extracted for " + layerName );

        if ( !mpicbg.trakem2.align.Util.serializeFeatures( layer.getProject(), siftParam, "layer", layer.getId(), fs ) )
            Utils.log( "FAILED to store serialized features for " + layerName );
    }
    else
        Utils.log( fs.size() + " features loaded for " + layerName );

    return fs;
}
 
開發者ID:trakem2,項目名稱:TrakEM2,代碼行數:33,代碼來源:AlignmentUtils.java

示例3: setupSIFT

import mpicbg.ij.SIFT; //導入依賴的package包/類
public boolean setupSIFT( final String title )
{
	/* SIFT */
	final GenericDialog gdSIFT = new GenericDialog( title + "SIFT parameters" );

	SIFT.addFields( gdSIFT, ppm.sift );

	gdSIFT.addMessage( "Local Descriptor Matching:" );
	gdSIFT.addNumericField( "closest/next_closest_ratio :", ppm.rod, 2 );

	gdSIFT.addMessage( "Miscellaneous:" );
	gdSIFT.addCheckbox( "clear_cache", ppm.clearCache );
	gdSIFT.addNumericField( "feature_extraction_threads :", ppm.maxNumThreadsSift, 0 );

	gdSIFT.showDialog();

	if ( gdSIFT.wasCanceled() )
		return false;

	SIFT.readFields( gdSIFT, ppm.sift );

	ppm.rod = ( float )gdSIFT.getNextNumber();
	ppm.clearCache = gdSIFT.getNextBoolean();
	ppm.maxNumThreadsSift = ( int )gdSIFT.getNextNumber();

	return true;
}
 
開發者ID:trakem2,項目名稱:TrakEM2,代碼行數:28,代碼來源:AbstractLayerAlignmentParam.java

示例4: readSIFTFields

import mpicbg.ij.SIFT; //導入依賴的package包/類
public boolean readSIFTFields( final GenericDialog gd )
{
	SIFT.readFields( gd, sift );
	rod = ( float )gd.getNextNumber();

	return !gd.invalidNumber();
}
 
開發者ID:trakem2,項目名稱:TrakEM2,代碼行數:8,代碼來源:Align.java

示例5: addFields

import mpicbg.ij.SIFT; //導入依賴的package包/類
public void addFields( final GenericDialog gd )
{
	SIFT.addFields( gd, sift );

	gd.addNumericField( "closest/next_closest_ratio :", rod, 2 );

	gd.addMessage( "Geometric Consensus Filter :" );
	gd.addNumericField( "maximal_alignment_error :", maxEpsilon, 2, 6, "px" );
	gd.addNumericField( "inlier_ratio :", minInlierRatio, 2 );
	gd.addChoice( "expected_transformation :", modelStrings, modelStrings[ expectedModelIndex ] );

	gd.addMessage( "Lens Model :" );
	gd.addNumericField( "power_of_polynomial_kernel :", dimension, 0 );
	gd.addNumericField( "lambda :", lambda, 6 );
}
 
開發者ID:trakem2,項目名稱:TrakEM2,代碼行數:16,代碼來源:Distortion_Correction.java

示例6: readFields

import mpicbg.ij.SIFT; //導入依賴的package包/類
public boolean readFields( final GenericDialog gd )
{
	SIFT.readFields( gd, sift );

	rod = ( float )gd.getNextNumber();

	maxEpsilon = ( float )gd.getNextNumber();
	minInlierRatio = ( float )gd.getNextNumber();
	expectedModelIndex = gd.getNextChoiceIndex();

	dimension = ( int )gd.getNextNumber();
	lambda = ( double )gd.getNextNumber();

	return !gd.invalidNumber();
}
 
開發者ID:trakem2,項目名稱:TrakEM2,代碼行數:16,代碼來源:Distortion_Correction.java

示例7: extractSIFTFeaturesThreaded

import mpicbg.ij.SIFT; //導入依賴的package包/類
static List< Feature >[] extractSIFTFeaturesThreaded(
		final int numberOfImages, final String directory,
		final String[] names ){
	//extract all SIFT Features

	final List< Feature >[] siftFeatures = new ArrayList[numberOfImages];
	final Thread[] threads = MultiThreading.newThreads();
	final AtomicInteger ai = new AtomicInteger(0); // start at second slice

	IJ.showStatus("Extracting SIFT Features");
	for (int ithread = 0; ithread < threads.length; ++ithread) {
		threads[ithread] = new Thread() {
			@Override
               public void run() {
				for (int i = ai.getAndIncrement(); i < numberOfImages; i = ai.getAndIncrement())
				{
					final ArrayList< Feature > fs = new ArrayList< Feature >();
					final ImagePlus imps = new Opener().openImage(directory + names[i + sp.firstImageIndex]);
					imps.setProcessor(imps.getTitle(), imps.getProcessor().convertToFloat());

					final FloatArray2DSIFT sift = new FloatArray2DSIFT( sp.sift.clone() );
					final SIFT ijSIFT = new SIFT( sift );

					ijSIFT.extractFeatures( imps.getProcessor(), fs );

					Collections.sort( fs );
					IJ.log("Extracting SIFT of image: "+i);

					siftFeatures[i]=fs;

				}
			}
		};
	}
	MultiThreading.startAndJoin(threads);

	return  siftFeatures;
}
 
開發者ID:trakem2,項目名稱:TrakEM2,代碼行數:39,代碼來源:Distortion_Correction.java

示例8: extract

import mpicbg.ij.SIFT; //導入依賴的package包/類
static protected ArrayList< Feature > extract( final SIFT ijSIFT, final ImageProcessor ip )
{
	final ArrayList< Feature > features = new ArrayList< Feature >();
	ijSIFT.extractFeatures( ip, features );
	return features;
}
 
開發者ID:saalfeldlab,項目名稱:z-spacing,代碼行數:7,代碼來源:LayerZPosition.java

示例9: extractFeaturesFromImage

import mpicbg.ij.SIFT; //導入依賴的package包/類
/**
 * Extract SIFT features from specified buffered image.
 *
 * @param  bufferedImage  image to process.
 *
 * @return list of extracted features.
 */
public List<Feature> extractFeaturesFromImage(final BufferedImage bufferedImage) {

    final Timer timer = new Timer();
    timer.start();

    // clone provided parameters since they get modified during feature extraction
    final FloatArray2DSIFT.Param siftParameters = coreSiftParameters.clone();
    final int w = bufferedImage.getWidth();
    final int h = bufferedImage.getHeight();
    final int minSize = w < h ? w : h;
    final int maxSize = w > h ? w : h;
    siftParameters.minOctaveSize = (int) (minScale * minSize - 1.0);
    siftParameters.maxOctaveSize = (int) Math.round(maxScale * maxSize);

    LOG.info("extractFeatures: entry, fdSize={}, steps={}, minScale={}, maxScale={}, minOctaveSize={}, maxOctaveSize={}",
             siftParameters.fdSize,
             siftParameters.steps,
             minScale,
             maxScale,
             siftParameters.minOctaveSize,
             siftParameters.maxOctaveSize);

    // Let imagePlus determine correct processor - original use of ColorProcessor resulted in
    // fewer extracted features when bufferedImage was loaded from disk.
    final ImagePlus imagePlus = new ImagePlus("", bufferedImage);

    final FloatArray2DSIFT sift = new FloatArray2DSIFT(siftParameters);
    final SIFT ijSIFT = new SIFT(sift);

    final List<Feature> featureList = new ArrayList<>();
    ijSIFT.extractFeatures(imagePlus.getProcessor(), featureList);

    if (featureList.size() == 0) {

        final StringBuilder sb = new StringBuilder(256);
        sb.append("no features were extracted");

        if (bufferedImage.getWidth() < siftParameters.minOctaveSize) {
            sb.append(" because montage image width (").append(bufferedImage.getWidth());
            sb.append(") is less than SIFT minOctaveSize (").append(siftParameters.minOctaveSize).append(")");
        } else if (bufferedImage.getHeight() < siftParameters.minOctaveSize) {
            sb.append(" because montage image height (").append(bufferedImage.getHeight());
            sb.append(") is less than SIFT minOctaveSize (").append(siftParameters.minOctaveSize).append(")");
        } else if (bufferedImage.getWidth() > siftParameters.maxOctaveSize) {
            sb.append(" because montage image width (").append(bufferedImage.getWidth());
            sb.append(") is greater than SIFT maxOctaveSize (").append(siftParameters.maxOctaveSize).append(")");
        } else if (bufferedImage.getHeight() > siftParameters.maxOctaveSize) {
            sb.append(" because montage image height (").append(bufferedImage.getHeight());
            sb.append(") is greater than SIFT maxOctaveSize (").append(siftParameters.maxOctaveSize).append(")");
        } else {
            sb.append(", not sure why, montage image width (").append(bufferedImage.getWidth());
            sb.append(") or height (").append(bufferedImage.getHeight());
            sb.append(") may be less than maxKernelSize derived from SIFT steps(");
            sb.append(siftParameters.steps).append(")");
        }

        LOG.warn(sb.toString());
    }

    LOG.info("extractFeatures: exit, extracted " + featureList.size() +
             " features, elapsedTime=" + timer.stop() + "ms");

    return featureList;
}
 
開發者ID:saalfeldlab,項目名稱:render,代碼行數:72,代碼來源:CanvasFeatureExtractor.java

示例10: extractAndSaveFeatures

import mpicbg.ij.SIFT; //導入依賴的package包/類
/**
 * Extract SIFT features and save them into the project folder.
 *
 * @param tiles
 * @param siftParam
 * @param clearCache
 * @throws Exception
 */
final static protected void extractAndSaveFeatures(
		final List< AbstractAffineTile2D< ? > > tiles,
		final FloatArray2DSIFT.Param siftParam,
		final boolean clearCache ) throws Exception
{
	final ExecutorService exec = Executors.newFixedThreadPool( p.maxNumThreads );

	/* extract features for all slices and store them to disk */
	final AtomicInteger counter = new AtomicInteger( 0 );
	final ArrayList< Future< ArrayList< Feature > > > siftTasks = new ArrayList< Future< ArrayList< Feature > > >();

	for ( int i = 0; i < tiles.size(); ++i )
	{
		final int tileIndex = i;
		siftTasks.add(
				exec.submit( new Callable< ArrayList< Feature > >()
				{
					@Override
					public ArrayList< Feature > call()
					{
						final AbstractAffineTile2D< ? > tile = tiles.get( tileIndex );

						final String patchName = patchName( tile.getPatch() );

						IJ.showProgress( counter.getAndIncrement(), tiles.size() - 1 );

						ArrayList< Feature > fs = null;
						if ( !clearCache )
							fs = mpicbg.trakem2.align.Util.deserializeFeatures( tile.getPatch().getProject(), siftParam, null, tile.getPatch().getId() );

						if ( null == fs )
						{
							final FloatArray2DSIFT sift = new FloatArray2DSIFT( siftParam );
							final SIFT ijSIFT = new SIFT( sift );
							fs = new ArrayList< Feature >();
							final ByteProcessor ip = tile.createMaskedByteImage();
							ijSIFT.extractFeatures( ip, fs );
							Utils.log( fs.size() + " features extracted for " + patchName );

							if ( !mpicbg.trakem2.align.Util.serializeFeatures( tile.getPatch().getProject(), siftParam, null, tile.getPatch().getId(), fs ) )
								Utils.log( "FAILED to store serialized features for " + patchName );
						}
						else
							Utils.log( fs.size() + " features loaded for " + patchName );

						return fs;
					}
				} ) );
	}

	/* join */
	for ( final Future< ArrayList< Feature > > fu : siftTasks )
		fu.get();

	siftTasks.clear();
	exec.shutdown();
}
 
開發者ID:trakem2,項目名稱:TrakEM2,代碼行數:66,代碼來源:ElasticMontage.java

示例11: addSIFTFields

import mpicbg.ij.SIFT; //導入依賴的package包/類
public void addSIFTFields( final GenericDialog gd )
{
	SIFT.addFields( gd, sift );
	gd.addNumericField( "closest/next_closest_ratio :", rod, 2 );
}
 
開發者ID:trakem2,項目名稱:TrakEM2,代碼行數:6,代碼來源:Align.java

示例12: run

import mpicbg.ij.SIFT; //導入依賴的package包/類
@Override
final public void run()
{
	final FloatArray2DSIFT sift = new FloatArray2DSIFT( p.sift );
	final SIFT ijSIFT = new SIFT( sift );

	for ( int i = ai.getAndIncrement(); i < tiles.size() && !isInterrupted(); i = ai.getAndIncrement() )
	{
		if (isInterrupted()) return;
		final AbstractAffineTile2D< ? > tile = tiles.get( i );
		Collection< Feature > features = deserializeFeatures( p, tile );
		if ( features == null )
		{
			/* extract features and, in case there is not enough memory available, try to free it and do again */
			boolean memoryFlushed;
			do
			{
				try
				{
					features = new ArrayList< Feature >();
					final long s = System.currentTimeMillis();
					ijSIFT.extractFeatures( tile.createMaskedByteImage(), features );
					Utils.log( features.size() + " features extracted in tile " + i + " \"" + tile.getPatch().getTitle() + "\" (took " + ( System.currentTimeMillis() - s ) + " ms)." );
					if ( !serializeFeatures( p, tile, features ) )
						Utils.log( "Saving features failed for tile \"" + tile.getPatch() + "\"" );
					memoryFlushed = false;
				}
				catch ( final OutOfMemoryError e )
				{
					Utils.log2( "Flushing memory for feature extraction" );
					Loader.releaseAllCaches();
					memoryFlushed = true;
				}
			}
			while ( memoryFlushed );
		}
		else
		{
			Utils.log( features.size() + " features loaded for tile " + i + " \"" + tile.getPatch().getTitle() + "\"." );
		}
		IJ.showProgress( ap.getAndIncrement(), steps );
	}
}
 
開發者ID:trakem2,項目名稱:TrakEM2,代碼行數:44,代碼來源:Align.java

示例13: setupSIFT

import mpicbg.ij.SIFT; //導入依賴的package包/類
public boolean setupSIFT( final String title )
{
	/* SIFT */
	final GenericDialog gdSIFT = new GenericDialog( title + "SIFT parameters" );

	SIFT.addFields( gdSIFT, sift );

	gdSIFT.addMessage( "Local Descriptor Matching:" );
	gdSIFT.addNumericField( "closest/next_closest_ratio :", rod, 2 );

	gdSIFT.addMessage( "Miscellaneous:" );
	gdSIFT.addNumericField( "feature_extraction_threads :", maxNumThreadsSift, 0 );

	gdSIFT.showDialog();

	if ( gdSIFT.wasCanceled() )
		return false;

	SIFT.readFields( gdSIFT, sift );

	rod = ( float )gdSIFT.getNextNumber();
	maxNumThreadsSift = ( int )gdSIFT.getNextNumber();

	return true;
}
 
開發者ID:trakem2,項目名稱:TrakEM2,代碼行數:26,代碼來源:DistortionCorrectionTask.java


注:本文中的mpicbg.ij.SIFT類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。