版本:1.01
本文对软件开发中编码作了统一的规定,除非约定发生改变,程序员必须遵守这些约定。
一、目的
简洁直观的编码方式对软件的维护十分重要。目的主要有:
① 保证公司所有的软件产品有统一的编码风格
② 易于公司内部程序员间的交流
③ 易于理解程序的逻辑结构
④ 减少编码错误的可能性
二、编码语言
IDL语言
开发工具:IDLDE
版本:6.4
三、IDLDE编辑器使用规则
1.在源代码中不要使用TAB符号,因为它将导致在不同的编辑器中代码的不同排列。程序员可以在编辑器中将TAB符号转化为空格,这样在不同的编辑器中代码保持排列的整齐。
在File->Preference->Editor选项中:
(1)选择use space;
(2)Number of spaces to indent for输入2;
(3)勾选 Convert tabs to spaces on save。
2.每个文件可以包含多个相关的源文件,但外部用户可以直接使用(调用)的源文件只能有一个,每个源文件不能超过500行。
3.每列不超过80个字符(含空格)。
4.类存放在单独的源文件中,每个文件只定义一个类。
5.文件结构按以下顺序排列
① 文件头说明(见“注释规则”)
② 代码
四、注释规则
1.文件头注释(为在unix平台使用,应尽可能使用英文)
在每个文件开始处的注释包括:
1)文件第一行编写程序名,版本,开始编写的时间,作者
; $Id: adapt_hist_equal.pro,v 1.13 2005/02/01 20:24:12 scottm Exp $
2)版权信息(可选)
; Copyright (c) 1999-2005, Research Systems, Inc. All rights reserved.
; Unauthorized reproduction prohibited.
3)调用程序的文件名
; NAME:
; ADAPT_HIST_EQUAL
4)调用程序的编写目的
; PURPOSE:
; Perform Adaptive Histogram Equalization (AHE), a form of
; automatic image contrast enhancement, using a method described
; by Pizer, et. al. Adaptive Histogram Equalization involves
; applying contrast enhancement based on the local region
; surrounding each pixel. That is, each pixel is mapped to an
; intensity proportional to its rank in its surrounding
; neighborhood. This routine implements what Pizer calls
; "Contrast Limited Adaptive Histogram Equalization", or CLAHE.
5)调用程序的类别(可选)
; CATEGORY:
; Image processing.
6)调用程序的调用方法
; CALLING SEQUENCE:
; Result = ADAPT_HIST_EQUAL(Image [, NREGIONS=nregions] [, CLIP=clip])
7)调用程序输入说明
; INPUTS:
; Image: A 2-dimensional array of byte type. Other types of
; images may be used, but they are converted to byte type before
; use. For proper operation, be sure that the range of pixels
; lies between 0 and 255.
8)调用程序的关键字含义
; KEYWORD PARAMETERS:
; CLIP: If non-zero, clip the histogram to limit its slope to "CLIP
; thereby limiting contrast. For example, if CLIP is 3, the
; slope of the histogram is limited to 3. By default, the slope
; and/or contrast is not limited. Noise overenhancement in
; nearly homogeneous regions is reduced by setting this
; parameter to values larger than 1.0.
; NREGIONS:
; TOP:
; FCN:
9)调用程序的输出
; OUTPUTS:
; The result of the function is a byte image with the same
; dimensions as the input parameter.
10)调用程序的条件说明
; RESTRICTIONS:
; Works only on byte images.
11)调用程序的说明
; PROCEDURE:
; The procedure described by Pizer, et.al., "Adaptive Histogram
; Equalization and Its Variations", Computer Vision, Graphics,
; and Image Processing, 39:355-368, is followed. This method has
; the advantages of being automatic, reproducible, locally
; adaptive, and usually produces superior images when compared
; with interactive contrast enhancement.
;
; The image is split into overlapping regions, each of size
; MaxDimension / NREGIONS. The distribution histogram for each
; region is computed. Then, for each pixel, its histogram
; equalized value is computed from the four overlapping regions
; that cover the pixel, normalized for the pixel's distance from
; each region's center.
12)调用程序的使用示例
; EXAMPLE:
; A = Read_Tiff('xyz.tif') ; Read an image
; TVSCL, Adapt_Hist_Equal(A) ;Contrast enhance and display.
;
; To perform adaptive histogram "equalization", with a logarithmic
; cumulative distribution (i.e. more pixels with lower values):
; y = alog(findgen(256)+1) ;a log shaped curve
; TVSCL, Adapt_Hist_Equal(A, FCN = y)
;
; The following example does adaptive histogram "equalization", with
; a gaussian probability (not cumulative) distribution. This results
; in most of the pixels having an intensity near the midrange:
; x = findgen(256)/255. ;Ramp from 0 to 1.
; y=exp(-((x-.5)/.2)^2) ;Gaussian centered at middle, full
; ;width at 1/2 max ~ 0.4
; ;Form cumulative distribution, transform and display:
; TVSCL, Adapt_Hist_Equal(A, FCN = TOTAL(y, /CUMULATIVE))
13)修改记录
; MODIFICATION HISTORY:
; DMS, RSI July, 1999.
2.源程序注释
如果文件除调用程序外,还包含其它源程序,需要对源程序进行注释
Function AHMHistogram, Im, ix0, iy0, sx, sy, CLIP=fclip, TOP=otop
; Make a histogram from the image Im, LL = ix0, iy0, size = sx, sy.
; CLIP = if set clip histogram according to Pizer.
3. 代码注释
在代码注释中,需在使用控制语句、调用自定义函数或过程、进行复杂的数算时,添加注释行,注释量不应少于代码量的20%。
五、命名规则
应尽量参照匈牙利命名法。
1.过程、函数名
以大写字母开头,每个新词都以大写字母开头,过程、函数名应有意义,易于理解和记忆。
2. 类名
以大写字母开头,没有下划线。每个新词都以大写字母开头。类名应有意义,易于理解和记忆。
3. 方法名
以大写字母开头,没有下划线。每个新词都以大写字母开头。方法名应有意义。
4. 变量名
以小写字母开头,新词以大写字母开头。变量名应有意义。