📄 zyy.java
字号:
});
}
return laplace2阶滤波;
}
/**
* This method initializes laplace2阶增强滤波
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getLaplace2阶增强滤波() {
if (laplace2阶增强滤波 == null) {
laplace2阶增强滤波 = new JMenuItem();
laplace2阶增强滤波.setText("laplace2阶增强滤波");
laplace2阶增强滤波.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("------------------laplace2阶增强滤波actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
if(fileName==null||fileName.trim().compareTo("")==0)
{
System.out.println("------------- please select a picture!");
JOptionPane.showMessageDialog(zyy.this,"请先打开要处理的图象!", "Message Dlg",JOptionPane.INFORMATION_MESSAGE);
}
else
{
processType="laplace2阶增强滤波";
//需要提示输入增强系数
//InputDlog_laplace2 input=new InputDlog_laplace2();
String inputValue = JOptionPane.showInputDialog("请输入增强系数delt");
if(inputValue!=null&&inputValue.trim().compareTo("")!=0)
{
try{
delt=Double.valueOf(inputValue).doubleValue();
}catch(Exception e1)
{
e1.printStackTrace();
JOptionPane.showMessageDialog(zyy.this,"输入的数据格式不正确", "Message Dlg",JOptionPane.INFORMATION_MESSAGE);
}
Laplace2Delt zyy=new Laplace2Delt(fileName,delt);
//imageProcessed=zyy.imageProcess();
ImageIcon a = new ImageIcon(zyy.imageProcess());
jLabel1.setIcon(a);
}
else
{
System.out.println("------------ in put is null");
}
}
}
});
}
return laplace2阶增强滤波;
}
/**
* This method initializes 局部阈值处理
*
* @return javax.swing.JMenuItem
*/
private JMenuItem get局部阈值处理() {
if (局部阈值处理 == null) {
局部阈值处理 = new JMenuItem();
局部阈值处理.setText("局部阈值处理");
局部阈值处理.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
System.out.println("------------------局部阈值处理actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
if(fileName==null||fileName.trim().compareTo("")==0)
{
System.out.println("------------- please select a picture!");
JOptionPane.showMessageDialog(zyy.this,"请先打开要处理的图象!", "Message Dlg",JOptionPane.INFORMATION_MESSAGE);
}
else
{
String inputValue_coefficients = JOptionPane.showInputDialog("请输入系数coefficients的值");
if(inputValue_coefficients!=null&&inputValue_coefficients.trim().compareTo("")!=0)
{
try{
coefficients=Double.valueOf(inputValue_coefficients).doubleValue();
}catch(Exception e2)
{
e2.printStackTrace();
JOptionPane.showMessageDialog(zyy.this,"输入的数据格式不正确", "Message Dlg",JOptionPane.INFORMATION_MESSAGE);
}
String inputValue_gate = JOptionPane.showInputDialog("请输入系数gate的值");
gate=Double.valueOf(inputValue_gate).doubleValue();
processType="局部阈值处理";
//需要提示输入增强系数
Jbfzcl zyy=new Jbfzcl(fileName,3,2,coefficients,gate);
//imageProcessed=zyy.imageProcess();
ImageIcon a = new ImageIcon(zyy.imageProcess());
jLabel1.setIcon(a);
}
else
{
System.out.println("---------------- input is null");
}
}
}
});
}
return 局部阈值处理;
}
/**
* This method initializes 全局阈值处理
*
* @return javax.swing.JMenuItem
*/
private JMenuItem get全局阈值处理() {
if (全局阈值处理 == null) {
全局阈值处理 = new JMenuItem();
全局阈值处理.setText("全局阈值处理");
全局阈值处理.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
//System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
System.out.println("------------------全局阈值处理actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
if(fileName==null||fileName.trim().compareTo("")==0)
{
System.out.println("------------- please select a picture!");
JOptionPane.showMessageDialog(zyy.this,"请先打开要处理的图象!", "Message Dlg",JOptionPane.INFORMATION_MESSAGE);
}
else
{
processType="全局阈值处理";
//需要提示输入增强系数
String inputValue_coefficients = JOptionPane.showInputDialog("请输入系数coefficients的值");
String inputValue_gate = JOptionPane.showInputDialog("请输入系数gate的值");
if(inputValue_coefficients!=null&&inputValue_coefficients.trim().compareTo("")!=0&&inputValue_gate!=null&&inputValue_gate.trim().compareTo("")!=0)
{
try
{
coefficients=Double.valueOf(inputValue_coefficients).doubleValue();
gate=Double.valueOf(inputValue_gate).doubleValue();
}catch(Exception e3)
{
e3.printStackTrace();
JOptionPane.showMessageDialog(zyy.this,"输入的数据格式不正确", "Message Dlg",JOptionPane.INFORMATION_MESSAGE);
}
Qjfzcl zyy=new Qjfzcl(fileName,coefficients,gate);
//imageProcessed=zyy.imageProcess();
ImageIcon a = new ImageIcon(zyy.imageProcess());
jLabel1.setIcon(a);
}
else
{
System.out.println("---------------- input is null");
}
}
}
});
}
return 全局阈值处理;
}
/**
* This method initializes 垂直边缘检测
*
* @return javax.swing.JMenuItem
*/
private JMenuItem get垂直边缘检测() {
if (垂直边缘检测 == null) {
垂直边缘检测 = new JMenuItem();
垂直边缘检测.setText("垂直边缘检测");
垂直边缘检测.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("------------------垂直边缘检测actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
if(fileName==null||fileName.trim().compareTo("")==0)
{
System.out.println("------------- please select a picture!");
JOptionPane.showMessageDialog(zyy.this,"请先打开要处理的图象!", "Message Dlg",JOptionPane.INFORMATION_MESSAGE);
}
else
{
processType="垂直边缘检测";
//需要提示输入增强系数//sobelCoefficients
String inputValue_sobelCoefficients = JOptionPane.showInputDialog("请输入系数sobelCoefficients的值(整数)");
try{
sobelCoefficients=Double.valueOf(inputValue_sobelCoefficients).doubleValue();
}catch(Exception e4)
{
e4.printStackTrace();
JOptionPane.showMessageDialog(zyy.this,"输入的数据格式不正确", "Message Dlg",JOptionPane.INFORMATION_MESSAGE);
}
int sobelCoefficients_int=(int)sobelCoefficients;
Czbyjc zyy=new Czbyjc(fileName,sobelCoefficients_int);
//imageProcessed=zyy.imageProcess();
ImageIcon a = new ImageIcon(zyy.imageProcess());
jLabel1.setIcon(a);
}
}
});
}
return 垂直边缘检测;
}
/**
* This method initializes 图像平滑
*
* @return javax.swing.JMenuItem
*/
private JMenuItem get图像平滑() {
if (图像平滑 == null) {
图像平滑 = new JMenuItem();
图像平滑.setText("图像平滑");
图像平滑.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("------------------图像平滑actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
if(fileName==null||fileName.trim().compareTo("")==0)
{
System.out.println("------------- please select a picture!");
JOptionPane.showMessageDialog(zyy.this,"请先打开要处理的图象!", "Message Dlg",JOptionPane.INFORMATION_MESSAGE);
}
else
{
processType="图像平滑";
//需要提示输入增强系数
Filter zyy=new Filter(fileName);
//imageProcessed=zyy.imageProcess();
ImageIcon a = new ImageIcon(zyy.imageProcess());
jLabel1.setIcon(a);
}
}
});
}
return 图像平滑;
}
public static void main(String[] args) {
// TODO 自动生成方法存根
zyy ks=new zyy();
ks.setVisible(true);
}
/**
* This is the default constructor
*/
public zyy() {
super();
initialize();
}
/*
public void paint(Graphics g)
{
super.paint(g);
int widthShow=getShowSize()[0];
int heightShow=getShowSize()[1];
g.drawImage(imageSelected,10,50,widthShow,heightShow,this);
g.drawImage(imageProcessed,10+widthShow+30,50,widthShow,heightShow,this);
}
*/
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(730, 351);
this.setJMenuBar(getJJMenuBar());
this.setContentPane(getJContentPane());
this.setForeground(java.awt.Color.cyan);
this.setLocation(new java.awt.Point(0,100));
this.setTitle("郑杨元的图象处理作业");
this.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentResized(java.awt.event.ComponentEvent e) {
repaint();
System.out.println("componentResized()"); // TODO Auto-generated Event stub componentResized()
}
});
this.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent e) {
repaint();
System.out.println("focusGained()"); // TODO Auto-generated Event stub focusGained()
}
});
this.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent e) {
repaint();
System.out.println("mouseClicked()"); // TODO Auto-generated Event stub mouseClicked()
}
});
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel3 = new JLabel();
jLabel3.setBounds(new java.awt.Rectangle(510,18,81,18));
jLabel3.setText("处理后的图象");
jLabel2 = new JLabel();
jLabel2.setBounds(new java.awt.Rectangle(110,17,88,18));
jLabel2.setText("处理前的图象");
jLabel1 = new JLabel();
jLabel1.setBounds(new java.awt.Rectangle(397,40,314,234));
jLabel1.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED));
jLabel1.setText("");
jLabel = new JLabel();
jLabel.setBounds(new java.awt.Rectangle(13,41,300,234));
jLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED));
jLabel.setText("");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setName("zyy");
jContentPane.setAutoscrolls(true);
jContentPane.setToolTipText("love");
jContentPane.add(getJButton1(), null);
jContentPane.add(jLabel, null);
jContentPane.add(jLabel1, null);
jContentPane.add(jLabel2, null);
jContentPane.add(jLabel3, null);
}
return jContentPane;
}
public void drawImage(int startX,int startY,int w,int h,String fileName)//x,y 是起始坐标,w h 是要显示的图象的高度和宽度
{
File file=new File(fileName);
try{
BufferedImage bufferedimage = ImageIO.read(file); //把wideth和height替换成想要的尺寸就可以了
int wideth = bufferedimage.getWidth(null);
int height = bufferedimage.getHeight(null);
wideth=wideth>w?w:wideth;
height=height>h?h:height;
BufferedImage bufferedimage1 = new BufferedImage(wideth, height, 1);
bufferedimage1.getGraphics().drawImage(bufferedimage, 0, 0, wideth, height, null);
}catch(Exception e)
{
e.printStackTrace();
}
}
/*
public int [] getShowSize()
{
int [] size_w_h=new int[2];
int width=0;
int height=0;
if(this.imageSelected!=null)
{
double width_d=imageSelected.getWidth(this);
double height_d=imageSelected.getHeight(this);
while(width_d>320||height_d>240)
{
width_d=width_d*3/4;
height_d=height_d*3/4;
}
width=(int)width_d;
height=(int)height_d;
}
size_w_h[0]=width;
size_w_h[1]=height;
System.out.println("-----showWidth:"+size_w_h[0]);
System.out.println("-----showheight:"+size_w_h[1]);
return size_w_h;
}
*/
/*
public void paint(Graphics g)
{
System.out.println("run in paint():11");
File file=new File("c:\\IMG_0027.jpg");
image= toolkit.getImage(file.getName());
System.out.println("run in paint():22");
g.drawImage(image,0,0,this);
System.out.println("run in paint():33");
System.out.println("run in paint():");
}
*/
} // @jve:decl-index=0:visual-constraint="4,5"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -