Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
noisee
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
imcf
noisee
Commits
74b036da
Commit
74b036da
authored
6 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Add detectValueRange() and mapTo8bitPreservingSaturation()
parent
e000afd9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/resources/scripts/Plugins/NoiSee/NoiSee_Bead_Analysis.ijm
+60
-0
60 additions, 0 deletions
...resources/scripts/Plugins/NoiSee/NoiSee_Bead_Analysis.ijm
with
60 additions
and
0 deletions
src/main/resources/scripts/Plugins/NoiSee/NoiSee_Bead_Analysis.ijm
+
60
−
0
View file @
74b036da
...
...
@@ -476,6 +476,66 @@ function stripOmeSuffix(orig) {
return orig;
}
function detectValueRange() {
// detect the *actual* value range bit depth of a 16-bit image, i.e. if the
// image contains pixels in a range from 5 to 3978 the value range depth is
// 12 bits (possible values from 0 to 4095)
// define the value range bit depths to test for (8 to 16):
possible_depths = Array.getSequence(17);
possible_depths = Array.slice(possible_depths, 8, 17);
Stack.getStatistics(_, _, _, max, _, _);
logi("maximum pixel value in stack: " + max);
saturated = false;
actual_depth = 16;
// traverse the possible depths array backwards:
for (i = lengthOf(possible_depths) - 1; i > 0; i--) {
sat = pow(2, possible_depths[i]) - 1;
logd("checking " + possible_depths[i] + " bit range (0-" + sat + ")");
if (max == sat) {
saturated = true;
actual_depth = possible_depths[i];
logd("saturated " + actual_depth + "-bit image detected!");
} else {
next_lower = pow(2, possible_depths[i-1]);
if (max < sat && max >= next_lower) {
actual_depth = possible_depths[i];
logd("non-saturated " + actual_depth + "-bit image detected!");
}
}
}
msg_sat = "(not saturated)";
if (saturated)
msg_sat = "(SATURATED!)";
logd("\ndetected value range: " + actual_depth + " bit " + msg_sat);
res = newArray(actual_depth, saturated);
return res;
}
function mapTo8bitPreservingSaturation(effectiveBits) {
// convert an image with 12 or 16 bit effective value range depth to 8 bit
// preserving saturation in the sense that only saturated pixels (65535 for
// 16 bits and 4095 for 12 bits) are mapped to the 8 bit saturation value
// (255), avoiding the usual binning that would happen if simply the display
// range was adjusted to the min/max values of the image (resulting in
// over-saturation of wrongly mapped pixels)
if (effectiveBits == 16) {
run("Divide...", "value=257.50 stack");
} else if (effectiveBits == 12) {
run("Divide...", "value=16.09 stack");
} else {
print("Invalid VALUE range detected: " + effectiveBits);
print("Input image needs to have a value range of 8, 12 or 16 bits!");
exit_show();
}
run("8-bit");
}
function clear_workspace() {
/*
* Ensure a clean workspace, i.e.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment