ome.units.quantity.Length Java Examples

The following examples show how to use ome.units.quantity.Length. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommonFunctions.java    From Stitching with GNU General Public License v2.0 5 votes vote down vote up
private static double getPosition( final Length planePos, final Length stageLabel, final boolean invert )
{
	// check plane position
	if ( planePos != null )
		return invert ? -planePos.value().doubleValue() : planePos.value().doubleValue();

	// check global stage label
	if ( stageLabel != null )
		return invert ? -stageLabel.value().doubleValue() : stageLabel.value().doubleValue();

	return 0;
}
 
Example #2
Source File: OrbitImageBioformats.java    From orbit-image-analysis with GNU General Public License v3.0 4 votes vote down vote up
public Length getPixelsPhysicalSizeX() {
    return pixelsPhysicalSizeX;
}
 
Example #3
Source File: NDPISReaderOrbit.java    From orbit-image-analysis with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void initFile(String id) throws FormatException, IOException {
    super.initFile(id);

    Location parent = new Location(id).getAbsoluteFile().getParentFile();

    String[] lines = DataTools.readFile(currentId).split("\r\n");

    for (String line : lines) {
        int eq = line.indexOf('=');
        if (eq < 0) {
            continue;
        }
        String key = line.substring(0, eq).trim();
        String value = line.substring(eq + 1).trim();

        if (key.equals("NoImages")) {
            ndpiFiles = new String[Integer.parseInt(value)];
            readers = new NDPIReader[ndpiFiles.length];

        }
        else if (key.startsWith("Image")) {
            int index = Integer.parseInt(key.replaceAll("Image", ""));
            ndpiFiles[index] = new Location(parent, value).getAbsolutePath();
            readers[index] = new NDPIReader();
            readers[index].setFlattenedResolutions(hasFlattenedResolutions());
        }
    }

    readers[0].setMetadataStore(getMetadataStore());
    readers[0].setId(ndpiFiles[0]);

    core = new ArrayList<CoreMetadata>(readers[0].getCoreMetadataList());
    for (int i=0; i<core.size(); i++) {
        CoreMetadata ms = core.get(i);
        ms.sizeC = readers.length;
        ms.rgb = false;
        ms.imageCount = ms.sizeC * ms.sizeZ * ms.sizeT;
    }

    samplesPerPixel = new int[ndpiFiles.length];
    bandUsed = new int[ndpiFiles.length];
    MetadataStore store = makeFilterMetadata();
    IFD ifd;
    for (int c=0; c<readers.length; c++) {     // populate channel names based on IFD entry
        if (c>0) // 0 is already open
            readers[c].setId(ndpiFiles[c]);
        try (RandomAccessInputStream in = new RandomAccessInputStream(ndpiFiles[c])) {
            TiffParser tp = new TiffParser(in);
            ifd = tp.getIFDs().get(0);
        }
        samplesPerPixel[c] = ifd.getSamplesPerPixel();
        String channelName = ifd.getIFDStringValue(TAG_CHANNEL);
        Float wavelength = (Float) ifd.getIFDValue(TAG_EMISSION_WAVELENGTH);
        store.setChannelName(channelName, getSeries(), c);
        store.setChannelEmissionWavelength(new Length(wavelength, UNITS.NANOMETER),getSeries(), c);

        bandUsed[c] = 0;
        if (samplesPerPixel[c]>=3) {
            // define band used based on emission wavelength
            // wavelength = 0  Colour Image
            // 380 =< wavelength <= 490 Blue
            // 490 < wavelength <= 580 Green
            // 580 < wavelength <= 780 Red
            bandUsed[c] = 0;
            if (380 < wavelength && wavelength <= 490) bandUsed[c] = 2;
            else if (490 < wavelength && wavelength <= 580) bandUsed[c] = 1;
            else if (580 < wavelength && wavelength <= 780) bandUsed[c] = 0;
        }
    }
    MetadataTools.populatePixels(store, this);
}