Skip to content

Commit

Permalink
User colormaps with divergent tag fully supported
Browse files Browse the repository at this point in the history
  • Loading branch information
RainerHeintzmann committed Nov 29, 2024
1 parent 8a13d7a commit 924ba1a
Show file tree
Hide file tree
Showing 7 changed files with 330 additions and 256 deletions.
7 changes: 5 additions & 2 deletions javacAll
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ cp "$myjar" "/mnt/c/Users/pi96doc/.julia/artifacts/View5D.jar"
cp "$myjar" "/mnt/c/NoBackup/DeconvCompileTest/DIPlib_3_2019/share/DIPimage/private/View5D.jar"
cp "$myjar" "/mnt/c/NoBackup/DeconvCompileTest/DIPlib_3_2017/share/DIPimage/private/View5D.jar"
cp "$myjar" "/mnt/c/Users/pi96doc/Desktop/UserPrograms/fiji-win64/Fiji.app/plugins/"
tar -czf "${myjar%.jar}-jar.tar.gz" "$myjar"
echo "${myjar%.jar}.jar.tar.gz"
cd target
totar=$(find -name '*.jar' | grep -v sources | grep -v javadoc)
tar -czf "${totar%.jar}-jar.tar.gz" "$totar"
echo "${totar%.jar}.jar.tar.gz"
# cp /*.class /usr/local/ImageJ/plugins/View5D/
#cp View5D_.jar /usr/local/ImageJ/plugins/View5D/
# cp View5D_.jar /windows/C/DriveF/JavaProgs/ImageJ/plugins/View5D/
Expand All @@ -43,3 +45,4 @@ echo "${myjar%.jar}.jar.tar.gz"
# cp -r examples /net/mobi1/data1/WinApps/ImageJ/plugins/View5D/
# cp *.class /net/mobi1/data1/MacOSX_local/ImageJ/plugins/View5D/


332 changes: 179 additions & 153 deletions src/main/java/view5d/Bundle.java

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions src/main/java/view5d/ImageCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -1999,26 +1999,26 @@ else if ((my3ddata.Times > 1))
//my3ddata.MyHistogram.UpdateAll();
return;
case 'C':
my3ddata.ToggleColor();
UpdateAll();
my3ddata.ToggleColor();
UpdateAll();
return ;
case 'c':
my3ddata.ToggleModel(-1);
UpdateAll();
my3ddata.ToggleModel(-1);
UpdateAll();
return ;
case 'd':
my3ddata.InvertCMap();
my3ddata.ToggleModel(-1);
my3ddata.InvertCMap();
// my3ddata.InvertCMap();
my3ddata.ToggleModel(-2);
// my3ddata.InvertCMap();
UpdateAll();
return ;
case 'o': // in color mode, all will be set to the current state
my3ddata.ToggleOvUn(-1);
UpdateAll();
my3ddata.ToggleOvUn(-1);
UpdateAll();
return ;
case 'O':
my3ddata.ToggleLog(-1);
UpdateAll();
my3ddata.ToggleLog(-1);
UpdateAll();
return ;
case ',': // moves along time direction
myPanel.RememberOffset();
Expand Down
199 changes: 121 additions & 78 deletions src/main/java/view5d/My3DData.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ APoint MarkerFromPosition(double px, double py, int dir, double dx, double dy)
return Pt;
}

public int AddLookUpTable(int MapSize,byte Reds[],byte Greens[],byte Blues[])
public int AddLookUpTable(int MapSize,byte Reds[],byte Greens[],byte Blues[], int type)
{
int lastLUT=0;
lastLUT=Bundle.ElementModels+Bundle.AddLookUpTable(MapSize,Reds,Greens,Blues);
lastLUT=Bundle.ElementModels+Bundle.AddLookUpTable(MapSize,Reds,Greens,Blues,type);
SetColorModelNr (ActiveElement,lastLUT);
GetBundleAt(ActiveElement).CompCMap();
return lastLUT; // returns the last existing total LUT index
Expand Down Expand Up @@ -988,30 +988,32 @@ public void ToggleOvUn(int newVal) {
copyLinkedProperties(ActiveElement);
}

public void ToggleModel(int elem,int newModel ) {
GetBundleAt(elem).ToggleModel(newModel);
if (elem == ActiveElement)
{
IndexColorModel mymodel = GetBundleAt(elem).ElementModel;
MySlice[0].TakeModel(mymodel);
MySlice[1].TakeModel(mymodel);
MySlice[2].TakeModel(mymodel);
}
if (GetBundleAt(elem).DispOverlay) // This element is displayed in the overlay
{
InvalidateColor();
}
if (elementsLinked)
copyLinkedProperties(elem);
public void ToggleModel(int elem, int newModel ) {
Bundle myBundle = GetBundleAt(elem);
myBundle.ToggleModel(newModel);
if (elem == ActiveElement)
{
IndexColorModel mymodel = myBundle.ElementModel;
MySlice[0].TakeModel(mymodel);
MySlice[1].TakeModel(mymodel);
MySlice[2].TakeModel(mymodel);
}
if (myBundle.DispOverlay) // This element is displayed in the overlay
{
InvalidateColor();
}
if (elementsLinked)
copyLinkedProperties(elem);
}

public void ToggleModel(int newModel ) {
ToggleModel(ActiveElement,newModel);
ToggleModel(ActiveElement, newModel);
}

public void InvertCMap()
public void SetInvertCMap(boolean inverse)
{
GetBundleAt(ActiveElement).cmapIsInverse = ! GetBundleAt(ActiveElement).cmapIsInverse;
GetBundleAt(ActiveElement).cmapIsInverse = inverse;
// ! GetBundleAt(ActiveElement).cmapIsInverse;
}
/*private void Setmincs(int elem, double val) {
GetBundleAt(elem).SetMincs(val);
Expand Down Expand Up @@ -1049,6 +1051,7 @@ public double GetScaledRange(int elem) {
//return ElementAt(elem).ScaleV*(Getmaxcs(elem)-Getmincs(elem));
}

// transfers the threshold values to all time steps as a scale and shift
public void transferThresh(int elem) {
for (int t=0;t < Times;t++) {
ElementAt(elem, t).SetScaleShift(Getmincs(elem), Getmaxcs(elem));
Expand Down Expand Up @@ -1081,11 +1084,19 @@ public boolean SetScaledMinMaxcs(int elem, double Min, double Max) {

public boolean AdjustThresh(int elementNum) {
boolean valid=true;
GetBundleAt(elementNum).cmapcHigh = Bundle.MaxCTable-1; // set the color map thresholds back to normal
GetBundleAt(elementNum).cmapcLow = 0;
GetBundleAt(elementNum).CompCMap();
Bundle myBundle = GetBundleAt(elementNum);
myBundle.cmapcHigh = Bundle.MaxCTable-1; // set the color map thresholds back to normal
myBundle.cmapcLow = 0;
//System.out.println("is-inv"+myBundle.cmapIsInverse+"\n");
myBundle.CompCMap();
//System.out.println("is-inv"+myBundle.cmapIsInverse+"\n");
double min = ElementAt(elementNum).ROIMinimum(ROIAt(elementNum));
double max = ElementAt(elementNum).ROIMaximum(ROIAt(elementNum));
if (myBundle.IsDivergentColormap()) {
max = Math.max(Math.abs(min), Math.abs(max));
min = -max;
// System.out.println("min"+min+" max"+max+"\n");
}
valid = SetThresh(elementNum,min,max);
transferThresh(elementNum);
return valid;
Expand Down Expand Up @@ -1155,35 +1166,38 @@ public boolean AdjustThreshGlobal() { // adjusts the threshold globally for al
}

public void copyLinkedProperties(int anElement) { // copies a particular element threshold values to all element
double TLow = GetBundleAt(anElement).GetMincs();
double THigh = GetBundleAt(anElement).GetMaxcs();
boolean ShowOvUn = GetBundleAt(anElement).ShowOvUn;
boolean LogScale = GetBundleAt(anElement).LogScale;
boolean cmapIsInverse = GetBundleAt(anElement).cmapIsInverse;
int ElementModelNr = GetBundleAt(anElement).ElementModelNr; // just a number for the current model
double Gamma = GetBundleAt(anElement).Gamma;
Bundle myBundle = GetBundleAt(anElement);
double TLow = myBundle.GetMincs();
double THigh = myBundle.GetMaxcs();
boolean ShowOvUn = myBundle.ShowOvUn;
boolean LogScale = myBundle.LogScale;
boolean cmapIsInverse = myBundle.cmapIsInverse;
int ElementModelNr = myBundle.ElementModelNr; // just a number for the current model
double Gamma = myBundle.Gamma;

for (int elementNum=0;elementNum<Elements;elementNum++) {
GetBundleAt(elementNum).SetMincs(TLow);
GetBundleAt(elementNum).SetMaxcs(THigh);
GetBundleAt(elementNum).ShowOvUn = ShowOvUn;
GetBundleAt(elementNum).LogScale = LogScale;
GetBundleAt(elementNum).cmapIsInverse = cmapIsInverse;
GetBundleAt(elementNum).ElementModelNr = ElementModelNr;
GetBundleAt(elementNum).Gamma = Gamma;
if (GetBundleAt(elementNum).cmapcLow > 0)
GetBundleAt(elementNum).CompCMap(); // This is usually faster than recomputing images
myBundle = GetBundleAt(elementNum);
myBundle.SetMincs(TLow);
myBundle.SetMaxcs(THigh);
myBundle.ShowOvUn = ShowOvUn;
myBundle.LogScale = LogScale;
myBundle.cmapIsInverse = cmapIsInverse;
myBundle.ElementModelNr = ElementModelNr;
myBundle.Gamma = Gamma;
if (myBundle.cmapcLow > 0)
myBundle.CompCMap(); // This is usually faster than recomputing images
else
CThreshToValThresh(elementNum,0.25,1.0); // If underflow a recomputation becomes necessary, but with 25% extra space
}
}

public void setColorMapThresh(int elem, int low, int high) // These functions are far quicker for the display especially for large images
{
GetBundleAt(elem).cmapcLow = low;
GetBundleAt(elem).cmapcHigh = high;
Bundle myBundle = GetBundleAt(elem);
myBundle.cmapcLow = low;
myBundle.cmapcHigh = high;

GetBundleAt(elem).CompCMap(); // This is usually faster than recomputing images
myBundle.CompCMap(); // This is usually faster than recomputing images
// if (GetBundleAt(elem).cmapcLow > 0)
// GetBundleAt(elem).CompCMap(); // This is usually faster than recomputing images
// else
Expand All @@ -1199,37 +1213,61 @@ public void setColorMapThresh(int elem, int low, int high) // These functions a
public void adjustColorMapLThresh(double howmuch) // These functions are far quicker for the display especially for large images
{
double howmany= (howmuch*Bundle.MaxCTable);
double max = GetBundleAt(ActiveElement).cmapcHigh;
double min = GetBundleAt(ActiveElement).cmapcLow;
Bundle myBundle = GetBundleAt(ActiveElement);
double max = myBundle.cmapcHigh;
double min = myBundle.cmapcLow;
if (howmany < 0 || max > min + howmany)
GetBundleAt(ActiveElement).cmapcLow += (int) howmany;
myBundle.cmapcLow += (int) howmany;
if (myBundle.IsDivergentColormap()) {
if (myBundle.cmapcLow > Bundle.MaxCTable/2)
myBundle.cmapcLow = Bundle.MaxCTable/2;
if (howmany > 0 || max - howmany > min)
myBundle.cmapcHigh -= (int) howmany;
if (myBundle.cmapcHigh < Bundle.MaxCTable/2)
myBundle.cmapcHigh = Bundle.MaxCTable/2;
}

if (GetBundleAt(ActiveElement).cmapcLow > 0)
GetBundleAt(ActiveElement).CompCMap(); // This is usually faster than recomputing images
if (myBundle.cmapcLow > 0)
myBundle.CompCMap(); // This is usually faster than recomputing images
else
CThreshToValThresh(ActiveElement,0.25,1.0); // If underflow a recomputation becomes necessary, but with 25% extra space
if (myBundle.IsDivergentColormap())
CThreshToValThresh(ActiveElement,0.25,0.75); // If underflow a recomputation becomes necessary, but with 25% extra space
else
CThreshToValThresh(ActiveElement,0.25,1.0); // If underflow a recomputation becomes necessary, but with 25% extra space
}

public void adjustColorMapUThresh(double howmuch)
{
double howmany= (howmuch*Bundle.MaxCTable);
double max = GetBundleAt(ActiveElement).cmapcHigh;
double min = GetBundleAt(ActiveElement).cmapcLow;
Bundle myBundle = GetBundleAt(ActiveElement);
double max = myBundle.cmapcHigh;
double min = myBundle.cmapcLow;
if (howmany > 0 || max + howmany > min)
GetBundleAt(ActiveElement).cmapcHigh += (int) howmany;

if (GetBundleAt(ActiveElement).cmapcHigh <= Bundle.MaxCTable-1)
GetBundleAt(ActiveElement).CompCMap(); // This is usually faster than recomputing images
myBundle.cmapcHigh += (int) howmany;
if (myBundle.IsDivergentColormap()) {
if (myBundle.cmapcHigh < Bundle.MaxCTable/2)
myBundle.cmapcHigh = Bundle.MaxCTable/2;
if (howmany > 0 || max > min - howmany)
myBundle.cmapcLow -= (int) howmany;
if (myBundle.cmapcLow > Bundle.MaxCTable/2)
myBundle.cmapcLow = Bundle.MaxCTable/2;
}
if (myBundle.cmapcHigh <= Bundle.MaxCTable-1)
myBundle.CompCMap(); // This is usually faster than recomputing images
else
if (myBundle.IsDivergentColormap())
CThreshToValThresh(ActiveElement,0.25,0.75); // If underflow a recomputation becomes necessary, but with 25% extra space
else
CThreshToValThresh(ActiveElement,0.0,0.75); // If underflow a recomputation becomes necessary, but with 25% extra space
}

public double GetMinThresh(int elem) // returns the Effective threshold independent of which part of it is colormap and which is Mincs
{
double max = GetBundleAt(elem).GetMaxcs(); // These are the datavalues to which the min and max of the colormap point
double min = GetBundleAt(elem).GetMincs();
Bundle myBundle = GetBundleAt(elem);
double max = myBundle.GetMaxcs(); // These are the datavalues to which the min and max of the colormap point
double min = myBundle.GetMincs();
// double cmax = GetBundleAt(elem).cmapcHigh; // These are the current indices into the colormap
double cmin = GetBundleAt(elem).cmapcLow; // index of the lowest currently used entry in the colortable
double cmin = myBundle.cmapcLow; // index of the lowest currently used entry in the colortable

// double scale = (max-min) / Bundle.MaxCTable;
double nmin = min + (max-min)*cmin / (Bundle.MaxCTable-1); // scale*cmin;
Expand All @@ -1238,23 +1276,26 @@ public double GetMinThresh(int elem) // returns the Effective threshold indepe

public double GetMaxThresh(int elem) // returns the Effective threshold independent of which part of it is colormap and which is Mincs
{
double max = GetBundleAt(elem).GetMaxcs(); // These are the datavalues to which the min and max of the colormap point
double min = GetBundleAt(elem).GetMincs();
double cmax = GetBundleAt(elem).cmapcHigh; // index of the highest currently used entry in the colortable
Bundle myBundle = GetBundleAt(elem);
double max = myBundle.GetMaxcs(); // These are the datavalues to which the min and max of the colormap point
double min = myBundle.GetMincs();
double cmax = myBundle.cmapcHigh; // index of the highest currently used entry in the colortable
// double cmin = GetBundleAt(elem).cmapcLow;

double nmax = min + (max-min)*cmax/(Bundle.MaxCTable-1);
return nmax;
}


public void CThreshToValThresh(int elem, double facmin, double facmax) // copies the color-map threshold to a real value threshold
// copies the color-map threshold to a real value threshold
public void CThreshToValThresh(int elem, double facmin, double facmax)
{ // The factor determines the percentage at of the colormap at which the new min/max position will point (defaults = 0,1.0)
Bundle myBundle = GetBundleAt(elem);
if (elem < 0) elem=ActiveElement;
double max = GetBundleAt(elem).GetMaxcs(); // These are the datavalues to which the min and max of the colormap point
double min = GetBundleAt(elem).GetMincs();
double cmax = GetBundleAt(elem).cmapcHigh; // These are the current indices into the colormap
double cmin = GetBundleAt(elem).cmapcLow;
double max = myBundle.GetMaxcs(); // These are the datavalues to which the min and max of the colormap point
double min = myBundle.GetMincs();
double cmax = myBundle.cmapcHigh; // These are the current indices into the colormap
double cmin = myBundle.cmapcLow;
// if (cmin == 0 && cmax == Bundle.MaxCTable-1) return; // No need to change anything!

double cmaxnew = (int) ((Bundle.MaxCTable-1)*facmax); // new indices into colormap
Expand All @@ -1265,34 +1306,36 @@ public void CThreshToValThresh(int elem, double facmin, double facmax) // copi
double nmax = max - scale*(Bundle.MaxCTable - (cmax+scale2*(Bundle.MaxCTable-1-cmaxnew)));
double nmin = min + scale*(cmin - scale2*cminnew);

GetBundleAt(elem).SetMincs(nmin);
GetBundleAt(elem).SetMaxcs(nmax);
GetBundleAt(elem).cmapcLow = (int) cminnew;
GetBundleAt(elem).cmapcHigh = (int) cmaxnew;
myBundle.SetMincs(nmin);
myBundle.SetMaxcs(nmax);
myBundle.cmapcLow = (int) cminnew;
myBundle.cmapcHigh = (int) cmaxnew;
InvalidateSlices();InvalidateProjs(elem);
transferThresh(elem);
GetBundleAt(elem).CompCMap();
myBundle.CompCMap();
}

public void addLThresh(double howmuch) {
double howmany= (howmuch*ActElement().MaxValue);
double max = GetBundleAt(ActiveElement).GetMaxcs();
double min = GetBundleAt(ActiveElement).GetMincs();
Bundle myBundle = GetBundleAt(ActiveElement);
double howmany= (howmuch*ActElement().MaxValue);
double max = myBundle.GetMaxcs();
double min = myBundle.GetMincs();
if (howmany < 0 || max > min + howmany)
{
GetBundleAt(ActiveElement).SetMincs(min + howmany);
myBundle.SetMincs(min + howmany);
InvalidateSlices();InvalidateProjs(ActiveElement);
}
transferThresh(ActiveElement);
}

public void addUThresh(double howmuch) {
double howmany=(howmuch*ActElement().MaxValue);
double max = GetBundleAt(ActiveElement).GetMaxcs();
double min = GetBundleAt(ActiveElement).GetMincs();
Bundle myBundle = GetBundleAt(ActiveElement);
double howmany=(howmuch*ActElement().MaxValue);
double max = myBundle.GetMaxcs();
double min = myBundle.GetMincs();
if (howmany > 0 || max + howmany > min)
{
GetBundleAt(ActiveElement).SetMaxcs(max + howmany);
myBundle.SetMaxcs(max + howmany);
InvalidateSlices();InvalidateProjs(ActiveElement);
}
transferThresh(ActiveElement);
Expand Down
Loading

0 comments on commit 924ba1a

Please sign in to comment.