IDL期末考试题代码+运行结果与截图.docx
- 文档编号:29159331
- 上传时间:2023-07-20
- 格式:DOCX
- 页数:14
- 大小:327.58KB
IDL期末考试题代码+运行结果与截图.docx
《IDL期末考试题代码+运行结果与截图.docx》由会员分享,可在线阅读,更多相关《IDL期末考试题代码+运行结果与截图.docx(14页珍藏版)》请在冰豆网上搜索。
IDL期末考试题代码+运行结果与截图
xx大学研究生课程考试(查)论文
2016—2017学年第1学期
《IDL程序设计》
课程名称:
IDL程序设计
任课教师:
xxxxxxxx
学院:
资源与环境科学学院
专业:
地理信息系统
学号:
xxxxxxxxx
姓名:
xxxxxx
成绩:
评语:
1.IDL与Matlab有何异同点?
IDL与Matlab的相同处在于:
①都是支持多种数据格式的可视化分析工具,具有跨平台、基于矩阵和高级语言的特点。
②都可以提供高度集成的环境。
③对于用户界面,都可以提供相应的工具和设计环境。
④提供面向对象的图形系统支持并且支持硬件图形加速。
⑤都可以与其他编程语言通过接口链接,实现协同编程。
IDL与Matlab的不同处在于:
①产品定位不同。
Matlab侧重于分析和精度计算,IDL侧重于图像处理。
②工具箱的形式不一样。
,IDL将所有提供的工具全部集成在环境内部,以函数或者其它的形式出现,而Matlab则归类出各种工具箱,让用户自选购买,具有一定的灵活性,但这并不意味着他的每个工具箱的功能都很强大。
③IDL5.5之后则自动支持多线程(CPU)的计算,大大地提高了计算速度,并且无需在代码中体现,而Matlab还做不出来这个功能。
④数据类型的不同。
前面说过,Matlab注重计算精度,但同时这也成为他面对大数量计算的瓶颈。
尽管IDL与Matlab支持的数据类型是一样的,但是IDL具有更加灵活的处理方式。
⑤图形显示方式的不同。
Matlab只支持面相对象的图形显示,而IDL则提供直接图形法的选择,因为有时候,直接图形法更加方便。
另外,Matlab不能支持真体数据的显示,这将对于包括医学影像(Medical Image)、地质数据、大气以及环境科学方面的应用成为障碍。
⑥网络解决方案。
尽管Mathworks提供的CGI是基于网络的产品,但他只是类似ION Script,而不能提供ION Java所能给予用户的解决方案。
2.读取图像\examples\data\convec.dat,并对它进行均值平滑(smooth和median),另外利用Sobel和Roberts函数使用以下3*3的窗口对图像进行卷积。
给出IDL编程代码及其运行结果。
Propinghuajuanji
file=filepath('convec.dat',subdirectory=['examples','data'])
imagesize=[248,248]
image=read_binary(file,data_dims=imagesize)
device,decomposed=0
loadct,0
window,1,xsize=imagesize[0],ysize=imagesize[1],title='convec'
tv,image
window,2,xsize=2*imagesize[0],ysize=imagesize[1],title='smooth'
result=smooth(image,10,/edge_truncate)
tv,result,0
result1=median(image,10)
tv,result1,1
window,3,xsize=2*imagesize[0],ysize=imagesize[1],title='juanji'
kernel=[[1,1,1],[1,-7,1],[1,1,1]]
tv,smooth(image,3,/edge_truncate),248,3
tv,sobel(image),0
tv,roberts(image),1
end
3.读取图像\examples\data\abnorm.dat,并对它进行Lee滤波(噪声处理)。
给出IDL编程代码及其运行结果.结果包括原始图像和噪声处理后的图像,直方图。
PROLeeFiltimg
file=filepath('abnorm.dat',SUBDIRECTORY=['examples','data'])
imageSize=[64,64]
image=READ_BINARY(file,DATA_DIMS=imageSize)
DEVICE,DECOMPOSED=0
LOADCT,0
WINDOW,0,xsize=48,ysize=48,TITLE='OriginalImage'
TVscl,image
WINDOW,1,xsize=48,ysize=48,TITLE='leefiltofImage'
filteredImage=LEEFILT(image,1)
tvscl,filteredImage
window,3,title='originalhistogram'
PLOT,HISTOGRAM(image),/XSTYLE,/YSTYLE,TITLE='OriginalImageHistogram',$
XTITLE='IntensityValue',YTITLE='NumberofPixelsofThatValue'
WINDOW,4,TITLE='HistogramofLeefiltImage'
PLOT,HISTOGRAM(filteredImage),/XSTYLE,/YSTYLE,$
TITLE='LeefiltImageHistogram',$
XTITLE='IntensityValue',YTITLE='NumberofPixelsofThatValue'
END
4.在ENVI批处理模式下对打开图像(多波段影像)进行统计;如最小值(Min),最大值(Max),平均值(Mean),标准差(Stdv)等统计特征。
给出IDL编程代码及其运行结果。
proexcise4
compile_optidl2
envi,/restore_base_save_files
envi_batch_init
file=filepath('alie.dat',SUBDIRECTORY=['examples','data'])
envi_open_file,file,r_fid=fid
envi_file_query,fid,ns=ns,nl=nl,nb=nb,dims=dims
abnorm=envi_get_data(fid=fid,dims=dims,pos=0)
pos=lindgen(nb)
envi_doit,'envi_stats_doit',fid=fid,pos=pos,dims=dims,comp_flag=0,dmin=dmin,
mean=dmean,dmax=dmax,stdv=stdv
print,'theminvalue:
'
print,dmin
print,'themeanvalue:
'
print,dmean
print,'themaxvalue:
'
print,dmax
print,'thestdvvalue:
'
print,stdv
end
运行结果:
ENVI>excise4
%Compiledmodule:
EXCISE4.
theminvalue:
0.000000000.000000000.000000000.000000000.00000000
themeanvalue:
1.400000046.7200000.0000000079.56000026.360000
themaxvalue:
13.000000122.000000.00000000180.00000142.00000
thestdvvalue:
3.278719345.7643600.0000000072.86922147.217476
ENVI>
5.读取一幅多波段影像的中心点光谱曲线,并Plot出来,用TimesNewRoman标示出其经纬度,给出IDL编程代码及其运行结果。
proSpectralcurve
envi_open_file,envi_pickfile(),r_fid=fid
envi_file_query,fid,nb=nb,nl=nl,ns=ns,wl=wl
xf=(nl/2)
yf=(ns/2)
envi_convert_file_coordinates,fid,xf,yf,xmap,ymap,/to_map
envi_convert_projection_coordinates,xmap,ymap,envi_get_projection(fid=fid),oxmap,oymap,envi_proj_create(/geographic)
r=findgen(nb)
!
P.FONT=0
DEVICE,SET_FONT="TIMES*24"
fori=0,nb-1dobegin
r[i]=envi_get_data(/complex,dims=[-1,nl/2,nl/2,ns/2,ns/2],fid=fid,pos=i)
print,r[i]
endfor
print,'lon:
',oxmap,'lat:
',oymap
plot,wl,r,/xstyle,/ystyle,title='Spectralcurve'
end
Plot图:
6.编写自定义函数计算阶乘1!
+2!
+…..9!
+10!
的和
FunctionFactorial,n
y=1l
ifnNe0Thenbegin
fori=1,ndobegin
y=y*i
endfor
endif
return,y
end
profactorial
sum=0
read,prompt='输入一个整数:
',n
fori=1,ndobegin
print,i,"!
=",factorial(i)
sum=sum+factorial(i);
endfor
print,sum
end
运行结果:
IDL>factorial
%Compiledmodule:
FACTORIAL.
%Compiledmodule:
FACTORIAL.
输入一个整数:
10
1!
=1
2!
=2
3!
=6
4!
=24
5!
=120
6!
=720
7!
=5040
8!
=40320
9!
=362880
10!
=3628800
4037913
IDL>
7.编写程序,读取图像\examples\data\convec.dat,并对它进行缩放(zoom)
prozooming
file=filepath('convec.dat',subdirectory=['examples','data'])
imagesize=[248,248]
image=read_binary(file,data_dims=imagesize)
device,decomposed=0
loadct,0
window,1,xsize=imagesize[0],ysize=imagesize[1],title='agrayscaleimage'
tv,image
zoom,/new_winow,fact=2.,xsize=imagesize[0],ysize=imagesize[1]
end
8.写出九乘数,写出程序代码。
projiujiuchengshu
i=1
while1dobegin
ifigt9thengoto,mylable
forj=1,idobegin
print,j,'*',i,'=',i*j,format='(4x,i1,1x,a1,1x,i1,a1,1x,i2,$)'
endfor
print&i++
endwhile
mylable:
print,'九九乘法表输出结束'
end
运行结果:
IDL>jiujiuchengshu
%Compiledmodule:
JIUJIUCHENGSHU.
1*1=1
1*2=22*2=4
1*3=32*3=63*3=9
1*4=42*4=83*4=124*4=16
1*5=52*5=103*5=154*5=205*5=25
1*6=62*6=123*6=184*6=245*6=306*6=36
1*7=72*7=143*7=214*7=285*7=356*7=427*7=49
1*8=82*8=163*8=244*8=325*8=406*8=487*8=568*8=64
1*9=92*9=183*9=274*9=365*9=456*9=547*9=638*9=729*9=81
九九乘法表输出结束
IDL>
9.编写程序:
在同一坐标系绘制0-2的画圆(x-100)^2+(y-100)^2=100^2
procircle
points=(2*!
pi/99.0)*FindGen(100)
x=100+100*Cos(points)
y=100+100*Sin(points)
window,0,xsize=300,ysize=300,title='thisisacircle'
plot,x,y,xtitle='thisisxtitle',ytitle='thisisytitle',title='thisisacircleplot'
END
运行结果:
10.编写自定义函数Factorial(n)=n!
计算并输出0-n的阶乘
FunctionFactorial,n
y=1l
ifnNe0Thenbegin
fori=1,ndobegin
y=y*i
endfor
endif
return,y
end
profactorial
read,prompt='输入一个整数:
',n
fori=1,ndobegin
print,i,"!
=",factorial(i)
endfor
end
运行结果:
IDL>factorial
%Compiledmodule:
FACTORIAL.
%Compiledmodule:
FACTORIAL.
输入一个整数:
15
1!
=1
2!
=2
3!
=6
4!
=24
5!
=120
6!
=720
7!
=5040
8!
=40320
9!
=362880
10!
=3628800
11!
=39916800
12!
=479001600
13!
=1932053504
14!
=1278945280
15!
=2004310016
IDL>
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- IDL 期末 考试题 代码 运行 结果 截图