Skip to content

Commit

Permalink
updated 16.12.2008 23:08
Browse files Browse the repository at this point in the history
  • Loading branch information
Wayne Rasband authored and dscho committed Dec 16, 2008
1 parent 1fef47f commit a2bd40f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 20 deletions.
Binary file removed ij.jar
Binary file not shown.
10 changes: 10 additions & 0 deletions ij/CompositeImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,16 @@ public void setChannelLut(LUT table) {
customLuts = true;
}

/* Sets the LUT of the specified channel using a clone of 'table'. */
public void setChannelLut(LUT table, int channel) {
int channels = getNChannels();
if (lut==null) setupLuts(channels);
if (channel<1 || channel>lut.length)
throw new IllegalArgumentException("Channel out of range");
lut[channel-1] = (LUT)table.clone();
cip = null;
}

/* Sets the IndexColorModel of the current channel. */
public void setChannelColorModel(IndexColorModel cm) {
byte[] reds = new byte[256];
Expand Down
13 changes: 6 additions & 7 deletions ij/VirtualStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

/** This class represents an array of disk-resident images. */
public class VirtualStack extends ImageStack {
static final int INITIAL_SIZE = 100;
String path;
int nSlices;
String[] names;
String[] labels;
int bitDepth;
private static final int INITIAL_SIZE = 100;
private String path;
private int nSlices;
private String[] names;
private String[] labels;
private int bitDepth;

/** Default constructor. */
public VirtualStack() { }
Expand Down Expand Up @@ -167,6 +167,5 @@ public void setBitDepth(int bitDepth) {
this.bitDepth = bitDepth;
}


}

3 changes: 1 addition & 2 deletions ij/io/TiffDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ else if (value==2) {
} else if (value==3)
fi.unit = "cm";
break;
case PLANAR_CONFIGURATION:
case PLANAR_CONFIGURATION: // 1=chunky, 2=planar
if (value==2 && fi.fileType==FileInfo.RGB48)
fi.fileType = FileInfo.GRAY16_UNSIGNED;
else if (value==2 && fi.fileType==FileInfo.RGB)
Expand All @@ -440,7 +440,6 @@ else if (value==1 && fi.samplesPerPixel==4)
fi.fileType = FileInfo.ARGB;
else if (value!=2 && !((fi.samplesPerPixel==1)||(fi.samplesPerPixel==3))) {
String msg = "Unsupported interleaved SamplesPerPixel: " + fi.samplesPerPixel;
//if (fi.samplesPerPixel==4) msg += " \n \n" + "ImageJ cannot open CMYK TIFFs";
error(msg);
}
break;
Expand Down
16 changes: 9 additions & 7 deletions ij/plugin/FITS_Writer.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
/**
* This plugin saves a 16 or 32 bit image in FITS format. It is a stripped-down version of the SaveAs_FITS
* plugin from the collection of astronomical image processing plugins by Jennifer West at
* http://www.umanitoba.ca/faculties/science/astronomy/jwest/plugins.html
* http://www.umanitoba.ca/faculties/science/astronomy/jwest/plugins.html.
*
* Version 2008-09-07 : preserves non-minimal FITS header if already present (F.V. Hessman, Univ. Goettingen)
* <br>Version 2008-09-07 : preserves non-minimal FITS header if already present (F.V. Hessman, Univ. Goettingen).
* <br>Version 2008-12-15 : fixed END card recognition bug (F.V. Hessman, Univ. Goettingen).
*/
public class FITS_Writer implements PlugIn {

Expand Down Expand Up @@ -68,7 +69,7 @@ else if (ip instanceof FloatProcessor)
void createHeader(String path, ImageProcessor ip, int numBytes) {
int numCards = 5;
String bitperpix = "";
if (numBytes==2) {bitperpix = " 16";}
if (numBytes==2) {bitperpix = " 16";}
else if (numBytes==4) {bitperpix = " -32";}
else if (numBytes==1) {bitperpix = " 8";}
appendFile(writeCard("SIMPLE", " T", "Created by ImageJ FITS_Writer 2008-09-07"), path);
Expand Down Expand Up @@ -202,7 +203,8 @@ else if (depth > 1) {

int iend = istart+1;
for (; iend < lines.length; iend++) {
if ( lines[iend].startsWith ("END ") ) break;
String s = lines[iend].trim();
if ( s.equals ("END") || s.startsWith ("END ") ) break;
}
if (iend >= lines.length) return null;

Expand Down Expand Up @@ -235,10 +237,10 @@ void copyHeader(String[] hdr, String path, ImageProcessor ip, int numBytes) {
String bitperpix = "";

// THIS STUFF NEEDS TO BE MADE CONFORMAL WITH THE PRESENT IMAGE
if (numBytes==2) {bitperpix = " 16";}
if (numBytes==2) {bitperpix = " 16";}
else if (numBytes==4) {bitperpix = " -32";}
else if (numBytes==1) {bitperpix = " 8";}
appendFile(writeCard("SIMPLE", " T", "Created by ImageJ FITS_Writer 2008-09-07"), path);
appendFile(writeCard("SIMPLE", " T", "Created by ImageJ FITS_Writer 2008-12-15"), path);
appendFile(writeCard("BITPIX", bitperpix, ""), path);
appendFile(writeCard("NAXIS", " 2", ""), path);
appendFile(writeCard("NAXIS1", " "+ip.getWidth(), "image width"), path);
Expand Down Expand Up @@ -269,6 +271,6 @@ void copyHeader(String[] hdr, String path, ImageProcessor ip, int numBytes) {
appendFile(end, path);
appendFile(filler, path);
}

}

20 changes: 16 additions & 4 deletions ij/plugin/HyperStackConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class HyperStackConverter implements PlugIn {
static final int CZT=0, CTZ=1, ZCT=2, ZTC=3, TCZ=4, TZC=5;
static final String[] orders = {"xyczt(default)", "xyctz", "xyzct", "xyztc", "xytcz", "xytzc"};
static int order = CZT;
static boolean splitRGB = true;

public void run(String arg) {
if (arg.equals("new"))
Expand All @@ -38,24 +39,35 @@ void convertStackToHS(ImagePlus imp) {
IJ.error("Stack to HyperStack", "Stack required");
return;
}
if (imp.getBitDepth()==24) {
new CompositeConverter().run("color");
return;
}
boolean rgb = imp.getBitDepth()==24;
String[] modes = {"Composite", "Color", "Grayscale"};
GenericDialog gd = new GenericDialog("Convert to HyperStack");
gd.addChoice("Order:", orders, orders[order]);
gd.addNumericField("Channels (c):", nChannels, 0);
gd.addNumericField("Slices (z):", nSlices, 0);
gd.addNumericField("Frames (t):", nFrames, 0);
gd.addChoice("Display Mode:", modes, modes[1]);
if (rgb) {
gd.setInsets(15, 0, 0);
gd.addCheckbox("Convert RGB to 3 Channel Hyperstack", splitRGB);
}
gd.showDialog();
if (gd.wasCanceled()) return;
order = gd.getNextChoiceIndex();
nChannels = (int) gd.getNextNumber();
nSlices = (int) gd.getNextNumber();
nFrames = (int) gd.getNextNumber();
int mode = gd.getNextChoiceIndex();
if (rgb)
splitRGB = gd.getNextBoolean();
if (rgb && splitRGB==true) {
new CompositeConverter().run(mode==0?"composite":"color");
return;
}
if (rgb && nChannels>1) {
IJ.error("HyperStack Converter", "RGB stacks are limited to one channel");
return;
}
if (nChannels*nSlices*nFrames!=stackSize) {
IJ.error("HyperStack Converter", "channels x slices x frames <> stack size");
return;
Expand Down

0 comments on commit a2bd40f

Please sign in to comment.