mpicbg.imglib.image.display.imagej.ImageJFunctions Java Examples
The following examples show how to use
mpicbg.imglib.image.display.imagej.ImageJFunctions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LRFFT.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("rawtypes") public static final Image< FloatType > wrap( final Img< net.imglib2.type.numeric.real.FloatType > i ) { if ( i instanceof ImagePlusImg ) { try { return ImageJFunctions.wrapFloat( ((ImagePlusImg) i).getImagePlus() ); } catch (ImgLibException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } } else { return ImgLib2.wrapFloatToImgLib1( i ); } }
Example #2
Source File: LRFFT.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("rawtypes") public static final Img< net.imglib2.type.numeric.real.FloatType > wrap( final Image< FloatType > i ) { final ContainerFactory c = i.getContainerFactory(); if ( c instanceof ImagePlusContainerFactory ) { try { return net.imglib2.img.display.imagej.ImageJFunctions.wrapFloat( ((ImagePlusContainer)i.getContainer()).getImagePlus() ); } catch (mpicbg.imglib.exception.ImgLibException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } } else { return ImgLib1.wrapFloatToImgLib2( i ); } }
Example #3
Source File: MappingFusionSequentialDifferentOutput.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
@Override public boolean saveAsTiffs( final String dir, final String name, final int channelIndex ) { if ( channelIndex > 0 ) return true; boolean success = true; for ( int i = 0; i < fusedImages.length; i++ ) { final ViewDataBeads view = viewStructure.getViews().get( angleIndicies[ i ] ); if ( viewStructure.getDebugLevel() <= ViewStructure.DEBUG_MAIN ) IOFunctions.println( "(" + new Date(System.currentTimeMillis()) + "): Saving '" + name + "_ch" + view.getChannel() + "_angle" + view.getAcqusitionAngle() + "'" ); success &= ImageJFunctions.saveAsTiffs( fusedImages[ i ], dir, name + "_ch" + view.getChannel() + "_angle" + view.getAcqusitionAngle(), ImageJFunctions.GRAY32 ); } return success; }
Example #4
Source File: FileOpenMenuEntry.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
@Override public void actionPerformed( final ActionEvent e ) { if ( chartPanel != null ) { // this might fail horribly, but at the moment it is the only solution // as right clicks in the chart are not reported to the mouse-listener // if they happen above the line drawings try { final JMenuItem item = (JMenuItem)e.getSource(); final JPopupMenu m = (JPopupMenu)item.getParent(); // location of the top left pixel of the chartpanel in screen coordinates final Point p = chartPanel.getLocationOnScreen(); // we parse the position of the JPopupMenu on the screen (AAARGH!!!) final String output = m.toString(); final String x = output.substring( output.indexOf( "desiredLocationX" ) ); final String y = output.substring( output.indexOf( "desiredLocationY" ) ); System.out.println( "chart: " +p ); System.out.println( "popup: " + x + ", " + y ); // and from that we get the relative coordinate in the chartpanel p.x = Integer.parseInt( x.substring( x.indexOf( "=" )+1, x.indexOf( "," ) ) ) - p.x; p.y = Integer.parseInt( y.substring( y.indexOf( "=" )+1, y.indexOf( "," ) ) ) - p.y; // now we transform it into the correct timelapse scale final int tp = MouseListenerTimelapse.getChartXLocation( p, chartPanel ); // now find the correct image for ( final RegistrationStatistics stat : data ) if ( stat.timePoint == tp ) { final Image<FloatType> image = LOCI.openLOCIFloatType( stat.worstView.getAbsolutePath(), new ArrayContainerFactory() ); ImageJFunctions.show( image ); break; } } catch ( Exception ex ) {} } }
Example #5
Source File: Bead_Registration.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
/** * Can be called with values[ 3 ], i.e. [initialsigma, sigma2, threshold] or * values[ 2 ], i.e. [initialsigma, threshold] * * The results are stored in the same array. * If called with values[ 2 ], sigma2 changing will be disabled * * @param text - the text which is shown when asking for the file * @param values - the intial values and also contains the result */ public static void getInteractiveDoGParameters( final String text, final double values[] ) { final GenericDialogPlus gd = new GenericDialogPlus( text ); gd.addFileField( "", spimDataDirectory, 50 ); gd.showDialog(); if ( gd.wasCanceled() ) return; final String file = gd.getNextString(); IOFunctions.println( "Loading " + file ); final Image<FloatType> img = LOCI.openLOCIFloatType( file, new ArrayContainerFactory() ); if ( img == null ) { IOFunctions.println( "File not found: " + file ); return; } img.getDisplay().setMinMax(); final ImagePlus imp = ImageJFunctions.copyToImagePlus( img ); img.close(); imp.show(); imp.setSlice( imp.getStackSize() / 2 ); imp.setRoi( 0, 0, imp.getWidth()/3, imp.getHeight()/3 ); final InteractiveDoG idog = new InteractiveDoG(); if ( values.length == 2 ) { idog.setSigma2isAdjustable( false ); idog.setInitialSigma( (float)values[ 0 ] ); idog.setThreshold( (float)values[ 1 ] ); } else { idog.setInitialSigma( (float)values[ 0 ] ); idog.setThreshold( (float)values[ 2 ] ); } idog.run( null ); while ( !idog.isFinished() ) SimpleMultiThreading.threadWait( 100 ); imp.close(); if ( values.length == 2) { values[ 0 ] = idog.getInitialSigma(); values[ 1 ] = idog.getThreshold(); } else { values[ 0 ] = idog.getInitialSigma(); values[ 1 ] = idog.getSigma2(); values[ 2 ] = idog.getThreshold(); } }
Example #6
Source File: Bead_Registration.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
/** * Can be called with values[ 3 ], i.e. [r1, r2, threshold] (r2 is only written as result) * * The results are stored in the same array. * * @param text - the text which is shown when asking for the file * @param values - the intial values and also contains the result */ public static void getInteractiveIntegralParameters( final String text, final double values[] ) { final GenericDialogPlus gd = new GenericDialogPlus( text ); gd.addFileField( "", spimDataDirectory, 50 ); gd.showDialog(); if ( gd.wasCanceled() ) return; final String file = gd.getNextString(); IOFunctions.println( "Loading " + file ); final Image<FloatType> img = LOCI.openLOCIFloatType( file, new ArrayContainerFactory() ); if ( img == null ) { IOFunctions.println( "File not found: " + file ); return; } img.getDisplay().setMinMax(); final ImagePlus imp = ImageJFunctions.copyToImagePlus( img ); img.close(); imp.show(); imp.setSlice( imp.getStackSize() / 2 ); final InteractiveIntegral ii = new InteractiveIntegral(); ii.setInitialRadius( Math.round( (float)values[ 0 ] ) ); ii.setThreshold( (float)values[ 2 ] ); ii.run( null ); while ( !ii.isFinished() ) SimpleMultiThreading.threadWait( 100 ); imp.close(); values[ 0 ] = ii.getRadius1(); values[ 1 ] = ii.getRadius2(); values[ 2 ] = ii.getThreshold(); }
Example #7
Source File: Block.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
public static void main( String[] args ) { new ImageJ(); //final Image< FloatType > img = LOCI.openLOCIFloatType( "/Users/preibischs/Desktop/Geburtstagsfaust.jpg", new ArrayContainerFactory() ); final Image< FloatType > img = LOCI.openLOCIFloatType( "/Users/preibischs/Desktop/spim.tif", new ArrayContainerFactory() ); final Image< FloatType > kernel = FourierConvolution.createGaussianKernel( img.getContainerFactory(), new double[]{ 10, 10, 10 } ); //ImageJFunctions.show( img ); //final FourierConvolution< FloatType, FloatType > t = new FourierConvolution<FloatType, FloatType>( img, kernel ); //t.process(); //ImageJFunctions.show( t.getResult() ); final int[] imgSize = img.getDimensions();//new int[]{ 256, 384 }; final int[] blockSize = new int[]{ 256, 256, 256 }; //for ( int d = 0; d < blockSize.length; ++d ) // blockSize[ d ] = img.getDimension( d ) + kernel.getDimension( d ) - 1; final int[] kernelSize = kernel.getDimensions();//new int[]{ 51, 25 }; final Block[] blocks = Block.divideIntoBlocks( imgSize, blockSize, kernelSize ); final ArrayList< Image< FloatType > > blockImgs = new ArrayList< Image< FloatType > >(); final ImageFactory< FloatType > factory = new ImageFactory< FloatType >( new FloatType(), new ArrayContainerFactory() ); ImageJFunctions.show( img ); for ( int i = 0; i < blocks.length; ++i ) blockImgs.add( factory.createImage( blockSize ) ); long time = 0; //while ( time >= 0 ) { time = System.currentTimeMillis(); for ( int i = 0; i < blocks.length; ++i ) { blocks[ i ].copyBlock( img, blockImgs.get( i ) ); //ImageJFunctions.show( block ); } System.out.println( System.currentTimeMillis() - time ); //System.exit( 0 ); } /* final FourierConvolution< FloatType, FloatType > t2 = new FourierConvolution<FloatType, FloatType>( blockImgs.get( 0 ), kernel ); //t2.setExtendImageByKernelSize( false ); //for ( final FloatType t : block ) // t.set( t.get() + 20*(i+1) ); */ final Image< FloatType > img2 = img.createNewImage(); //while ( time > 0 ) { time = System.currentTimeMillis(); for ( int i = 0; i < blocks.length; ++i ) { //t2.replaceImage( blockImgs.get( i ) ); //t2.process(); blocks[ i ].pasteBlock( img2, blockImgs.get( i ) ); //ImageJFunctions.show( t.getResult() ); } System.out.println( System.currentTimeMillis() - time ); } ImageJFunctions.show( img2 ); }
Example #8
Source File: BeadSegmentation.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
public void segment( final SPIMConfiguration conf, final ArrayList<ViewDataBeads> views ) { final double threshold = conf.threshold; // // Extract the beads // for ( final ViewDataBeads view : views ) { if ( conf.segmentation == SegmentationTypes.DOG ) { if ( viewStructure.getDebugLevel() <= ViewStructure.DEBUG_MAIN ) IOFunctions.println("(" + new Date(System.currentTimeMillis()) + "): Starting Scale Space Bead Extraction for " + view.getName() ); view.setBeadStructure( extractBeadsLaPlaceImgLib( view, conf ) ); if ( debugBeads ) { Image<FloatType> img = getFoundBeads( view ); img.setName( "imglib" ); img.getDisplay().setMinMax(); ImageJFunctions.copyToImagePlus( img ).show(); SimpleMultiThreading.threadHaltUnClean(); } } else if ( conf.segmentation == SegmentationTypes.THRESHOLD ) { if ( viewStructure.getDebugLevel() <= ViewStructure.DEBUG_MAIN ) IOFunctions.println("(" + new Date(System.currentTimeMillis()) + "): Starting Threshold Bead Extraction for " + view.getName() ); view.setBeadStructure( extractBeadsThresholdSegmentation( view, (float)threshold, conf.minSize, conf.maxSize, conf.minBlackBorder) ); } else if ( conf.segmentation == SegmentationTypes.DOM ) { if ( viewStructure.getDebugLevel() <= ViewStructure.DEBUG_MAIN ) IOFunctions.println("(" + new Date(System.currentTimeMillis()) + "): Starting Integral Image based DOM Bead Extraction for " + view.getName() ); view.setBeadStructure( extractBeadsDOM( view, conf ) ); } else { throw new RuntimeException( "Unknown segmentation: " + conf.segmentation ); } if ( viewStructure.getDebugLevel() <= ViewStructure.DEBUG_MAIN ) IOFunctions.println( "Found peaks (possible beads): " + view.getBeadStructure().getBeadList().size() + " in view " + view.getName() ); // // do we want to re-localize all detections with a gauss fit? // if ( conf.doFit == 3 ) { if ( viewStructure.getDebugLevel() <= ViewStructure.DEBUG_MAIN ) IOFunctions.println("(" + new Date(System.currentTimeMillis()) + "): Starting Gaussian fit for all detections (this will take a little)"); double sxy = 2;//10; double sz = 2;//(1.5 * sxy) / conf.zStretching; IJ.log( "Assumed sigma: [" + sxy + ", " + sxy + ", " + sz + "]" ); final double[] typicalSigma = new double[]{ sxy, sxy, sz }; gaussFit( view.getImage(), view.getBeadStructure().getBeadList(), typicalSigma ); } // close the image if no re-localization is required and/or the memory is low if ( !( conf.doFit == 2 && conf.doGaussKeepImagesOpen ) ) view.closeImage(); // // Store segmentation in a file // if ( conf.writeSegmentation ) IOFunctions.writeSegmentation( view, conf.registrationFiledirectory ); } if ( viewStructure.getDebugLevel() <= ViewStructure.DEBUG_MAIN ) { int p1 = (int)Math.round( (double)benchmark.openFiles/((double)benchmark.computation+(double)benchmark.openFiles) * 100 ); int p2 = (int)Math.round( (double)benchmark.computation/((double)benchmark.computation+(double)benchmark.openFiles) * 100 ); IJ.log( "Opening files took: " + benchmark.openFiles/1000 + " sec (" + p1 + " %)" ); IJ.log( "Computation took: " + benchmark.computation/1000 + " sec (" + p2 + " %)" ); } }
Example #9
Source File: PairWiseStitchingImgLib.java From Stitching with GNU General Public License v2.0 | 3 votes |
/** * return an {@link Image} of {@link UnsignedByteType} as input for the PhaseCorrelation. If no rectangular roi * is selected, it will only wrap the existing ImagePlus! * * @param imp - the {@link ImagePlus} * @param channel - which channel (if channel=0 means average all channels) * @param timepoint - which timepoint * * @return - the {@link Image} or null if it was not an ImagePlus.GRAY8 or if channel = 0 */ public static Image<UnsignedByteType> getWrappedImageUnsignedByte( final ImagePlus imp, final int channel, final int timepoint ) { if ( channel == 0 || imp.getType() != ImagePlus.GRAY8 ) return null; return ImageJFunctions.wrapByte( Hyperstack_rearranger.getImageChunk( imp, channel, timepoint ) ); }
Example #10
Source File: PairWiseStitchingImgLib.java From Stitching with GNU General Public License v2.0 | 3 votes |
/** * return an {@link Image} of {@link UnsignedShortType} as input for the PhaseCorrelation. If no rectangular roi * is selected, it will only wrap the existing ImagePlus! * * @param imp - the {@link ImagePlus} * @param channel - which channel (if channel=0 means average all channels) * @param timepoint - which timepoint * * @return - the {@link Image} or null if it was not an ImagePlus.GRAY16 or if channel = 0 */ public static Image<UnsignedShortType> getWrappedImageUnsignedShort( final ImagePlus imp, final int channel, final int timepoint ) { if ( channel == 0 || imp.getType() != ImagePlus.GRAY16 ) return null; return ImageJFunctions.wrapShort( Hyperstack_rearranger.getImageChunk( imp, channel, timepoint ) ); }
Example #11
Source File: PairWiseStitchingImgLib.java From Stitching with GNU General Public License v2.0 | 3 votes |
/** * return an {@link Image} of {@link FloatType} as input for the PhaseCorrelation. If no rectangular roi * is selected, it will only wrap the existing ImagePlus! * * @param imp - the {@link ImagePlus} * @param channel - which channel (if channel=0 means average all channels) * @param timepoint - which timepoint * * @return - the {@link Image} or null if it was not an ImagePlus.GRAY32 or if channel = 0 */ public static Image<FloatType> getWrappedImageFloat( final ImagePlus imp, final int channel, final int timepoint ) { if ( channel == 0 || imp.getType() != ImagePlus.GRAY32 ) return null; return ImageJFunctions.wrapFloat( Hyperstack_rearranger.getImageChunk( imp, channel, timepoint ) ); }
Example #12
Source File: DOM.java From SPIM_Registration with GNU General Public License v2.0 | 2 votes |
public static void main( String args[] ) { new ImageJ(); //Image< FloatType > img1 = new ImageFactory<FloatType>( new FloatType(), new ArrayContainerFactory() ).createImage( new int[]{ 13, 13, 13 } ); //meanMirror( null, img1, 7, 7, 7, 0, 0 ); //ImageJFunctions.show( img1 ); //SimpleMultiThreading.threadHaltUnClean(); Image< FloatType > img = LOCI.openLOCIFloatType( "/Users/preibischs/Documents/Microscopy/SPIM/HisYFP-SPIM/spim_TL18_Angle0.tif", new ArrayContainerFactory() ); long ti = System.currentTimeMillis(); Image<FloatType> cb = computeContentBasedWeighting( img, 20, 40, 2.73f ); System.out.println( "Content-based took: " + (System.currentTimeMillis() - ti) + " ms." ); ImageJFunctions.show( cb ); SimpleMultiThreading.threadHaltUnClean(); final IntegralImageLong< FloatType > intImg = new IntegralImageLong<FloatType>( img, new Converter< FloatType, LongType >() { @Override public void convert( final FloatType input, final LongType output ) { output.set( Util.round( input.get() ) ); } } ); intImg.process(); final Image< LongType > integralImg = intImg.getResult(); meanMirror( integralImg, img, 31, 31, 11 ); ImageJFunctions.show( img ); SimpleMultiThreading.threadHaltUnClean(); final FloatType min = new FloatType(); final FloatType max = new FloatType(); DOM.computeMinMax( img, min, max ); final Image< FloatType > domImg = img.createNewImage(); long t = 0; int num = 10; for ( int i = 0; i < num; ++i ) { long t1 = System.currentTimeMillis(); DOM.computeDifferencOfMean3d( integralImg, domImg, 3, 3, 3, 5, 5, 5, min.get(), max.get() ); long t2 = System.currentTimeMillis(); t += (t2 - t1); System.out.println( "run " + i + ": " + (t2-t1) + " ms." ); } System.out.println( "avg: " + (t/num) + " ms." ); //DOM.computeDifferencOfMean( integralImg, img, 3, 3, 3, 5, 5, 5, min.get(), max.get() ); }
Example #13
Source File: SPIMImageFusion.java From SPIM_Registration with GNU General Public License v2.0 | votes |
public ImagePlus getFusedImageCopy() { return ImageJFunctions.copyToImagePlus( getFusedImage() ); }
Example #14
Source File: SPIMImageFusion.java From SPIM_Registration with GNU General Public License v2.0 | votes |
public ImagePlus getFusedImageVirtual() { return ImageJFunctions.displayAsVirtualStack( getFusedImage() ); }
Example #15
Source File: SPIMImageFusion.java From SPIM_Registration with GNU General Public License v2.0 | votes |
public boolean saveAsTiffs( final String dir, final String name, final int channelIndex ) { return ImgLibSaver.saveAsTiffs( getFusedImage(), dir, name + "_ch" + viewStructure.getChannelNum( channelIndex ), ImageJFunctions.GRAY32 ); }