Skip to content
Permalink
Browse files

input image stats/params/vals now in DataContainer

SingleWindowDisplay used to also add a bunch of nice image
stats/values/parameters gotten from imglib2. These were missing from PDF
output and the IJ.log output. So now all these nice stats are put in the
DataContainer as ValueResults, and used everywhere a ResultsHandler
implementation like SingleWindowDisplay or the PDFWriter handles the
value results. It means there are no longer separateresults and stats
sections... but at least the output is the same in every case.
  • Loading branch information...
chalkie666 authored and tomka committed Jul 28, 2015
1 parent a493b2c commit 4cfc8861f05f277075c3fb7881ebf0d7e54c67c3
@@ -10,9 +10,9 @@
import results.ResultHandler;

/**
* This class implements some basic checks for the input image
* data. For instance is the percentage of zero-zero pixels
* checked or how many pixels are saturated.
* This class implements some basic checks for the input image data. For
* instance: Is the percentage of zero-zero or saturated pixels too high? Also,
* we get basic image properties / stats from imglib2,
*/
public class InputCheck<T extends RealType< T >> extends Algorithm<T> {
/* the maximum allowed ratio between zero-zero and
@@ -30,6 +30,16 @@
// the saturated pixel ratio of channel 2
double saturatedRatioCh2;

// general image stats/parameters/values
double ch1Max;
double ch2Max;
double ch1Min;
double ch2Min;
double ch1Mean;
double ch2Mean;
double ch1Integral;
double ch2Integral;

public InputCheck() {
super("input data check");
}
@@ -46,24 +56,31 @@ public void execute(DataContainer<T> container)
TwinCursor<T> cursor = new TwinCursor<T>(img1.randomAccess(),
img2.randomAccess(), Views.iterable(mask).cursor());

double ch1Max = container.getMaxCh1();
double ch2Max = container.getMaxCh2();
// get various general image properties/stats/values from the DataContainer
ch1Max = container.getMaxCh1();
ch2Max = container.getMaxCh2();
ch1Min = container.getMinCh1();
ch2Min = container.getMinCh2();
ch1Mean = container.getMeanCh1();
ch2Mean = container.getMeanCh2();
ch1Integral = container.getIntegralCh1();
ch2Integral = container.getIntegralCh2();

// the total amount of pixels that have been taken into consideration
int N = 0;
// the amount of pixels that are zero in both channels
int Nzero = 0;
// the amount of ch1 pixels with the maximum ch1 value;
int NsaturatedCh1 = 0;
// the amount of ch2 pixels with the maximum ch2 value;
int NsaturatedCh2 = 0;
long N = 0;
// the number of pixels that are zero in both channels
long Nzero = 0;
// the number of ch1 pixels with the maximum ch1 value;
long NsaturatedCh1 = 0;
// the number of ch2 pixels with the maximum ch2 value;
long NsaturatedCh2 = 0;

while (cursor.hasNext()) {
cursor.fwd();
double ch1 = cursor.getFirst().getRealDouble();
double ch2 = cursor.getSecond().getRealDouble();

// is the current pixels combination a zero pixel?
// is the current pixels combination a zero-zero pixel?
if (Math.abs(ch1 + ch2) < 0.00001)
Nzero++;

@@ -116,5 +133,16 @@ public void processResults(ResultHandler<T> handler) {
handler.handleValue("% zero-zero pixels", zeroZeroPixelRatio, 2);
handler.handleValue("% saturated ch1 pixels", saturatedRatioCh1, 2);
handler.handleValue("% saturated ch2 pixels", saturatedRatioCh2, 2);

// Make the ResultsHander implementation deal with the images'
// stats/parameters/values
handler.handleValue("Channel 1 Max", ch1Max, 3);
handler.handleValue("Channel 2 Max", ch2Max, 3);
handler.handleValue("Channel 1 Min", ch1Min, 3);
handler.handleValue("Channel 2 Min", ch2Min, 3);
handler.handleValue("Channel 1 Mean", ch1Mean, 3);
handler.handleValue("Channel 2 Mean", ch2Mean, 3);
handler.handleValue("Channel 1 Integrated (Sum) Intensity", ch1Integral, 3);
handler.handleValue("Channel 2 Integrated (Sum) Intensity", ch2Integral, 3);
}
}
@@ -121,8 +121,7 @@ public void handleValue(String name, double value) {
}

public void handleValue(String name, double value, int decimals) {
//send (output parameter name, value) to IJ.log for scraping batch results
handleValue(name, IJ.d2s(value, decimals));
listOfPDFTexts.add(new Paragraph(name + ": " + IJ.d2s(value, decimals)));
}

/**
@@ -320,20 +320,6 @@ protected String makeHtmlText() {
}

out.println("</TABLE>");

// print some image statistics
out.print("<H1>Image statistics</H1>");
out.print("<TABLE>");
printTableRow(out, "Min channel 1", dataContainer.getMinCh1());
printTableRow(out, "Max channel 1", dataContainer.getMaxCh1());
printTableRow(out, "Mean channel 1", dataContainer.getMeanCh1());

printTableRow(out, "Min channel 2", dataContainer.getMinCh2());
printTableRow(out, "Max channel 2", dataContainer.getMaxCh2());
printTableRow(out, "Mean channel 2", dataContainer.getMeanCh2());

out.println("</TABLE>");

out.print("</html>");
out.close();

0 comments on commit 4cfc886

Please sign in to comment.
You can’t perform that action at this time.