|
参考例子:C:\Users\Public\Documents\MVTec\HALCON-12.0\examples\hdevelop\Applications\Object-Recognition-2D\classify_pills_auto_select_features.hdev- * *********************************************************
- * Feature procedure
- * Contains the names, properties and calculation of
- * all supproted features.
- * It consists of similar blocks for each feature.
- *
- * If you like to add your own features, please use
- * the external procedure get_custom_features.hdvp
- * in the HALCON procedures/templates directory.
- * *********************************************************
- *
- * Insert location of your custom procedure here
- *
- get_system ('empty_region_result', EmptyRegionResult)
- set_system ('empty_region_result', 'true')
- AccumulatedResults := []
- CustomResults := []
- count_obj (Region, NumRegions)
- get_image_size (Image, ImageWidth, ImageHeight)
- *
- for I := 0 to |Namelist| - 1 by 1
- CurrentName := Namelist[I]
- *
- get_custom_features (Region, Image, CurrentName, Mode, CustomResults)
- AccumulatedResults := [AccumulatedResults,CustomResults]
- *
- *
- * ************************************
- * HALCON REGION FEATURES
- * ************************************
- *
- * ************************************
- * BASIC
- * ************************************
- * ** area ***
- Name := 'area'
- Groups := ['region','rot_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- area_center (Region, Feature, _, _)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** width ***
- Name := 'width'
- Groups := 'region'
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- smallest_rectangle1 (Region, Row1, Column1, Row2, Column2)
- Feature := Column2 - Column1 + 1
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** height ***
- Name := 'height'
- Groups := 'region'
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- smallest_rectangle1 (Region, Row1, Column1, Row2, Column2)
- Feature := Row2 - Row1 + 1
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** ra ***
- Name := 'ra'
- Groups := ['region','rot_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- elliptic_axis (Region, Ra, Rb, Phi)
- Feature := Ra
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** rb ***
- Name := 'rb'
- Groups := ['region','rot_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- elliptic_axis (Region, Ra, Rb, Phi)
- Feature := Rb
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** phi ***
- Name := 'phi'
- Groups := ['region','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- elliptic_axis (Region, Ra, Rb, Phi)
- Feature := Phi
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** roundness ***
- Name := 'roundness'
- Groups := ['region','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- roundness (Region, Distance, Sigma, Roundness, Sides)
- Feature := Roundness
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** num_sides ***
- Name := 'num_sides'
- Groups := ['region','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- roundness (Region, Distance, Sigma, Roundness, Sides)
- Feature := Sides
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** num_connected ***
- Name := 'num_connected'
- Groups := ['region','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- connect_and_holes (Region, NumConnected, NumHoles)
- Feature := NumConnected
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** num_holes ***
- Name := 'num_holes'
- Groups := ['region','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- connect_and_holes (Region, NumConnected, NumHoles)
- Feature := NumHoles
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** area_holes ***
- Name := 'area_holes'
- Groups := ['region','rot_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- area_holes (Region, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** max_diameter ***
- Name := 'max_diameter'
- Groups := ['region','rot_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- diameter_region (Region, Row1, Column1, Row2, Column2, Diameter)
- Feature := Diameter
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** orientation ***
- Name := 'orientation'
- Groups := ['region','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- orientation_region (Region, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * SHAPE
- * ************************************
- *
- * ************************************
- * ** outer_radius ***
- Name := 'outer_radius'
- Groups := ['region','rot_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- smallest_circle (Region, Row, Column, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** inner_radius ***
- Name := 'inner_radius'
- Groups := ['region','rot_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- inner_circle (Region, Row, Column, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** inner_width ***
- Name := 'inner_width'
- Groups := 'region'
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- inner_rectangle1 (Region, Row1, Column1, Row2, Column2)
- Feature := Column2 - Column1 + 1
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** inner_height ***
- Name := 'inner_height'
- Groups := 'region'
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- inner_rectangle1 (Region, Row1, Column1, Row2, Column2)
- Feature := Row2 - Row1 + 1
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** circularity ***
- Name := 'circularity'
- Groups := ['region','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- circularity (Region, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** compactness ***
- Name := 'compactness'
- Groups := ['region','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- compactness (Region, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** convexity ***
- Name := 'convexity'
- Groups := ['region','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- convexity (Region, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** rectangularity ***
- Name := 'rectangularity'
- Groups := ['region','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- rectangularity (Region, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** anisometry ***
- Name := 'anisometry'
- Groups := ['region','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- eccentricity (Region, Anisometry, Bulkiness, StructureFactor)
- Feature := Anisometry
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** bulkiness ***
- Name := 'bulkiness'
- Groups := ['region','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- eccentricity (Region, Anisometry, Bulkiness, StructureFactor)
- Feature := Bulkiness
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** struct_factor ***
- Name := 'struct_factor'
- Groups := ['region','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- eccentricity (Region, Anisometry, Bulkiness, StructureFactor)
- Feature := StructureFactor
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** dist_mean ***
- Name := 'dist_mean'
- Groups := ['region','rot_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- roundness (Region, Distance, Sigma, Roundness, Sides)
- Feature := Distance
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** dist_deviation ***
- Name := 'dist_deviation'
- Groups := ['region','rot_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- roundness (Region, Distance, Sigma, Roundness, Sides)
- Feature := Sigma
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** euler_number ***
- Name := 'euler_number'
- Groups := ['region','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- euler_number (Region, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** rect2_phi ***
- Name := 'rect2_phi'
- Groups := ['region','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- smallest_rectangle2 (Region, Row, Column, Phi, Length1, Length2)
- Feature := Phi
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** rect2_len1 ***
- Name := 'rect2_len1'
- Groups := ['region','rot_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- smallest_rectangle2 (Region, Row, Column, Phi, Length1, Length2)
- Feature := Length1
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** rect2_len2 ***
- Name := 'rect2_len2'
- Groups := ['region','rot_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- smallest_rectangle2 (Region, Row, Column, Phi, Length1, Length2)
- Feature := Length2
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** contlength ***
- Name := 'contlength'
- Groups := ['region','rot_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- contlength (Region, ContLength)
- Feature := ContLength
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- * REGION FEATURES
- * ************************************
- * MISC
- * ************************************
- * ** porosity ***
- Name := 'porosity'
- Groups := ['region','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- area_holes (Region, AreaHoles)
- area_center (Region, Area, Row, Column)
- if (Area == 0)
- Feature := 0.0
- else
- Feature := real(AreaHoles) / (Area + AreaHoles)
- endif
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- * HALCON GRAY VALUE FEATURES
- * ************************************
- * BASIC
- * ************************************
- *
- * ** gray_area ***
- Name := 'gray_area'
- Groups := ['gray','rot_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- area_center_gray (Region, Image, Area, Row, Column)
- Feature := Area
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** gray_ra ***
- Name := 'gray_ra'
- Groups := ['gray','rot_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- elliptic_axis_gray (Region, Image, Ra, Rb, Phi)
- Feature := Ra
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** gray_rb ***
- Name := 'gray_rb'
- Groups := ['gray','rot_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- elliptic_axis_gray (Region, Image, Ra, Rb, Phi)
- Feature := Rb
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** gray_phi ***
- Name := 'gray_phi'
- Groups := ['gray','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- elliptic_axis_gray (Region, Image, Ra, Rb, Phi)
- Feature := Phi
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** gray_min ***
- Name := 'gray_min'
- Groups := ['gray','rot_invar','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- min_max_gray (Region, Image, 0, Min, Max, Range)
- Feature := Min
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** gray_max ***
- Name := 'gray_max'
- Groups := ['gray','rot_invar','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- min_max_gray (Region, Image, 0, Min, Max, Range)
- Feature := Max
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** gray_range ***
- Name := 'gray_range'
- Groups := ['gray','rot_invar','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- min_max_gray (Region, Image, 0, Min, Max, Range)
- Feature := Range
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * TEXTURE
- * ************************************
- *
- * ************************************
- * ** gray_mean ***
- Name := 'gray_mean'
- Groups := ['gray','texture','rot_invar','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- intensity (Region, Image, Mean, Deviation)
- Feature := Mean
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** gray_deviation ***
- Name := 'gray_deviation'
- Groups := ['gray','texture','rot_invar','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- intensity (Region, Image, Mean, Deviation)
- Feature := Deviation
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** gray_plane_deviation ***
- Name := 'gray_plane_deviation'
- Groups := ['gray','texture','rot_invar','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- plane_deviation (Region, Image, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** gray_anisotropy ***
- Name := 'gray_anisotropy'
- Groups := ['gray','texture','rot_invar','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- entropy_gray (Region, Image, Entropy, Anisotropy)
- Feature := Anisotropy
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** gray_entropy ***
- Name := 'gray_entropy'
- Groups := ['gray','texture','rot_invar','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- entropy_gray (Region, Image, Entropy, Anisotropy)
- Feature := Entropy
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** gray_hor_proj ***
- Name := 'gray_hor_proj'
- Groups := ['gray','texture','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- Size := 20
- calc_feature_gray_proj (Region, Image, 'hor', Size, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** gray_vert_proj ***
- Name := 'gray_vert_proj'
- Groups := ['gray','texture','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- Size := 20
- calc_feature_gray_proj (Region, Image, 'vert', Size, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** gray_hor_proj_histo ***
- Name := 'gray_hor_proj_histo'
- Groups := ['gray','texture','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- Size := 20
- calc_feature_gray_proj (Region, Image, 'hor_histo', Size, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** gray_vert_proj_histo ***
- Name := 'gray_vert_proj_histo'
- Groups := ['gray','texture','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- Size := 20
- calc_feature_gray_proj (Region, Image, 'vert_histo', Size, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** grad_dir_histo ***
- Name := 'grad_dir_histo'
- Groups := ['gray','texture']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- NumBins := 20
- calc_feature_grad_dir_histo (Region, Image, NumBins, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** edge_density ***
- Name := 'edge_density'
- Groups := ['gray','texture','rot_invar','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- calc_feature_edge_density (Region, Image, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** edge_density_histogram ***
- Name := 'edge_density_histogram'
- Groups := ['gray','texture','rot_invar','scale_invar']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- NumBins := 4
- calc_feature_edge_density_histogram (Region, Image, NumBins, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** edge_density_pyramid ***
- NameRegExp := 'edge_density_pyramid_([234])'
- Names := 'edge_density_pyramid_' + [2:4]
- Groups := ['gray','texture','rot_invar','scale_invar']
- * ****************
- if (CurrentName =~ NameRegExp)
- * ** Calculate feature ***
- NumPyramids := number(regexp_match(CurrentName,NameRegExp))
- calc_feature_pyramid (Region, Image, 'edge_density', NumPyramids, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups_pyramid (Mode, Groups, CurrentName, Names, NameRegExp, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** edge_density_histogram_pyramid ***
- NameRegExp := 'edge_density_histogram_pyramid_([234])'
- Names := 'edge_density_histogram_pyramid_' + [2:4]
- Groups := ['gray','texture','rot_invar','scale_invar']
- * ****************
- if (CurrentName =~ NameRegExp)
- * ** Calculate feature ***
- NumPyramids := number(regexp_match(CurrentName,NameRegExp))
- calc_feature_pyramid (Region, Image, 'edge_density_histogram', NumPyramids, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups_pyramid (Mode, Groups, CurrentName, Names, NameRegExp, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * ** cooc ***
- Name := 'cooc'
- Groups := ['gray','texture']
- * ****************
- if (Name == CurrentName)
- * ** Calculate feature ***
- Feature := []
- cooc_feature_image (Region, Image, 6, 0, Energy, Correlation, Homogeneity, Contrast)
- if (NumRegions > 0)
- Index := [0:4:4 * NumRegions - 1]
- Feature[Index] := Energy
- Feature[1 + Index] := Correlation
- Feature[2 + Index] := Homogeneity
- Feature[3 + Index] := Contrast
- endif
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** cooc_pyramid ***
- NameRegExp := 'cooc_pyramid_([234])'
- Names := 'cooc_pyramid_' + [2:4]
- Groups := ['gray','texture']
- * ****************
- if (CurrentName =~ NameRegExp)
- * ** Calculate feature ***
- NumPyramids := number(regexp_match(CurrentName,NameRegExp))
- calc_feature_pyramid (Region, Image, 'cooc', NumPyramids, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups_pyramid (Mode, Groups, CurrentName, Names, NameRegExp, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- *
- * ************************************
- *
- * ************************************
- * POLAR TRANSFORM FEATURES
- * ************************************
- *
- * ************************************
- * ** polar_gray_proj ***
- Name := 'polar_gray_proj'
- Groups := ['gray','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- Width := 100
- Height := 40
- calc_feature_polar_gray_proj (Region, Image, 'hor_gray', Width, Height, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** polar_grad_proj ***
- Name := 'polar_grad_proj'
- Groups := ['gray','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- Width := 100
- Height := 40
- calc_feature_polar_gray_proj (Region, Image, 'hor_sobel_amp', Width, Height, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** polar_grad_x_proj ***
- Name := 'polar_grad_x_proj'
- Groups := ['gray','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- Width := 100
- Height := 40
- calc_feature_polar_gray_proj (Region, Image, 'hor_sobel_x', Width, Height, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** polar_grad_y_proj ***
- Name := 'polar_grad_y_proj'
- Groups := ['gray','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- Width := 100
- Height := 40
- calc_feature_polar_gray_proj (Region, Image, 'hor_sobel_y', Width, Height, Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** polar_gray_proj_histo ***
- Name := 'polar_gray_proj_histo'
- Groups := ['gray','rot_invar','scale_invar']
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- Width := 100
- Height := 40
- calc_feature_polar_gray_proj (Region, Image, 'vert_gray', Width, Height, Projection)
- NumBins := 20
- Feature := []
- for Index := 1 to NumRegions by 1
- Start := (Index - 1) * Width
- tuple_histo_range (Projection[Start:Start + Width - 1], 0, 255, NumBins, Histo, BinSize)
- Feature := [Feature,Histo]
- endfor
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * COLOR FEATURES
- * ************************************
- *
- * ************************************
- * ** cielab_mean ***
- Name := 'cielab_mean'
- Groups := 'color'
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- calc_feature_color_intensity (Region, Image, 'cielab', 'mean', Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** cielab_dev ***
- Name := 'cielab_dev'
- Groups := 'color'
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- calc_feature_color_intensity (Region, Image, 'cielab', 'deviation', Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** hls_mean ***
- Name := 'hls_mean'
- Groups := 'color'
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- calc_feature_color_intensity (Region, Image, 'hls', 'mean', Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** hls_dev ***
- Name := 'hls_dev'
- Groups := 'color'
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- calc_feature_color_intensity (Region, Image, 'hls', 'deviation', Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** rgb_mean ***
- Name := 'rgb_mean'
- Groups := 'color'
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- calc_feature_color_intensity (Region, Image, 'rgb', 'mean', Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- * ************************************
- *
- * ************************************
- * ** rgb_dev ***
- Name := 'rgb_dev'
- Groups := 'color'
- * *************
- if (Name == CurrentName)
- * ** Calculate feature ***
- calc_feature_color_intensity (Region, Image, 'rgb', 'deviation', Feature)
- * *************************
- append_length_or_values (Mode, Feature, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endif
- append_names_or_groups (Mode, Name, Groups, CurrentName, AccumulatedResults, ExtendedResults)
- AccumulatedResults := ExtendedResults
- endfor
- Output := AccumulatedResults
- set_system ('empty_region_result', EmptyRegionResult)
- return ()
复制代码
|
|