Search in sources :

Example 1 with ColorTable

use of net.imglib2.display.ColorTable in project imagej-ui-swing by imagej.

the class SwingImageDisplayPanel method updateColorBar.

private void updateColorBar(final int c) {
    final DatasetView view = imageDisplayService.getActiveDatasetView(display);
    // no active dataset
    if (view == null)
        return;
    List<ColorTable> colorTables = view.getColorTables();
    if (c >= colorTables.size())
        return;
    final ColorTable lut = colorTables.get(c);
    colorBar.setColorTable(lut);
    colorBar.repaint();
}
Also used : DatasetView(net.imagej.display.DatasetView) ColorTable(net.imglib2.display.ColorTable)

Example 2 with ColorTable

use of net.imglib2.display.ColorTable in project imagej-ui-swing by imagej.

the class SwingColorTableWidget method doRefresh.

// -- AbstractUIInputWidget methods ---
@Override
public void doRefresh() {
    ColorTable colorTable = getValue();
    fillImage(colorTable);
    picLabel.setIcon(new ImageIcon(image));
    picLabel.repaint();
}
Also used : ImageIcon(javax.swing.ImageIcon) ColorTable(net.imglib2.display.ColorTable)

Example 3 with ColorTable

use of net.imglib2.display.ColorTable in project imagej-ui-swing by imagej.

the class SwingColorBar method main.

// -- Main method --
public static void main(final String[] args) {
    final ColorTable[] luts = { ColorTables.FIRE, ColorTables.ICE, ColorTables.SPECTRUM, ColorTables.RED, ColorTables.GREEN, ColorTables.BLUE, ColorTables.CYAN, ColorTables.MAGENTA, ColorTables.YELLOW, ColorTables.GRAYS, ColorTables.REDGREEN, ColorTables.RGB332 };
    final JFrame frame = new JFrame();
    frame.setTitle("LUTs");
    final JPanel pane = new JPanel();
    frame.setContentPane(pane);
    pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    for (final ColorTable lut : luts) {
        final SwingColorBar colorBar = new SwingColorBar(lut);
        colorBar.setBorder(new LineBorder(Color.black));
        pane.add(colorBar);
    }
    frame.pack();
    frame.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) JFrame(javax.swing.JFrame) ColorTable(net.imglib2.display.ColorTable) BoxLayout(javax.swing.BoxLayout) LineBorder(javax.swing.border.LineBorder)

Example 4 with ColorTable

use of net.imglib2.display.ColorTable in project imagej-plugins-commands by imagej.

the class FlipAxis method swapColorTables.

// NB - this is one approach to swapping color tables. Ideally when the
// metadata branch is merged Axes can be tagged with color tables and Views
// will automatically return the right one. Then we can use the setImg() of
// the inverted view of the axis and color tables will auto remap.
private void swapColorTables() {
    if (axisType == Axes.X || axisType == Axes.Y)
        return;
    long numPlanes = numPlanes(dataset);
    if (dataset.getColorTableCount() != numPlanes)
        return;
    for (int i = 0; i < (numPlanes / 2) - 1; i++) {
        int partner = findPartner(i);
        if (partner != i) {
            ColorTable table = dataset.getColorTable(i);
            dataset.setColorTable(dataset.getColorTable(partner), i);
            dataset.setColorTable(table, partner);
        }
    }
}
Also used : ColorTable(net.imglib2.display.ColorTable)

Example 5 with ColorTable

use of net.imglib2.display.ColorTable in project imagej-plugins-commands by imagej.

the class ReorderAxis method newData.

private ImgPlus<? extends RealType<?>> newData() {
    DatasetView view = imageDisplayService.getActiveDatasetView(display);
    ColorTable[] origTable = origViewTables(view);
    double[] origMin = origDisplayMins(view);
    double[] origMax = origDisplayMaxes(view);
    Dataset newData = dataset.duplicate();
    int[] positions = newPositions();
    int tableCount = dataset.getColorTableCount();
    for (int i = 0; i < positions.length; i++) {
        copyHypersliceData(axisNum, dataset, positions[i], newData, i);
        if (channelsCase) {
            // set dataset color table
            ColorTable table = dataset.getColorTable(positions[i]);
            if (i < tableCount)
                newData.setColorTable(table, i);
            // set view color table
            view.setColorTable(origTable[positions[i]], i);
            // set display range
            view.setChannelRange(i, origMin[positions[i]], origMax[positions[i]]);
        }
    }
    return newData.getImgPlus();
}
Also used : DatasetView(net.imagej.display.DatasetView) ColorTable(net.imglib2.display.ColorTable) Dataset(net.imagej.Dataset)

Aggregations

ColorTable (net.imglib2.display.ColorTable)11 DatasetView (net.imagej.display.DatasetView)4 Dataset (net.imagej.Dataset)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 URL (java.net.URL)1 BoxLayout (javax.swing.BoxLayout)1 ImageIcon (javax.swing.ImageIcon)1 JFrame (javax.swing.JFrame)1 JPanel (javax.swing.JPanel)1 LineBorder (javax.swing.border.LineBorder)1 Position (net.imagej.Position)1 LUTService (net.imagej.lut.LUTService)1 DefaultResultsTable (net.imagej.table.DefaultResultsTable)1 ColorTable8 (net.imglib2.display.ColorTable8)1 ColorRGB (org.scijava.util.ColorRGB)1 Document (org.w3c.dom.Document)1 NodeList (org.w3c.dom.NodeList)1