Skip to content

C# helper class for serializing image metadata into Open Microscopy's OME-XML Tiff format.

License

Notifications You must be signed in to change notification settings

boonepeter/OME-Tiff-Csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OME-Tiff-Csharp

Helper class for serializing image metadata into Open Microscopy's OME-XML Tiff format.

This class is auto generated from the most recent OME-TIFF schema.

The schema used can also be found in Schema.

Here is an example using Bitmiracles's LibTiff.NET to open the image:

using System.IO;
using System.Xml.Serialization;
using BitMiracle.LibTiff.Classic;
using OMETiffCsharp.OMETiff;

public void ReadMetadata(string filename)
{
    OME Metadata;
    // Open tiff file using LibTiff.NET
    using (Tiff input = Tiff.Open(filename, "r"))
    {
        // Get OME metadata from description tag
        string desc = input.GetField(TiffTag.IMAGEDESCRIPTION)[0].ToString();
        
        XmlSerializer Serializer = new XmlSerializer((typeof(OME)));
        using (TextReader tr = new StringReader(desc))
        {
            Metadata = (OME)Serializer.Deserialize(tr);
        }
    }
    
    // Now access the elements. 
    // Can iterate through items
    string creator = Metadata.Creator;
    var items = Metadata.Items;
    for (int i = 0; i < items.Length; i++)
    {
        if (items[i].GetType() == typeof(Image))
        {
            // process Image type  
	}
}

You can look at the tests for working examples.

This work is derived in part from the OME specification. Copyright (C) 2002-2016 Open Microscopy Environment

About

C# helper class for serializing image metadata into Open Microscopy's OME-XML Tiff format.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages