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

VirtualImagePlus: Retain B&C settings for each slice #4131

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ public synchronized void setSlice(int index) {
}
// Keep the user-defined color limits
proc.getChild().setMinAndMax(this.getDisplayRangeMin(), this.getDisplayRangeMax());
int bitDepth = this.getBitDepth();
int range = 256;
if (bitDepth==16) {
range = 65536;
int defaultRange = this.getDefault16bitRange();
if (defaultRange>0)
range = (int)Math.pow(2,defaultRange)-1;
}
int tableSize = bitDepth==16?65536:256;
int[] table = new int[tableSize];
int min = (int)this.getDisplayRangeMin();
int max = (int)this.getDisplayRangeMax();
for (int i=0; i<tableSize; i++) {
if (i<=min)
table[i] = 0;
else if (i>=max)
table[i] = range-1;
else
table[i] = (int)(((double)(i-min)/(max-min))*range);
}
proc.getChild().applyTable(table);

// if we call setProcessor(getTitle(), proc), the type will be set
// to GRAY32 (regardless of the actual processor type)
setProcessor(getTitle(), proc.getChild());
Expand Down
Loading