IDL考前复习(六) image函数keywords

前言
  考试考image的函数的keywords的中文解释,下午也用了用,虽然不大习惯,但是和MATLAB比一比读一读英文再实践实践还是可以理解的。这篇文章应该估计就辣鸡站站姐会看了,白嫖的人太多,还想看博客考高分,想什么桃子呢。
IDL其实和MATLAB差不多都是先创造一个figure(窗体)爷爷辈的对象,然后创造axis(显示的框轴)、axes(坐标轴)再到他们下面有许多的属性关键词可以修改。至于怎么修改,参考DOC以及 根据英文就能猜个大概,然后修修改改,一下就明白了,不大需要死记硬背,敲一下就明白,如果不敲就根据英文猜个大概来。

  a = DIALOG_PICKFILE(title='请选择图像')
  b = dialog_pickfile(title='请选择图像')
  c = dialog_pickfile(title='请选择图像')
  p1 = IMAGE(a,dimensions=[1500,1000],$  ;窗口的大小
    layout = [2,2,1],$  ;22列显示在第一个显示
    margin = [0,20,0,20],$  ;距离边缘的大小
    /NO_TOOLBAR,$           ;没有工具条
    /IRREGULAR,$            ;可以不是规则显示
    IMAGE_DIMENSIONS=[300,200],$  ;图像的大小
    /device,title='我变形了')                  ;利用系统的坐标,而非归一化的坐标系,TITLE是个属性而不是关键词
  p2 = PLOT([1,2,3,4],[1,2,3,4],/current,layout=[2,2,2],title='测试下overplot',axis_style=3)  ;axis_style用来控制坐标轴的样式
  p3 = PLOT([2,3,4],[1,2,3],layout=[2,2,2],/overplot)
  P4 = IMAGE(b,layout = [2,2,3],/current,title='测试下缓冲,好像没啥用',/buffer)
  P5 = IMAGE(c,layout=[2,2,4],/current,title='天王盖地虎,老子一米五')

在这里插入图片描述

语法
  IDL在doc里面留下的语法是这样的:
graphic = IMAGE(DATA[,X,Y] [,Keywords=value],[,Properties=value,][,Map Properties=value,][,Map Grid Properties=value]])

graphic = Image(Filename[,Keywords=value,][,Properties=value][,Map Properties=value][,Map Grid Properties=value])

Keywords
  Keywords are applied only during the initial creation of the graphic.
  就是一开始创建窗口就必须把keywords的属性设置好否则后续无法利用*.keywords的方法寻访之后修改相关属性。
与之相对应的是doc后面的properties。
  Properties can be set as keywords to the function during creation, or retrieved or changed using the “.” notation after creation.就是属性是可以通过结构体来访问的,
所以创建keywords就得想好了语句加进去,否则就不能再行修改了。而properties是可以根据var.properties来就行修改的,由于考试只要看keywords就行,所以可以考虑自动忽略,像图像的title就是properties,可以后续进行修改的。

Axis_STYLE

Axis_STYLE=value

  1. 0 - No axes. Decrease the margins so the graphic almost fills the window. This is the default for images.
  2. 1 - Single X, Y (and Z if 3D) axes located at the minimum data value. The margins will be adjusted to leave space for the axes. This is the default for 3D graphics.
  3. 2 - Box axes - multiple axes located at both the minimum and maximum data values. The margins will be adjusted to leave space for the axes. This is the default for 2D graphics.
  4. 3 - Crosshair-style axes - located at the midpoint of each data dimension. Since the axes are in the middle, decrease the margins so the graphic almost fills the window. This is the default for polar plots.
  5. 4 - No axes, but use the same margins as if axes were there. This is useful if you want to later add another graphic that does have axes, and you want the two visualizations to be aligned properly.

  这个是坐标轴的坐标轴属性,有4个value,可以看下面的表,有多个值,可以设置没有坐标轴,或者坐标轴是这几种样式得。可以看到上面程序中我在第二个layout中把axis style变成3就变成了交叉型的坐标轴,有各种各样的坐标轴,但是估计考试就考知道是坐标轴修改的属性就好了。

buffer
  Set this keyword to 1 to direct the graphics to an off-screen buffer instead of creating a window.
   buffer可以让读取图像时读入缓存,避免一起开图框导致内存崩溃的情况,如果没有图像的框它会存入缓存,如果有的话也会都入缓存,buffer本身就是缓冲的意思。

current
  Set this keyword to create the graphic in the current window with a new set of axes. If no window exists, a new window is created. The WINDOW’s SetCurrent method may be used to set the current window.
r, set this keyword to an existing IDL Graphic reference to make that window be the current window and direct the new graphic to that window.
  就是说如果你一开始没有一个figure窗口的话加入current它会自动创建一个,而如果有的话它会继续在这个窗口继续作图。

device
  Set this keyword if values are specified in device coordinates (pixels) for the MARGIN and POSITION keywords. (Normalized coordinates are the default for these keywords.)
  这个驱动坐标系是系统坐标而不是窗口自带的归一化坐标,这会关系到后续的margin、position如何对它赋值,是用归一化还是用驱动的坐标,讲白话的话就是你用0.几几(归一化坐标)、或者(400,300)以像素为单位进行坐标的控制。因为后面position、location、margin都会涉及到这个坐标的位置,所以需要提前的控制好

dimensions
  Set this keyword to a two-element vector of the form [width, height] to specify the window dimensions in pixels. If you do not specify a value for DIMENSIONS, IDL by default uses the values of the IDL_GR_WIN_HEIGHT and IDL_GR_WIN_WIDTH preferences for Windows platforms or the IDL_GR_X_HEIGHT and IDL_GR_X_WIDTH preferences for X Windows systems on UNIX.

这个控制的生成窗体的大小,width和height控制这个窗体的宽和高,IDL会自动的设置windows的窗体的大小,也会自动设置unix系统的大小。

Tip: The minimum width is set by the toolbar in the window, usually around 400 pixels. If you want to create a smaller graphics window, you can use the NO_TOOLBAR keyword.默认的窗体的大小为 400 像素,但是你自己在成的时候可以自行添加,像我上面就生成了个1500*1000的窗体,我在图上标注出来了。

layout
  Set this keyword to a three-element vector [ncol, nrow, index] that arranges graphics in a grid. The first dimension ncol is the number of columns in the grid, nrow is the number of rows, and index is the grid position at which to place the graphic (starting at element 1). This keyword is ignored if either OVERPLOT or POSITION is specified.
  这个就是可以生成均匀大小的显示的axes,比如你控制layout=[2,2,1],那么我就生成2行2列axes共4幅axes用来显示,1表示在第一个axes用来显示图像。以此类推。

location
Set this keyword to a two-element vector [X offset, Y offset] giving the window’s screen offset in pixels.
这个就是控制你显示图像距离原点的距离,2个偏移值,x、y,测试的时候发现距离左边并不是完全从窗口最左边开始的,而是还是有一定值的。

margin
  Set this keyword to the current graphic’s margin values in the layout specified by the LAYOUT property. Use a scalar value to set the same margin on all sides, or use a four-element vector [left, bottom, right, top] to specify different margins on each side.By default, margin values are expressed in normalized units ranging from 0.0 to 0.5. If the DEVICE keyword is set, the values are given in device units (pixels).This keyword is ignored if either OVERPLOT or POSITION is specified.
  margin是边缘的意思,就是控制你在显示的时候距离边缘的大小,可以用一个比例来限制,也可以利用一个矩阵来控制,如果是归一化的话得用0-0.5用device坐标的话可以具体化,如果是用device的话可以用像素作为单位,可以看第一幅图,由于到top的边缘被设置成了0,所以,title='我变形了’就显示不出来了。
这个和location还是需要区别区别的。

no_toolbar
  By default the graphics window will have a toolbar containing some common tools such as Print and Save. Set this keyword to remove the toolbar. This keyword has no effect if the window is already created.
  就是一开始生成窗体会有一个工具条,如果你想一开始没有工具条的话加上这个keywords就可以了,正如我一开始没有加入工具条,一般工具条是放在bottom即底部的。

nodata
  Set this keyword to 1 to create the graphic, but without any data attached to it. The axes and title (if present) are also created and displayed. If the OVERPLOT keyword is specified, axis ranges will not change.
  您仍然必须提供有效的输入参数。输入参数的数据范围用于自动设置轴的范围。[XYZ]范围属性可用于覆盖这些默认范围。
  将此关键字设置为1以创建图形,但不附加任何数据。轴和标题(如果存在)也会创建和显示。如果指定了overplot关键字,轴范围将不会更改。
在这里插入图片描述

例如这个,你会发现它会创造一个空的轴体,但数据不会被放进去,可能看这个看的不大明显,那就看plot加入nodata这个关键词后的效果。即显示出空的轴体。

在这里插入图片描述
不仅可以看到工具条还在,即没加入no_toolbar关键词后的样子,也看到nodata关键词加入之后的效果了。

overplot
  Set this keyword to 1 (one) to place the graphic on top of the currently-selected graphic within the current window. The two graphics items will then share the same set of axes. If no current window exists, then this keyword is ignored and a new window is created.If you have a graphic in another window that is not currently selected, you can also set this keyword to that graphic’s reference to overplot on top of that graphic.Tip: If you want your graphic to have a new set of axes, you should use the CURRENT keyword instead.
  将此关键字设置为1(一)可将图形放置在当前窗口中当前选定图形的顶部。两个图形项将共享同一组轴。如果当前窗口不存在,则忽略此关键字并创建一个新窗口。 如果您在另一个窗口中有一个当前未选中的图形,您也可以将此关键字设置为该图形的引用,以在该图形的顶部进行过打印。 提示:如果你想让你的图形有一组新的轴,你应该使用CURRENT关键字。

  就是说你可以用overplot来覆盖原来的图形,如果不想覆盖,继续新建坐标轴就可以了,可以看第二幅图,如果不加overplot会导致画出的直线只有第二条,而没有第一条(matlab经验)。overplot也可以关注下绘制散点图里面加入的keywords,如果不加,会覆盖图像。

widgets
  By default, when running from the IDL Workbench, the graphics window will use the native widgets for your platform. Set this keyword to instead use IDL widgets for the graphics window. This keyword is ignored when running from the IDL command line, since IDL widgets are always used in that case.
  默认情况下,从IDL工作台运行时,图形窗口将使用您的平台的本机小部件。将此关键字设置为对图形窗口使用IDL小部件。从IDL命令行运行时,将忽略此关键字,因为在这种情况下总是使用IDL小部件。
   这个我也不是特别懂啥意思,可能是下面的工具条啥的,就是toolbar有保存画图标字啥工具用的是IDL还是系统自带的?。

geotiff
  Set this keyword equal to an anonymous structure containing the GeoTIFF tags from a GeoTIFF file. For information on GeoTIFF tags, see the GEOTIFF keyword in the READ_TIFF function.
  这个是地理参考的意思,你读入图像的时候会有一个地理参考,即一个结构体,如果你在显示加上的时候也会带上这个地理参考。
在这里插入图片描述
这个就是geotiff的样子,geotiff在我从数学和编程角度看遥感影像中写到过一些,这个图也是从那里拿出来的,geotifftags就是一系列地理标签,包含各种各样的信息,所以其实如果你会创建标签的话甚至可能不用做几何校正(如果需求高的话得做几何精校正),我猜MRT(重投影工具)用的也是这种方法吧。

image_dimensions
  Set this keyword to a 2-element vector, [width, height], to specify the image dimensions (in data units). By default, the dimensions equal the number of columns and rows in the image. If this property is set then the X and Y arguments are ignored.
  将此关键字设置为2元素向量,[宽度,高度],以指定图像尺寸(以数据单位为单位)。默认情况下,尺寸等于图像中的列数和行数。如果设置了此属性,则忽略X和Y参数。
这个是显示图像的大小,就是可以不铺满整个axes的轴。

image_location
  Set this keyword to a 2-element vector, [x, y], to specify the location of the lower-left pixel in data units. By default, the location is [0, 0]. If this property is set then the X and Y arguments are ignored.
  将此关键字设置为2元素向量[x,y],以指定数据单位中左下角像素的位置。默认情况下,位置为[0,0]。如果设置了此属性,则忽略X和Y参数。
这个和之前的location一样,但是因为是加了image应该是专门限制图像。

ireegular
  Set this keyword to 1 to force the data to be gridded onto a regular grid. Set this keyword to 0 to disable automatic gridding. By default, if this keyword is not specified, then IDL will automatically grid the data if the X and Y locations are not on a 2D evenly-spaced grid.
  将此关键字设置为1可强制将数据网格化到常规网格中。将此关键字设置为0可禁用自动网格。默认情况下,如果未指定此关键字,那么如果X和Y位置不在二维等间距网格上,IDL将自动网格化数据。
  就是说通过这个不规则关键词得限定,可以将它限制到常规网格中,不加得话会自动限定,加了得话你可以不规则,像matlab处理的时候是可以有圆形,正方形等多种框的。

order
  Set this keyword to force the rows of the image data to be drawn from top to bottom. By default, image data is drawn from the bottom row up to the top row.
设置此关键字可强制从上到下绘制图像数据行。默认情况下,图像数据从底行向上绘制到顶行。order主要控制显示图像的方向,有时候是正的有时候是反的,加上之后可能正也kennel反,平常自己注意看看就行了吧。

Python和IDL在图像处理的优劣势(我自己准备答的)
Python的优势:

1.开源,开源不仅在于它有众多程序猿会来维护各种各样形形色色的代码,更重要的是,它不会面临版权或者被封的问题,如果工程或者学术发paper的时候MATLAB、IDL是需要提交序列号证明你购买了软件,而MATLAB、IDL等软件售价高的离谱,python就不会面临这种问题。
2.python正因为开源所以会有各种各样的包被贡献出来,像opencv就是传统的图像处理的包,而像yolo等包的不断发展,像车道识别、人脸识别等等越来约方便和容易。
3.python的配置相对比较容易,包管理起来也比较方便。IDE(编辑器)更多,而且拥有众多社区,所以学习入门交流起来更加地方便。
4.出图更加的美观。

python的劣势:
1.python的各色各样的包也注定了它有时候下载起来麻烦,需要各种各样的环境、驱动去提供环境,像windows配置tensorflow的gpu版本,配置起来非常的麻烦。
2.python做图像处理时处理矩阵过度依赖于numpy宏包,不像IDL拥有原生的矩阵处理方法,所以运行效率会相对较慢。
3.python作为面对对象的一种语言,其效率肯定不会像c++那么高,作为解释性的语言它只需要能够运行起来即可。

IDL优势:
1.ENVI的底层是IDL,既然ENVI那么多功能能够实现,就说明IDL可以实现很多功能,即IDL处理地理数据较为方便。
2.IDL的矩阵处理是原生的,所以运行速度会更快。
3.处理地理数据时其加上的keywords即可,不像python还需要调用gdal的包,这说明其实IDL集成的还是有点东西的。

IDL劣势:
1.相对于python,IDL最大的劣势就是闭源,需要找相应的代码时基本都无法找到,只能自己现编,且正版还需要版权费(高昂)。
2.IDL处理矩阵时,寻访的顺序是先列再行,与传统的语言都不一样,所以观念需要转变。
3.IDL的语法混乱,pro和function经常混在一起,甚至某些有function也有procdure,需要看帮助和适应。
4.IDL在各个系统的支持上没有像python那么好。

结尾
  这个blog感觉有点像专属blog,感觉粉丝里就辣鸡站站姐会看,而且图像里有冒犯华大哥的图像,千万别给我大哥看,要不又得被骂成煞笔,现在还活得好好的,要不我就是3米长的水准尺下的亡魂了。

  • 5
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值