import com.sun.media.jai.widget.DisplayJAI; import java.awt.GridLayout; import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.media.jai.operator.MedianFilterDescriptor; import javax.swing.BorderFactory; import javax.swing.JScrollPane;
import javax.swing.border.TitledBorder;
/*
* Median.java
* 版权所有 - 贺向前
* 地址:重庆市渝中区医学院路1号
* 重庆医科大学基础医学院计算机教研室 * 邮编:400016
* 邮件:hexiangqian@gmail.com
* QQ: 910019784
* 于重庆,石桥铺枫丹苑 2011-11-1, 18:09:13 * 未经授权,不得复制、传播。 */
/** *
* @author Administrator
*/
public class Median extends javax.swing.JFrame {
/** Creates new form Median */ public Median() { initComponents(); setTitle(\中值滤波\
setLayout(new GridLayout(2,2)); }
private void showImage(PlanarImage im,String str){ DisplayJAI dj=new DisplayJAI(im);
JScrollPane jp=new JScrollPane(dj);
TitledBorder titled=BorderFactory.createTitledBorder(\ jp.setBorder(titled); add(jp);
}
private PlanarImage loadFile(String fileName){
PlanarImage dst=JAI.create(\
return dst;
}
/** This method is called from within the constructor to * initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */
@SuppressWarnings(\
// setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 400, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 300, Short.MAX_VALUE) ); pack(); }//
private void formMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: String fileName=\
PlanarImage im0=loadFile(fileName); showImage(im0,\ PlanarImage
im1=(PlanarImage)JAI.create(\ARE,new Integer(5));
showImage(im1,\ PlanarImage
im2=(PlanarImage)JAI.create(\
w Integer(3));
showImage(im2,\ PlanarImage
im3=(PlanarImage)JAI.create(\S,new Integer(5));
showImage(im3,\
JAI.create(\ pack(); show();
}
/**
* @param args the command line arguments */
public static void main(String args[]) { /* Set the Nimbus look and feel */
// For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo javax.swing.UIManager.getInstalledLookAndFeels()) { info : if (\ javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Median.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Median.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Median.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Median.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Median().setVisible(true); } });
} // Variables declaration - do not modify // End of variables declaration }