public ThresholdMenu() {
		super("Threshold");
		setEnabled(true);
		
		JMenuItem threshold = new JMenuItem("Threshold");
		threshold.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Panel panel = (((Window) getTopLevelAncestor()).getPanel());
				if (panel.getImage() == null) {
					return;
				}
				JDialog thresholdDialog = new ThresholdDialog(panel);
				thresholdDialog.setVisible(true);
			}
		});
		
		JMenuItem globalThreshold = new JMenuItem("Global");
		globalThreshold.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Panel panel = (((Window) getTopLevelAncestor()).getPanel());
				Image image = panel.getImage();
				if (image == null) {
					return;
				}
				if (image.getType() == ImageType.GREYSCALE) {
					JDialog otsuThresholdDialog = new GlobalThresholdDialog(panel);
					otsuThresholdDialog.setVisible(true);					
				} else {
					JDialog otsuThresholdDialog = new ColorGlobalThresholdDialog(panel);
					otsuThresholdDialog.setVisible(true);					
				}
			}
		});
		
		JMenuItem otsuThreshold = new JMenuItem("Otsu");
		otsuThreshold.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Panel panel = (((Window) getTopLevelAncestor()).getPanel());
				if (panel.getImage() == null) {
					return;
				}
				panel.setImage(ThresholdUtils.otsu(panel.getImage()));
				panel.repaint();
			}
		});
		
		JMenuItem hysteresis = new JMenuItem("Hysteresis");
		hysteresis.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Panel panel = (((Window) getTopLevelAncestor()).getPanel());
				if (panel.getImage() == null) {
					return;
				}
				JDialog dialog = new HysteresisThresholdDialog(panel);
				dialog.setVisible(true);
			}
		});
		

		
		add(threshold);
		add(globalThreshold);
		add(otsuThreshold);
		add(hysteresis);
	}