-
-
Notifications
You must be signed in to change notification settings - Fork 55
Set TIFF DPI from volume voxel size #785
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
base: main
Are you sure you want to change the base?
Changes from all commits
722ec6e
f9e8df6
36844ab
d4d310e
cf63f52
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 |
|---|---|---|
|
|
@@ -60,6 +60,24 @@ int main(int argc, char** argv) | |
|
|
||
| const uint16_t compression = parseCompression(compressionStr); | ||
|
|
||
| // Try to read voxelsize from meta.json to set TIFF DPI | ||
| float dpi = 0.f; | ||
| { | ||
| fs::path metaPath = fs::path(inputPath) / "meta.json"; | ||
| if (fs::exists(metaPath)) { | ||
| try { | ||
| auto meta = json::parse(std::ifstream(metaPath)); | ||
| if (meta.contains("voxelsize")) { | ||
| double vs = meta["voxelsize"].get<double>(); | ||
| dpi = voxelSizeToDpi(vs); | ||
|
Comment on lines
+71
to
+72
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.
Useful? React with 👍 / 👎.
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. That seems like a good point. |
||
| if (dpi > 0.f) | ||
| std::cout << "Voxel size: " << vs << " µm → DPI: " << dpi << "\n"; | ||
| } | ||
| } catch (...) { | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Open zarr dataset | ||
| fs::path inRoot(inputPath); | ||
| std::string dsName = std::to_string(level); | ||
|
|
@@ -110,11 +128,7 @@ int main(int argc, char** argv) | |
| fs::path outPath = outDir / fname.str(); | ||
|
|
||
| constexpr uint32_t tileSize = 256; | ||
| TiffWriter writer(outPath, | ||
| static_cast<uint32_t>(X), | ||
| static_cast<uint32_t>(Y), | ||
| cvType, tileSize, tileSize, | ||
| 0.0f, compression); | ||
| TiffWriter writer(outPath, static_cast<uint32_t>(X), static_cast<uint32_t>(Y), cvType, tileSize, tileSize, 0.0f, compression, dpi); | ||
|
|
||
| for (uint32_t ty = 0; ty < Y; ty += tileSize) { | ||
| for (uint32_t tx = 0; tx < X; tx += tileSize) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
vc_render_tifxyz, DPI is derived from rawvoxelsizeonly, but render resolution already changes withgroup_idxviads_scale = 2^-group_idx(same file, lines 1258 and 1458), so any run with--group-idx > 0gets TIFF resolution tags that are too high for the generated pixel grid. This produces inconsistent spatial metadata between rendered outputs from different OME-Zarr levels.Useful? React with 👍 / 👎.