1 package ij.plugin.filter;
21 public void run(ImageProcessor ip) {
22 String info = getImageInfo(imp, ip);
23 if (info.indexOf(
"----")>0)
24 showInfo(info, 400, 500);
26 showInfo(info, 300, 300);
29 public String getImageInfo(
ImagePlus imp, ImageProcessor ip) {
30 String infoProperty = null;
31 if (infoProperty==null)
33 String info = getInfo(imp, ip);
34 if (infoProperty!=null)
35 return infoProperty +
"\n------------------------\n" + info;
41 String getInfo(
ImagePlus imp, ImageProcessor ip) {
42 String s =
new String(
"\n");
43 s +=
"Title: " + imp.
getTitle() +
"\n";
49 s +=
"Width: "+
IJ.
d2s(imp.getWidth()*cal.
pixelWidth,2)+
" " + units+
" ("+imp.getWidth()+
")\n";
50 s +=
"Height: "+
IJ.
d2s(imp.getHeight()*cal.
pixelHeight,2)+
" " + units+
" ("+imp.getHeight()+
")\n";
54 if (xResolution==yResolution)
55 s +=
"Resolution: "+
IJ.
d2s(xResolution,places) +
" pixels per "+unit+
"\n";
57 s +=
"X Resolution: "+
IJ.
d2s(xResolution,places) +
" pixels per "+unit+
"\n";
58 s +=
"Y Resolution: "+
IJ.
d2s(yResolution,places) +
" pixels per "+unit+
"\n";
61 s +=
"Width: " + imp.getWidth() +
" pixels\n";
62 s +=
"Height: " + imp.getHeight() +
" pixels\n";
67 s +=
"Bits per pixel: 8 ";
72 lut =
"grayscale " + lut;
74 lut =
"inverted " + lut;
75 s +=
"(" + lut +
")\n";
77 case ImagePlus.GRAY16:
case ImagePlus.GRAY32:
78 if (type==ImagePlus.GRAY16) {
80 s +=
"Bits per pixel: 16 (unsigned short)\n";
82 s +=
"Bits per pixel: 32 (float)\n";
83 s +=
"Display range: ";
84 double min = ip.getMin();
85 double max = ip.getMax();
90 s += IJ.d2s(min,digits) +
" - " + IJ.d2s(max,digits) +
"\n";
92 case ImagePlus.COLOR_256:
93 s +=
"Bits per pixel: 8 (color LUT)\n";
95 case ImagePlus.COLOR_RGB:
96 s +=
"Bits per pixel: 32 (RGB)\n";
101 if (ip.getMinThreshold()==ip.NO_THRESHOLD)
102 s +=
"No Threshold\n";
104 double lower = ip.getMinThreshold();
105 double upper = ip.getMaxThreshold();
112 s +=
"Threshold: "+IJ.d2s(lower,dp)+
"-"+IJ.d2s(upper,dp)+
"\n";
114 ImageCanvas ic = imp.getCanvas();
115 double mag = ic.getMagnification();
117 s +=
"Magnification: " + mag +
"\n";
122 s +=
"Calibration Function: ";
123 if (curveFit==Calibration.UNCALIBRATED_OD)
124 s +=
"Uncalibrated OD\n";
126 s += CurveFitter.fList[curveFit]+
"\n";
129 s +=
" a: "+IJ.d2s(c[0],6)+
"\n";
130 s +=
" b: "+IJ.d2s(c[1],6)+
"\n";
132 s +=
" c: "+IJ.d2s(c[2],6)+
"\n";
134 s +=
" c: "+IJ.d2s(c[3],6)+
"\n";
136 s +=
" c: "+IJ.d2s(c[4],6)+
"\n";
140 s +=
"Uncalibrated\n";
144 if (fi.directory!=null && fi.fileName!=null) {
145 s +=
"Path: " + fi.directory + fi.fileName +
"\n";
147 if (fi.url!=null && !fi.url.equals(
"")) {
148 s +=
"URL: " + fi.url +
"\n";
152 Roi roi = imp.getRoi();
156 s +=
"No Selection\n";
159 s += roi.getTypeAsString()+
" Selection";
160 String name = roi.getName();
162 s +=
" (\"" + name +
"\")";
164 Rectangle r = roi.getBounds();
165 if (roi instanceof Line) {
166 Line line = (Line)roi;
167 s +=
" X1: " + IJ.d2s(line.x1*cal.
pixelWidth) +
"\n";
168 s +=
" Y1: " + IJ.d2s(yy(line.y1,imp)*cal.
pixelHeight) +
"\n";
169 s +=
" X2: " + IJ.d2s(line.x2*cal.
pixelWidth) +
"\n";
170 s +=
" Y2: " + IJ.d2s(yy(line.y2,imp)*cal.
pixelHeight) +
"\n";
172 }
else if (cal.
scaled()) {
173 s +=
" X: " + IJ.d2s(r.x*cal.
pixelWidth) +
" (" + r.x +
")\n";
174 s +=
" Y: " + IJ.d2s(yy(r.y,imp)*cal.
pixelHeight) +
" (" + r.y +
")\n";
175 s +=
" Width: " + IJ.d2s(r.width*cal.
pixelWidth) +
" (" + r.width +
")\n";
176 s +=
" Height: " + IJ.d2s(r.height*cal.
pixelHeight) +
" (" + r.height +
")\n";
178 s +=
" X: " + r.x +
"\n";
179 s +=
" Y: " + yy(r.y,imp) +
"\n";
180 s +=
" Width: " + r.width +
"\n";
181 s +=
" Height: " + r.height +
"\n";
189 int yy(
int y, ImagePlus imp) {
190 return Analyzer.updateY(y, imp.getHeight());
193 void showInfo(String info,
int width,
int height) {
194 new TextWindow(
"Info for "+imp.getTitle(), info, width, height);