MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / run

Method run

packageFiles/plugins/Debayer_Image.java:32–95  ·  view source on GitHub ↗
(ImageProcessor ip)

Source from the content-addressed store, hash-verified

30 }
31
32 public void run(ImageProcessor ip) {
33 width = imp.getWidth();
34 height = imp.getHeight();
35 ImageStack rgb = new ImageStack(width, height, imp.getProcessor().getColorModel());
36 String[] orders = {"R-G-R-G", "B-G-B-G", "G-R-G-R", "G-B-G-B"};
37 String[] algorithms = {"Replication", "Bilinear", "Smooth Hue", "Adaptive Smooth Hue"};
38 //boolean showStack = true;
39
40 String options = "";
41
42 GenericDialog dia = new GenericDialog("Debayer...", IJ.getInstance());
43
44 dia.addChoice("Order of first row:", orders, orders[1]);
45 dia.addChoice("Demosaicing algorithm:", algorithms, algorithms[0]);
46 //dia.addCheckbox("Display RGB Stack?", showStack);
47 dia.addMessage("Filter options:");
48 dia.addCheckbox("Apply Median Filter?", median);
49 dia.addCheckbox("Apply Gaussian Filter?", gauss);
50 dia.addNumericField("Radius for Median Filter", med_radius, 2);
51 dia.addNumericField("Radius for Gaussian Filter", gauss_radius, 2);
52 dia.addMessage("Contrast options:");
53 dia.addCheckbox("Normalize Values?", normalize);
54 dia.addCheckbox("Equalize Histogram?", equalize);
55 dia.addCheckbox("Use Stack Histogram?", stackHist);
56 dia.addCheckbox("Display Colour Image?", showColour);
57
58 dia.showDialog();
59
60 if (dia.wasCanceled()) return;
61
62 int row_order = dia.getNextChoiceIndex();
63 int algorithm = dia.getNextChoiceIndex();
64 //showStack = dia.getNextBoolean();
65 median = dia.getNextBoolean();
66 gauss = dia.getNextBoolean();
67 med_radius = (int)dia.getNextNumber();
68 gauss_radius = (int)dia.getNextNumber();
69 normalize = dia.getNextBoolean();
70 equalize = dia.getNextBoolean();
71 stackHist = dia.getNextBoolean();
72 showColour = dia.getNextBoolean();
73
74 options = "saturated=0.5";
75 if (normalize) options = options + " normalize";
76 if (equalize) options = options + " equalize";
77 options = options + " normalize_all";
78 if (stackHist) options = options + " use";
79
80 if (algorithm == 0) rgb = replicate_decode(row_order);
81 else if (algorithm == 1) rgb = average_decode(row_order);
82 else if (algorithm == 2) rgb = smooth_decode(row_order);
83 else if (algorithm == 3) rgb = adaptive_decode(row_order);
84 ImagePlus rgb_imp = imp.createImagePlus();
85 rgb_imp.setStack("RGB Stack", rgb);
86 rgb_imp.setCalibration(imp.getCalibration());
87 rgb_imp.show();
88
89 if (median) IJ.run("Median...", "radius="+med_radius+" stack");

Callers

nothing calls this directly

Calls 15

getInstanceMethod · 0.95
addChoiceMethod · 0.95
addMessageMethod · 0.95
addCheckboxMethod · 0.95
addNumericFieldMethod · 0.95
showDialogMethod · 0.95
wasCanceledMethod · 0.95
getNextChoiceIndexMethod · 0.95
getNextBooleanMethod · 0.95
getNextNumberMethod · 0.95
replicate_decodeMethod · 0.95
average_decodeMethod · 0.95

Tested by

no test coverage detected