Search in sources :

Example 6 with ImageProcessorReader

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

the class ImagePlusReader method createVirtualStack.

private ImageStack createVirtualStack(ImportProcess process, int s, List<LUT> luts) throws FormatException, IOException {
    final ImporterOptions options = process.getOptions();
    final ImageProcessorReader reader = process.getReader();
    reader.setSeries(s);
    final int zCount = process.getZCount(s);
    final int cCount = process.getCCount(s);
    final int tCount = process.getTCount(s);
    final IMetadata meta = process.getOMEMetadata();
    final int imageCount = reader.getImageCount();
    // CTR FIXME: Make virtual stack work with different color modes?
    final BFVirtualStack virtualStack = new BFVirtualStack(options.getId(), reader, false, false, false);
    for (int i = 0; i < imageCount; i++) {
        String label = constructSliceLabel(i, reader, meta, s, zCount, cCount, tCount);
        virtualStack.addSlice(label);
    }
    if (luts != null) {
        for (int c = 0; c < cCount; c++) {
            int index = reader.getIndex(0, c, 0);
            ImageProcessor ip = reader.openProcessors(index)[0];
            final ColorModel cm = ip.getColorModel();
            final LUT lut = cm instanceof LUT ? (LUT) cm : null;
            luts.add(lut);
        }
    }
    return virtualStack;
}
Also used : ImageProcessor(ij.process.ImageProcessor) IMetadata(loci.formats.meta.IMetadata) ImageProcessorReader(loci.plugins.util.ImageProcessorReader) ColorModel(java.awt.image.ColorModel) LUT(ij.process.LUT) BFVirtualStack(loci.plugins.util.BFVirtualStack)

Example 7 with ImageProcessorReader

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

the class ColorDialog method constructDialog.

@Override
protected GenericDialog constructDialog() {
    GenericDialog gd = new GenericDialog("Bio-Formats Custom Colorization");
    // CTR FIXME - avoid problem with MAX_SLIDERS in GenericDialog
    final ImageProcessorReader reader = process.getReader();
    final List<Panel> swatches = new ArrayList<Panel>();
    for (int s = 0; s < process.getSeriesCount(); s++) {
        if (!options.isSeriesOn(s))
            continue;
        reader.setSeries(s);
        for (int c = 0; c < reader.getSizeC(); c++) {
            Color color = options.getCustomColor(s, c);
            if (color == null)
                color = options.getDefaultCustomColor(c);
            gd.addSlider(makeLabel("Red:", s, c), 0, 255, color.getRed());
            gd.addSlider(makeLabel("Green:", s, c), 0, 255, color.getGreen());
            gd.addSlider(makeLabel("Blue:", s, c), 0, 255, color.getBlue());
            Panel swatch = createSwatch(color);
            gd.addPanel(swatch, GridBagConstraints.CENTER, new Insets(5, 0, 5, 0));
            swatches.add(swatch);
        }
    }
    // change swatch colors when sliders move
    List<TextField> colorFields = getNumericFields(gd);
    attachListeners(colorFields, swatches);
    WindowTools.addScrollBars(gd);
    return gd;
}
Also used : Panel(java.awt.Panel) Insets(java.awt.Insets) ImageProcessorReader(loci.plugins.util.ImageProcessorReader) GenericDialog(ij.gui.GenericDialog) Color(java.awt.Color) ArrayList(java.util.ArrayList) TextField(java.awt.TextField)

Example 8 with ImageProcessorReader

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

the class ColorDialog method harvestResults.

@Override
protected boolean harvestResults(GenericDialog gd) {
    final ImageProcessorReader reader = process.getReader();
    for (int s = 0; s < process.getSeriesCount(); s++) {
        if (!options.isSeriesOn(s))
            continue;
        reader.setSeries(s);
        for (int c = 0; c < reader.getSizeC(); c++) {
            int red = (int) gd.getNextNumber();
            int green = (int) gd.getNextNumber();
            int blue = (int) gd.getNextNumber();
            Color color = new Color(red, green, blue);
            options.setCustomColor(s, c, color);
        }
    }
    return true;
}
Also used : ImageProcessorReader(loci.plugins.util.ImageProcessorReader) Color(java.awt.Color)

Example 9 with ImageProcessorReader

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

the class ImportProcess method initializeStack.

/**
 * Performed following ImportStep.STACK notification.
 */
private void initializeStack() throws FormatException, IOException {
    IFormatReader r = baseReader;
    if (options.isGroupFiles()) {
        r = fileStitcher = new FileStitcher(baseReader);
        // overwrite base filename with file pattern
        String id = options.getId();
        fileStitcher.setId(id);
        fileStitcher.setUsingPatternIds(true);
        fileStitcher.setCanChangePattern(false);
    }
    r.setId(options.getId());
    if (options.isGroupFiles()) {
        options.setId(fileStitcher.getFilePattern().getPattern());
    }
    final byte[][] lut8 = r.get8BitLookupTable();
    final int sizeC = r.getSizeC();
    r = channelFiller = new ChannelFiller(r);
    if (channelFiller.isFilled()) {
        BF.warn(options.isQuiet(), getIdName() + ": index values will be lost");
    }
    r = channelSeparator = new ChannelSeparator(r);
    r = dimensionSwapper = new DimensionSwapper(r);
    if (options.isAutoscale() || FormatTools.isFloatingPoint(r)) {
        r = minMaxCalculator = new MinMaxCalculator(r);
    }
    if (options.doStitchTiles()) {
        r = tileStitcher = new TileStitcher(r);
    }
    r = virtualReader = new VirtualReader(r);
    reader = new ImageProcessorReader(r);
    if (options != null && !options.showROIs()) {
        baseReader.getMetadataOptions().setMetadataLevel(MetadataLevel.NO_OVERLAYS);
    }
    setId();
    computeSeriesLabels(reader);
}
Also used : IFormatReader(loci.formats.IFormatReader) FileStitcher(loci.formats.FileStitcher) ImageProcessorReader(loci.plugins.util.ImageProcessorReader) MinMaxCalculator(loci.formats.MinMaxCalculator) DimensionSwapper(loci.formats.DimensionSwapper) TileStitcher(loci.formats.TileStitcher) ChannelFiller(loci.formats.ChannelFiller) VirtualReader(loci.plugins.util.VirtualReader) ChannelSeparator(loci.formats.ChannelSeparator)

Example 10 with ImageProcessorReader

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

the class SwapDialog method constructDialog.

@Override
protected GenericDialog constructDialog() {
    ImageProcessorReader reader = process.getReader();
    int seriesCount = process.getSeriesCount();
    GenericDialog gd = new GenericDialog("Dimension swapping options");
    String[] labels = { "Z", "C", "T" };
    for (int s = 0; s < seriesCount; s++) {
        if (!options.isSeriesOn(s))
            continue;
        reader.setSeries(s);
        String[] sizes = new String[] { String.valueOf(reader.getSizeZ()), String.valueOf(reader.getSizeC()), String.valueOf(reader.getSizeT()) };
        gd.addMessage("Series " + (s + 1) + ":\n");
        for (int i = 0; i < labels.length; i++) {
            gd.addChoice(labels[i] + "_" + (s + 1), sizes, sizes[i]);
        }
    }
    List<Choice> choices = WindowTools.getChoices(gd);
    zChoice = choices.get(0);
    cChoice = choices.get(1);
    tChoice = choices.get(2);
    zChoice.addItemListener(this);
    cChoice.addItemListener(this);
    tChoice.addItemListener(this);
    WindowTools.addScrollBars(gd);
    return gd;
}
Also used : Choice(java.awt.Choice) ImageProcessorReader(loci.plugins.util.ImageProcessorReader) GenericDialog(ij.gui.GenericDialog)

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