• 大小: 24KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-12
  • 语言: Java
  • 标签: 图像分割  

资源简介

基于java的图像分割(数字图像处理),程序中包含 全局阈值分割,Roberts边缘检测分割,灰度图像,直方图。

资源截图

代码片段和文件信息

package ImageProcess;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.frame;
import java.awt.Graphics;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;  
  
public class histshow extends frame{  

private static final long serialVersionUID = 1L;
int data[];  
    int histogram[] = new int[256];  
      
    public histshow(){  
        this.settitle(“图像的灰度直方图“);  
        Panel pdown;  
        Button quit;   
        pdown = new Panel();  
        quit = new Button(“关闭窗口“);  
        this.add(pdown BorderLayout.SOUTH);   
        pdown.add(quit);  
        quit.addActionListener(new ActionListener(){  
            public void actionPerformed(ActionEvent e){  
                jQuit_ActionPerformed(e);  
            }  
        });  
        // 添加窗口监听事件  
        addWindowListener(new WindowAdapter(){  
            public void windowClosing(WindowEvent e){  
                histshow.this.dispose();  
            }  
        });  
    }  
    public void jQuit_ActionPerformed(ActionEvent e){  
        this.setVisible(false);  
    }  
    public void getData(int[] data int iw int ih){  
        this.data = data;  
        for (int i = 0; i < iw * ih; i++){  
            int grey = data[i] & 0xff;  
            histogram[grey]++;  
        }  
          
        // 找出最大的数进行标准化.  
        int temp = histogram[0];  
        for (int i = 0; i < 256; i++){  
            if (temp <= histogram[i]){  
            temp = histogram[i];  
            //System.out.println(temp);  
            }  
        }  
        for (int i = 0; i < 256; i++){  
            histogram[i] = histogram[i] * 200 / temp;  
            //System.out.println(temp);  
        }  
    }  
    //画出直方图  
    public void paint(Graphics g){  
        // 画出水平和垂直的轴  
        g.drawLine(100 250 356 250);  
        g.drawLine(100 50 100 250);  
        // 画出横轴坐标  
        g.drawString(“0“ 98 263);  
        g.drawString(“50“ 145 263);  
        g.drawString(“100“ 193 263);  
        g.drawString(“150“ 243 263);  
        g.drawString(“200“ 293 263);  
        g.drawString(“250“ 343 263);  
        // 画出纵轴坐标  
        g.drawString(“0.5“ 83 145);  
        g.drawString(“1“ 90 60);  
        // 画出图像的直方图  
        for (int i = 0; i < 256; i++){  
            g.drawLine(100 + i 250 100 + i 250 - histogram[i]);  
        }  
        g.drawString(“该图像的灰度直方图如上所示.“ 160 280);  
    }  
}  

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-11-28 22:58  ImageProcess\
     文件         301  2017-11-28 22:58  ImageProcess\.classpath
     文件         388  2017-11-28 22:58  ImageProcess\.project
     目录           0  2017-11-28 22:58  ImageProcess\.settings\
     文件         598  2017-11-28 22:58  ImageProcess\.settings\org.eclipse.jdt.core.prefs
     目录           0  2017-11-30 21:53  ImageProcess\bin\
     目录           0  2017-11-30 21:53  ImageProcess\bin\ImageProcess\
     文件         680  2017-11-30 21:53  ImageProcess\bin\ImageProcess\ImageProc$1.class
     文件         844  2017-11-30 21:53  ImageProcess\bin\ImageProcess\ImageProc$2.class
     文件         844  2017-11-30 21:53  ImageProcess\bin\ImageProcess\ImageProc$3.class
     文件         844  2017-11-30 21:53  ImageProcess\bin\ImageProcess\ImageProc$4.class
     文件         848  2017-11-30 21:53  ImageProcess\bin\ImageProcess\ImageProc$5.class
     文件         698  2017-11-30 21:53  ImageProcess\bin\ImageProcess\ImageProc$6.class
     文件         705  2017-11-30 21:53  ImageProcess\bin\ImageProcess\ImageProc$7.class
     文件         844  2017-11-30 21:53  ImageProcess\bin\ImageProcess\ImageProc$8.class
     文件         699  2017-11-30 21:53  ImageProcess\bin\ImageProcess\ImageProc$9.class
     文件       10357  2017-11-30 21:53  ImageProcess\bin\ImageProcess\ImageProc.class
     文件         699  2017-11-30 21:53  ImageProcess\bin\ImageProcess\ImageShow$1.class
     文件         657  2017-11-30 21:53  ImageProcess\bin\ImageProcess\ImageShow$2.class
     文件        2186  2017-11-30 21:53  ImageProcess\bin\ImageProcess\ImageShow.class
     文件         693  2017-12-01 08:57  ImageProcess\bin\ImageProcess\histshow$1.class
     文件         651  2017-12-01 08:57  ImageProcess\bin\ImageProcess\histshow$2.class
     文件        2324  2017-12-01 08:57  ImageProcess\bin\ImageProcess\histshow.class
     目录           0  2017-11-28 22:59  ImageProcess\src\
     目录           0  2017-11-29 13:19  ImageProcess\src\ImageProcess\
     文件       12697  2017-11-29 19:25  ImageProcess\src\ImageProcess\ImageProc.java
     文件        1835  2017-11-29 18:53  ImageProcess\src\ImageProcess\ImageShow.java
     文件        2710  2017-12-01 08:57  ImageProcess\src\ImageProcess\histshow.java

评论

共有 条评论

相关资源