Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read scale from metadata #11

Open
swharden opened this issue Mar 13, 2023 · 0 comments
Open

Read scale from metadata #11

swharden opened this issue Mar 13, 2023 · 0 comments

Comments

@swharden
Copy link
Owner

swharden commented Mar 13, 2023

using Tiff image = Tiff.Open("demo.tif", "r");

StringBuilder sb = new();

foreach (TiffTag tag in Enum.GetValues(typeof(TiffTag)))
{
    FieldValue[] values = image.GetField(tag);

    if (values is null)
        continue;

    foreach (FieldValue value in values)
        sb.AppendLine($"{tag} = {value}");
}

Console.WriteLine(sb);
SUBFILETYPE = 0
IMAGEWIDTH = 256
IMAGELENGTH = 256
BITSPERSAMPLE = 16
COMPRESSION = NONE
PHOTOMETRIC = MINISBLACK
IMAGEDESCRIPTION = ImageJ=1.53q
images=48
channels=2
frames=24
hyperstack=true
mode=composite
unit=micron
finterval=1
loop=false
min=169.0
max=8191.0
STRIPOFFSETS = System.UInt64[]
SAMPLESPERPIXEL = 1
ROWSPERSTRIP = 16
STRIPBYTECOUNTS = System.UInt64[]
XRESOLUTION = 0.848324
YRESOLUTION = 0.848324
PLANARCONFIG = CONTIG
RESOLUTIONUNIT = NONE
TILEOFFSETS = System.UInt64[]
TILEBYTECOUNTS = System.UInt64[]
public static double GetMicronsPerPixel(string tifFilePath)
{
    using Tiff image = Tiff.Open(tifFilePath, "r");
    return 1.0 / (float)image.GetField(TiffTag.XRESOLUTION).First().Value;
}

metrics of interest:

unit=micron
XRESOLUTION = 0.848324
YRESOLUTION = 0.848324
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant