1、本科生毕业设计姓 名: 学 号: 学 院: 计算机科学与技术学院 专 业: 计算机科学与技术 设计题目: 基于谱聚类的图像分割 专 题: 图像分割的设计与实现 指导教师: 职 称: 副教授 大学毕业设计任务书学院 计算机 专业年级 学生姓名 任务下达日期: 毕业设计日期: 毕业设计题目: 毕业设计专题题目 毕业设计主要内容和要求:院长签章: 指导教师签字:中国矿业大学毕业设计指导教师评阅书指导教师评语(基础理论及基本技能的掌握;独立解决实际问题的能力;研究内容的理论依据和技术方法;取得的主要成果及创新点;工作态度及工作量;总体评价及建议成绩;存在问题;是否同意答辩等):成 绩: 指导教师签字:
2、年 月 日中国矿业大学毕业设计评阅教师评阅书评阅教师评语(选题的意义;基础理论及基本技能的掌握;综合运用所学知识解决实际问题的能力;工作量的大小;取得的主要成果及创新点;写作的规范程度;总体评价及建议成绩;存在问题;是否同意答辩等):成 绩: 评阅教师签字: 年 月 日中国矿业大学毕业设计答辩及综合成绩答 辩 情 况提 出 问 题回 答 问 题正 确基本正确有一般性错误有原则性错误没有回答答辩委员会评语及建议成绩:答辩委员会主任签字: 年 月 日学院领导小组综合评定成绩:学院领导小组负责人: 年 月 日需求分析一、 利用前台,得到一张原始JPG图片;二、 把这张图片传到后台,JAVA通过JRI
3、调用R;三、 利用R调用K-Means的改进算法,实现对这张图片的处理,由于一张图片的像素值是一个矩阵,可以得到一组关于像素值的数据;四、 把这组像素值进行分类,对各类赋予不同的颜色进行标记,从而区分出需要的图片信息;五、 把得到的新图片传到前台;六、 前台对进行处理后的图片进行显示,从图像中得到需要的信息,从而实现图像的分割。概要设计模块功能图:图片:在本系统中所能使用到的图片属性为颜色和大小,颜色对应不同的像素,大小对应图像的像素点形成矩阵的大小;前台:前台用来接收图片和显示图片;后台(JAVA):用来接收图片并且调用R来实现对图片的处理;后台(R):在被调用后,把图片信息转化成数据信息形
4、成矩阵,从而实现对图片信息的处理。经过上述的处理后,把新生成的图像信息返回,并在前端进行显示,从而实现图像分割。把图像分割系统划分成二个子系统:接收图片并显示子系统,处理图片子系统。首先从外界得到需要进行分割的图片,通过接收图片并显示子系统把图片进行输入到系统中;然后再把图片输入到处理图片子系统,输入此系统后,把图片信息转化为矩阵,然后利用JAVA调用R,利用R中K-MEANS算法对矩阵信息进行分类获得新的矩阵,最终把矩阵信息转化成图片,实现对图片的处理;最后把处理后得到的新图片输入到显示图片子系统,从而实现图像分割,获得所需要的信息。详细设计程序流程图: 实现代码;一实现图片文件选择器:pa
5、ckage pri.study.convert;import java.awt.EventQueue;import javax.swing.ImageIcon;import javax.swing.JFileChooser;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import java.awt.BorderLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import jav
6、a.io.File;import javax.swing.JButton;import org.rosuda.REngine.REXPMismatchException;import org.rosuda.REngine.Rserve.RserveException;public class MyApp implements ActionListener private JFrame frame;JButton selectPrePic = new JButton(选择要转换的图片);JLabel prePic = new JLabel(New label);JLabel label = ne
7、w JLabel(转换前的图片:);JButton convertPic = new JButton(转换图片);JLabel label_1 = new JLabel(转换后的图片:);JLabel label_2 = new JLabel(提示:转换后的图片默认放在转换前图片所在目录下);JLabel curPic = new JLabel(转化浓厚的图片);JFileChooser jfc = new JFileChooser();/ 文件选择器private int i=0;String prePicPath=;String curPicPath=;/* * Create the ap
8、plication. */public MyApp() initialize();/* * Initialize the contents of the frame. */private void initialize() jfc.setCurrentDirectory(new File(d:/);/ 文件选择器的初始目录定为d盘frame = new JFrame();frame.setBounds(200, 150, 880, 400);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);JPanel myPanel=new JPane
9、l();myPanel.setLayout(null);frame.getContentPane().add(myPanel, BorderLayout.CENTER);selectPrePic.addActionListener(this);selectPrePic.setBounds(10, 10, 153, 23);convertPic.addActionListener(this);convertPic.setBounds(423, 9, 93, 23);prePic.setBounds(20, 90, 320, 250);curPic.setBounds(423, 90, 320,
10、250);label.setBounds(20, 42, 139, 15);label_1.setBounds(423, 42, 143, 15);label_2.setBounds(423, 65, 320, 15);myPanel.add(prePic);myPanel.add(label);myPanel.add(convertPic);myPanel.add(label_1);myPanel.add(label_2);myPanel.add(curPic);myPanel.add(selectPrePic);/ImageIcon ico=new ImageIcon(d:/myPlotP
11、ic.png);/JLabel lblPrepic = new JLabel(hebe,ico,JLabel.CENTER);/frame.getContentPane().add(lblPrepic, BorderLayout.CENTER);public void actionPerformed(ActionEvent e) / TODO Auto-generated method stub/if (e.getSource().equals(button1) / 判断触发方法的按钮是哪个/jfc.setFileSelectionMode(1);/ 设定只能选择到文件夹/int state
12、= jfc.showOpenDialog(null);/ 此句是打开文件选择器界面的触发语句/if (state = 1) /return;/ else /File f = jfc.getSelectedFile();/ f为选择到的目录/text1.setText(f.getAbsolutePath();/ 绑定到选择文件,先择文件事件if (e.getSource().equals(selectPrePic) jfc.setFileSelectionMode(0);/ 设定只能选择到文件int state = jfc.showOpenDialog(null);/ 此句是打开文件选择器界面的
13、触发语句if (state = 1) return;/ 撤销则返回 else File f = jfc.getSelectedFile();/ f为选择到的文件/System.out.print(f.getPath();/trim()是取出字符串前后的空格和特殊字符String temp01=f.getAbsolutePath().trim();String sub1=temp01.substring(0,3);String sub2=temp01.substring(2, temp01.length();prePicPath=sub1+sub2;System.out.print(prePic
14、Path);String temp02=f.getParent();String sub01=temp01.substring(0,3);String sub02=temp01.substring(2, temp02.length();/curPicPath=sub01+sub02+convert0+i+.jpg;curPicPath=sub01+sub02+convert0+i+.jpg;System.out.print(curPicPath-+curPicPath);/显示转换前的图片ImageIcon iconPrePic=new ImageIcon(f.getAbsolutePath(
15、);prePic.setIcon(iconPrePic);if (e.getSource().equals(convertPic) try ConvertPicByR conve=ConvertPicByR.getInstance();conve.DoConvertPic(prePicPath, curPicPath);/显示转换后的图片ImageIcon iconPrePic=new ImageIcon(curPicPath);curPic.setIcon(iconPrePic); catch (RserveException e1) / TODO Auto-generated catch
16、blocke1.printStackTrace(); catch (REXPMismatchException e1) / TODO Auto-generated catch blocke1.printStackTrace();/JOptionPane.showMessageDialog(null, init a dialog for test!, tips, 2); author zzj/* * Launch the application. */public static void main(String args) EventQueue.invokeLater(new Runnable(
17、) public void run() try MyApp window = new MyApp();window.frame.setVisible(true); catch (Exception e) e.printStackTrace(););二实现JAVA调用R:package pri.study.convert;import java.awt.EventQueue;import javax.swing.ImageIcon;import javax.swing.JFileChooser;import javax.swing.JFrame;import javax.swing.JLabel
18、;import javax.swing.JPanel;import java.awt.BorderLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.File;import javax.swing.JButton;import org.rosuda.REngine.REXPMismatchException;import org.rosuda.REngine.Rserve.RserveException;public class MyApp implements
19、 ActionListener private JFrame frame;JButton selectPrePic = new JButton(选择要转换的图片);JLabel prePic = new JLabel(New label);JLabel label = new JLabel(转换前的图片:);JButton convertPic = new JButton(转换图片);JLabel label_1 = new JLabel(转换后的图片:);JLabel label_2 = new JLabel(提示:转换后的图片默认放在转换前图片所在目录下);JLabel curPic =
20、new JLabel(转化浓厚的图片);JFileChooser jfc = new JFileChooser();/ 文件选择器private int i=0;String prePicPath=;String curPicPath=;/* * Create the application. */public MyApp() initialize();/* * Initialize the contents of the frame. */private void initialize() jfc.setCurrentDirectory(new File(d:/);/ 文件选择器的初始目录定
21、为d盘frame = new JFrame();frame.setBounds(200, 150, 880, 400);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);JPanel myPanel=new JPanel();myPanel.setLayout(null);frame.getContentPane().add(myPanel, BorderLayout.CENTER);selectPrePic.addActionListener(this);selectPrePic.setBounds(10, 10, 153, 23);c
22、onvertPic.addActionListener(this);convertPic.setBounds(423, 9, 93, 23);prePic.setBounds(20, 90, 320, 250);curPic.setBounds(423, 90, 320, 250);label.setBounds(20, 42, 139, 15);label_1.setBounds(423, 42, 143, 15);label_2.setBounds(423, 65, 320, 15);myPanel.add(prePic);myPanel.add(label);myPanel.add(co
23、nvertPic);myPanel.add(label_1);myPanel.add(label_2);myPanel.add(curPic);myPanel.add(selectPrePic);/ImageIcon ico=new ImageIcon(d:/myPlotPic.png);/JLabel lblPrepic = new JLabel(hebe,ico,JLabel.CENTER);/frame.getContentPane().add(lblPrepic, BorderLayout.CENTER);public void actionPerformed(ActionEvent
24、e) / TODO Auto-generated method stub/if (e.getSource().equals(button1) / 判断触发方法的按钮是哪个/jfc.setFileSelectionMode(1);/ 设定只能选择到文件夹/int state = jfc.showOpenDialog(null);/ 此句是打开文件选择器界面的触发语句/if (state = 1) /return;/ else /File f = jfc.getSelectedFile();/ f为选择到的目录/text1.setText(f.getAbsolutePath();/ 绑定到选择文件
25、,先择文件事件if (e.getSource().equals(selectPrePic) jfc.setFileSelectionMode(0);/ 设定只能选择到文件int state = jfc.showOpenDialog(null);/ 此句是打开文件选择器界面的触发语句if (state = 1) return;/ 撤销则返回 else File f = jfc.getSelectedFile();/ f为选择到的文件/System.out.print(f.getPath();/trim()是取出字符串前后的空格和特殊字符String temp01=f.getAbsolutePat
26、h().trim();String sub1=temp01.substring(0,3);String sub2=temp01.substring(2, temp01.length();prePicPath=sub1+sub2;System.out.print(prePicPath);String temp02=f.getParent();String sub01=temp01.substring(0,3);String sub02=temp01.substring(2, temp02.length();/curPicPath=sub01+sub02+convert0+i+.jpg;curPi
27、cPath=sub01+sub02+convert0+i+.jpg;System.out.print(curPicPath-+curPicPath);/显示转换前的图片ImageIcon iconPrePic=new ImageIcon(f.getAbsolutePath();prePic.setIcon(iconPrePic);if (e.getSource().equals(convertPic) try ConvertPicByR conve=ConvertPicByR.getInstance();conve.DoConvertPic(prePicPath, curPicPath);/显
28、示转换后的图片ImageIcon iconPrePic=new ImageIcon(curPicPath);curPic.setIcon(iconPrePic); catch (RserveException e1) / TODO Auto-generated catch blocke1.printStackTrace(); catch (REXPMismatchException e1) / TODO Auto-generated catch blocke1.printStackTrace();/JOptionPane.showMessageDialog(null, init a dialo
29、g for test!, tips, 2); author zzj/* * Launch the application. */public static void main(String args) EventQueue.invokeLater(new Runnable() public void run() try MyApp window = new MyApp();window.frame.setVisible(true); catch (Exception e) e.printStackTrace(););三在R中实现图像的处理:public static void DoConver
30、tPic(String prePicPath,String curPicPath) throws RserveException /R commands c.eval(library(jpeg); / String temp=orgpic-readJPEG(+prePicPath+); / System.out.print(temp); c.eval(orgpic-readJPEG(+prePicPath+); c.eval(dim(orgpic); / c.eval(orgpic100,200,); / c.eval(hist(orgpic,2); / String temp=negativ
31、e-function(orgpic);/ System.out.print(temp); c.eval(negative-function(orgpic)return(1-orgpic); / c.eval(); / c.eval(return(1-orgpic); / c.eval(); c.eval(writeJPEG(negative(orgpic),target=+curPicPath+,quality=0.95); c.eval();摘 要为了加强煤矿矿区环境保护,对矿区周边环境的水质监测数据进行有效处理,方便环境监测部门按照国家规范进行定期或不定期的经常性监测测定,建立健全污染源档
32、案,为加强污染源管理提供监测数据,并根据监测数据做出环境质量评价。本文系统分析了煤矿环境监测过程中水质监测原始数据的处理方法与处理流程,对水质监测中的各项监测指标及其监测方法进行了归纳总结,在此基础上建立了一个比较完善的基于C/S模式的煤矿环境水质监测系统。本系统以.NET与 SQL server 2000为基础进行内容的组织与架构,充分利用了网络技术的优势,采用了切合实际的C/S软件体系结构模式,包含了水质监测数据处理所应有的功能。同时,加入了基础数据管理、水质监测报告生成、月度汇总报表、年度汇总报表、图形统计分析报表、使用帮助,完善了系统的功能。本系统采用C/S软件体系结构模式有利于提高数
33、据的处理与传输的效率,系统在构架时采用三层的设计模式:数据连接层、数据访问层及数据应用层,采用这种层次结构一方面提高了数据的访问传输效率,另一方面提高了系统的扩展性和服务器的效率,有利于系统后期的维护。本文对煤矿环境水质监测系统进行了整体设计,将系统划分为8个主要的功能模块,即系统管理、基础数据管理、原始数据处理、监测报告管理、统计汇总报表、用户管理、设备管理、帮助信息,对各模块的功能进行了设计,描述了系统中主要数据的数据结构以及一些关键性的算法,给出了系统实施所需的硬件环境和软件平台,论述了系统在将来的可扩展性和与其他环境监测子系统的可整合性。 关键词:水质监测;C/S软件体系结构模式; A
34、BSTRACTTo strengthen the environmental quality of mine,for treatment the water quality monitoring data which geted in mine surrounding environment effectively, convenient the environmental monitoring departments whit regular or unregular monitoring by national norms, established the source files, to
35、 strengthen the management of pollution provide monitoring data,and according to the monito ring data to make an environmental quality assessment.In this paper, the original data processing method and the treatment process in the m -ine environment monitoring of water quality monitoring process are
36、analyzed based on practices.the monitoring indicatorsare and monitoring methods in the water quality moni -toring are summarized. Based on this,a pafected Mine Environmental Monitoring Syste -m was builded,which is based on C/S mode.The system used the advantage of network technology successfully,us
37、ing the realistic C/S Software Architecture Mode,based on .NET and SQL server 2000 for organizing the contents and the system structure, with function which included in the water quality monitoring data calculation. Meanwhile,add the basic data managemen t,the water quality monitoring report generat
38、ion,the month summary statements, the year summary statements,the graphical statistical analysis statements,the using help,which improve the function of the system.The system use the C/S Software Architecture Mode,which can improve the data processing and transmi ssion efficiency.The systems structu
39、re using this three design patterns layer: data link layer, data Access layer and the data application layer.this can improve the datas transmission and visit efficiency,and also improve the systems scalability and the serverss efficiency. the maintenance of the system become easier.Key words: water
40、 quality monitoring; C/S modeIn this article, The mine environmental water quality monitoring system is overall designed,and the system is divided into eight modules:The system management module,The basic date management module, The orig inal data processing module,The monitoring report management module,The statistical summary statements module,The system users management module,The equipment management module,The help message module. the function of the module are designed, description the main data structures and some of