Changeset 4203

Ignore:
Timestamp:
07/17/08 09:12:13 (12 years ago)
Message:

More cleanup. Removed some unused methods from ImageTools, and moved loci.formats.codec.AdobeDeflateCodec to loci.formats.codec.ZlibCodec.

Location:
trunk/loci/formats
Files:
1 deleted
13 edited

Unmodified
Removed
• trunk/loci/formats/ImageTools.java

 r4178 } /** Perform demosaicing on a byte array, assuming a {B, G, G, R} mosaic. */ public static short[][] demosaic(short[][] input, int w, int h) { for (int i=0; i= 0) { sum += (int) input[0][indices[j]]; count++; } } if (count > 0) { input[0][i] = (short) (sum / count); } } if (needsGreen) { int sum = 0; int count = 0; int[] indices = {i - w, i - 1, i + 1, i + w}; for (int j=0; j= 0) { sum += (int) input[1][indices[j]]; count++; } } if (count > 0) { input[1][i] = (short) (sum / count); } } if (needsBlue) { int sum = 0; int count = 0; int[] indices = null; if (!needsRed) { indices = new int[] {i - w - 1, i - w + 1, i + w - 1, i + w + 1}; } else if ((i / w) % 2 == 1) indices = new int[] {i - w, i + w}; else indices = new int[] {i - 1, i + 1}; for (int j=0; j= 0) { sum += (int) input[2][indices[j]]; count++; } } if (count > 0) { input[2][i] = (short) (sum / count); } } } // Before returning, perform convolution with a 5x5 pseudo-Gaussian filter. // This is *not* an optimal filter, but it works reasonably well. short[] newRed = new short[w * h]; short[] newGreen = new short[w * h]; short[] newBlue = new short[w * h]; float[][] kernel = new float[5][5]; kernel[0] = new float[] {0.458f, 0.823f, 1f, 0.823f, 0.458f}; kernel[1] = new float[] {0.823f, 1f, 1.09f, 1f, 0.823f}; kernel[2] = new float[] {1f, 1.09f, 1.135f, 1.09f, 1f}; kernel[3] = new float[] {0.823f, 1f, 1.09f, 1f, 0.823f}; kernel[4] = new float[] {0.458f, 0.823f, 1f, 0.823f, 0.458f}; for (int i=0; i 0) { int off = i*w + j + diff - 1; redRow += kernelRow[diff - 1] * input[0][off]; greenRow += kernelRow[diff - 1] * input[1][off]; blueRow += kernelRow[diff - 1] * input[2][off]; sum += kernelRow[diff - 1]; diff--; } } else { for (int m=0; m<5; m++) { int off = i*w + j + m; redRow += kernelRow[m] * input[0][off]; greenRow += kernelRow[m] * input[1][off]; blueRow += kernelRow[m] * input[2][off]; sum += kernelRow[m]; } } if (sum == 0) sum = 1; newRed[i*w + j] = (short) (redRow / sum); newGreen[i*w + j] = (short) (greenRow / sum); newBlue[i*w + j] = (short) (blueRow / sum); } } for (int i=0; i 0) { int off = (i + diff - 1) * w + j; redCol += kernelCol[diff - 1] * newRed[off]; greenCol += kernelCol[diff - 1] * newGreen[off]; blueCol += kernelCol[diff - 1] * newBlue[off]; sum += kernelCol[diff - 1]; diff--; } } else { for (int m=0; m<5; m++) { int off = (i + m) * w + j; redCol += kernelCol[m] * newRed[off]; greenCol += kernelCol[m] * newGreen[off]; blueCol += kernelCol[m] * newBlue[off]; sum += kernelCol[m]; } } if (sum == 0) sum = 1; input[0][i*w + j] = (short) (redCol / sum); input[1][i*w + j] = (short) (greenCol / sum); input[2][i*w + j] = (short) (blueCol / sum); } } return input; } /** Perform autoscaling on the given BufferedImage. */ public static BufferedImage autoscale(BufferedImage img) {
• trunk/loci/formats/TiffTools.java

 r4048 } else if (compression == PROPRIETARY_DEFLATE || compression == DEFLATE) { return new AdobeDeflateCodec().decompress(input); return new ZlibCodec().decompress(input); } else if (compression == THUNDERSCAN) {

 r4200 public short[][] get16BitLookupTable() { FormatTools.assertId(currentId, true, 1); return lut[lastChannel]; return lut == null ? null : lut[lastChannel]; } int[] coords = getZCTCoords(no); /* debug */ System.out.println("mapping channel " + coords[1] + " to " + channelIndexes[coords[1]]); coords[1] = channelIndexes[coords[1]]; lastChannel = coords[1]; // check that no two indexes are equal boolean valid = true; for (int i=0; i channelIndexes[q]) { channelIndexes[q] = channelIndexes[n]; } } channelIndexes[q]++; } } // normalize channel indexes to [0, sizeC-1] if (valid) { int nextIndex = 0; for (int i=0; i= nextIndex) { min = channelIndexes[q]; minIndex = q; } } channelIndexes[minIndex] = nextIndex++; } } else { for (int i=0; i= nextIndex) { min = channelIndexes[q]; minIndex = q; } } channelIndexes[minIndex] = nextIndex++; } // set up thumbnail file mapping RandomAccessStream thumb = getFile(thumbId); if (thumb != null) { try { RandomAccessStream thumb = getFile(thumbId); byte[] b = new byte[(int) thumb.length()]; thumb.read(b); Arrays.fill(core.thumbSizeY, thumbReader.getSizeY()); } catch (IOException e) { if (debug) LogTools.trace(e); } // initialize lookup table int count = (int) Math.min(core.sizeC[0], lutNames.size()); for (int c=0; c

 r4202 import loci.formats.meta.FilterMetadata; import loci.formats.meta.MetadataStore; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; /**
• trunk/loci/formats/in/LeicaHandler.java

 r4202 import loci.formats.*; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; case 4: ts.add(new Integer(len)); break; default: extras *= len;

 r4200 import java.io.IOException; import java.text.*; import java.util.*; import loci.formats.*; import loci.formats.meta.FilterMetadata; import loci.formats.meta.MetadataStore; /**

 r4202 import java.io.*; import java.util.*; import java.util.zip.*; import javax.xml.parsers.*; import loci.formats.*; import loci.formats.codec.ByteVector; import loci.formats.codec.JPEG2000Codec; import loci.formats.codec.*; import loci.formats.meta.FilterMetadata; import loci.formats.meta.MetadataStore; int effectiveX = getSizeX(); if ((getSizeX() % 2) != 0) effectiveX++; byte[] t = new byte[effectiveX * getSizeY() * pixel]; Inflater decompresser = new Inflater(); decompresser.setInput(b); try { decompresser.inflate(t); } catch (DataFormatException e) { throw new FormatException(e); } decompresser.end(); byte[] t = new ZlibCodec().decompress(b, null); for (int row=0; row

 r4202 import java.io.*; import java.util.*; import java.util.zip.*; import javax.xml.parsers.*; import loci.formats.*; import loci.formats.codec.Base64Codec; import loci.formats.codec.CBZip2InputStream; import loci.formats.codec.*; import loci.formats.meta.MetadataRetrieve; import loci.formats.meta.MetadataStore; } else if (compress.equals("zlib")) { try { Inflater decompressor = new Inflater(); decompressor.setInput(pixels, 0, pixels.length); pixels = new byte[planeSize]; decompressor.inflate(pixels); decompressor.end(); } catch (DataFormatException dfe) { throw new FormatException("Error uncompressing zlib data.", dfe); } pixels = new ZlibCodec().decompress(pixels, null); }

 r4202 import java.io.*; import java.util.Vector; import java.util.zip.*; import loci.formats.*; import loci.formats.codec.*; in.read(b); Inflater inf = new Inflater(); inf.setInput(b, 0, b.length); byte[] output = new byte[uncompressedSize]; try { inf.inflate(output); } catch (DataFormatException exc) { if (debug) trace(exc); throw new FormatException("Compressed header not supported."); } inf.end(); byte[] output = new ZlibCodec().decompress(b, null); RandomAccessStream oldIn = in;