Skip to content

Commit

Permalink
Better indexed color logic; still broken in various cases though.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrueden committed Jun 2, 2010
1 parent f7df373 commit 9d31f0f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
15 changes: 12 additions & 3 deletions components/loci-plugins/src/loci/plugins/in/ImagePlusReader.java
Expand Up @@ -306,11 +306,20 @@ private List<ImagePlus> concatenate(List<ImagePlus> imps) {
private List<ImagePlus> applyColors(List<ImagePlus> imps) {
final ImporterOptions options = process.getOptions();

// CTR FIXME - problems with single channel data
// CTR FIXME - problems with sizeC > 7
// CTR FIXME - problems with default color mode
int mode = -1;
if (options.isColorModeComposite()) mode = CompositeImage.COMPOSITE;
int sizeC = process.getReader().getSizeC();
if (sizeC == 1) {
// NB: Cannot use CompositeImage for single-channel images.
// CTR FIXME finish sizeC==1 case
loci.plugins.BF.warn(options.isQuiet(), "sizeC = 1");//TEMP
}
else if (sizeC > 7) {
// NB: Cannot use CompositeImage when there are more than seven channels.
// CTR FIXME finish sizeC>7 case
loci.plugins.BF.warn(options.isQuiet(), "sizeC > 7");//TEMP
}
else if (options.isColorModeComposite()) mode = CompositeImage.COMPOSITE;
else if (options.isColorModeColorized()) mode = CompositeImage.COLOR;
else if (options.isColorModeGrayscale()) mode = CompositeImage.GRAYSCALE;
else if (options.isColorModeCustom()) mode = CompositeImage.COLOR;
Expand Down
27 changes: 19 additions & 8 deletions components/loci-plugins/src/loci/plugins/in/ImportProcess.java
Expand Up @@ -415,24 +415,35 @@ private void initializeStack() throws FormatException, IOException {
}
r.setId(options.getId());

boolean fillIndexed;
final boolean fillIndexed;
if (r.isIndexed()) {
final int bpp = FormatTools.getBytesPerPixel(r.getPixelType());
final byte[][] lut8 = r.get8BitLookupTable();
final boolean defaultColorMode = options.isColorModeDefault();

// NB: ImageJ only supports 8-bit RGB color tables.
// In addition, we only keep the indices in default color mode.
final boolean keepColorTable = defaultColorMode &&
bpp == 1 && lut8 != null && lut8.length >= 1 && lut8.length <= 3;

if (r.isFalseColor()) {
// false color; never fill indices
// false color; never fill the indices
fillIndexed = false;
if (!keepColorTable) {
// warn the user that we'll have to throw away the color table
BF.warn(options.isQuiet(),
"false color table will be lost: " + getIdName());
}
}
else {
// true color; fill indices unless 8-bit RGB with default color mode
int bpp = FormatTools.getBytesPerPixel(r.getPixelType());
byte[][] lut8 = r.get8BitLookupTable();
boolean defaultColorMode = options.isColorModeDefault();
fillIndexed = !defaultColorMode || bpp > 1 || lut8 == null || lut8[0].length > 3;
// true color; if we can't keep the color table, then fill the indices
fillIndexed = !keepColorTable;
}
}
else fillIndexed = false; // no need to fill non-indexed data
if (fillIndexed) {
r = channelFiller = new ChannelFiller(r);
BF.warn(options.isQuiet(), "Index values will be lost");
BF.warn(options.isQuiet(), "index values will be lost: " + getIdName());
}

r = channelSeparator = new ChannelSeparator(r);
Expand Down

0 comments on commit 9d31f0f

Please sign in to comment.