Search in sources :

Example 16 with ImageProcessorReader

use of loci.plugins.util.ImageProcessorReader in project bioformats by openmicroscopy.

the class ImagePlusReader method readProcessors.

/**
 * HACK: This method mainly exists to prompt the user for a missing
 * LuraWave license code, in the case of LWF-compressed Flex.
 *
 * @see ImportProcess#setId()
 */
private ImageProcessor[] readProcessors(ImportProcess process, int no, Region r, boolean thumbnail) throws FormatException, IOException {
    final ImageProcessorReader reader = process.getReader();
    final ImporterOptions options = process.getOptions();
    boolean first = true;
    for (int i = 0; i < LuraWave.MAX_TRIES; i++) {
        String code = LuraWave.initLicenseCode();
        try {
            if (thumbnail) {
                return reader.openThumbProcessors(no);
            }
            return reader.openProcessors(no, r.x, r.y, r.width, r.height);
        } catch (FormatException exc) {
            if (options.isQuiet() || options.isWindowless())
                throw exc;
            if (!LuraWave.isLicenseCodeException(exc))
                throw exc;
            // prompt user for LuraWave license code
            code = LuraWave.promptLicenseCode(code, first);
            if (code == null)
                throw exc;
            if (first)
                first = false;
        }
    }
    throw new FormatException(LuraWave.TOO_MANY_TRIES);
}
Also used : ImageProcessorReader(loci.plugins.util.ImageProcessorReader) FormatException(loci.formats.FormatException)

Example 17 with ImageProcessorReader

use of loci.plugins.util.ImageProcessorReader in project bioformats by openmicroscopy.

the class ImagePlusReader method readImages.

private List<ImagePlus> readImages(boolean thumbnail) throws FormatException, IOException {
    final ImporterOptions options = process.getOptions();
    final ImageProcessorReader reader = process.getReader();
    List<ImagePlus> imps = new ArrayList<ImagePlus>();
    // beginning timing
    startTiming();
    // read in each image series
    for (int s = 0; s < reader.getSeriesCount(); s++) {
        if (!options.isSeriesOn(s))
            continue;
        final ImagePlus imp = readImage(s, thumbnail);
        imps.add(imp);
    }
    // concatenate compatible images
    imps = concatenate(imps);
    // colorize images, as appropriate
    imps = applyColors(imps);
    // split dimensions, as appropriate
    imps = splitDims(imps);
    // when all image windows are closed, the Bio-Formats reader is closed
    if (options.isVirtual()) {
        process.getVirtualReader().setRefCount(imps.size());
    }
    // end timing
    finishTiming();
    return imps;
}
Also used : ImageProcessorReader(loci.plugins.util.ImageProcessorReader) ArrayList(java.util.ArrayList) VirtualImagePlus(loci.plugins.util.VirtualImagePlus) ImagePlus(ij.ImagePlus)

Example 18 with ImageProcessorReader

use of loci.plugins.util.ImageProcessorReader in project bioformats by openmicroscopy.

the class RangeDialog method constructDialog.

@Override
protected GenericDialog constructDialog() {
    ImageProcessorReader r = process.getReader();
    int seriesCount = process.getSeriesCount();
    // construct dialog
    GenericDialog gd = new GenericDialog("Bio-Formats Range Options");
    for (int s = 0; s < seriesCount; s++) {
        if (!options.isSeriesOn(s))
            continue;
        r.setSeries(s);
        gd.addMessage(process.getSeriesLabel(s).replaceAll("_", " "));
        String suffix = seriesCount > 1 ? "_" + (s + 1) : "";
        // if (r.isOrderCertain()) {
        if (r.getEffectiveSizeC() > 1) {
            gd.addNumericField("C_Begin" + suffix, process.getCBegin(s) + 1, 0);
            gd.addNumericField("C_End" + suffix, process.getCEnd(s) + 1, 0);
            gd.addNumericField("C_Step" + suffix, process.getCStep(s), 0);
        }
        if (r.getSizeZ() > 1) {
            gd.addNumericField("Z_Begin" + suffix, process.getZBegin(s) + 1, 0);
            gd.addNumericField("Z_End" + suffix, process.getZEnd(s) + 1, 0);
            gd.addNumericField("Z_Step" + suffix, process.getZStep(s), 0);
        }
        if (r.getSizeT() > 1) {
            gd.addNumericField("T_Begin" + suffix, process.getTBegin(s) + 1, 0);
            gd.addNumericField("T_End" + suffix, process.getTEnd(s) + 1, 0);
            gd.addNumericField("T_Step" + suffix, process.getTStep(s), 0);
        }
    // }
    // else {
    // gd.addNumericField("Begin" + suffix, process.getCBegin(s) + 1, 0);
    // gd.addNumericField("End" + suffix, process.getCEnd(s) + 1, 0);
    // gd.addNumericField("Step" + suffix, process.getCStep(s), 0);
    // }
    }
    WindowTools.addScrollBars(gd);
    return gd;
}
Also used : ImageProcessorReader(loci.plugins.util.ImageProcessorReader) GenericDialog(ij.gui.GenericDialog)

Example 19 with ImageProcessorReader

use of loci.plugins.util.ImageProcessorReader in project bioformats by openmicroscopy.

the class RangeDialog method needPrompt.

// -- ImporterDialog methods --
@Override
protected boolean needPrompt() {
    if (process.isWindowless() || !options.isSpecifyRanges())
        return false;
    ImageProcessorReader r = process.getReader();
    int seriesCount = process.getSeriesCount();
    int currentSeries = r.getSeries();
    for (int s = 0; s < seriesCount; s++) {
        r.setSeries(s);
        if (options.isSeriesOn(s) && r.getImageCount() > 1) {
            r.setSeries(currentSeries);
            return true;
        }
    }
    r.setSeries(currentSeries);
    return false;
}
Also used : ImageProcessorReader(loci.plugins.util.ImageProcessorReader)

Example 20 with ImageProcessorReader

use of loci.plugins.util.ImageProcessorReader in project bioformats by openmicroscopy.

the class RangeDialog method harvestResults.

@Override
protected boolean harvestResults(GenericDialog gd) {
    ImageProcessorReader r = process.getReader();
    int seriesCount = process.getSeriesCount();
    for (int s = 0; s < seriesCount; s++) {
        if (!options.isSeriesOn(s))
            continue;
        r.setSeries(s);
        int sizeC = r.getEffectiveSizeC();
        int sizeZ = r.getSizeZ();
        int sizeT = r.getSizeT();
        boolean certain = r.isOrderCertain();
        int cBegin = process.getCBegin(s);
        int cEnd = process.getCEnd(s);
        int cStep = process.getCStep(s);
        int zBegin = process.getZBegin(s);
        int zEnd = process.getZEnd(s);
        int zStep = process.getZStep(s);
        int tBegin = process.getTBegin(s);
        int tEnd = process.getTEnd(s);
        int tStep = process.getTStep(s);
        // if (certain) {
        if (r.getEffectiveSizeC() > 1) {
            cBegin = (int) gd.getNextNumber() - 1;
            cEnd = (int) gd.getNextNumber() - 1;
            cStep = (int) gd.getNextNumber();
        }
        if (r.getSizeZ() > 1) {
            zBegin = (int) gd.getNextNumber() - 1;
            zEnd = (int) gd.getNextNumber() - 1;
            zStep = (int) gd.getNextNumber();
        }
        if (r.getSizeT() > 1) {
            tBegin = (int) gd.getNextNumber() - 1;
            tEnd = (int) gd.getNextNumber() - 1;
            tStep = (int) gd.getNextNumber();
        }
        // }
        // else {
        // cBegin = (int) gd.getNextNumber() - 1;
        // cEnd = (int) gd.getNextNumber() - 1;
        // cStep = (int) gd.getNextNumber();
        // }
        int maxC = certain ? sizeC : r.getImageCount();
        if (cBegin < 0)
            cBegin = 0;
        if (cBegin >= maxC)
            cBegin = maxC - 1;
        if (cEnd < cBegin)
            cEnd = cBegin;
        if (cEnd >= maxC)
            cEnd = maxC - 1;
        if (cStep < 1)
            cStep = 1;
        if (zBegin < 0)
            zBegin = 0;
        if (zBegin >= sizeZ)
            zBegin = sizeZ - 1;
        if (zEnd < zBegin)
            zEnd = zBegin;
        if (zEnd >= sizeZ)
            zEnd = sizeZ - 1;
        if (zStep < 1)
            zStep = 1;
        if (tBegin < 0)
            tBegin = 0;
        if (tBegin >= sizeT)
            tBegin = sizeT - 1;
        if (tEnd < tBegin)
            tEnd = tBegin;
        if (tEnd >= sizeT)
            tEnd = sizeT - 1;
        if (tStep < 1)
            tStep = 1;
        options.setCBegin(s, cBegin);
        options.setCEnd(s, cEnd);
        options.setCStep(s, cStep);
        options.setZBegin(s, zBegin);
        options.setZEnd(s, zEnd);
        options.setZStep(s, zStep);
        options.setTBegin(s, tBegin);
        options.setTEnd(s, tEnd);
        options.setTStep(s, tStep);
    }
    return true;
}
Also used : ImageProcessorReader(loci.plugins.util.ImageProcessorReader)

Aggregations

ImageProcessorReader (loci.plugins.util.ImageProcessorReader)20 FormatException (loci.formats.FormatException)5 ImageProcessor (ij.process.ImageProcessor)4 LUT (ij.process.LUT)4 ImagePlus (ij.ImagePlus)3 GenericDialog (ij.gui.GenericDialog)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 VirtualImagePlus (loci.plugins.util.VirtualImagePlus)3 CompositeImage (ij.CompositeImage)2 ImageStack (ij.ImageStack)2 Color (java.awt.Color)2 ColorModel (java.awt.image.ColorModel)2 StatusEvent (loci.common.StatusEvent)2 ChannelFiller (loci.formats.ChannelFiller)2 ChannelSeparator (loci.formats.ChannelSeparator)2 DimensionSwapper (loci.formats.DimensionSwapper)2 MinMaxCalculator (loci.formats.MinMaxCalculator)2 IMetadata (loci.formats.meta.IMetadata)2 BFVirtualStack (loci.plugins.util.BFVirtualStack)2