()
| 785 | } |
| 786 | |
| 787 | public void displayCounts() { |
| 788 | ImagePlus imp = getImage(); |
| 789 | String firstColumnHdr = "Slice"; |
| 790 | rt = new ResultsTable(); |
| 791 | int row = 0; |
| 792 | if (imp!=null && imp.getStackSize()>1 && positions!=null) { |
| 793 | int nChannels = 1; |
| 794 | int nSlices = 1; |
| 795 | int nFrames = 1; |
| 796 | boolean isHyperstack = true; |
| 797 | if (imp.isComposite() || imp.isHyperStack()) { |
| 798 | nChannels = imp.getNChannels(); |
| 799 | nSlices = imp.getNSlices(); |
| 800 | nFrames = imp.getNFrames(); |
| 801 | int nDimensions = 2; |
| 802 | if (nChannels>1) nDimensions++; |
| 803 | if (nSlices>1) nDimensions++; |
| 804 | if (nFrames>1) nDimensions++; |
| 805 | if (nDimensions==3) { |
| 806 | isHyperstack = false; |
| 807 | if (nChannels>1) |
| 808 | firstColumnHdr = "Channel"; |
| 809 | } else |
| 810 | firstColumnHdr = "Image"; |
| 811 | } |
| 812 | int firstSlice = Integer.MAX_VALUE; |
| 813 | for (int i=0; i<nPoints; i++) { |
| 814 | if (positions[i]>0 && positions[i]<firstSlice) |
| 815 | firstSlice = positions[i]; |
| 816 | } |
| 817 | if (firstSlice==Integer.MAX_VALUE) |
| 818 | firstSlice = 0; |
| 819 | int lastSlice = 0; |
| 820 | if (firstSlice>0) { |
| 821 | for (int i=0; i<nPoints; i++) { |
| 822 | if (positions[i]>lastSlice) |
| 823 | lastSlice = positions[i]; |
| 824 | } |
| 825 | } |
| 826 | if (firstSlice>0) { |
| 827 | for (int slice=firstSlice; slice<=lastSlice; slice++) { |
| 828 | rt.setValue(firstColumnHdr, row, slice); |
| 829 | if (isHyperstack) { |
| 830 | int[] position = imp.convertIndexToPosition(slice); |
| 831 | if (nChannels>1) |
| 832 | rt.setValue("Channel", row, position[0]); |
| 833 | if (nSlices>1) |
| 834 | rt.setValue("Slice", row, position[1]); |
| 835 | if (nFrames>1) |
| 836 | rt.setValue("Frame", row, position[2]); |
| 837 | } |
| 838 | for (int counter=0; counter<nCounters; counter++) { |
| 839 | int count = 0; |
| 840 | for (int i=0; i<nPoints; i++) { |
| 841 | if (slice==positions[i] && counter==counters[i]) |
| 842 | count++; |
| 843 | } |
| 844 | rt.setValue("Ctr "+counter, row, count); |
no test coverage detected