-
Notifications
You must be signed in to change notification settings - Fork 0
Generalize position finder #5
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
Changes from 5 commits
78058c2
c23834c
96c21b4
63b0544
ec01c49
93b32d5
505262d
06b9e68
c06f296
26c0c52
d04e225
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| Welcome to the stitching extension for [QuPath](http://qupath.github.io)! | ||
|
|
||
| This extension adds support for combining TIFF images based on their "XResolution", "XPosition", "YResolution", "YPosition", "ImageWidth", and "ImageLength" tags. | ||
| This extension adds support for combining TIFF images based on their names and "XResolution", "XPosition", "YResolution", "YPosition", "ImageWidth", and "ImageLength" tags. | ||
|
|
||
| The extension is intended for QuPath v0.6 and later. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR means it is compatible only with v0.7.0.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR is actually v0.6.0 compatible, but two previous PR weren't: the TIFF writer PR, and the use of the new |
||
| It is not compatible with earlier QuPath versions. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package qupath.ext.stitching.core; | ||
|
|
||
| import java.io.FileInputStream; | ||
| import java.io.IOException; | ||
| import java.util.Arrays; | ||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * A class that checks whether a file represents a TIFF file. This is done by looking at the first four bytes of the | ||
| * provided file, which must match: [0x49, 0x49, 0x2A, 0x00] or [0x4D, 0x4D, 0x00, 0x2A]. | ||
| */ | ||
| public class TiffFileChecker { | ||
|
|
||
| private TiffFileChecker() { | ||
| throw new AssertionError("This class is not instantiable"); | ||
| } | ||
|
|
||
| /** | ||
| * Check if the provided path points to a TIFF file. Take a look at the class documentation for more information. | ||
| * | ||
| * @param path the path pointing to the file to test | ||
| * @throws IOException if the path doesn't point to an existing file or if the file cannot be read | ||
| * @throws IllegalArgumentException if the provided file is not a TIFF file | ||
| * @throws NullPointerException if the provided path is null | ||
| */ | ||
| public static void checkTiffFile(String path) throws IOException { | ||
| byte[] bytes; | ||
| try (FileInputStream inputStream = new FileInputStream(Objects.requireNonNull(path))) { | ||
| bytes = inputStream.readNBytes(4); | ||
| } | ||
|
|
||
| if (bytes.length < 4) { | ||
| throw new IllegalArgumentException(String.format("%s contains less than 4 bytes, so it cannot be a TIFF file", path)); | ||
| } | ||
|
|
||
| if (!((bytes[0] == 0x49 && bytes[1] == 0x49 && bytes[2] == 0x2A && bytes[3] == 0x00) || | ||
| (bytes[0] == 0x4D && bytes[1] == 0x4D && bytes[2] == 0x00 && bytes[3] == 0x2A))) { | ||
| throw new IllegalArgumentException(String.format( | ||
| "The first four bytes of %s (%s) don't match the TIFF specifications", | ||
| path, | ||
| Arrays.toString(bytes) | ||
| )); | ||
| } | ||
| } | ||
| } |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.