@@ -105,6 +105,35 @@ private String getNameFromWavelength(Double value)
105
105
return value .toString ();
106
106
}
107
107
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
+
108
137
/**
109
138
* Populates the default color for the channel if one does not already
110
139
* exist.
@@ -119,6 +148,7 @@ private void populateDefault(ChannelData channelData,
119
148
int channelIndex = channelData .getChannelIndex ();
120
149
Channel channel = channelData .getChannel ();
121
150
LogicalChannel lc = channelData .getLogicalChannel ();
151
+ int [] defaultColor ;
122
152
if (isGraphicsDomain )
123
153
{
124
154
log .debug ("Setting color channel to RGB." );
@@ -162,6 +192,7 @@ private void populateDefault(ChannelData channelData,
162
192
}
163
193
return ;
164
194
}
195
+ //not set by
165
196
//First we check the emission wavelength.
166
197
Double valueWavelength = getValue (lc .getEmissionWave ());
167
198
if (valueWavelength != null ) {
@@ -484,22 +515,27 @@ public void process(IObjectContainerStore store)
484
515
//Think of strategy for images with high number of channels
485
516
//i.e. > 6
486
517
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
+ }
503
539
}
504
540
505
541
//Need to reset the color of transmitted light
0 commit comments