12 public void run(String arg) {
28 String msg =
"Converting to " + item;
30 long start = System.currentTimeMillis();
31 boolean isRoi = imp.getRoi()!=null;
33 boolean saveChanges = imp.
changes;
37 Undo.setup(
Undo.TYPE_CONVERSION, imp);
39 if (item.equals(
"8-bit"))
41 else if (item.equals(
"16-bit"))
43 else if (item.equals(
"32-bit"))
45 else if (item.equals(
"RGB Color")) {
47 }
else if (item.equals(
"8-bit Color")) {
48 int nColors = getNumber();
49 start = System.currentTimeMillis();
59 catch (IllegalArgumentException e) {
60 unsupportedConversion(imp);
69 IJ.showTime(imp, start,
"");
74 void unsupportedConversion(
ImagePlus imp) {
76 "Supported Conversions:\n" +
78 "8-bit -> 16-bit*\n" +
79 "8-bit -> 32-bit*\n" +
80 "8-bit -> RGB Color*\n" +
81 "16-bit -> 8-bit*\n" +
82 "16-bit -> 32-bit*\n" +
83 "16-bit -> RGB Color*\n" +
84 "32-bit -> 8-bit*\n" +
85 "32-bit -> 16-bit\n" +
86 "32-bit -> RGB Color*\n" +
87 "8-bit Color -> 8-bit (grayscale)*\n" +
88 "8-bit Color -> RGB Color\n" +
89 "RGB Color -> 8-bit (grayscale)*\n" +
90 "RGB Color -> 8-bit Color*\n" +
91 "RGB Color -> RGB Stack\n" +
92 "RGB Color -> HSB Stack\n" +
93 "RGB Stack -> RGB Color\n" +
94 "HSB Stack -> RGB Color\n" +
96 "* works with stacks\n"
103 GenericDialog gd =
new GenericDialog(
"MedianCut");
104 gd.addNumericField(
"Number of Colors (2-256):", 256, 0);
106 if (gd.wasCanceled())
108 int n = (int)gd.getNextNumber();