科学网

 找回密码
  注册

tag 标签: 二次开发

相关帖子

版块 作者 回复/查看 最后发表

没有相关内容

相关日志

液压支架的参数化设计及其顶梁的结构优化研究
bshen 2019-8-26 09:59
硕士学位毕业论文 硕士研究生: 徐沛鑫 指导教师:沈斌 教授 答辩时间:2013.06 摘要 液压支架是综合机械化采煤中的重要设备,在确保其安全性和功能的基础上,进行轻量化设计,减少重量,对于降低产品成本、提高经济效益,具有重要的意义。 本文首先对液压支架进行了参数化建模,利用Pro/E进行了二次开发,为后期的结构优化效率的提高了奠定了基础。然后以顶梁为例对轻量化的方法进行了研究,为该课题整架的优化研究提供了理论和方法,具体内容如下: 1. 为了能够快速提供优化过程中所需要的模型,对液压支架采用了参数化的骨架建模,实现了模型的快速修改和重生。 2. 利用Pro/E二次开发程序,开发了液压支架的参数化设计平台及尺寸驱动平台。该平台实现了液压支架的参数化受力分析,为液压支架的设计提供了力学依据。同时也可以通过对骨架参数刷新,实现液压支架模型的驱动再生。并且在该平台中添加了参数关联功能,实现了对模型中任意参数的尺寸驱动。 3. 建立了液压支架顶梁的有限元模型,并进行了有限元计算,得到了不同工况下液压支架顶梁的应力和应变,为顶梁轻量化分析的奠定了基础。 4. 为了对顶梁进行轻量化研究,选取了三个顶梁关键部件尺寸作为设计变量,以降低顶梁在不同工况下最大应力为研究目标,通过试验设计选取了试验样本点,并通过有限元计算得到了样本点的响应值。同时引入了牛顿插值法进行最大应力计算,为提高整架结构优化的效率进行了探索研究。 5. 基于响应面法,建立了顶梁最大应力的近似模型,并对响应面模型进行了验证。响应面模型的建立解决了液压支架顶梁结构优化过程中高精度有限元计算费时费力且优化效率低的问题,使优化效率得到了提高。液压支架顶梁的优化研究为其他部件以及整架结构的优化提供了思路和方法。 关键词 :液压支架,二次开发,顶梁,代理模型,结构优化 ABSTRACT Hydraulic support is an important mechanized coal mining equipment . E nsuring its security and functionality , to make lightweight design, reduc e weight , is of great significance for reducing product costs and improve economic efficiency . This article first made the parametric modeling of hydraulic support and se condary development by Pro/E, to base the foundation of efficiency improvement von structural optimization. Then made an example by roof beam to study methods of lightweight. Thus providing methods and theory for the entire shelf optimization, specific content is as follows: 1. To be able to provide the required model for optimization and to achieve the function of rapid changes and remodeling, the hydraulic support was made by parametric skeleton modeling. 2. Hydraulic support parametric design and dimension-driven platform was established by using Pro/E secondary development program me. The platform can provide parametric stress analysis for hydraulic support design. And it can achieve hydraulic support model driven generation by refreshing skeleton parameters. A parameter correlation function was added to the platform and realized dimension-driven of any parameter. 3. A hydraulic support roof beam finite element model was established and was made finite calculation. Then stress and strain of hydraulic support roof beam in different conditions was achieved. It is the foundation of roof beam lightweight analysis. 4. In order to study roof beam lightweight, three key components dimensions was selected design variables a nd the reduction of maximum stress of roof beam in different conditions was selected as research objectives. Sample points was selected through experiment design, and response of sample points was calculated by element finite analysis. T he introduction of the maximum stress calculation von Newton interpolation method explored in order to improve the efficiency of the whole frame structure optimization 5. Based on the response surface method, a maximum stress of the top beam approximation model was established, and the response surface model was proven. Response surface model solved the time-consuming problem and low efficiency von high accuracy finite element calculation during the structural optimization of hydraulic support beam. Thus improving the efficiency of optimization. The optimization research of hydraulic support roof beam provided ideas and methods for optimization of entire frame structure and other components. Key words: hydraulic support, secondary development, roof beam, a gent model , structure optimization
个人分类: 硕士研究生毕业论文|1620 次阅读|0 个评论
液压支架顶梁参数化设计及其二次开发研究
bshen 2019-8-25 11:36
硕士学位毕业论文 硕士研究生: 姚秀卿 指导教师:沈斌 教授 答辩时间:2012.06 摘要 我国煤层储量丰富,在中厚煤层开采中需要使用到高性能的综采设备。液压支架是煤矿综采设备的重要组成部分,其主要作用是与采煤机配合,实现采煤的综合机械化,提高采煤效率。对液压支架的参数化建模设计方法进行研究,对于企业实现快速设计、提高市场竞争力具有重要的现实意义。 本文分析 了国内外 CAD 技术的研究状况,以及参数化设计方法的理论及其在实际设计过程中的应用。通过对液压支架结构以及工作原理的研究,对液压支架进行功能模块划分,建立模块化系统。在参数化设计中,以顶梁为研究对象,采用自顶向下的设计方法,完成从装配体到各个零部件的三维建模,将设计信息以数据共享的方式,依次从装配体传递到组件、组件下的零件,同时通过自定义驱动参数以及关系式的设置实现模型中零部件的装配约束和几何约束,从而建立了顶梁的参数化信息模型。使用该参数化信息模型可以从全局设计的角度控制整个三维模型的生成,便于设计后续阶段对产品模型的修改以及优化。 在完成顶梁参数化信息模型的基础上,本文对 CAD 二次开发技术进行了研究,通过设计系统的开发使本课题的参数化设计效率进一步提升。根据通用软件的开发方法,确定了本课题的设计系统的开发环境、网络架构以及所使用的相关技术,得出了系统的总体方案。在对 Pro/E 软件自带的开发工具 Pro/TOOLKIT 充分研究的基础上,使用 Visual C++ 语言,结合 Pro/TOOLKIT 包含的库函数,完成设计系统参数化驱动建模的程序功能;使用 MFC 控件 与 Pro/TOOLKIT 底层函数相结合 搭建界面友好的系统菜单以及各模块的界面;针对传统设计过程中设计数据管理效率不高的问题,本文利用了数据库对设计数据进行管理,使用 ADO 技术设计出高效的数据库接口,使设计系统与数据库有效连接。 本文开发的设计系统具有参数化建模、设计信息管理等功能。使用该设计系统,用户可以利用良好的人机界面通过参数输入或者调用数据库已有设计数据完成液压支架顶梁的零部件设计,有效地提高了设计效率以及设计质量。 关键词 :液压支架,顶梁,参数化设计,二次开发 ABSTRACT The coal reserve is rich in China, the height quality coal mining equipment is used in the thick seam. The hydraulic support is an important part of coal mining equipment, it works together with the shear to get the comprehensive mechanization of coal mining, in order to improve the mining efficiency. The research of the design method of the hydraulic support has important practical significance for the rapid design and also can enhance the market competitiveness of a company. This article describes the status of CAD technology both at home and abroad, as well as the theory of parametric design method. On basis of the study of the principle of hydraulic support, determining the way of the parametric design for hydraulic support, then dividing the function module of hydraulic support. Take the upper beam of hydraulic support as example, using the top-down design method, passing the design information from the assembly to the parts or components with data sharing method, then set up the custom design parameters and the relationship, in order to establish the parametric information model, then get the control of the modeling of the entire 3D model, so that it’s convenient to modify or optimize the model later. In addition, research on the secondary development technology of CAD on base of conventional parametric design method, so as to improve the parametric design competence of CAD through the secondary development. Developing the user application program with Pro/TOOLKIT and VC++, integrating the application to CAD system, with an good interface user can easily input the parameters to regenerate the template model to get the required model. In this way people can avoid the repetitive work in the develop term, so that reduce the design cost time and improve the design quality. The efficiency of data management in the traditional design is not good enough, in order to solve this problem, we use the database technology to manage the design information, and connect the database system together with the secondary developed design system, so that the design system consist of parametric modeling and data management functions. The research in this text contributes to the product development in the modern design and manufacture side for the company, and the design way can be also used in other product design system. Key Words: hydraulic support , the upper beam , parametric design , secondary development
个人分类: 硕士研究生毕业论文|1488 次阅读|0 个评论
[转载]利用Arcgis Engine 二次开发的使用和总结
linqy 2017-12-22 11:35
Arcgis Engine 初体验   先放一张第一版系统的图,由于公司机密不能提供源码,但是各个小功能提供源码,为需要的同仁提供些许帮助。 接下来进入正题,将逐一展示利用Arcgis Engine开发的程序小例子。 Arcgis Engine小程序们    一、较完全编辑功能GIS程序   开发原理:通过隐藏Arcgis Engine工具条开发的较全编辑功能GIS小程序,调用Arcgis Engine工具时使用内置Command进行传值。   包含功能:     1、基础编辑功能(打开.shp文件、绘制多边形、修改多边形)     2、扩展编辑功能(添加顶点、删除顶点、触摸拖动点)     3、锁定图层功能,防止修改其他图层   预览图: 下载地址: gisCommand.rar    二、字段搜索要素和空间搜索要素GIS程序   开发原理:使用内置的字段搜索功能搜索要素,通过新建多边形进行重叠要素查询(空间查询,也可选用其他空间)。   包含功能:     1、根据字段搜索要素     2、空间关系搜索要素   预览图: 下载地址: gisSearch.rar    三、图层重叠搜索GIS程序   开发原理:使用要素合并成临时图层然后与其他图层比对搜索出与其他图层重叠的要素。   包含功能:     1、搜索两图层的重叠要素   预览图: 下载地址: gisFeatureSearch.rar    四、要素合并、裁剪及检测要素重叠GIS程序   开发原理:使用内置要素合并和裁剪方法进行合并和裁剪,使用空间关系判断进行检测重叠判断。   包含功能:     1、合并要素     2、裁剪要素     3、检测重叠并提醒重叠要素个数   预览图: 下载地址: gisVertex.rar    五、自定义触屏拖拽顶点控件   上面涉及到拖拽点功能的程序都已引用该DLL了。   下载地址: SnapAndMoveVertex.rar 一些我搜集的Sharpmap资料和Arcgis Engine资料      1、 gis520地信免费资源共享_igis520的网盘 http://igis520.7958.com/folder-7678922   2、 gis资源网盘 http://laoheitan.400gb.com/u/1906276/3210355   3、ArcEngine跨屏幕画线解决办法 http://bbs.esrichina-bj.cn/esri/archiver/?tid-27758.html   4、地图数据编辑_添加节点 http://blog.3snews.net/space.php?uid=64155do=blogid=61731   5、Sample: Custom vertex editing commands (ArcObjects .NET 10 SDK)      http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//0001000002pz000000   6、ArcEngine编辑功能的实现(二) - yhexie - 博客园 http://www.cnblogs.com/yhlx125/archive/2012/02/27/2369572.html   7、使用ArcEngine的Select Features工具,如何获取选中的要素 http://blog.csdn.net/brokencar/article/details/6069997   8、 线围成的面多边形自动构建 http://www.cnblogs.com/yhlx125/archive/2012/03/01/2374999.html   9、用ArcEngine的工具条添加图层要素 http://www.doc88.com/p-909236632317.html   10、ArcGIS Runtime加载本地Shape数据和编辑Shape数据 http://blog.csdn.net/arcgis_cs/article/details/7547730   11、C#如何保存新加入shp的地图文档为mxd? http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=17395page=1   12、ArcGIS Engine中创建Shapfile文件 http://bbs.esrichina-bj.cn/esri/viewthread.php?tid=48944   13、ArcGIS10.0下载与安装 http://blog.sina.com.cn/s/blog_71dbfe2e0101b2hy.html   14、arcgis10.0下载地址及安装教程和注册机.rar http://pan.baidu.com/share/link?shareid=103102uk=1143478374   15、ArcGIS Engine基础开发教程(5)——学习地图查询 http://www.gisall.com/html/59/4359-899.html   16、ArcEngine空间数据查询_百度文库 http://wenku.baidu.com/view/ed3a5afe04a1b0717fd5ddd3.html   17、ArcGIS Engine基础开发教程(2)——学习几何对象与空间参考 http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=46367   18、ArcMap的Editor工具,实现要素拖动、编辑 http://www.cnblogs.com/aplsc/archive/2008/08/31/1280594.html   19、 ArcEngine 一些实现代码 - 李炳南 - 博客园 http://www.cnblogs.com/alex-bn-lee/archive/2012/04/08/2437358.html   20、分享AE中编辑功能的代码过程 和 思路_ArcEngine_GIS开发 http://210.43.24.222/chy/3sbase/news/?595.html   21、在地图上移动点,线,面的方法 http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=47446   22、关于节点编辑 http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=53988   23、Move Vertex of polyline and polygon http://forums.esri.com/Thread.asp?c=159f=1707t=285835   24、ArcGIS Runtime快速入门_百度文库 http://wenku.baidu.com/view/ed044e3d67ec102de2bd8965.html   25、ArcGIS Runtime 本地API介绍(一) http://blog.csdn.net/arcgis_all/article/details/8215094   26、SharpMap深度分析:地图渲染、坐标和比例尺 - 马维峰 - 博客园 http://maweifeng.cnblogs.com/archive/2006/03/06/344089.html   27、 GIS资料网盘 http://www.bego.cc/u/256394/2672612/5      标 红 为着重推荐。 原文本文地址: http://www.cnblogs.com/zdp06623/p/3359876.html
个人分类: ArcGIS 二次开发|2319 次阅读|0 个评论
[转载]【程序设计】【Dede二次开发程序详解】
lcj2212916 2014-6-24 01:36
【名稱】: Dede二次开发程序详解 【作者】: --- 【大小】:434KB 【格式】:PDF 【語言】:簡體中文 【內容簡介】: DedeCms 系统的模板是非固定的,用户可以在新建栏目时可以自行选择栏目模板,官方仅提供最基本的默认模板,即是内置系统模型的各个模板,由于DedeCms支持自定义频道模型,用户自定义新频道模型后,还需要按该模型的字段设计一套新的模板,此外,DedeCms 也支持使用风格的形式使用模板,默认风格是default,它表示系统默认使用cmspath/templets/default 这个文件夹的模板, 如果你下载了一套新的模板,你可以不必要删除default 原有的文件,把下载的模板文件夹命名你想要的风格名称,如style2 等,然后在后台修改了默认的模板风格名称为style2 ,那系统将使用templets/style2 这文件当作默认模板,但是若你手工指定了栏目模板的位置,则后台参数风格的定义无效。 一、概念,设计和使用模板,必须要理解下面几个概念 1、板块(封面)模板: .............. 【下載載點】: http://www.400gb.com/file/67077926
1094 次阅读|0 个评论
基于pFEPG的二次开发软件(部分)
serenashi 2012-10-26 15:45
pFEPG 是一个有限元程序的开发设计平台,针对不同问题生成不同计算程序; pFEPG 所有代码完全开放,用户可随意定制、修改以及二次开发。不需要专门数据库,程序移植性好;基于 pFEPG 二次开发的有限元软件是完全独立的有限元软件。 pFEPG 除了各个行业的软件应用外,基于 pFEPG 进行二次开发的各种衍生软件业有众多的行业用户 1、电机有限元分析系统 2、出砂机理与井眼稳定性分析系统 3、压力容器分析设计系统 4、二维围岩稳定性分析系统RAS 5、深部工程软岩大变形力学分析设计系统 6、胜利油田延时水压裂模拟软件 7、铸造过程仿真模拟专用分析软件 8、输电线路三维电磁环境计算软件(国家电网电科院) 9、机械磨具冲压过程仿真软件(中国机械科学研究总院) 有限元应用软件开发: 1 、根据行业各种有限元问题针对性开发的各种有限元仿真应用软件 2 、实时采集相关数据并进行实时计算及自适应修正的有限元应用软件 3 、适用于工程现场配置简易、功能强大、快速便捷之需求的嵌入式软件 4 、与企业已有软件进行无缝集成的各种有限元软件。 用户也可以利用 pFEPG 独立进行 CAE 应用软件的二次开发 用户自己编写代码 基于商用有限元软件 基于 pFEPG 有限元软件 开发周期长 开发周期短 开发周期短 代码庞大、易出错 按软件特定要求进行开发 代码精炼;通过 pFEPG 软件 自动生成,保证代码准确性 灵活,可面向各种有限元问题 不灵活,限定于软件特点 灵活,可面向各种有限元问题 开发时间成本大 搭建开发环境投入大 综合成本最低 独立软件;便于申请软件科研成果 不独立;不便于申请软件科研成果 独立软件;便于申请软件科研成果 不限学科、不限领域 限学科,限领域 不限学科,不限领域 面向 “ 创新 ” 面向 “ 傻瓜 ” 面向 “ 创新 ” 便于集成 不便于集成 便于集成
个人分类: 学习|5879 次阅读|0 个评论
IDL下保存数据为ENVI格式的方法
dongyanqing 2012-5-19 11:47
IDL下保存数据为ENVI格式的方法
1. 保存到 ENVI 内存中 ENVI_ENTER_DATA 可以将数据保存到内存,示例代码如下。这种保存到内存的方式需要获取 r_fid 便于后续操作。 ENVI ; 将读取的第一个波段存储到内存中 ENVI ENVI_ENTER_DATA, data, r_fid = rFid 2. 保存为 ENVI 格式文件 ENVI 标准格式文件包含二进制数据文件和头信息文件(扩展名为 hdr ), 可以利用 ENVI 函数 ENVI_WRITE_ENVI_FILE 直接输出。或 先输出二进制数据文件,再输出 hdr 头文件。示例代码如下: ENVI ;data = findgen(300,200) ENVI ; 定义输出文件名 ENVI out_file = 'c:\temp\tm_band1.img' ENVI ; 二进制方式输出 ENVI OPENW,lun,out_file,/get_lun ENVI WRITEU,lun,data ENVI FREE_LUN,lun ENVI ; 写出文件的头文件信息并打开文件(图 20.4 ) ENVI ENVI_SETUP_HEAD, fname=out_file, $ ENVI ns=300, nl=200, nb=1, $ ENVI interleave=0, $ ENVI data_type=size(data,/type), $ ENVI offset=0, /write, /open 多波段文件进行连续的 writeu 输出,最后 envi_setup_head 的时候 nb 等参数设置正确即可。 3. 存为其他数据格式 如果需要存储为其他格式如 ArcGIS 的 GDB 、 ArcView 、 ASCII 、 ENVI 、 ERDAS 、 ERMAPPER 、 Esri Grid 、 JPEG2000 、 NITF 、 PCI 和 TIFF 格式等,可以先利用 2 方法存储为 ENVI 标准格式,再调用 ENVI_OUTPUT_TO_GDB 或 ENVI_OUTPUT_TO_EXTERNAL_FORMAT 输出为,最后删除原 ENVI 格式文件即可。 示例代码如下: ENVI ; 获取待存储的文件 fid ENVI envi_open_file,out_file,r_fid = fid ENVI ; 获取文件相关信息 ENVI envi_file_query,fid ,dims = dims,nb = nb ENVI ; 定义输出文件名 ENVI out_name = 'c:\temp\envi_out.tif' ENVI ; 调用函数输出为 tiff 文件 ENVI ENVI_OUTPUT_TO_EXTERNAL_FORMAT, $ dims = dims,pos = lindgen(nb),out_name = out_name,/tiff,fid = fid ENVI ; 删除原文件 ENVI envi_file_mng,id = fid,/remove,/delete
个人分类: ENVI|31996 次阅读|0 个评论
[转载]UPFs教程1
onduty 2012-4-17 15:41
1.简单介绍 UPFs(User ProgrammableFeatures,用户可编程接口)是用户在ANSYS提供的Fortran和C语言源代码(并非真正的源代码,仅仅是 ANSYS公司定义好的子程序函数)的基础上,修改其用户可编程子程序和函数,从源代码的层次上扩充ANSYS的功能。用户需要在相应的Fortran和 C语言编译器的支持下,将编译修改后的源代码与ANSYS库相连接形成用户版本的ANSYS可执行文件。 所谓的“用户可编程子程序和函数”,以ANSYS12.0版本为例,在安装时不默认安装,需要选择自定义安装方式,并选择ansys customization files。安装后这些子程序和函数存在于C:\Program Files\ANSYS Inc\v120\ansys\customize\user目录下,多为*.F,即fortran文件,用户可对其进行修改,拷贝到相关文件夹并编译连 接。 2.利用UPFs可以完成的工作: (1)对ANSYS数据库进行操作。 (2)定义特定的荷载类型。 (3)定义新的单元类型。 (4)在非线性功能中实现对用户实参的运算。 (5)接触问题中实现用户摩擦系数。 (6)定义特定的非线性材料特性———如用户塑性屈服准则、蠕变方程、超弹性特性、失效准则、粘弹性性质等。 (7)用户优化———可以用自己的算法和中断准则替换ANSYS优化过程。 (8)定义用户介入计算过程的方式———在每个ANSYS运行求解、载荷步、子步和平衡迭代的开始和结束处允许用户介入,并允许用户在求解过程中评估计算结果。 3.常用的子程序及函数 (1)用户自定义命令 user01.F-user10.F 用户可以使用它们自定义ANSYS命令 在ANSYS中执行usr1(或user2)等命令调用以上user01.F(user02.F)中定义的功能。这里也可以使用/ MD命令为user01.F指定一个新名称,再通过该名称执行命令。/ MD命令的格式为:/ MD,NewCmd,1。 (2)用户自定义单元 ?.F-?.F 用于定义单元的基本属性,如单元形状,自由度等 l100.F-l105.F 是核心程序,主要用于计算单元矩阵、载荷向量,并实现扩展解的计算和处理 x100.F-x105.F 重载单元缺省特性 p100.F-p105.F 提供单元输出功能 注:最多可以定义6个新的单元类型 (3)用户自定义材料特性 Userpl.F 定义用户塑性准则 Usermat.F、usermat1d.F、usermat3d.F、usermatbm.F、usermatps.F对指定单元类型定义用户材料本构模型 userfc1.F-userfc6.F定义用户破坏准则 usercr.F和usercreep.F定义用户蠕变准则 (4)参数处理过程 pardim 创建参数数组 parevl 参数操作过程 pardef 列表中加入新参数 此外还有很多,不一一列出 (5)干预计算过程———通过命令USRCAL可激活下列过程 nBegANSYS启动时执行 USolBeg 求解开始时执行 USolFeg 求解结束时执行 ULdBeg 载荷步开始时执行 ULdFin 载荷步结束时执行 USsBeg 子步开始时执行 USsFin 子步结束时执行 nFin ANSYS任务结束时执行 使用这些子函数可以有效的控制ansys程序,载荷步,子步等的运行。 UPFS教程第一讲.pdf (85.78 KB) 下载次数: 60 2010-7-27 14:31 4.ansys12.0 upfs的编译连接(2010.7.28 ) (1)下载安装vis l st io 2005 professional (2)下载安装Intel vis l fortran 11 (3)下载安装ANSYS12.0.1 32位,在电驴下载即可,注意安装时选择安装ANSYS customization Files (4)修改环境变量( 很重要的一步,不然会出现很多问题) 可参照该文:Compiling UPFs and Creating Customized ANSYS Executables Compiling UPFs and Creating Customized ANSYS Executables .pdf (189.26 KB)
个人分类: ANSYS|4314 次阅读|0 个评论
ENVI下将图像各波段单独存为文件的解决与分析测试
dongyanqing 2012-1-10 09:39
ENVI下将图像各波段单独存为文件的解决与分析测试
论坛里面的一个问题“ENVI怎样将图像各波段分开为单独文件”。IDL二次开发调用ENVI函数可以轻松实现,用哪个函数呢,有 “cf_doit”、“resize_doit”、“math_doit”、“envi_layer_stacking_doit”等几个。当然了,将各波段一次全部读出来再写成二进制文件也行(分块也可以,稍微麻烦些),一旦遇到大数据了不好控制内存占用。 基于: http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=60383 对上面几种方式的调用和花费时间简单进行了测试,程序主界面如下: sav程序 http://www.rayfile.com/files/7cb9e3de-3b25-11e1-91d0-0015c55db73d/ 主要功能代码如下: FOR i= 0 , N_ELEMENTS (files)- 1 DO BEGIN ; 构建输出文件名 fileName = FILE_BASENAME (files ) pointPos = STRPOS (fileName, '.' ) ; 查找文件名中点的位置 IF pointPos NE - 1 THEN BEGIN fileName= STRMID (fileName, 0 ,pointPos) ENDIF ENVI_OPEN_FILE , files , r_fid=fid IF (fid EQ - 1 ) THEN BEGIN tmp = DIALOG_MESSAGE (files + ' 文件读取错误 ' ,$ title = !sys_title, /error) CONTINUE ENDIF ; 文件信息 ENVI_FILE_QUERY , fid, dims=dims, nb=nb,bnames = bnames,DATA_TYPE = dt,$ ns = ns, nl = nl startTime = systime ( 1 ) for curBand = 0 ,nb- 1 do begin out_name = outfiledir+ PATH_SEP ()+fileName+ '_band' + StrTrim (curBand+ 1 , 2 )+ '.img' envi_doit , 'cf_doit' , $ fid=fid, pos=curBand, dims=dims, $ remove= 0 , out_name=out_name endfor ; print , 'cf_doit time' , systime ( 1 )-startTime startTime = systime ( 1 ) for curBand = 0 ,nb- 1 do begin out_name = outfiledir+ PATH_SEP ()+fileName+ '_band_resize' + StrTrim (curBand+ 1 , 2 )+ '.img' envi_doit , 'resize_doit' , $ fid=fid, pos=curBand, dims=dims, $ interp= 1 , rfact= , $ out_name=out_name endfor print , 'resize_doit time' , systime ( 1 )-startTime startTime = systime ( 1 ) for curBand = 0 ,nb- 1 do begin out_name = outfiledir+ PATH_SEP ()+fileName+ '_band_bandmath' + StrTrim (curBand+ 1 , 2 )+ '.img' pos = curBand exp = 'b1' envi_doit , 'math_doit' , $ fid=fid, pos=pos, dims=dims, $ exp=exp, out_name=out_name endfor print , 'math_doit time' , systime ( 1 )-startTime startTime = systime ( 1 ) for curBand = 0 ,nb- 1 do begin pos = curBand out_proj = envi_get_projection (fid=fid, $ pixel_size=out_ps) out_name = outfiledir+ PATH_SEP ()+fileName+ '_layer_stacking' + StrTrim (curBand+ 1 , 2 )+ '.img' envi_doit , 'envi_layer_stacking_doit' , $ fid=fid, pos=pos, dims=dims, $ out_dt=dt, out_name=out_name, $ interp= 2 , out_ps=out_ps, $ out_proj=out_proj endfor print , 'layer_stacking_doit time' , systime ( 1 )-startTime ; 依次读写文件 startTime = systime ( 1 ) for curBand = 0 ,nb- 1 do begin pos = curBand map_info = envi_get_map_info (fid=fid) out_name = outfiledir+ PATH_SEP ()+fileName+ '_writeu' + StrTrim (curBand+ 1 , 2 )+ '.img' openw ,lun,out_name,/get writeu ,lun, envi_get_data (fid=fid, dims=dims, pos=pos) free_lun ,lun ENVI_SETUP_HEAD , fname=out_name, $ ns=ns, nl=nl, nb= 1 , $ interleave= 0 , data_type=dt, $ offset= 0 , /write,$ MAP_INFO = MAP_INFO endfor print , 'writeU time' , systime ( 1 )-startTime ; 输出完成 ENVI_FILE_MNG , id=fid, /remove ; 设置进度条 IDLITWDPROGRESSBAR_SETVALUE ,(*pState). PRSBAR ,(i+ 1 )*per ENDFOR 对 70M 左右的 224 个波段的高光谱数据测试,各方法花费的时间如下: cf_doit time 2.5090001 resize_doit time 3.3580000 math_doit time 3.5969999 layer_stacking_doit time 8.9680002 writeU time 2.2889998 这里的 writeU 最快,cf_doit次之,也在意料之中 , 因其他函数均支持分块处理。故最保险的函数还是 选用cf_doit 。
个人分类: ENVI|8469 次阅读|0 个评论
ENVI二次开发基础入门与基本函数使用
dongyanqing 2011-12-29 22:12
ENVI二次开发关键在于基础函数调用方式与入门的视频; IDL12-08-3ENVI二次开发函数调用基础 L12-08-5ENVI面向对象特征提取之二次开发
个人分类: ENVI|4956 次阅读|0 个评论
ENVI二次开发综述与常用源代码分享
dongyanqing 2011-6-19 02:00
ENVI二次开发综述与常用源代码分享
ENVI 具备了丰富的二次开发功能函数接口,基本涵盖了 ENVI 下所有的功能,且通过 IDL 语言有输出助手(导出为 COM 或 JAVA 类)、 Callable 、 IDLDrawWidget 和 COM_IDL_CONNECT 等多种方式与其他语言进行集成。 遥感与 GIS 一体化的应用模式如下: 下表对 ENVI 二次开发中常用的功能代码进行汇总。 功 能 源码名称 初始化 ENVI startENVI.pro 定标 cal_calibration.pro 大气校正 cal_quac.pro 融合 cal_sharpen.pro 镶嵌 cal_mosaic.pro 裁剪 cal_subset.pro 分类 ( 监督 + 非监督 ) cal_class.pro 面向对象特征提取 cal_fx.pro 结束 ENVI endENVI.pro 二次开发的基本流程框架图如下: 打包下载: ENVI二次开发常用功能代码.rar 附各个模块的源代码 初始化ENVI ;+ ;ENVI二次开发功能代码 ; ;Author: DYQ ;问题讨论: ; http://hi.baidu.com/dyqwrp ; http://bbs.esrichina-bj.cn/ESRI/?fromuid=9806 ;描述: ; 初始化ENVI ; ;调用方法: ;(1) ENVI的处理过程中不显示进度条 ; startEnvi ;(2) ENVI的处理过程中显示进度条 ; startEnvi,/ShowProcess ;- PRO startENVI, showProcess = showProcess compile_opt idl2 ENVI, /restore_base_save_files ENVI_BATCH_INIT, NO_STATUS_WINDOW = 1- keyWord_set(showProcess) END 定标 ;+ ;ENVI二次开发功能代码 ; ;Author: DYQ ;问题讨论: ; http://bbs.esrichina-bj.cn/ESRI/?fromuid=9806 ; http://hi.baidu.com/dyqwrp ;描述: ; 定标 ; ;调用方法: ; cal_Calibration, 'c:\temp\can_tmr.img','c:\temp\result.img', , ] ;注意事项: ; gainoffset参数与波段个数一一对应 ; ;- Pro cal_calibration, infile, outFile, gainOffset,wl = wv;(可选关键字,wv是定标后单位) COMPILE_OPT idl2 CATCH, Error_status errorshow = 'Sorry to see the error,'+ $ ' please send the error Information to "dongyq@esrichina-bj.cn"' IF Error_status NE 0 THEN BEGIN tmp = DIALOG_MESSAGE(errorshow+STRING(13b)+$ !ERROR_STATE.MSG,/error,title = '错误提示!') return ENDIF ;获取ENVI的配置参数 cfg = envi_get_configuration_values() tmppath = cfg.DEFAULT_TMP_DIRECTORY ;是否设置了输出文件名 IF N_ELEMENTS(outFile) EQ 0 THEN out_name=tmppath+PATH_SEP()+'void.tmp' ENVI_OPEN_FILE,infile,R_fid= fid ;获取信息 ENVI_FILE_QUERY, FID, $ dims = dims, $ BNAMES = BNAMEs, $ NB = NB ;定标功能 ENVI_DOIT,'gainoff_doit', fid=fid, pos=LINDGEN(nb), dims=dims, out_name=outFile, $ gain=1./gainOffset , offset=gainOffset , r_fid=r_fid, in_memory=0,$ OUT_DT = 4 ENVI_FILE_QUERY, r_fid, $ dims = dims, $ DATA_TYPE = 4, $ INTERLEAVE = INTERLEAVE, $ NB = NB, $ NL = NL, $ NS=NS ,$ OFFSET = OFFSET map_info = ENVI_GET_MAP_INFO(fid=r_fid) ;先关掉文件 ENVI_FILE_MNG, id = fid,/Remove ENVI_FILE_MNG, id = r_fid,/Remove ;再写入头文件 ENVI_SETUP_HEAD, $ DATA_TYPE = DATA_TYPE, $ BNAMES = '定标后:'+BNAMES, $ DESCRIP = '定标公式 y=x/gain+offset', $ FNAME=outFile,$ INTERLEAVE = INTERLEAVE, $ MAP_INFO = map_info, $ wl = wv, $ NB = NB, $ NL = NL, $ NS=NS ,$ OFFSET = OFFSET,$ /Write END 大气校正 ;+ ;ENVI二次开发功能代码 ; ;Author: DYQ ;问题讨论: ; http://hi.baidu.com/dyqwrp ; http://bbs.esrichina-bj.cn/ESRI/?fromuid=9806 ;描述: ; 大气校正 ; ;调用方法: ;cal_QUAC,inputfile,outputfile ; ;- PRO CAL_QUAC,inputfile,outputfile COMPILE_OPT idl2 CATCH, Error_status errorshow = 'Sorry to see the error,'+ $ ' please send the error Information to "dongyq@esrichina-bj.cn"' IF Error_status NE 0 THEN BEGIN tmp = DIALOG_MESSAGE(errorshow+STRING(13b)+$ !ERROR_STATE.MSG,/error,title = '错误提示!') return ENDIF ENVI_OPEN_FILE, inputfile, r_fid=fid IF (fid EQ -1) THEN BEGIN RETURN ENDIF ENVI_FILE_QUERY, fid, dims=dims, nb=nb, sensor_type=sensor_type pos = LINDGEN(nb) sensor = envi_sensor_type(sensor_type) ; Perform QUick Atmospheric Correction ENVI_DOIT, 'envi_quac_doit', $ fid=fid, pos=pos, dims=dims, $ quac_sensor=sensor, $ out_name=outputfile, r_fid=r_fid ; END 融合 ;+ ;ENVI二次开发功能代码 ; ;Author: DYQ ;问题讨论: ; http://hi.baidu.com/dyqwrp ; http://bbs.esrichina-bj.cn/ESRI/?fromuid=9806 ;描述: ;图像融合 ; ;调用方法: ;CAL_SHARPEN,inputfileMulti,inputfilePan,outputfile,method ;inputfileMulti是低分辨率的多光谱影像 ;inputfilePan是高分全色影像 ; ;Method : 0-HSV融合 ; 1-color-normalized融合 ; 2-Gram-Schmidt融合 ; 3-主成份分析融合 ;- PRO CAL_SHARPEN,inputfileMulti,inputfilePan,outputfile,method COMPILE_OPT idl2 CATCH, Error_status errorshow = 'Sorry to see the error,'+ $ ' please send the error Information to "dongyq@esrichina-bj.cn"' IF Error_status NE 0 THEN BEGIN tmp = DIALOG_MESSAGE(errorshow+STRING(13b)+$ !ERROR_STATE.MSG,/error,title = '错误提示!') return ENDIF ;打开全色影像 ENVI_OPEN_FILE, inputfilePan, r_fid=h_fid IF (h_fid EQ -1) THEN BEGIN ENVI_BATCH_EXIT RETURN ENDIF ;获取影像参数 ; ENVI_FILE_QUERY, h_fid, ns=h_ns, nl=h_nl,$ dims = h_dims,nb = h_nb ; 打开多光谱影像 ENVI_OPEN_FILE, inputfileMulti, r_fid=m_fid IF (m_fid EQ -1) THEN BEGIN ENVI_BATCH_EXIT RETURN ENDIF ;获取影像参数 ENVI_FILE_QUERY, m_fid, dims=m_dims, $ bnames=m_bnames,nb = m_nb IF method LT 2 THEN BEGIN ; Set the keywords f_dims = f_pos = ; rgb_fid = out_bname = ;ENVI的融合功能 ENVI_DOIT, 'sharpen_doit', $ fid=rgb_fid, pos=lindgen(m_nb), f_fid=h_fid, $ f_dims=f_dims, f_pos=f_pos, $ out_name=outputfile, method=1, $ interp=0, out_bname=out_bname RETURN ENDIF CASE method OF ; 2: BEGIN out_bname = 'GS_Sharpen_band_'+STRTRIM(LINDGEN(m_nb),2) ENVI_DOIT, 'ENVI_GS_SHARPEN_DOIT', $ DIMS= m_dims, $ fID = m_fid, $ HIRES_DIMS = h_dims, $ HIRES_FID = h_fid,$ HIRES_POS = LINDGEN(h_nb),$ INTERP = 2,$ METHOD = 0 ,$ OUT_BNAME = out_bname , $ OUT_NAME = outputfile,$ POS =LINDGEN(m_nb) END 3: BEGIN out_bname = 'PC_Sharpen_band_'+STRTRIM(LINDGEN(m_nb),2) ENVI_DOIT, 'ENVI_PC_SHARPEN_DOIT', $ DIMS= m_dims, $ fID = m_fid, $ HIRES_DIMS = h_dims, $ HIRES_FID = h_fid,$ HIRES_POS = LINDGEN(h_nb),$ INTERP = 2,$ OUT_BNAME = out_bname , $ OUT_NAME = outputfile,$ POS =LINDGEN(m_nb) END ELSE: ENDCASE END 镶嵌 ;+ ;ENVI二次开发功能代码 ; ;Author: DYQ ;问题讨论: ; http://hi.baidu.com/dyqwrp ; http://bbs.esrichina-bj.cn/ESRI/?fromuid=9806 ;描述: ; 镶嵌 ; ;调用方法: ; cal_mosaic, txtFile ; 输入为txt配置文件完整路径 ; ;- PRO georef_mosaic_setup, fids=fids, dims=dims, out_ps=out_ps, $ xsize=xsize, ysize=ysize, x0=x0, y0=y0, map_info=map_info COMPILE_OPT IDL2 IF KEYWORD_SET(dims) THEN $ IF N_ELEMENTS(fids) NE N_ELEMENTS(dims ) THEN dims=0 ; IF N_ELEMENTS(fids) LT 2 THEN BEGIN xsize = -1 ysize = -1 x0 = -1 y0 = -1 RETURN ENDIF ; if no DIMS passed in ; nfiles = N_ELEMENTS(fids) IF (KEYWORD_SET(dims) EQ 0) THEN BEGIN dims = FLTARR(5, nfiles) FOR i=0, nfiles-1 DO BEGIN ENVI_FILE_QUERY, fids , ns=ns, nl=nl dims = ENDFOR ENDIF UL_corners_X = DBLARR(nfiles) UL_corners_Y = DBLARR(nfiles) east = -1e34 west = 1e34 north = -1e34 south = 1e34 FOR i=0,nfiles-1 DO BEGIN pts = , dims ], $ ; UL , dims ], $ ; UR , dims ], $ ; LL , dims ] ] ; LR ENVI_CONVERT_FILE_COORDINATES, fids , pts , pts , xmap, ymap, /to_map UL_corners_X = xmap UL_corners_Y = ymap east = east MAX(xmap) west = west MIN(xmap) north = north MAX(ymap) south = south MIN(ymap) ENDFOR xsize = east - west ysize = north - south ; xsize_pix = FIX( xsize/out_ps )+1 ysize_pix = FIX( ysize/out_ps )+1 ; proj = ENVI_GET_PROJECTION(fid=fids ) map_info = ENVI_MAP_INFO_CREATE(proj=proj, mc= , ps=out_ps) temp = BYTARR(10,10) ENVI_ENTER_DATA, temp, map_info=map_info, /no_realize, r_fid=tmp_fid ; find the x and y offsets for the images ; x0 = LONARR(nfiles) y0 = LONARR(nfiles) FOR i=0,nfiles-1 DO BEGIN ENVI_CONVERT_FILE_COORDINATES, tmp_fid, xpix, ypix, UL_corners_X , UL_corners_Y x0 = xpix y0 = ypix ENDFOR ; delete the tmp file ENVI_FILE_MNG, id=tmp_fid, /remove, /no_warning END ; PRO mosaic_files,info,pos=pos,rasterfilenames=rasterfilenames,output=output,crop=crop,$ file_pattern=file_pattern COMPILE_OPT idl2 IF N_ELEMENTS(background) EQ 0 THEN background=0 IF N_ELEMENTS(crop) NE 4 THEN crop= ELSE crop= * IF N_ELEMENTS(rasterfilenames) EQ 0 AND N_ELEMENTS(file_pattern) EQ 0 THEN BEGIN IF rasterfilenames EQ '' THEN RETURN ENDIF IF N_ELEMENTS(file_pattern) NE 0 THEN BEGIN rasterfilenames=FILE_SEARCH(file_pattern) ENDIF numfiles=N_ELEMENTS(rasterfilenames) rasterfids=LONARR(numfiles) IF N_ELEMENTS(output) EQ 0 THEN BEGIN output=ENVI_PICKFILE(title='Output Mosaick Filename:') IF output EQ '' THEN RETURN ENDIF ; tlb = WIDGET_AUTO_BASE(title='镶嵌参数设置') we = WIDGET_PARAM(tlb, dt=4, field=3, $ default=-999., uvalue='param', /auto, $ PROMPT ='忽略数据值') result = AUTO_WID_MNG(tlb) IF (result.accept EQ 0) THEN RETURN ignoreValue = result.param ENVI_OPEN_FILE, rasterfilenames , r_fid=tempfid rasterfids =tempfid ENVI_FILE_QUERY,tempfid,nb=nb,ns=tempns,nl=tempnl,data_type=data_type map_info = ENVI_GET_MAP_INFO(fid=tempfid) out_ps=map_info.ps IF N_ELEMENTS(pos) EQ 0 OR N_ELEMENTS(pos) GT nb THEN pos=LINDGEN(nb) posarr=LONARR(N_ELEMENTS(pos),numfiles) FOR i=0,numfiles-1 DO posarr =pos dimsarr=LONARR(5,numfiles) dimsarr = -crop use_see_through = LONARR(numfiles) FOR i=1,numfiles-1 DO BEGIN ENVI_OPEN_FILE, rasterfilenames , r_fid=tempfid rasterfids =tempfid ENVI_FILE_QUERY,tempfid,nb=nb,ns=tempns,nl=tempnl dimsarr = -crop ENDFOR georef_mosaic_setup, fids=rasterfids, out_ps=out_ps, dims=dimsarr, xsize=xsize, ysize=ysize,$ x0=x0, y0=y0, map_info=map_info ; USE_SEE_THROUGH = INTARR(N_ELEMENTS(rasterfids))+1 seeTv = MAKE_ARRAY(N_ELEMENTS(rasterfids),value =ignoreValue ) ENVI_DOIT, 'mosaic_doit', fid=rasterfids, pos=posarr, $ dims=dimsarr, out_name=output, xsize=xsize, $ ysize=ysize, x0=x0, y0=y0, georef=1, $ out_dt=data_type, pixel_size=out_ps, $ background=ignoreValue,SEE_THROUGH_VAL=seeTv,$ USE_SEE_THROUGH = USE_SEE_THROUGH,$ map_info=map_info END PRO cal_mosaic, txtFile COMPILE_OPT idl2 CATCH, Error_status errorshow = 'Sorry to see the error,'+ $ ' please send the error Information to "dongyq@esrichina-bj.cn"' IF Error_status NE 0 THEN BEGIN tmp = DIALOG_MESSAGE(errorshow+STRING(13b)+$ !ERROR_STATE.MSG,/error,title = '错误提示!') return ENDIF ;如果文件不存在则返回 IF ~FILE_TEST(txtFile) THEN RETURN; ;解析 nFiles = FILE_LINES(txtFile) ; filenames = STRARR(nFiles) OPENR,lun,txtfile,/get_ READF,lun,filenames FREE_LUN,lun ; mosaic_files,rasterfilenames = filenames ,output = filenames END 裁剪 ;+ ;ENVI二次开发功能代码 ; ;Author: DYQ ;问题讨论: ; http://hi.baidu.com/dyqwrp ; http://bbs.esrichina-bj.cn/ESRI/?fromuid=9806 ;描述: ; 基于shape矢量文件裁剪 ; ;调用方法: ; cal_subset,infile, shapefile, resultfile ; infile:待裁剪的栅格文件 ; shapefile:矢量文件 ; resultfile:裁剪后存储结果 ;- PRO cal_subset,infile, shapefile, resultfile compile_opt idl2 CATCH, Error_status errorshow = 'Sorry to see the error,'+ $ ' please send the error Information to "dongyq@esrichina-bj.cn"' IF Error_status NE 0 THEN BEGIN tmp = DIALOG_MESSAGE(errorshow+STRING(13b)+$ !ERROR_STATE.MSG,/error,title = '错误提示!') return ENDIF shapeobj = OBJ_NEW('IDLffShape', shapefile) ENVI_OPEN_FILE,infile,r_fid = fid ENVI_FILE_QUERY, fid, ns = ns, nb = nb, nl = nl, dims = dims,BNAMES = BNAMES shapeobj-GETPROPERTY, N_Entities = nEntities ; ; shape_type =5--多边形 8-- 多个多边形 ;BOUNDS 边界值 ; roi_ids = LONARR(nEntities1) FOR i=0, nEntities-1 DO BEGIN entitie = shapeobj-GETENTITY(i) ;多边形则进行转换,否则不做任何操作 IF (entitie.SHAPE_TYPE EQ 5) THEN BEGIN record = *(entitie.VERTICES) ;转换为文件坐标 ENVI_CONVERT_FILE_COORDINATES,fid,xmap,ymap,record ,record ;创建ROI roi_ids = ENVI_CREATE_ROI(color=4, $ ns = ns , nl = nl) ENVI_DEFINE_ROI, roi_ids , /polygon, xpts=REFORM(xMap), ypts=REFORM(yMap) ;roi_ids = roi_id ;记录XY的区间,裁剪用 ;记录XY的区间,裁剪用 IF i EQ 0 THEN BEGIN xmin = ROUND(MIN(xMap,max = xMax)) yMin = ROUND(MIN(yMap,max = yMax)) ENDIF ELSE BEGIN xmin = xMin ROUND(MIN(xMap)) xMax = xMax ROUND(MAX(xMap)) yMin = yMin ROUND(MIN(yMap)) yMax = yMax ROUND(MAX(yMap)) ENDELSE ENDIF shapeobj-DESTROYENTITY, entitie ENDFOR OBJ_DESTROY, shapeobj ; xMin = xMin 0 xmax = xMax ns-1 yMin = yMin 0 ymax = yMax nl-1 out_dims = ;获取ENVI的配置参数 cfg = envi_get_configuration_values() tmppath = cfg.DEFAULT_TMP_DIRECTORY ;创建掩膜,裁剪后掩 ENVI_MASK_DOIT,$ AND_OR =1, $ OUT_NAME = tmppath+path_sep()+'void.mask', $ ROI_IDS= roi_ids, $ ;ROI的ID ns = ns, nl = nl, $ /inside, $ ;区域内或外 r_fid = m_fid ENVI_MASK_APPLY_DOIT, FID = fid, POS = INDGEN(nb), DIMS = out_dims, $ M_FID = m_fid, M_POS = , VALUE = 0, $ out_name = resultfile;,$ ;out_bnames = BNAMES+"("+"subset by "+STRTRIM(FILE_BASENAME(shapefile),2)+")" ;掩膜文件ID移除 ENVI_FILE_MNG, id =m_fid,/remove END 监督与非监督分类 ;+ ;ENVI二次开发功能代码 ; ;Author: DYQ ;问题讨论: ; http://hi.baidu.com/dyqwrp ; http://bbs.esrichina-bj.cn/ESRI/?fromuid=9806 ;描述: ; 分类处理,包括监督分类和非监督分类 ; ;调用方法: ; ;CAL_CLASS,inputfile,outputfile, method,... ; ;inputFile:待分类影像 ;outpurfile:分类结果; ;Method : 0--5为监督分类,6、7为非监督分类 ; ; 1-最小距离 1 ; 2-最大似然 2 ; 3-马氏距离 5 ; 4-神经元网络 ENVI_NEURAL_NET_DOIT ; 5-向量机 ENVI_SVM_DOIT ; 6-IsoData 4 ; 7-K-Means 7 ;注意:每一种算法需要使用的参数说明可参考ENVI帮助文档 ; PRO CAL_CLASS,inputfile,outputfile, method,$ ;感兴趣区文件 roifile = roifile,$ ;平行六面体分类算法可选参数 STDV = stdv, $ STD_MULT =STD_MULT,$ ;神经元网络分类算法参数 theta = theta, $ eta = eta, $ alpha = alpha, $ act_type = act_type, $ rms_crit = rms_crit, $ num_layers = num_layers, $ num_sweeps = num_sweeps, $ ;向量机 thresh = thresh, $ penalty = penalty, $ kernel_type = kernel_type, $ kernel_degree = kernel_degree, $ kernel_bias = kernel_bias ,$ ;K-Means 算法可选参数 ITERATIONS = ITERATIONS, $ NUM_CLASSES = NUM_CLASSES , $ ;ISO算法参数 CHANGE_THRESH = CHANGE_THRESH, $ ISO_MERGE_DIST = ISO_MERGE_DIST, $ ISO_MERGE_PAIRS = ISO_MERGE_PAIRS, $ ISO_MIN_PIXELS = ISO_MIN_PIXELS, $ ISO_SPLIT_SMULT = ISO_SPLIT_SMULT, $ ISO_SPLIT_STD = ISO_SPLIT_STD, $ MIN_CLASSES = MIN_CLASSES COMPILE_OPT idl2 CATCH, Error_status errorshow = 'Sorry to see the error,'+ $ ' please send the error Information to "dongyq@esrichina-bj.cn"' IF Error_status NE 0 THEN BEGIN tmp = DIALOG_MESSAGE(errorshow+STRING(13b)+$ !ERROR_STATE.MSG,/error,title = '错误提示!') return ENDIF ;输入数据预处理 ENVI_OPEN_FILE, inputfile, r_fid=fid IF (fid EQ -1) THEN BEGIN RETURN ENDIF ;获取文件信息 ENVI_FILE_QUERY, fid, dims=dims, nb=nb pos = LINDGEN(nb) out_name = outputfile CASE method OF ;-IsoData 4 6: BEGIN IF ~KEYWORD_SET(CHANGE_THRESH) THEN CHANGE_THRESH = .05 IF ~KEYWORD_SET(NUM_CLASSES) THEN NUM_CLASSES = 10 IF ~KEYWORD_SET(ITERATIONS) THEN ITERATIONS = 1 IF ~KEYWORD_SET(ISO_MERGE_DIST) THEN ISO_MERGE_DIST = 1 IF ~KEYWORD_SET(ISO_MERGE_PAIRS) THEN ISO_MERGE_PAIRS = 2 IF ~KEYWORD_SET(ISO_MIN_PIXELS) THEN ISO_MIN_PIXELS = 1 IF ~KEYWORD_SET(ISO_SPLIT_SMULT) THEN ISO_SPLIT_SMULT = 1 IF ~KEYWORD_SET(ISO_SPLIT_STD) THEN ISO_SPLIT_STD = 1 IF ~KEYWORD_SET(MIN_CLASSES) THEN MIN_CLASSES = 5 out_bname = 'IsoData' ENVI_DOIT, 'class_doit', fid=fid, pos=pos, dims=dims, $ out_bname=out_bname, out_name=out_name, method=4, $ r_fid=r_fid, $ NUM_CLASSES = NUM_CLASSES, $ ITERATIONS = ITERATIONS, $ in_memory=0, $ CHANGE_THRESH = CHANGE_THRESH, $ ISO_MERGE_DIST = ISO_MERGE_DIST, $ ISO_MERGE_PAIRS = ISO_MERGE_PAIRS, $ ISO_MIN_PIXELS = ISO_MIN_PIXELS, $ ISO_SPLIT_SMULT = ISO_SPLIT_SMULT, $ ISO_SPLIT_STD = ISO_SPLIT_STD, $ MIN_CLASSES = MIN_CLASSES END ;-K-Means 7 7: BEGIN IF ~KEYWORD_SET(NUM_CLASSES) THEN NUM_CLASSES = 5 IF ~KEYWORD_SET(CHANGE_THRESH) THEN CHANGE_THRESH = .5 IF ~KEYWORD_SET(ITERATIONS) THEN ITERATIONS = 1 out_bname = 'K-Means' thresh=REPLICATE(0.05,num_classes) ENVI_DOIT, 'class_doit', fid=fid, pos=pos, dims=dims, $ out_bname=out_bname, out_name=out_name, method=7, $ r_fid=r_fid, $ lookup = BYTARR(3,num_classes+1), $ NUM_CLASSES = NUM_CLASSES, $ in_memory=0, CHANGE_THRESH=CHANGE_THRESH,$ ITERATIONS = ITERATIONS END ;-平行六面体 0 0: BEGIN ENVI_RESTORE_ROIS, roifile roi_ids = ENVI_GET_ROI_IDS(fid=fid, $ roi_colors=roi_colors, roi_names=class_names) class_names = num_classes = N_ELEMENTS(roi_ids) ; Set the unclassified class to black and use roi colors lookup = BYTARR(3,num_classes+1) lookup = roi_colors ; 计算类ROI的基本统计信息 mean = FLTARR(N_ELEMENTS(pos), num_classes) stdv = FLTARR(N_ELEMENTS(pos), num_classes) cov = FLTARR(N_ELEMENTS(pos),N_ELEMENTS(pos),num_classes) FOR j=0, num_classes-1 DO BEGIN ; roi_dims= ),0,0,0,0] ENVI_DOIT, 'envi_stats_doit', fid=fid, pos=pos, $ dims=roi_dims, comp_flag=4, mean=c_mean, $ stdv=c_stdv, cov=c_cov MEAN = c_mean stdv = c_stdv cov = c_cov ENDFOR ; thresh=REPLICATE(0.05,num_classes) out_bname = 'parallelepiped' ENVI_DOIT, 'class_doit', fid=fid, pos=pos, dims=dims, $ out_bname=out_bname, out_name=out_name, method=0, $ mean=mean, stdv=stdv, std_mult=st_mult, $ lookup=lookup, class_names=class_names, $ in_memory=0;, thresh=thresh END ;-最小距离 1 1: BEGIN ENVI_RESTORE_ROIS, roifile roi_ids = ENVI_GET_ROI_IDS(fid=fid, $ roi_colors=roi_colors, roi_names=class_names) class_names = num_classes = N_ELEMENTS(roi_ids) ; Set the unclassified class to black and use roi colors lookup = BYTARR(3,num_classes+1) lookup = roi_colors ; 计算类ROI的基本统计信息 ; mean = FLTARR(N_ELEMENTS(pos), num_classes) stdv = FLTARR(N_ELEMENTS(pos), num_classes) cov = FLTARR(N_ELEMENTS(pos),N_ELEMENTS(pos),num_classes) FOR j=0, num_classes-1 DO BEGIN ; roi_dims= ),0,0,0,0] ENVI_DOIT, 'envi_stats_doit', fid=fid, pos=pos, $ dims=roi_dims, comp_flag=4, mean=c_mean, $ stdv=c_stdv, cov=c_cov MEAN = c_mean stdv = c_stdv cov = c_cov ENDFOR ; thresh=REPLICATE(0.05,num_classes) out_bname = 'MinimumDistance' ENVI_DOIT, 'class_doit', fid=fid, pos=pos, dims=dims, $ out_bname=out_bname, out_name=out_name, method=1, $ mean=mean, stdv=stdv, std_mult=st_mult, $ lookup=lookup, class_names=class_names, $ in_memory=0 END ;-最大似然 2 2: BEGIN ENVI_RESTORE_ROIS, roifile roi_ids = ENVI_GET_ROI_IDS(fid=fid, $ roi_colors=roi_colors, roi_names=class_names) class_names = num_classes = N_ELEMENTS(roi_ids) ; Set the unclassified class to black and use roi colors lookup = BYTARR(3,num_classes+1) lookup = roi_colors ; 计算类ROI的基本统计信息 ; mean = FLTARR(N_ELEMENTS(pos), num_classes) stdv = FLTARR(N_ELEMENTS(pos), num_classes) cov = FLTARR(N_ELEMENTS(pos),N_ELEMENTS(pos),num_classes) FOR j=0, num_classes-1 DO BEGIN ; roi_dims= ),0,0,0,0] ENVI_DOIT, 'envi_stats_doit', fid=fid, pos=pos, $ dims=roi_dims, comp_flag=4, mean=c_mean, $ stdv=c_stdv, cov=c_cov MEAN = c_mean stdv = c_stdv cov = c_cov ENDFOR ; thresh=REPLICATE(0.05,num_classes) out_bname = 'MaximumLikelihood' ENVI_DOIT, 'class_doit', fid=fid, pos=pos, dims=dims, $ out_bname=out_bname, out_name=out_name, method=2, $ mean=mean, stdv=stdv, std_mult=st_mult, $ lookup=lookup, class_names=class_names, $ cov = cov,$ in_memory=0 END ;-马氏距离 5 3: BEGIN ENVI_RESTORE_ROIS, roifile roi_ids = ENVI_GET_ROI_IDS(fid=fid, $ roi_colors=roi_colors, roi_names=class_names) class_names = num_classes = N_ELEMENTS(roi_ids) ; Set the unclassified class to black and use roi colors lookup = BYTARR(3,num_classes+1) lookup = roi_colors ; 计算类ROI的基本统计信息 ; mean = FLTARR(N_ELEMENTS(pos), num_classes) stdv = FLTARR(N_ELEMENTS(pos), num_classes) cov = FLTARR(N_ELEMENTS(pos),N_ELEMENTS(pos),num_classes) FOR j=0, num_classes-1 DO BEGIN ; roi_dims= ),0,0,0,0] ENVI_DOIT, 'envi_stats_doit', fid=fid, pos=pos, $ dims=roi_dims, comp_flag=4, mean=c_mean, $ stdv=c_stdv, cov=c_cov MEAN = c_mean stdv = c_stdv cov = c_cov ENDFOR ; thresh=REPLICATE(0.05,num_classes) out_bname = 'Mahalanobis' ENVI_GET_ROI_INFORMATION, roi_ids,nPts = nPts ENVI_DOIT, 'class_doit', fid=fid, pos=pos, dims=dims, $ out_bname=out_bname, out_name=out_name, method=5, $ mean=mean, stdv=stdv, std_mult=st_mult, $ lookup=lookup, class_names=class_names, $ cov = cov,NPTS = nPts, $ in_memory=0 END ;-神经元网络 ENVI_NEURAL_NET_DOIT 4: BEGIN IF ~KEYWORD_SET(theta) THEN theta = .9 IF ~KEYWORD_SET(eta) THEN eta = .2 IF ~KEYWORD_SET(alpha) THEN alpha = .9 IF ~KEYWORD_SET(act_type) THEN act_type = 0 IF ~KEYWORD_SET(rms_crit) THEN rms_crit = .1 IF ~KEYWORD_SET(num_layers) THEN num_layers = 3 IF ~KEYWORD_SET(num_sweeps) THEN num_sweeps = 10 ENVI_RESTORE_ROIS, roifile roi_ids = ENVI_GET_ROI_IDS(fid=fid, $ roi_colors=lookup, roi_names=class_names) ; Set the classification variables ; num_classes = N_ELEMENTS(roi_ids) class_names = lookup = REFORM( ,3,num_classes+1) ; ; Call the doit ; ENVI_DOIT, 'envi_neural_net_doit', $ fid=fid, pos=pos, dims=dims, $ out_name=out_name, rule_out_name='', $ theta=theta, eta=eta, alpha=alpha, $ num_classes=num_classes, num_sweeps=num_sweeps, $ num_layers=num_layers, act_type=act_type, $ rms_crit=rms_crit, roi_ids=roi_ids, /train, $ class_names=class_names, lookup=lookup END ;-向量机 ENVI_SVM_DOIT 5: BEGIN IF ~KEYWORD_SET(thresh) THEN thresh = .5 IF ~KEYWORD_SET(penalty) THEN penalty=75 IF ~KEYWORD_SET(kernel_type) THEN kernel_type=1 IF ~KEYWORD_SET(kernel_degree) THEN kernel_degree=3 IF ~KEYWORD_SET(kernel_bias) THEN kernel_bias = 2. ENVI_RESTORE_ROIS, roifile roi_ids = ENVI_GET_ROI_IDS(fid=fid) ; Call the svm classification doit routine envi_doit, 'envi_svm_doit', $ fid=fid, pos=pos, dims=dims, $ out_name=out_name, $ roi_ids=roi_ids, thresh=thresh, $ penalty=penalty, kernel_type= kernel_type, $ kernel_degree=kernel_degree, kernel_bias=kernel_bias END ELSE: ENDCASE END 面向对象特征提取 ;+ ;ENVI二次开发功能代码 ; ;Author: DYQ ;问题讨论: ; http://hi.baidu.com/dyqwrp ; http://bbs.esrichina-bj.cn/ESRI/?fromuid=9806 ;描述: ; 面向对象特征提取 ; ;调用方法: ; cal_FX,in_file,out_file,scale_level,merge_level,ruleset_filename ; in_file:FX输入文件 ; out_file:fx的输出shape结果 ; scale_level:fx的分割比例 ; merge_level:fx的合并比例 ; releset_filename:FX的规则配置文件,需要定制修改! ;- PRO cal_FX,in_file,out_file,scale_level,merge_level,ruleset_filename CATCH, Error_status errorshow = 'Sorry to see the error,'+ $ ' please send the error Information to "dongyq@esrichina-bj.cn"' IF Error_status NE 0 THEN BEGIN tmp = DIALOG_MESSAGE(errorshow+STRING(13b)+$ !ERROR_STATE.MSG,/error,title = '错误提示!') return ENDIF ; 打开文件 ENVI_OPEN_FILE, in_file, r_fid=in_fid ;文件打开出错则退出 IF (in_fid EQ -1) THEN RETURN ;获取文件信息 ENVI_FILE_QUERY, in_fid, dims=dims, nb=nb IF ~FILE_TEST(ruleset_filename) THEN RETURN IF ~FILE_TEST(FILE_DIRNAME(out_file),/directory) THEN FILE_MKDIR,FILE_DIRNAME(out_file) ; 执行FX. ENVI_DOIT, 'envi_fx_doit', $ pos=LINDGEN(nb), $ dims=dims, $ fid=in_fid, $ scale_level=scale_level, $ merge_level=merge_level, $ vector_filename=out_file, $ conf_threshold=0.10, $ ruleset_filename=ruleset_filename, $ r_fid = out_fid END 结束ENVI ;+ ;ENVI二次开发功能代码 ; ;Author: DYQ ;问题讨论: ; http://hi.baidu.com/dyqwrp ; http://bbs.esrichina-bj.cn/ESRI/?fromuid=9806 ;描述: ; 关闭ENVI ; ;调用方法: ; endENVI ;- PRO endENVI ; ENVI_BATCH_EXIT END
个人分类: ENVI|14465 次阅读|0 个评论

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-16 04:05

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部