NOTICE! This is a static HTML version of a legacy ImageJ Trac ticket.

The ImageJ project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Ticket #930 (closed defect: fixed)

Opened 2012-02-02T12:06:03-06:00

Last modified 2012-02-13T16:40:54-06:00

Verify multichannel ImagePluses of type COLOR_RGB are supported

Reported by: bdezonia Owned by: bdezonia
Priority: major Milestone: imagej2-b1-initial
Component: Legacy Compatibility Version:
Severity: serious Keywords:
Cc: Blocked By:
Blocking:

Description

Before the major refactor of the legacy layer I think there code was in place to support the synchronization of multichannel ImagePluses whose planes were COLOR_RGB data. Looking now I can't tell if that is indeed the case. Make sure that this kind of data is kept in synch across the legacy layer.

Change History

comment:1 Changed 2012-02-02T13:38:14-06:00 by bdezonia

The following plugin could help test this. It modifies an existing image to become multichannel color. It was meant to be run when Boats was first loaded.

Also create a related plugin that just creates a new multichannel color image and does imp.show() on it to simulate new creations of this kind of data.

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import ij.plugin.frame.*;

public class ChangeCurrImpToMultichannelColorImpPlugin implements PlugIn {

private final int X = 720;
private final int Y = 576;

public void run(String arg) {

ImagePlus currImp = WindowManager.getCurrentImage();
ImageStack stack = new ImageStack(X,Y,null);
stack.addSlice("0",plane(0));
stack.addSlice("1",plane(1));
stack.addSlice("2",plane(2));
currImp.setStack(stack);
System.out.println("is color = " + (currImp.getType()==ImagePlus.COLOR_RGB));
System.out.println(" num chan = " + currImp.getNChannels());

}

private int[] plane(int channel) {

int[] plane = new int[X * Y];
int pixelVal = (0xff << 24) | (0xff << (channel*8));
for (int i = 0; i < plane.length; i++)

plane[i] = pixelVal;

return plane;

}

}

comment:2 Changed 2012-02-13T15:56:15-06:00 by bdezonia

The above plugin runs correctly.

Still the code logic needs to be inspected to make sure we support multichannel color rgb ImagePluses correctly.

comment:3 Changed 2012-02-13T16:33:14-06:00 by bdezonia

The run() method of the plugin before did not setDimensions(). I've fixed it below. The 3 RGB planes come in as 9 ubyte planes. That is correct.

Will continue to look at logic otherwise.

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import ij.plugin.frame.*;

public class ChangeCurrImpToMultichannelColorImpPlugin implements PlugIn {

private final int X = 720;
private final int Y = 576;

public void run(String arg) {

ImagePlus currImp = WindowManager.getCurrentImage();
ImageStack stack = new ImageStack(X,Y,null);
stack.addSlice("0",plane(0));
stack.addSlice("1",plane(1));
stack.addSlice("2",plane(2));
currImp.setStack(stack);

currImp.setDimensions(3,1,1);

System.out.println("is color = " + (currImp.getType()==ImagePlus.COLOR_RGB));
System.out.println(" num chan = " + currImp.getNChannels());

}

private int[] plane(int channel) {

int[] plane = new int[X * Y];
int pixelVal = (0xff << 24) | (0xff << (channel*8));
for (int i = 0; i < plane.length; i++)

plane[i] = pixelVal;

return plane;

}

}

comment:4 Changed 2012-02-13T16:40:34-06:00 by bdezonia

  • Status changed from new to closed
  • Resolution set to fixed

Logic looks good.

comment:5 Changed 2012-02-13T16:40:54-06:00 by bdezonia

  • Milestone changed from imagej-2.0-beta2 to imagej-2.0-beta1