Skip to content

Commit 0206542

Browse files
committed
Merge pull request #3140 from jburel/rnd-one-channel
Set the color to grey if one channel.
2 parents 89679e0 + 696b785 commit 0206542

File tree

1 file changed

+52
-16
lines changed

1 file changed

+52
-16
lines changed

Diff for: components/blitz/src/ome/formats/model/ChannelProcessor.java

+52-16
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,35 @@ private String getNameFromWavelength(Double value)
105105
return value.toString();
106106
}
107107

108+
/**
109+
* Sets the default color if it is a single channel image.
110+
*
111+
* @param channelData Channel data to use to set the color.
112+
*/
113+
private void setSingleChannel(ChannelData channelData)
114+
{
115+
int channelIndex = channelData.getChannelIndex();
116+
Channel channel = channelData.getChannel();
117+
Integer red = getValue(channel.getRed());
118+
Integer green = getValue(channel.getGreen());
119+
Integer blue = getValue(channel.getBlue());
120+
Integer alpha = getValue(channel.getAlpha());
121+
RString name;
122+
//color already set by Bio-formats
123+
if (red != null && green != null && blue != null && alpha != null) {
124+
return;
125+
}
126+
int[] defaultColor = ColorsFactory.newGreyColor();
127+
channel.setRed(
128+
rint(defaultColor[ColorsFactory.RED_INDEX]));
129+
channel.setGreen(
130+
rint(defaultColor[ColorsFactory.GREEN_INDEX]));
131+
channel.setBlue(
132+
rint(defaultColor[ColorsFactory.BLUE_INDEX]));
133+
channel.setAlpha(
134+
rint(defaultColor[ColorsFactory.ALPHA_INDEX]));
135+
}
136+
108137
/**
109138
* Populates the default color for the channel if one does not already
110139
* exist.
@@ -119,6 +148,7 @@ private void populateDefault(ChannelData channelData,
119148
int channelIndex = channelData.getChannelIndex();
120149
Channel channel = channelData.getChannel();
121150
LogicalChannel lc = channelData.getLogicalChannel();
151+
int[] defaultColor;
122152
if (isGraphicsDomain)
123153
{
124154
log.debug("Setting color channel to RGB.");
@@ -162,6 +192,7 @@ private void populateDefault(ChannelData channelData,
162192
}
163193
return;
164194
}
195+
//not set by
165196
//First we check the emission wavelength.
166197
Double valueWavelength = getValue(lc.getEmissionWave());
167198
if (valueWavelength != null) {
@@ -484,22 +515,27 @@ public void process(IObjectContainerStore store)
484515
//Think of strategy for images with high number of channels
485516
//i.e. > 6
486517
sizeC = pixels.getSizeC().getValue();
487-
for (int c = 0; c < sizeC; c++)
488-
{
489-
channelData = ChannelData.fromObjectContainerStore(store, i, c);
490-
//Color section
491-
populateDefault(channelData, isGraphicsDomain);
492-
493-
//only retrieve if not graphics
494-
if (!isGraphicsDomain) {
495-
//Determine if the channel same emission wavelength.
496-
v = ColorsFactory.hasEmissionData(channelData);
497-
if (!v)
498-
{
499-
count++;
500-
}
501-
m.put(channelData, v);
502-
}
518+
if (sizeC == 1) {
519+
channelData = ChannelData.fromObjectContainerStore(store, i, 0);
520+
setSingleChannel(channelData);
521+
} else {
522+
for (int c = 0; c < sizeC; c++)
523+
{
524+
channelData = ChannelData.fromObjectContainerStore(store, i, c);
525+
//Color section
526+
populateDefault(channelData, isGraphicsDomain);
527+
528+
//only retrieve if not graphics
529+
if (!isGraphicsDomain) {
530+
//Determine if the channel same emission wavelength.
531+
v = ColorsFactory.hasEmissionData(channelData);
532+
if (!v)
533+
{
534+
count++;
535+
}
536+
m.put(channelData, v);
537+
}
538+
}
503539
}
504540

505541
//Need to reset the color of transmitted light

0 commit comments

Comments
 (0)