(一) 判断对象为空
对于region是否为空,用下面的算子。
IsEqual1是个inter型,如果为空则为1,否则为0
gen_empty_region(EmptyRegion1) test_equal_region(EmptyRegion1,CheckARegion,IsEqual1) if(IsEqual1==1) return() endif
判断hobject为空则用算子test_equal_obj
判断object为空,count_obj是不准确的。也可以使用area_center后通过面积大于0判定。
判断hobject对象的数量则用
count_obj(EmptyRegion, Number1)
判断htuple的数量则用算子tuple_length
tuple_length(Row1, len1) tuple_length(Column1, len2) if(len1>1 or len2>1) Area:=[-4] return() endif
(二)元组的几个特殊用法
元组的tuple的切片方式
a:=[1,2,3,4,5,6]
b:=a[1:4]
*[2,3,4,5]
类似python的切片
gen_tuple_const(|Rows|,1.0)
得到指定数量的值够成的元组。
---------------------------------
tuple_split(Parameter[15], ',', roistr)
tuple_number(roistr, roi)
---------------------------------
* 将一个Tuple数组赋值给变量 Tuple1 := [1,2,3,4,5,6,7,8,9] *给Tuple数组元素赋值 Tuple1[1] := 0 * 批量改变数组元素的值 Tuple1[1,3,5] := 'wh' * 批量给Tuple数组赋值,其值为0到10000连续数值 Tuple3 := [0:100] * 批量给Tuple数组赋值,其值为3到200连续数值,步长为1 Tuple4 := [3:2:100] * 批量给Tuple数组赋值,其值为100到-100连续数值,步长为-10 Tuple5 := [100:-10:-100] * 对两个Tuple数组进行合并操作 TupleInt1 := [3,1,2,9,1] TupleInt2 := [10,2,4,3,2] tuple_union (TupleInt1, TupleInt2, UnionInt) * 对两个Tuple数组进行交集操作 TupleInt3 := [3,1,2,9,1] TupleInt4 := [10,2,4,3,2] tuple_intersection (TupleInt3, TupleInt4, IntersectionInt) * 对Tuple数组元素进行替换 OriginalTuple := [0,1,2,3,4,5] tuple_replace (OriginalTuple, [0,1], ['x','y'], Replaced) * 向Tuple数组插入数值 OriginalTuple := [0,1,2,3,4,5] tuple_insert (OriginalTuple, 3, 'x', InsertSingleValueA)
------------------------------
获取元组中指定范围的数
ss := [12,34,5,3,56,31,54,7,8,22,14,75,134,634,323,546] tuple_greater_elem (ss, 50, Greater) tuple_less_elem (ss, 200, Less) tuple_and (Less, Greater, And) * 方法一 tuple_select_mask (ss, And, Selected) * 方法二 tuple_find (And, 1, Indices) tuple_select (ss, Indices, Selected1)
---------------------
作者:hackpig
来源:www.skcircle.com
版权声明:本文为博主原创文章,转载请附上博文链接!

