intensity(Regions, Image ::: Mean, Deviation)Regions(输入对象):在此区域内计算特征。这些区域是从图像中分割出来的一部分或多部分,通常是感兴趣区域(ROI, Regions Of Interest)。
Image(输入对象):单通道图像,通常是指灰度图像。它可以是多种类型的单通道图像,包括但不限于字节类型 (byte)、方向类型 (direction)、循环类型 (cyclic)、整型 (int1, int2, uint2, int4) 或浮点型 (real)。
Mean(输出控制):一个区域的平均灰度值。如果输入的 Regions 是一个数组,则 Mean 也会是一个数组,其中每个元素对应于输入区域数组中的一个区域的平均灰度值。
Deviation(输出控制):区域内灰度值的标准偏差。与 Mean 类似,如果输入的 Regions 是多个区域,则 Deviation 也会是一个数组,其中每个元素对应于输入区域数组中的一个区域的灰度值标准偏差。
案例
* particle.hdev: Measurement of small particles
*dev_update_off()dev_close_window()dev_open_window(0,0,512,512,'black', WindowID)set_display_font(WindowID,14,'mono','true','false')read_image(Image,'particle')dev_display(Image)dev_disp_text('Original image','window',12,12,'black',[],[])dev_disp_text('Press Run (F5) to continue','window','bottom','right','black',[],[])stop()* 阈值处理
threshold(Image, Large,110,255)* Dilate regions with a circular structuring element
* 膨胀
dilation_circle(Large, LargeDilation,7.5)dev_display(Image)dev_set_draw('margin')dev_set_line_width(3)dev_set_color('red')dev_display(LargeDilation)dev_set_draw('fill')dev_disp_text('Exclude large areas from processing','window',12,12,'black',[],[])dev_disp_text('Press Run (F5) to continue','window','bottom','right','black',[],[])stop()* Continue to calculate small regions
* Return the complement of a region
*获取补集
complement(LargeDilation, NotLarge)*将原图-补集
reduce_domain(Image, NotLarge, ParticlesRed)* 去除杂志
mean_image(ParticlesRed, Mean,31,31)* Segment the image using a local threshold
*获取亮点阈值
dyn_threshold(ParticlesRed, Mean, SmallRaw,3,'light')* 亮点进行开运算
opening_circle(SmallRaw, Small,2.5)* 连接亮点
connection(Small, SmallConnection)dev_display(Image)dev_set_colored(12)dev_display(SmallConnection)dev_disp_text('Extracted small particles','window',12,12,'black',[],[])dev_disp_text('Press Run (F5) to continue','window','bottom','right','black',[],[])stop()* Continue to select several regions and to get information
dev_set_color('green')dev_display(Image)dev_set_draw('margin')dev_display(SmallConnection)
Button :=1* Define limits for the displayed message at the end of the while-loop.
MaxRow :=450
MaxColumn :=440
MinRow :=40
MinColumn :=100while(Button ==1)dev_disp_text(['Select object with left mouse button','Right button to quit'],'window',12,12,'black','box_color','#fce9d4dd')dev_set_color('green')* 点击区域点
get_mbutton(WindowID, Row, Column, Button)dev_display(Image)dev_display(SmallConnection)dev_set_color('red')* 获取到选中的区域
select_region_point(SmallConnection, SmallSingle, Row, Column)dev_display(SmallSingle)count_obj(SmallSingle, NumSingle)if(NumSingle ==1)* 计算平均灰度值和偏差
intensity(SmallSingle, Image, MeanGray, DeviationGray)*获取区域面积大小
area_center(SmallSingle, Area, Row, Column)* Limit the message so that it is displayed entirely inside the graphics window.if(Row > MaxRow)
Row := MaxRow
endif
if(Column > MaxColumn)
Column := MaxColumn
endif
if(Row < MinRow)
Row := MinRow
endif
if(Column < MinColumn)
Column := MinColumn
endif
dev_disp_text(['Area = '+ Area,'Intensity = '+ MeanGray$'.3'],'image', Row +10, Column -90,'black','box_color','#fce9d4dd')
endif
endwhile
dev_set_line_width(1)dev_update_on()