01.11.2014 Views

Reference Manual HALCON/C

Reference Manual HALCON/C

Reference Manual HALCON/C

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>HALCON</strong> Version 6.0<br />

MVTec Software GmbH<br />

<strong>HALCON</strong>/C<br />

<strong>Reference</strong> <strong>Manual</strong>


This manual describes the operators of the image analysis system <strong>HALCON</strong>, version 6.0, in C syntax. It was<br />

generated on November 15, 2000.<br />

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in<br />

any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without prior written<br />

permission of the publisher.<br />

Copyright c­ 1997-2000 by MVTec Software GmbH, München, Germany<br />

MVTec Software GmbH<br />

More information about <strong>HALCON</strong> can be found at:<br />

http://www.mvtec.com


Contents<br />

1 Classification 1<br />

clear sampset ............................................ 1<br />

close all class box .......................................... 1<br />

close class box ........................................... 2<br />

create class box ........................................... 2<br />

descript class box .......................................... 2<br />

T enquire class box ......................................... 3<br />

T enquire reject class box ..................................... 4<br />

get class box param ......................................... 4<br />

T learn class box .......................................... 5<br />

learn sampset box .......................................... 6<br />

read class box ............................................ 7<br />

read sampset ............................................. 7<br />

set class box param ......................................... 8<br />

test sampset box ........................................... 9<br />

write class box ........................................... 9<br />

2 File 11<br />

2.1 Images................................................ 11<br />

read image .............................................. 11<br />

T read image ............................................ 11<br />

read sequence ............................................ 12<br />

write image ............................................. 14<br />

T write image ............................................ 14<br />

2.2 Misc ................................................. 15<br />

file exists ............................................... 15<br />

T read world file .......................................... 15<br />

2.3 Region................................................ 16<br />

read region .............................................. 16<br />

write region ............................................. 17<br />

2.4 Text ................................................. 17<br />

close all files ............................................. 17<br />

close file ............................................... 18<br />

fnew line ............................................... 18<br />

fread char .............................................. 19<br />

fread string .............................................. 19<br />

fwrite string ............................................. 20<br />

T fwrite string ............................................ 20<br />

open file ............................................... 21<br />

2.5 Tuple................................................. 22<br />

read tuple .............................................. 22<br />

T read tuple ............................................. 22<br />

write tuple .............................................. 23<br />

T write tuple ............................................. 23<br />

2.6 XLD ................................................. 23<br />

read contour xld arc info ...................................... 23<br />

i


ii<br />

Contents<br />

read polygon xld arc info ...................................... 24<br />

write contour xld arc info ...................................... 25<br />

write polygon xld arc info ..................................... 25<br />

3 Filter 27<br />

3.1 Affine-Transformations ....................................... 27<br />

T affine trans image ......................................... 27<br />

mirror image ............................................. 29<br />

polar trans image .......................................... 29<br />

rotate image ............................................. 30<br />

zoom image factor ......................................... 31<br />

zoom image size ........................................... 32<br />

3.2 Arithmetic.............................................. 33<br />

abs image .............................................. 33<br />

add image .............................................. 33<br />

div image .............................................. 35<br />

invert image ............................................. 36<br />

max image .............................................. 36<br />

min image .............................................. 37<br />

mult image .............................................. 38<br />

scale image ............................................. 39<br />

sub image .............................................. 40<br />

3.3 Bit .................................................. 41<br />

bit and ................................................ 41<br />

bit lshift ............................................... 42<br />

bit mask ............................................... 42<br />

bit not ................................................ 43<br />

bit or ................................................. 44<br />

bit rshift ............................................... 44<br />

bit slice ............................................... 45<br />

bit xor ................................................ 46<br />

3.4 Color................................................. 47<br />

rgb1 to gray ............................................. 47<br />

rgb3 to gray ............................................. 47<br />

trans from rgb ............................................ 48<br />

trans to rgb ............................................. 52<br />

3.5 Edges................................................. 55<br />

close edges .............................................. 55<br />

close edges length .......................................... 56<br />

derivate gauss ............................................ 57<br />

diff of gauss ............................................. 59<br />

edges image ............................................. 60<br />

edges sub pix ............................................ 63<br />

frei amp ............................................... 65<br />

frei dir ................................................ 66<br />

highpass image ........................................... 67<br />

T info edges ............................................. 68<br />

kirsch amp .............................................. 69<br />

kirsch dir ............................................... 70<br />

laplace ................................................ 72<br />

laplace of gauss ........................................... 73<br />

prewitt amp ............................................. 74<br />

prewitt dir .............................................. 75<br />

roberts ................................................ 76<br />

robinson amp ............................................ 77<br />

robinson dir ............................................. 78<br />

sobel amp .............................................. 79<br />

sobel dir ............................................... 80<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Contents<br />

iii<br />

3.6 Enhancement............................................. 82<br />

emphasize .............................................. 82<br />

equ histo image ........................................... 83<br />

illuminate .............................................. 84<br />

scale image max ........................................... 85<br />

3.7 FFT ................................................. 85<br />

convol fft ............................................... 85<br />

convol gabor ............................................. 86<br />

energy gabor ............................................. 87<br />

fft generic .............................................. 88<br />

fft image ............................................... 89<br />

fft image inv ............................................. 90<br />

gen bandfilter ............................................ 91<br />

gen bandpass ............................................ 92<br />

gen filter mask ............................................ 93<br />

gen gabor .............................................. 94<br />

gen highpass ............................................. 96<br />

gen lowpass ............................................. 96<br />

gen sin bandpass .......................................... 97<br />

gen std bandpass .......................................... 98<br />

phase deg .............................................. 99<br />

phase rad ............................................... 100<br />

power byte .............................................. 100<br />

power ln ............................................... 101<br />

power real .............................................. 102<br />

3.8 Lines................................................. 103<br />

bandpass image ........................................... 103<br />

lines facet .............................................. 103<br />

lines gauss .............................................. 105<br />

3.9 Match ................................................ 107<br />

adapt template ............................................ 107<br />

best match .............................................. 108<br />

T best match ............................................. 108<br />

best match mg ............................................ 109<br />

best match pre mg .......................................... 110<br />

best match rot ............................................ 111<br />

T best match rot ........................................... 111<br />

best match rot mg .......................................... 113<br />

T best match rot mg ........................................ 113<br />

clear template ............................................ 114<br />

corner response ........................................... 114<br />

create template ............................................ 115<br />

create template rot .......................................... 117<br />

exhaustive match .......................................... 118<br />

exhaustive match mg ........................................ 120<br />

fast match .............................................. 121<br />

fast match mg ............................................ 122<br />

T fast match mg ........................................... 122<br />

fill dvf ................................................ 123<br />

gen gauss pyramid ......................................... 124<br />

monotony .............................................. 125<br />

optical flow match .......................................... 126<br />

T optical flow match ........................................ 126<br />

read template ............................................ 127<br />

set offset template .......................................... 128<br />

set reference template ........................................ 128<br />

write template ............................................ 129<br />

3.10 Misc ................................................. 129<br />

<strong>HALCON</strong> 6.0


iv<br />

Contents<br />

convol image ............................................ 129<br />

expand domain gray ......................................... 130<br />

gray inside .............................................. 131<br />

gray skeleton ............................................ 132<br />

T lut trans .............................................. 133<br />

T principal comp .......................................... 134<br />

symmetry .............................................. 134<br />

topographic sketch .......................................... 135<br />

3.11 Noise................................................. 136<br />

T add noise distribution ....................................... 136<br />

add noise white ........................................... 137<br />

T gauss distribution ......................................... 138<br />

T noise distribution mean ...................................... 138<br />

T sp distribution ........................................... 139<br />

3.12 Smoothing.............................................. 140<br />

anisotrope diff ............................................ 140<br />

eliminate min max ......................................... 141<br />

eliminate sp ............................................. 143<br />

fill interlace ............................................. 144<br />

gauss image ............................................. 145<br />

T info smooth ............................................ 146<br />

mean image ............................................. 147<br />

mean n ................................................ 148<br />

mean sp ............................................... 148<br />

median image ............................................ 149<br />

median separate ........................................... 151<br />

median weighted .......................................... 152<br />

midrange image ........................................... 153<br />

rank image .............................................. 154<br />

sigma image ............................................. 155<br />

smooth image ............................................ 156<br />

trimmed mean ............................................ 158<br />

3.13 Texture................................................ 159<br />

deviation image ........................................... 159<br />

entropy image ............................................ 160<br />

texture laws ............................................. 161<br />

T texture laws ............................................ 161<br />

3.14 Wiener-Filter . . . . . ........................................ 162<br />

gen psf defocus ........................................... 162<br />

gen psf motion ........................................... 163<br />

simulate defocus ........................................... 165<br />

simulate motion ........................................... 166<br />

wiener filter ............................................. 167<br />

wiener filter ni ............................................ 169<br />

4 Graphics 173<br />

4.1 Drawing ............................................... 173<br />

drag region1 ............................................. 173<br />

drag region2 ............................................. 174<br />

drag region3 ............................................. 175<br />

draw circle .............................................. 176<br />

draw circle mod ........................................... 176<br />

draw ellipse ............................................. 177<br />

draw ellipse mod .......................................... 178<br />

draw line ............................................... 180<br />

draw line mod ............................................ 181<br />

draw point .............................................. 182<br />

draw point mod ........................................... 183<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Contents<br />

v<br />

draw polygon ............................................ 184<br />

draw rectangle1 ........................................... 184<br />

draw rectangle1 mod ........................................ 186<br />

draw rectangle2 ........................................... 187<br />

draw rectangle2 mod ........................................ 188<br />

draw region ............................................. 189<br />

4.2 Gnuplot ............................................... 190<br />

gnuplot close ............................................ 190<br />

gnuplot open file .......................................... 190<br />

gnuplot open pipe .......................................... 191<br />

T gnuplot plot ctrl .......................................... 191<br />

T gnuplot plot funct 1d ....................................... 192<br />

gnuplot plot image ......................................... 192<br />

4.3 LUT ................................................. 193<br />

disp lut ................................................ 193<br />

draw lut ............................................... 194<br />

get fixed lut ............................................. 195<br />

T get lut ............................................... 196<br />

get lut style ............................................. 196<br />

T query lut .............................................. 197<br />

set fixed lut ............................................. 197<br />

set lut ................................................ 198<br />

T set lut ............................................... 198<br />

set lut style ............................................. 200<br />

write lut ............................................... 201<br />

4.4 Mouse ................................................ 202<br />

get mbutton ............................................. 202<br />

get mposition ............................................ 203<br />

get mshape .............................................. 203<br />

T query mshape ........................................... 204<br />

set mshape .............................................. 204<br />

4.5 Output ................................................ 205<br />

disp arc ............................................... 205<br />

T disp arc .............................................. 205<br />

disp arrow .............................................. 206<br />

T disp arrow ............................................. 206<br />

disp channel ............................................. 208<br />

T disp channel ............................................ 208<br />

disp circle .............................................. 209<br />

T disp circle ............................................. 209<br />

disp color .............................................. 210<br />

T disp distribution .......................................... 210<br />

disp ellipse .............................................. 211<br />

T disp ellipse ............................................ 211<br />

disp image .............................................. 213<br />

disp line ............................................... 214<br />

T disp line .............................................. 214<br />

disp obj ............................................... 215<br />

T disp polygon ........................................... 216<br />

disp rectangle1 ............................................ 217<br />

T disp rectangle1 .......................................... 217<br />

disp rectangle2 ............................................ 219<br />

T disp rectangle2 .......................................... 219<br />

disp region .............................................. 220<br />

disp xld ............................................... 221<br />

4.6 Parameters.............................................. 221<br />

get comprise ............................................. 221<br />

get draw ............................................... 222<br />

<strong>HALCON</strong> 6.0


vi<br />

Contents<br />

get fix ................................................ 222<br />

T get hsi ............................................... 223<br />

get icon ............................................... 223<br />

get insert ............................................... 224<br />

get line approx ........................................... 225<br />

T get line style ........................................... 225<br />

get line width ............................................ 225<br />

T get paint .............................................. 226<br />

get part ................................................ 226<br />

get part style ............................................. 227<br />

T get pixel .............................................. 228<br />

T get rgb ............................................... 228<br />

get shape ............................................... 229<br />

T query all colors .......................................... 229<br />

T query color ............................................ 230<br />

T query colored ........................................... 231<br />

T query gray ............................................. 231<br />

T query insert ............................................ 232<br />

query line width ........................................... 232<br />

T query paint ............................................ 233<br />

T query shape ............................................ 233<br />

set color ............................................... 234<br />

T set color .............................................. 234<br />

set colored .............................................. 235<br />

set comprise ............................................. 236<br />

set draw ............................................... 237<br />

set fix ................................................ 237<br />

set gray ............................................... 238<br />

T set gray .............................................. 238<br />

T set hsi ............................................... 239<br />

set icon ................................................ 240<br />

set insert ............................................... 241<br />

set line approx ............................................ 242<br />

T set line style ............................................ 242<br />

set line width ............................................ 243<br />

T set paint .............................................. 244<br />

set part ................................................ 248<br />

set part style ............................................. 249<br />

T set pixel .............................................. 250<br />

T set rgb ............................................... 251<br />

set shape ............................................... 252<br />

4.7 Text ................................................. 253<br />

get font ................................................ 253<br />

get string extents .......................................... 253<br />

T get string extents ......................................... 253<br />

get tposition ............................................. 254<br />

get tshape .............................................. 255<br />

new line ............................................... 255<br />

T query font ............................................. 256<br />

T query tshape ............................................ 257<br />

read char ............................................... 257<br />

read string .............................................. 258<br />

set font ................................................ 259<br />

set tposition ............................................. 260<br />

set tshape .............................................. 260<br />

T write string ............................................ 261<br />

4.8 Window ............................................... 262<br />

clear rectangle ............................................ 262<br />

T clear rectangle ........................................... 262<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Contents<br />

vii<br />

clear window ............................................ 263<br />

close window ............................................ 263<br />

copy rectangle ............................................ 264<br />

T copy rectangle ........................................... 264<br />

dump window ............................................ 266<br />

T dump window ........................................... 266<br />

get window extents ......................................... 267<br />

get window pointer3 ........................................ 268<br />

get window type ........................................... 268<br />

move rectangle ........................................... 269<br />

T move rectangle .......................................... 269<br />

new extern window ......................................... 271<br />

open textwindow .......................................... 273<br />

open window ............................................ 277<br />

T query window type ........................................ 280<br />

set window attr ........................................... 280<br />

set window dc ............................................ 281<br />

set window extents ......................................... 282<br />

set window type ........................................... 283<br />

slide image .............................................. 284<br />

5 Image 285<br />

5.1 Channel ............................................... 285<br />

access channel ............................................ 285<br />

append channel ........................................... 286<br />

channels to image .......................................... 286<br />

compose2 .............................................. 286<br />

compose3 .............................................. 287<br />

compose4 .............................................. 287<br />

compose5 .............................................. 288<br />

compose6 .............................................. 289<br />

compose7 .............................................. 289<br />

count channels ............................................ 290<br />

T count channels .......................................... 290<br />

decompose2 ............................................. 290<br />

decompose3 ............................................. 291<br />

decompose4 ............................................. 292<br />

decompose5 ............................................. 292<br />

decompose6 ............................................. 293<br />

decompose7 ............................................. 293<br />

image to channels .......................................... 294<br />

5.2 Creation ............................................... 295<br />

copy image ............................................. 295<br />

gen image1 ............................................. 295<br />

gen image1 extern .......................................... 296<br />

gen image1 rect ........................................... 298<br />

gen image3 ............................................. 299<br />

gen image const ........................................... 301<br />

gen image gray ramp ........................................ 302<br />

gen image proto ........................................... 303<br />

gen image surface second order .................................. 304<br />

get image time ............................................ 306<br />

region to bin ............................................. 306<br />

region to label ............................................ 307<br />

region to mean ........................................... 308<br />

5.3 Domain ............................................... 309<br />

add channels ............................................. 309<br />

change domain ............................................ 310<br />

full domain ............................................. 310<br />

<strong>HALCON</strong> 6.0


viii<br />

Contents<br />

get domain .............................................. 311<br />

rectangle1 domain .......................................... 311<br />

reduce domain ............................................ 312<br />

5.4 Features ............................................... 313<br />

area center gray ........................................... 313<br />

T area center gray .......................................... 313<br />

cooc feature image ......................................... 314<br />

T cooc feature image ........................................ 314<br />

cooc feature matrix ......................................... 315<br />

elliptic axis gray ........................................... 316<br />

T elliptic axis gray ......................................... 316<br />

entropy gray ............................................. 317<br />

T entropy gray ............................................ 317<br />

fit surface first order ........................................ 318<br />

T fit surface first order ....................................... 318<br />

fit surface second order ....................................... 319<br />

T fit surface second order ...................................... 319<br />

fuzzy entropy ............................................ 320<br />

T fuzzy entropy ........................................... 320<br />

fuzzy perimeter ........................................... 321<br />

T fuzzy perimeter .......................................... 321<br />

gen cooc matrix ........................................... 322<br />

T gray histo ............................................. 323<br />

T gray projections .......................................... 324<br />

histo 2dim .............................................. 325<br />

intensity ............................................... 326<br />

T intensity .............................................. 326<br />

min max gray ............................................ 326<br />

T min max gray ........................................... 326<br />

moments gray plane ......................................... 328<br />

T moments gray plane ....................................... 328<br />

plane deviation ........................................... 329<br />

T plane deviation .......................................... 329<br />

select gray .............................................. 330<br />

T select gray ............................................. 330<br />

T shape histo all ........................................... 331<br />

T shape histo point ......................................... 332<br />

5.5 Format................................................ 333<br />

change format ............................................ 333<br />

crop domain ............................................. 334<br />

crop part ............................................... 334<br />

crop rectangle1 ........................................... 335<br />

tile channels ............................................. 336<br />

tile images .............................................. 337<br />

T tile images offset ......................................... 338<br />

5.6 Framegrabber ............................................ 340<br />

close all framegrabbers ....................................... 340<br />

close framegrabber ......................................... 340<br />

T get framegrabber lut ....................................... 341<br />

get framegrabber param ....................................... 341<br />

T get framegrabber param ..................................... 341<br />

grab image .............................................. 342<br />

grab image async .......................................... 343<br />

grab image start ........................................... 344<br />

grab region .............................................. 345<br />

grab region async .......................................... 346<br />

info framegrabber .......................................... 346<br />

T info framegrabber ......................................... 346<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Contents<br />

ix<br />

open framegrabber .......................................... 348<br />

T open framegrabber ........................................ 348<br />

T set framegrabber lut ....................................... 350<br />

set framegrabber param ....................................... 351<br />

T set framegrabber param ...................................... 351<br />

5.7 Manipulation............................................. 351<br />

get grayval .............................................. 351<br />

T get grayval ............................................ 351<br />

get image pointer1 ......................................... 352<br />

get image pointer1 rect ....................................... 353<br />

get image pointer3 ......................................... 354<br />

paint gray .............................................. 355<br />

paint region ............................................. 356<br />

set grayval .............................................. 357<br />

T set grayval ............................................. 357<br />

5.8 Type-Conversion........................................... 358<br />

complex to real ........................................... 358<br />

convert image type ......................................... 358<br />

dvf to int1 .............................................. 359<br />

int1 to dvf .............................................. 359<br />

real to complex ........................................... 360<br />

6 Lines 361<br />

6.1 Access . ............................................... 361<br />

T approx chain ........................................... 361<br />

T approx chain simple ....................................... 364<br />

6.2 Features ............................................... 366<br />

line orientation ............................................ 366<br />

T line orientation .......................................... 366<br />

line position ............................................. 367<br />

T line position ............................................ 367<br />

T partition lines ........................................... 368<br />

T select lines ............................................ 369<br />

T select lines longest ........................................ 370<br />

7 Morphology 373<br />

7.1 Gray-Values ............................................. 373<br />

dual rank ............................................... 373<br />

gen disc se .............................................. 374<br />

gray bothat .............................................. 375<br />

gray closing ............................................. 376<br />

gray dilation ............................................. 377<br />

gray dilation rect .......................................... 377<br />

gray erosion ............................................. 378<br />

gray erosion rect ........................................... 379<br />

gray opening ............................................. 379<br />

gray range rect ........................................... 380<br />

gray tophat .............................................. 381<br />

read gray se ............................................. 381<br />

7.2 Region................................................ 382<br />

bottom hat .............................................. 382<br />

boundary ............................................... 383<br />

closing ................................................ 384<br />

closing circle ............................................ 385<br />

closing golay ............................................ 387<br />

closing rectangle1 .......................................... 388<br />

dilation1 ............................................... 389<br />

dilation2 ............................................... 390<br />

<strong>HALCON</strong> 6.0


x<br />

Contents<br />

dilation circle ............................................ 391<br />

dilation golay ............................................ 392<br />

dilation rectangle1 .......................................... 394<br />

dilation seq ............................................. 395<br />

erosion1 ............................................... 396<br />

erosion2 ............................................... 397<br />

erosion circle ............................................ 399<br />

erosion golay ............................................ 400<br />

erosion rectangle1 .......................................... 401<br />

erosion seq .............................................. 402<br />

fitting ................................................. 403<br />

gen struct elements ......................................... 404<br />

golay elements ............................................ 405<br />

hit or miss .............................................. 408<br />

hit or miss golay .......................................... 409<br />

hit or miss seq ............................................ 410<br />

minkowski add1 ........................................... 411<br />

minkowski add2 ........................................... 412<br />

minkowski sub1 ........................................... 414<br />

minkowski sub2 ........................................... 415<br />

morph hat .............................................. 416<br />

morph skeleton ........................................... 417<br />

morph skiz .............................................. 418<br />

opening ............................................... 419<br />

opening circle ............................................ 420<br />

opening golay ............................................ 422<br />

opening rectangle1 ......................................... 423<br />

opening seg ............................................. 424<br />

pruning ................................................ 425<br />

thickening .............................................. 426<br />

thickening golay ........................................... 427<br />

thickening seq ............................................ 428<br />

thinning ............................................... 429<br />

thinning golay ............................................ 430<br />

thinning seq ............................................. 431<br />

top hat ................................................ 433<br />

8 Object 435<br />

8.1 Information ............................................. 435<br />

count obj ............................................... 435<br />

get channel info ........................................... 435<br />

T get channel info .......................................... 435<br />

get obj class ............................................. 436<br />

T get obj class ............................................ 436<br />

test equal obj ............................................ 437<br />

test equal region ........................................... 438<br />

test obj def .............................................. 438<br />

8.2 Manipulation............................................. 439<br />

clear obj ............................................... 439<br />

concat obj .............................................. 440<br />

copy obj ............................................... 441<br />

gen empty obj ............................................ 442<br />

T integer to obj ........................................... 442<br />

T obj to integer ........................................... 443<br />

select obj ............................................... 443<br />

9 Regions 445<br />

9.1 Access . ............................................... 445<br />

T get region chain .......................................... 445<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Contents<br />

xi<br />

T get region contour ........................................ 446<br />

T get region convex ......................................... 446<br />

T get region points ......................................... 447<br />

T get region polygon ........................................ 448<br />

T get region runs .......................................... 449<br />

9.2 Affine-Transformations ....................................... 449<br />

T affine trans region ......................................... 449<br />

mirror region ............................................ 450<br />

move region ............................................. 451<br />

transpose region ........................................... 452<br />

zoom region ............................................. 453<br />

9.3 Creation ............................................... 454<br />

gen checker region ......................................... 454<br />

gen circle .............................................. 455<br />

T gen circle ............................................. 455<br />

gen ellipse .............................................. 457<br />

T gen ellipse ............................................. 457<br />

gen empty region .......................................... 458<br />

gen grid region ........................................... 459<br />

gen random region ......................................... 460<br />

gen random regions ......................................... 461<br />

gen rectangle1 ............................................ 463<br />

T gen rectangle1 ........................................... 463<br />

gen rectangle2 ............................................ 464<br />

T gen rectangle2 ........................................... 464<br />

T gen region histo .......................................... 465<br />

gen region hline ........................................... 466<br />

T gen region hline .......................................... 466<br />

gen region line ........................................... 467<br />

T gen region line .......................................... 467<br />

gen region points .......................................... 468<br />

T gen region points ......................................... 468<br />

T gen region polygon ........................................ 469<br />

T gen region polygon filled ..................................... 470<br />

gen region runs ........................................... 471<br />

T gen region runs .......................................... 471<br />

label to region ............................................ 472<br />

9.4 Features ............................................... 473<br />

area center .............................................. 473<br />

T area center ............................................. 473<br />

circularity .............................................. 474<br />

T circularity ............................................. 474<br />

compactness ............................................. 475<br />

T compactness ............................................ 475<br />

connect and holes .......................................... 475<br />

T connect and holes ......................................... 475<br />

contlength .............................................. 476<br />

T contlength ............................................. 476<br />

convexity ............................................... 477<br />

T convexity ............................................. 477<br />

diameter region ........................................... 478<br />

T diameter region .......................................... 478<br />

eccentricity .............................................. 479<br />

T eccentricity ............................................ 479<br />

elliptic axis ............................................. 480<br />

T elliptic axis ............................................ 480<br />

euler number ............................................. 481<br />

T euler number ........................................... 481<br />

<strong>HALCON</strong> 6.0


xii<br />

Contents<br />

T find neighbors ........................................... 482<br />

get region index ........................................... 483<br />

T get region index .......................................... 483<br />

T get region thickness ........................................ 483<br />

hamming distance .......................................... 484<br />

T hamming distance ......................................... 484<br />

hamming distance norm ....................................... 485<br />

T hamming distance norm ..................................... 485<br />

inner circle .............................................. 486<br />

T inner circle ............................................ 486<br />

moments region 2nd ......................................... 487<br />

T moments region 2nd ....................................... 487<br />

moments region 2nd invar ..................................... 488<br />

T moments region 2nd invar .................................... 488<br />

moments region 2nd rel invar .................................... 489<br />

T moments region 2nd rel invar .................................. 489<br />

moments region 3rd ......................................... 490<br />

T moments region 3rd ....................................... 490<br />

moments region 3rd invar ...................................... 491<br />

T moments region 3rd invar .................................... 491<br />

moments region central ....................................... 492<br />

T moments region central ...................................... 492<br />

moments region central invar .................................... 493<br />

T moments region central invar .................................. 493<br />

orientation region .......................................... 494<br />

T orientation region ......................................... 494<br />

roundness .............................................. 495<br />

T roundness ............................................. 495<br />

T runlength distribution ....................................... 496<br />

runlength features .......................................... 497<br />

T runlength features ......................................... 497<br />

select region point .......................................... 498<br />

T select region spatial ........................................ 499<br />

select shape ............................................. 500<br />

T select shape ............................................ 500<br />

select shape proto .......................................... 503<br />

T select shape proto ......................................... 503<br />

select shape std ........................................... 504<br />

smallest circle ............................................ 505<br />

T smallest circle ........................................... 505<br />

smallest rectangle1 ......................................... 506<br />

T smallest rectangle1 ........................................ 506<br />

smallest rectangle2 ......................................... 507<br />

T smallest rectangle2 ........................................ 507<br />

T spatial relation .......................................... 508<br />

test region point ........................................... 509<br />

9.5 Sets.................................................. 510<br />

complement ............................................. 510<br />

difference .............................................. 511<br />

intersection .............................................. 512<br />

union1 ................................................ 513<br />

union2 ................................................ 513<br />

9.6 Transformation............................................ 514<br />

background seg ........................................... 514<br />

clip region .............................................. 515<br />

clip region rel ............................................ 516<br />

connection .............................................. 517<br />

crop domain rel ........................................... 518<br />

distance transform .......................................... 519<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Contents<br />

xiii<br />

eliminate runs ............................................ 520<br />

expand region ............................................ 521<br />

fill up ................................................ 522<br />

fill up shape ............................................. 523<br />

hamming change region ....................................... 524<br />

interjacent .............................................. 525<br />

junctions skeleton .......................................... 526<br />

merge regions line scan ....................................... 527<br />

partition dynamic .......................................... 528<br />

partition rectangle .......................................... 528<br />

rank region .............................................. 529<br />

remove noise region ......................................... 530<br />

shape trans .............................................. 531<br />

skeleton ............................................... 532<br />

sort region .............................................. 533<br />

T split skeleton lines ........................................ 533<br />

split skeleton region ......................................... 535<br />

10 Segmentation 537<br />

auto threshold ............................................ 537<br />

bin threshold ............................................. 538<br />

char threshold ............................................ 538<br />

T char threshold ........................................... 538<br />

check difference ........................................... 539<br />

class 2dim sup ............................................ 541<br />

class 2dim unsup .......................................... 543<br />

class ndim box ........................................... 544<br />

class ndim norm ........................................... 545<br />

T class ndim norm ......................................... 545<br />

T detect edge segments ....................................... 546<br />

dual threshold ............................................ 548<br />

dyn threshold ............................................ 549<br />

expand gray ............................................. 551<br />

T expand gray ............................................ 551<br />

expand gray ref ........................................... 552<br />

T expand gray ref .......................................... 552<br />

expand line ............................................. 554<br />

fast threshold ............................................ 555<br />

T histo to thresh ........................................... 556<br />

hysteresis threshold ......................................... 557<br />

learn ndim box ........................................... 558<br />

T learn ndim norm ......................................... 559<br />

local max .............................................. 560<br />

nonmax suppression amp ...................................... 561<br />

nonmax suppression dir ....................................... 562<br />

plateaus ............................................... 563<br />

plateaus center ............................................ 563<br />

pouring ................................................ 564<br />

regiongrowing ............................................ 566<br />

regiongrowing mean ......................................... 567<br />

T regiongrowing mean ....................................... 567<br />

regiongrowing n ........................................... 568<br />

threshold ............................................... 573<br />

T threshold .............................................. 573<br />

threshold sub pix .......................................... 574<br />

watersheds .............................................. 575<br />

zero crossing ............................................. 575<br />

zero crossing sub pix ........................................ 576<br />

<strong>HALCON</strong> 6.0


xiv<br />

Contents<br />

11 System 579<br />

11.1 Database............................................... 579<br />

count relation ............................................ 579<br />

T get modules ............................................ 580<br />

reset obj db ............................................. 581<br />

11.2 Error-Handling............................................ 582<br />

T get check ............................................. 582<br />

get error text ............................................. 582<br />

get spy ................................................ 583<br />

T query spy ............................................. 584<br />

set check ............................................... 584<br />

T set check ............................................. 584<br />

set spy ................................................ 585<br />

11.3 Information ............................................. 587<br />

disp info ............................................... 587<br />

T get chapter info .......................................... 588<br />

T get keywords ........................................... 589<br />

T get operator info ......................................... 589<br />

T get operator name ......................................... 590<br />

T get param info .......................................... 591<br />

T get param names ......................................... 593<br />

get param num ........................................... 593<br />

T get param types .......................................... 594<br />

T query operator info ........................................ 595<br />

T query param info ......................................... 595<br />

T search operator .......................................... 596<br />

11.4 Operating-System .......................................... 596<br />

count seconds ............................................ 596<br />

system call .............................................. 597<br />

wait seconds ............................................. 597<br />

11.5 Parallelization ............................................ 598<br />

check par hw potential ....................................... 598<br />

load par knowledge ......................................... 599<br />

store par knowledge ......................................... 600<br />

11.6 Parameters.............................................. 600<br />

get system .............................................. 600<br />

T get system ............................................. 600<br />

set system .............................................. 603<br />

T set system ............................................. 603<br />

11.7 Serial................................................. 608<br />

clear serial .............................................. 608<br />

close all serials ........................................... 608<br />

close serial .............................................. 609<br />

get serial param ........................................... 609<br />

open serial .............................................. 610<br />

read serial .............................................. 610<br />

T read serial ............................................. 610<br />

set serial param ........................................... 611<br />

write serial .............................................. 612<br />

T write serial ............................................ 612<br />

11.8 Sockets................................................ 613<br />

close socket ............................................. 613<br />

get next socket data type ...................................... 613<br />

open socket accept ......................................... 614<br />

open socket connect ......................................... 615<br />

receive image ............................................ 616<br />

receive region ............................................ 616<br />

receive tuple ............................................. 617<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Contents<br />

xv<br />

receive xld .............................................. 617<br />

send image .............................................. 617<br />

send region ............................................. 618<br />

send tuple .............................................. 618<br />

send xld ............................................... 619<br />

socket accept connect ........................................ 620<br />

12 Tools 621<br />

12.1 Affine-Transformations ....................................... 621<br />

T affine trans point 2d ....................................... 621<br />

T affine trans point 3d ....................................... 622<br />

T dvf to hom mat2d ......................................... 623<br />

T hom mat2d compose ....................................... 623<br />

T hom mat2d identity ........................................ 624<br />

T hom mat2d invert ......................................... 624<br />

T hom mat2d rotate ......................................... 625<br />

T hom mat2d scale ......................................... 626<br />

T hom mat2d slant ......................................... 627<br />

T hom mat2d to affine par ..................................... 628<br />

T hom mat2d translate ....................................... 629<br />

T hom mat3d compose ....................................... 629<br />

T hom mat3d identity ........................................ 631<br />

T hom mat3d invert ......................................... 631<br />

T hom mat3d rotate ......................................... 632<br />

T hom mat3d scale ......................................... 634<br />

T hom mat3d translate ....................................... 635<br />

T vector angle to rigid ....................................... 637<br />

T vector to hom mat2d ....................................... 638<br />

T vector to rigid ........................................... 639<br />

T vector to similarity ........................................ 639<br />

12.2 Background-Estimator ........................................ 640<br />

close all bg esti ........................................... 640<br />

close bg esti ............................................. 640<br />

create bg esti ............................................ 641<br />

get bg esti params .......................................... 644<br />

give bg esti ............................................. 645<br />

run bg esti .............................................. 646<br />

set bg esti params .......................................... 647<br />

update bg esti ............................................ 649<br />

12.3 Barcode ............................................... 650<br />

T decode 1d bar code ........................................ 650<br />

T decode 2d bar code ........................................ 651<br />

T discrete 1d bar code ....................................... 652<br />

T find 1d bar code ......................................... 653<br />

T find 1d bar code region ...................................... 657<br />

T find 2d bar code ......................................... 658<br />

T gen 1d bar code descr ...................................... 661<br />

T gen 1d bar code descr gen .................................... 662<br />

T gen 2d bar code descr ...................................... 663<br />

T get 1d bar code .......................................... 665<br />

T get 2d bar code .......................................... 666<br />

T get 2d bar code pos ........................................ 670<br />

12.4 Calibration.............................................. 672<br />

T caltab points ............................................ 672<br />

T camera calibration ........................................ 673<br />

T change radial distortion cam par ................................. 678<br />

T change radial distortion contours xld .............................. 679<br />

T change radial distortion image .................................. 680<br />

<strong>HALCON</strong> 6.0


xvi<br />

Contents<br />

T contour to world plane xld .................................... 680<br />

T convert pose type ......................................... 681<br />

create caltab ............................................. 682<br />

T create pose ............................................ 685<br />

T disp caltab ............................................. 691<br />

find caltab .............................................. 692<br />

T find marks and pose ....................................... 694<br />

T get line of sight .......................................... 696<br />

T get pose type ........................................... 697<br />

T hand eye calibration ....................................... 698<br />

T hom mat3d to pose ........................................ 704<br />

T image points to world plane ................................... 705<br />

T pose to hom mat3d ........................................ 706<br />

T project 3d point .......................................... 708<br />

T read cam par ........................................... 709<br />

T read pose ............................................. 711<br />

T set origin pose .......................................... 712<br />

T sim caltab ............................................. 712<br />

T write cam par ........................................... 714<br />

T write pose ............................................. 716<br />

12.5 Fourier-Descriptor.......................................... 718<br />

T abs invar fourier coeff ...................................... 718<br />

T fourier 1dim ............................................ 719<br />

T fourier 1dim inv ......................................... 720<br />

T invar fourier coeff ......................................... 721<br />

T match fourier coeff ........................................ 722<br />

T move contour orig ........................................ 723<br />

T prep contour fourier ....................................... 723<br />

12.6 Function ............................................... 724<br />

T abs funct 1d ............................................ 724<br />

T create funct 1d array ....................................... 724<br />

T create funct 1d pairs ....................................... 725<br />

T distance funct 1d ......................................... 725<br />

T funct 1d to pairs ......................................... 726<br />

T get pair funct 1d ......................................... 726<br />

T integrate funct 1d ......................................... 727<br />

T match funct 1d trans ....................................... 727<br />

T negate funct 1d .......................................... 728<br />

T num points funct 1d ....................................... 729<br />

read funct 1d ............................................ 729<br />

T read funct 1d ........................................... 729<br />

T sample funct 1d .......................................... 730<br />

T scale y funct 1d .......................................... 730<br />

T smooth funct 1d gauss ...................................... 731<br />

T smooth funct 1d mean ...................................... 731<br />

T transform funct 1d ........................................ 732<br />

T write funct 1d ........................................... 732<br />

T x range funct 1d ......................................... 733<br />

T y range funct 1d ......................................... 733<br />

12.7 Geometry .............................................. 734<br />

angle ll ................................................ 734<br />

T angle ll .............................................. 734<br />

angle lx ............................................... 735<br />

T angle lx .............................................. 735<br />

distance lr .............................................. 736<br />

T distance lr ............................................. 736<br />

distance pl .............................................. 737<br />

T distance pl ............................................. 737<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Contents<br />

xvii<br />

distance pp .............................................. 738<br />

T distance pp ............................................ 738<br />

distance pr .............................................. 739<br />

T distance pr ............................................. 739<br />

distance ps .............................................. 740<br />

T distance ps ............................................ 740<br />

distance rr min ........................................... 741<br />

T distance rr min .......................................... 741<br />

distance rr min dil .......................................... 742<br />

T distance rr min dil ........................................ 742<br />

distance sl .............................................. 742<br />

T distance sl ............................................. 742<br />

distance sr .............................................. 744<br />

T distance sr ............................................. 744<br />

distance ss .............................................. 744<br />

T distance ss ............................................. 744<br />

get points ellipse .......................................... 746<br />

T get points ellipse ......................................... 746<br />

intersection ll ............................................ 747<br />

T intersection ll ........................................... 747<br />

projection pl ............................................. 748<br />

T projection pl ............................................ 748<br />

12.8 Hough . ............................................... 749<br />

hough circle trans .......................................... 749<br />

T hough circle trans ......................................... 749<br />

hough circles ............................................ 749<br />

T hough circles ........................................... 749<br />

hough line trans ........................................... 750<br />

T hough lines ............................................ 751<br />

T select matching lines ....................................... 752<br />

12.9 Kalman-Filter . . . . ........................................ 753<br />

T filter kalman ............................................ 753<br />

T read kalman ............................................ 757<br />

T sensor kalman ........................................... 759<br />

T update kalman ........................................... 760<br />

12.10Matching............................................... 763<br />

clear shape model .......................................... 763<br />

create shape model ......................................... 763<br />

T find shape model ......................................... 765<br />

inspect shape model ......................................... 767<br />

read shape model .......................................... 768<br />

write shape model .......................................... 769<br />

12.11 Measure ............................................... 769<br />

close measure ............................................ 769<br />

gen measure arc ........................................... 769<br />

gen measure rectangle2 ....................................... 771<br />

T measure pairs ........................................... 773<br />

T measure pos ............................................ 775<br />

T measure projection ........................................ 776<br />

T measure thresh .......................................... 777<br />

12.12OCR ................................................. 778<br />

append ocr trainf .......................................... 778<br />

T append ocr trainf ......................................... 778<br />

close all ocrs ............................................. 780<br />

close ocr ............................................... 780<br />

T concat ocr trainf ......................................... 781<br />

T create ocr class box ........................................ 781<br />

do ocr multi ............................................. 784<br />

<strong>HALCON</strong> 6.0


xviii<br />

Contents<br />

T do ocr multi ............................................ 784<br />

T do ocr single ........................................... 785<br />

T info ocr class box ......................................... 786<br />

T ocr change char .......................................... 787<br />

T ocr get features .......................................... 787<br />

read ocr ............................................... 788<br />

T read ocr trainf ........................................... 789<br />

read ocr trainf names ........................................ 789<br />

T read ocr trainf names ....................................... 789<br />

read ocr trainf select ........................................ 790<br />

T read ocr trainf select ....................................... 790<br />

testd ocr class box .......................................... 790<br />

T testd ocr class box ........................................ 790<br />

traind ocr class box ......................................... 791<br />

T traind ocr class box ........................................ 791<br />

trainf ocr class box ......................................... 792<br />

T trainf ocr class box ........................................ 792<br />

write ocr ............................................... 793<br />

write ocr trainf ........................................... 794<br />

T write ocr trainf .......................................... 794<br />

write ocr trainf image ........................................ 795<br />

T write ocr trainf image ...................................... 795<br />

12.13OCV................................................. 795<br />

close all ocvs ............................................ 795<br />

close ocv ............................................... 796<br />

create ocv proj ............................................ 796<br />

T create ocv proj .......................................... 796<br />

do ocv simple ............................................ 797<br />

T do ocv simple ........................................... 797<br />

read ocv ............................................... 799<br />

traind ocv proj ............................................ 799<br />

T traind ocv proj .......................................... 799<br />

write ocv ............................................... 800<br />

12.14 Shape-from . . . . . ........................................ 801<br />

depth from focus .......................................... 801<br />

T depth from focus ......................................... 801<br />

estimate al am ............................................ 802<br />

T estimate al am .......................................... 802<br />

estimate sl al lr ........................................... 802<br />

T estimate sl al lr .......................................... 802<br />

estimate sl al zc ........................................... 803<br />

T estimate sl al zc .......................................... 803<br />

estimate tilt lr ............................................ 804<br />

T estimate tilt lr ........................................... 804<br />

estimate tilt zc ............................................ 804<br />

T estimate tilt zc .......................................... 804<br />

T phot stereo ............................................ 804<br />

select grayvalues from channels .................................. 805<br />

sfs mod lr .............................................. 806<br />

sfs orig lr .............................................. 807<br />

sfs pentland ............................................. 808<br />

shade height field .......................................... 810<br />

13 Tuple 813<br />

13.1 Arithmetic.............................................. 813<br />

tuple abs ............................................... 813<br />

T tuple abs .............................................. 813<br />

tuple acos .............................................. 813<br />

T tuple acos ............................................. 813<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Contents<br />

xix<br />

tuple add ............................................... 814<br />

T tuple add ............................................. 814<br />

tuple asin .............................................. 814<br />

T tuple asin ............................................. 814<br />

tuple atan .............................................. 815<br />

T tuple atan ............................................. 815<br />

tuple atan2 .............................................. 815<br />

T tuple atan2 ............................................ 815<br />

tuple cos ............................................... 816<br />

T tuple cos .............................................. 816<br />

tuple cosh .............................................. 816<br />

T tuple cosh ............................................. 816<br />

tuple div ............................................... 817<br />

T tuple div .............................................. 817<br />

tuple exp ............................................... 817<br />

T tuple exp ............................................. 817<br />

tuple fabs .............................................. 818<br />

T tuple fabs ............................................. 818<br />

tuple fmod .............................................. 818<br />

T tuple fmod ............................................. 818<br />

tuple ldexp .............................................. 818<br />

T tuple ldexp ............................................ 818<br />

tuple log ............................................... 819<br />

T tuple log .............................................. 819<br />

tuple log10 .............................................. 819<br />

T tuple log10 ............................................ 819<br />

tuple mult .............................................. 820<br />

T tuple mult ............................................. 820<br />

tuple neg ............................................... 820<br />

T tuple neg ............................................. 820<br />

tuple pow .............................................. 821<br />

T tuple pow ............................................. 821<br />

tuple rad ............................................... 821<br />

T tuple rad .............................................. 821<br />

tuple sin ............................................... 822<br />

T tuple sin .............................................. 822<br />

tuple sinh .............................................. 822<br />

T tuple sinh ............................................. 822<br />

tuple sqrt ............................................... 823<br />

T tuple sqrt ............................................. 823<br />

tuple sub ............................................... 823<br />

T tuple sub ............................................. 823<br />

tuple tan ............................................... 823<br />

T tuple tan .............................................. 823<br />

tuple tanh .............................................. 824<br />

T tuple tanh ............................................. 824<br />

13.2 Bit-Operations............................................ 824<br />

tuple band .............................................. 824<br />

T tuple band ............................................. 824<br />

tuple bnot .............................................. 825<br />

T tuple bnot ............................................. 825<br />

tuple bor ............................................... 825<br />

T tuple bor .............................................. 825<br />

tuple bxor .............................................. 826<br />

T tuple bxor ............................................. 826<br />

tuple lsh ............................................... 826<br />

T tuple lsh .............................................. 826<br />

tuple rsh ............................................... 827<br />

T tuple rsh .............................................. 827<br />

<strong>HALCON</strong> 6.0


xx<br />

Contents<br />

13.3 Comparison ............................................. 828<br />

tuple equal .............................................. 828<br />

T tuple equal ............................................ 828<br />

tuple greater ............................................. 828<br />

T tuple greater ............................................ 828<br />

tuple greater equal .......................................... 829<br />

T tuple greater equal ........................................ 829<br />

tuple less ............................................... 829<br />

T tuple less ............................................. 829<br />

tuple less equal ........................................... 830<br />

T tuple less equal .......................................... 830<br />

tuple not equal ............................................ 830<br />

T tuple not equal .......................................... 830<br />

13.4 Conversion.............................................. 831<br />

tuple chr ............................................... 831<br />

T tuple chr .............................................. 831<br />

tuple chrt ............................................... 831<br />

T tuple chrt ............................................. 831<br />

tuple deg ............................................... 832<br />

T tuple deg ............................................. 832<br />

tuple number ............................................. 832<br />

T tuple number ........................................... 832<br />

tuple ord ............................................... 833<br />

T tuple ord .............................................. 833<br />

tuple ords .............................................. 833<br />

T tuple ords ............................................. 833<br />

tuple real ............................................... 834<br />

T tuple real ............................................. 834<br />

tuple round .............................................. 834<br />

T tuple round ............................................ 834<br />

tuple string .............................................. 835<br />

T tuple string ............................................ 835<br />

13.5 Creation ............................................... 836<br />

tuple concat ............................................. 836<br />

T tuple concat ............................................ 836<br />

tuple gen const ........................................... 836<br />

T tuple gen const .......................................... 836<br />

13.6 Element-Order............................................ 837<br />

tuple inverse ............................................. 837<br />

T tuple inverse ............................................ 837<br />

tuple sort ............................................... 837<br />

T tuple sort ............................................. 837<br />

tuple sort index ........................................... 838<br />

T tuple sort index .......................................... 838<br />

13.7 Features ............................................... 838<br />

tuple ceil ............................................... 838<br />

T tuple ceil ............................................. 838<br />

tuple deviation ............................................ 839<br />

T tuple deviation .......................................... 839<br />

tuple floor .............................................. 839<br />

T tuple floor ............................................. 839<br />

tuple is number ........................................... 840<br />

T tuple is number .......................................... 840<br />

tuple length ............................................. 840<br />

T tuple length ............................................ 840<br />

tuple max .............................................. 840<br />

T tuple max ............................................. 840<br />

tuple mean .............................................. 841<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Contents<br />

xxi<br />

T tuple mean ............................................ 841<br />

tuple min ............................................... 841<br />

T tuple min ............................................. 841<br />

tuple sum .............................................. 842<br />

T tuple sum ............................................. 842<br />

13.8 Logical-Operations ......................................... 842<br />

tuple and ............................................... 842<br />

T tuple and ............................................. 842<br />

tuple not ............................................... 843<br />

T tuple not .............................................. 843<br />

tuple or ................................................ 843<br />

T tuple or .............................................. 843<br />

tuple xor ............................................... 844<br />

T tuple xor .............................................. 844<br />

13.9 Selection............................................... 844<br />

tuple first n ............................................. 844<br />

T tuple first n ............................................ 844<br />

tuple last n .............................................. 845<br />

T tuple last n ............................................ 845<br />

tuple select .............................................. 845<br />

T tuple select ............................................ 845<br />

tuple select range .......................................... 846<br />

T tuple select range ......................................... 846<br />

tuple str bit select .......................................... 847<br />

T tuple str bit select ......................................... 847<br />

13.10String-Operators........................................... 847<br />

tuple environment .......................................... 847<br />

T tuple environment ......................................... 847<br />

tuple split .............................................. 848<br />

T tuple split ............................................. 848<br />

tuple str first n ............................................ 848<br />

T tuple str first n .......................................... 848<br />

tuple str last n ............................................ 849<br />

T tuple str last n ........................................... 849<br />

tuple strchr .............................................. 849<br />

T tuple strchr ............................................ 849<br />

tuple strlen .............................................. 850<br />

T tuple strlen ............................................ 850<br />

tuple strrchr ............................................. 850<br />

T tuple strrchr ............................................ 850<br />

tuple strrstr .............................................. 851<br />

T tuple strrstr ............................................ 851<br />

tuple strstr .............................................. 852<br />

T tuple strstr ............................................. 852<br />

14 XLD 853<br />

14.1 Access . ............................................... 853<br />

T get contour xld .......................................... 853<br />

T get lines xld ............................................ 853<br />

T get parallels xld .......................................... 854<br />

T get polygon xld .......................................... 855<br />

14.2 Creation ............................................... 855<br />

T gen contour polygon xld ..................................... 855<br />

gen contour region xld ....................................... 856<br />

gen contours skeleton xld ...................................... 857<br />

gen ellipse contour xld ....................................... 858<br />

T gen ellipse contour xld ...................................... 858<br />

gen parallels xld ........................................... 859<br />

<strong>HALCON</strong> 6.0


xxii<br />

Contents<br />

gen polygons xld .......................................... 860<br />

mod parallels xld .......................................... 861<br />

14.3 Features ............................................... 862<br />

area center xld ............................................ 862<br />

T area center xld .......................................... 862<br />

contour point num xld ....................................... 863<br />

dist ellipse contour xld ....................................... 863<br />

T dist ellipse contour xld ...................................... 863<br />

fit circle contour xld ........................................ 865<br />

T fit circle contour xld ....................................... 865<br />

fit ellipse contour xld ........................................ 867<br />

T fit ellipse contour xld ....................................... 867<br />

fit line contour xld ......................................... 869<br />

T fit line contour xld ........................................ 869<br />

T get contour angle xld ....................................... 871<br />

T get contour attrib xld ....................................... 872<br />

T get contour global attrib xld ................................... 872<br />

T get regress params xld ...................................... 873<br />

info parallels xld .......................................... 874<br />

length xld .............................................. 875<br />

T length xld ............................................. 875<br />

local max contours xld ....................................... 875<br />

max parallels xld .......................................... 876<br />

moments any xld .......................................... 877<br />

T moments any xld ......................................... 877<br />

moments xld ............................................. 878<br />

T moments xld ........................................... 878<br />

T query contour attribs xld ..................................... 879<br />

T query contour global attribs xld ................................. 879<br />

select contours xld ......................................... 880<br />

14.4 Transformation............................................ 881<br />

add noise white contour xld .................................... 881<br />

T affine trans contour xld ...................................... 882<br />

T affine trans polygon xld ..................................... 883<br />

clip contours xld ........................................... 883<br />

combine roads xld .......................................... 884<br />

gen parallel contour xld ....................................... 885<br />

merge cont line scan xld ...................................... 886<br />

regress contours xld ......................................... 887<br />

segment contours xld ........................................ 888<br />

smooth contours xld ......................................... 890<br />

split contours xld .......................................... 890<br />

T union straight contours histo xld ................................. 891<br />

union straight contours xld ..................................... 892<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Chapter 1<br />

Classification<br />

clear sampset ( long SampKey )<br />

Free memory of a data set.<br />

clear sampset frees the memory which was used for training data set having read by read sampset. This<br />

memory is only reusable in combination with read sampset.<br />

Parameter<br />

º SampKey (input control) ..........................................................featureset long<br />

Number of the data set.<br />

Result<br />

clear sampset returns H MSG TRUE. An exception handling is raised if the key SampKey does not exist.<br />

Parallelization Information<br />

clear sampset is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

create class box, T enquire class box, T learn class box, write class box<br />

See Also<br />

test sampset box, learn sampset box, read sampset<br />

Tools<br />

Module<br />

close all class box ( )<br />

Destroy all classificators.<br />

close all class box deletes all classificators and frees the used memory space. All the trained data will be<br />

lost.<br />

Attention<br />

Since all classificators are closed by close all class box all handles become invalid.<br />

Result<br />

If it is possible to close the classificators the operator close all class box returns the value H MSG TRUE.<br />

Otherwise an exception handling is raised.<br />

Parallelization Information<br />

close all class box is local and processed completely exclusively without parallelization.<br />

close class box<br />

Tools<br />

Alternatives<br />

Module<br />

1


2 CHAPTER 1. CLASSIFICATION<br />

close class box ( long ClassifHandle )<br />

Destroy the classificator.<br />

close class box deletes the classificator and frees the used memory space. All the trained data will be lost.<br />

For saving this trained data you should use write class box before.<br />

Parameter<br />

º ClassifHandle (input control) ...................................................class box long<br />

Classificator’s handle number.<br />

Result<br />

close class box returns H MSG TRUE.<br />

Parallelization Information<br />

close class box is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

create class box, T enquire class box, T learn class box, write class box<br />

See Also<br />

create class box, T enquire class box, T learn class box<br />

Tools<br />

Module<br />

create class box ( long *ClassifHandle )<br />

Create a new classificator.<br />

create class box creates a new adaptive classificator. All procedures which are explained in chapter classification<br />

refer to such a initialized classificator (of type 2). See T learn class box for more details about the<br />

functionality of the classificator.<br />

Parameter<br />

º ClassifHandle (output control) ................................................class box long *<br />

Classificator’s handle number.<br />

Result<br />

create class box returns H MSG TRUE if the parameter is correct. An exception handling is raised if a<br />

classificator with this name already exists or there is not enough memory.<br />

Parallelization Information<br />

create class box is local and processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

T learn class box, T enquire class box, write class box, close class box,<br />

clear sampset<br />

See Also<br />

T learn class box, T enquire class box, close class box<br />

Tools<br />

Module<br />

descript class box ( long ClassifHandle, long Dimensions )<br />

Description of the classificator.<br />

A classificator uses a set of hyper cuboids for every class. With these hyper cuboids it is attempted to get the array<br />

attributes inside the class. descript class box returns for every class the expansion of every appropriate<br />

cuboid from dimension 1 up to Dimensions (to ’standard output’).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3<br />

Parameter<br />

º ClassifHandle (input control) ...................................................class box long<br />

Classificator’s handle number.<br />

º Dimensions (input control) .........................................................integer long<br />

Highest dimension for output.<br />

Default Value : 3<br />

descript class box returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

descript class box is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

create class box, T learn class box, set class box param<br />

Possible Successor Functions<br />

T enquire class box, T learn class box, write class box, close class box<br />

See Also<br />

create class box, T enquire class box, T learn class box, read class box,<br />

write class box<br />

Module<br />

Tools<br />

T enquire class box ( Htuple ClassifHandle, Htuple FeatureList,<br />

Htuple *Class )<br />

Classify a tuple of attributes.<br />

FeatureList is a tuple of any floating point- or integer numbers (attributes) which has to be assigned to a class<br />

with assistance of a previous trained (T learn class box) classificator. It is possible to specify attributes as<br />

unknown by indicating the symbol ’£’ instead of a number. If you specify n values, then all following values, i.e.<br />

the attributes n+1 until ’max’, are automatically supposed to be undefined.<br />

See T learn class box for more details about the functionality of the classificator.<br />

You may call the procedures T learn class box and T enquire class box alternately, so that it is possible<br />

to classify already in the phase of learning. This means you could see when a satisfying behavior had been<br />

reached.<br />

Parameter<br />

º ClassifHandle (input control) ...........................................class box Htuple . long<br />

Classificator’s handle number.<br />

º FeatureList (input control) ........................real-array Htuple . double / long / const char *<br />

Array of attributes which has to be classified.<br />

Default Value : 1.0<br />

º Class (output control) .....................................................integer Htuple . long *<br />

Number of the class to which the array of attributes had been assigned.<br />

T enquire class box returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

T enquire class box is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

create class box, T learn class box, set class box param<br />

Possible Successor Functions<br />

T learn class box, write class box, close class box<br />

T enquire reject class box<br />

Alternatives<br />

<strong>HALCON</strong> 6.0


4 CHAPTER 1. CLASSIFICATION<br />

See Also<br />

test sampset box, T learn class box, learn sampset box<br />

Tools<br />

Module<br />

T enquire reject class box ( Htuple ClassifHandle, Htuple FeatureList,<br />

Htuple *Class )<br />

Classify a tuple of attributes with rejection class.<br />

FeatureList is a tuple of any floating point- or integer numbers (attributes) which has to be assigned to a class<br />

with assistance of a previous trained (T learn class box) classificator. It is possible to specify attributes as<br />

unknown by indicating the symbol ’£’ instead of a number. If you specify n values, then all following values, i.e.<br />

the attributes n+1 until ’max’, are automatically supposed to be undefined.<br />

If the array of attributes cannot be assigned to a class, i.e. the array does not reside inside of one of the hyper<br />

boxes, then in contrary to T enquire class box not the next class is going to be returned, but the rejection<br />

class -1 as a result is going to be passed.<br />

See T learn class box for more details about the functionality of the classificator.<br />

You may call the procedures T learn class box and T enquire class box alternately, so that it is possible<br />

to classify already in the phase of learning. By this means you could see when a satisfying behavior had been<br />

reached.<br />

Parameter<br />

º ClassifHandle (input control) ...........................................class box Htuple . long<br />

Classificator’s handle number.<br />

º FeatureList (input control) ........................real-array Htuple . double / long / const char *<br />

Array of attributes which has to be classfied.<br />

Default Value : 1.0<br />

º Class (output control) .....................................................integer Htuple . long *<br />

Number of the class, to which the array of attributes had been assigned or -1 for the rejection class.<br />

Result<br />

T enquire reject class box returns H MSG TRUE.<br />

Parallelization Information<br />

T enquire reject class box is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

create class box, T learn class box, set class box param<br />

Possible Successor Functions<br />

T learn class box, write class box, close class box<br />

T enquire class box<br />

Alternatives<br />

See Also<br />

test sampset box, T learn class box, learn sampset box<br />

Tools<br />

Module<br />

get class box param ( long ClassifHandle, const char *Flag,<br />

double *Value )<br />

Get information about the current parameter.<br />

get class box param gets the parameter of the classificator. The meaning of the parameter is explained in<br />

set class box param.<br />

Default values:<br />

’min samples for split’ = 80,<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5<br />

’split error’ = 0.1,<br />

’prop constant’ = 0.25<br />

Parameter<br />

º ClassifHandle (input control) ...................................................class box long<br />

Classificator’s handle number.<br />

º Flag (input control) ............................................................string const char *<br />

Name of the system parameter.<br />

Default Value : ’split error’<br />

Value List : Flag ¾’split error’, ’prop constant’, ’used memory’, ’min samples for split’<br />

º Value (output control) ...................................................number double * / long *<br />

Value of the system parameter.<br />

Result<br />

get class box param returns H MSG TRUE. An exception handling is raised if Flag has been set with<br />

wrong values.<br />

Parallelization Information<br />

get class box param is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

create class box, T enquire class box, T learn class box, write class box<br />

Possible Successor Functions<br />

set class box param, T learn class box, T enquire class box, write class box,<br />

close class box, clear sampset<br />

create class box, set class box param<br />

Tools<br />

See Also<br />

Module<br />

T learn class box ( Htuple ClassifHandle, Htuple Features,<br />

Htuple Class )<br />

Train the classificator.<br />

Features is a tuple of any floating point numbers or integers (attributes) which has to be assigned to the class<br />

Class. This class is specified by an integer. You may use procedure T enquire class box later to find the<br />

most probable class for any array (=tupel). The algorithm tries to describe the set of arrays of one class by hyper<br />

cuboids in the feature space. On demand you may even create several cuboids per class. Hence it is possible to<br />

learn disjunct concepts, too. I.e such concepts which split in several ”‘cluster”’ of points in the feature space. The<br />

data structure is hidden to the user and only accessible with such procedures which are described in this chapter.<br />

It is possible to specify attributes as unknown by indicating the symbol ’£’ instead of a number. If you specify n<br />

values, then all following values, i.e. the attributes n+1 until ’max’, are automatically supposed to be undefined.<br />

You may call the procedures T learn class box and T enquire class box alternately, so that it is possible<br />

to classify already in the phase of learning. By this means you could see when a satisfying behavior had been<br />

reached.<br />

The classificator is going to be bigger using further training. This means, that it is not advisable to continue training<br />

after reaching a satisfactory behavior.<br />

Parameter<br />

º ClassifHandle (input control) ...........................................class box Htuple . long<br />

Classificator’s handle number.<br />

º Features (input control) .........................number-array Htuple . double / long / const char *<br />

Array of attributes to learn.<br />

Default Value : ’[1.0,1.5,2.0]’<br />

º Class (input control) ........................................................integer Htuple . long<br />

Class to which the array has to be assigned.<br />

Default Value : 1<br />

<strong>HALCON</strong> 6.0


6 CHAPTER 1. CLASSIFICATION<br />

Result<br />

T learn class box returns H MSG TRUE for a normal case. An exception handling is raised if there are<br />

memory allocation problems. The number of classes is constrained. If this limit is passed, an exception handling<br />

is raised, too.<br />

Parallelization Information<br />

T learn class box is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

create class box, T enquire class box<br />

Possible Successor Functions<br />

test sampset box, T learn class box, T enquire class box, write class box,<br />

close class box, clear sampset<br />

See Also<br />

test sampset box, close class box, create class box, T enquire class box,<br />

learn sampset box<br />

Module<br />

Tools<br />

learn sampset box ( long ClassifHandle, long SampKey,<br />

const char *Outfile, long NSamples, double StopError, long ErrorN )<br />

Train the classificator with one data set.<br />

learn sampset box trains the classificator with data for the key SampKey (see read sampset). The training<br />

sequence is terminated at least after NSamples examples. If NSamples is bigger than the number of examples<br />

in SampKey, then a cyclic start at the beginning occurs. If the error underpasses the value StopError,<br />

then the training sequence is prematurely terminated. StopError is calculated with N / ErrorN. Whereby N<br />

significates the number of examples which were wrong classified during the last ErrorN training examples. Typically<br />

ErrorN is the number of examples in SampKey and NSamples is a multiple of it. If you want a data set<br />

with 100 examples to run 5 times at most and if you want it to terminate with an error lower than 5%, then the<br />

corresponding values are NSamples = 500, ErrorN = 100 and StopError = 0.05. A protocol of the training<br />

activity is going to be written in file Outfile.<br />

Parameter<br />

º ClassifHandle (input control) ...................................................class box long<br />

Classificator’s handle number.<br />

º SampKey (input control) ..........................................................featureset long<br />

Number of the data set to train.<br />

º Outfile (input control) .....................................................filename const char *<br />

Name of the protocol file.<br />

Default Value : ’training prot’<br />

º NSamples (input control) ............................................................integer long<br />

Number of arrays of attributes to learn.<br />

Default Value : 500<br />

º StopError (input control) ...........................................................real double<br />

Classification error for termination.<br />

Default Value : 0.05<br />

º ErrorN (input control) ...............................................................integer long<br />

Error during the assignment.<br />

Default Value : 100<br />

Result<br />

learn sampset box returns H MSG TRUE. An exception handling is raised if key SampKey does not exist<br />

or there are problems while opening the file.<br />

Parallelization Information<br />

learn sampset box is local and processed completely exclusively without parallelization.<br />

create class box<br />

Possible Predecessor Functions<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7<br />

Possible Successor Functions<br />

test sampset box, T enquire class box, write class box, close class box,<br />

clear sampset<br />

See Also<br />

test sampset box, T enquire class box, T learn class box, read sampset<br />

Tools<br />

Module<br />

read class box ( long ClassifHandle, const char *FileName )<br />

Read the classificator from a file.<br />

read class box reads the saved classificator from the file FileName (see write class box). The values<br />

of the current classificator are overwritten.<br />

Attention<br />

All values of the classificator are going to be overwritten.<br />

Parameter<br />

º ClassifHandle (input control) ...................................................class box long<br />

Classificator’s handle number.<br />

º FileName (input control) ...................................................filename const char *<br />

Filename of the classificators.<br />

Default Value : ’klassifikator1’<br />

Result<br />

read class box returns H MSG TRUE. An exception handling is raised if it was not possible to open file<br />

FileName or the file has the wrong format.<br />

Parallelization Information<br />

read class box is local and processed completely exclusively without parallelization.<br />

create class box<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

test sampset box, T enquire class box, write class box, close class box,<br />

clear sampset<br />

See Also<br />

create class box, write class box<br />

Tools<br />

Module<br />

read sampset ( const char *FileName, long *SampKey )<br />

Read a training data set from a file.<br />

The training examples are accessible with the key SampKey by calling procedures clear sampset and<br />

learn sampset box. You may edit the file using an editor. Every row contains an array of attributes with<br />

corresponding class. An example for a format might be:<br />

(1.0, 25.3, *, 17 | 3)<br />

This row specifies an array of attributes which belong to class 3. In this array the third attribute is unknown.<br />

Attributes upwards 5 are supposed to be unknown, too. You may insert comments like /* .. */ in any place.<br />

Parameter<br />

º FileName (input control) ...................................................filename const char *<br />

Filename of the data set to train.<br />

Default Value : ’sampset1’<br />

<strong>HALCON</strong> 6.0


8 CHAPTER 1. CLASSIFICATION<br />

º SampKey (output control) .......................................................featureset long *<br />

Identification of the data set to train.<br />

Result<br />

read sampset returns H MSG TRUE. An exception handling is raised if it is not possible to open the file or it<br />

contains syntax errors or there is not enough memory.<br />

Parallelization Information<br />

read sampset is local and processed completely exclusively without parallelization.<br />

create class box<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

test sampset box, T enquire class box, write class box, close class box,<br />

clear sampset<br />

See Also<br />

test sampset box, clear sampset, learn sampset box<br />

Tools<br />

Module<br />

set class box param ( long ClassifHandle, const char *Flag,<br />

double Value )<br />

Set system parameters for classification.<br />

set class box param modifies parameter which manipulate the training sequence while calling<br />

T learn class box. Only parameters of the classificator are modified, all other classificators remain unmodified.<br />

’min samples for split’ is the number of examples at least which have to train in one cuboid of this<br />

classificator, before the cuboid is allowed to divide itself. ’split error’ indicates the critical error. By its exceeding<br />

the cuboid divides itself, if there are more than ’min samples for split’ examples to train. ’prop constant’ manipulates<br />

the extension of the cuboids. It is proportional to the average distance of the training examples in this cuboid<br />

to the center of the cuboid. More detailed:<br />

extension ¢ prop = average distance of the expectation value.<br />

This relation is valid in every dimension. Hence inside a cuboid the dimensions of the feature space are supposed<br />

to be independent.<br />

The parameters are set with problem independent default values, which must not modified without any reason.<br />

Parameters are only important during a learning sequence. They do not influence on the behavior of<br />

T enquire class box.<br />

Default setting:<br />

’min samples for split’ = 80,<br />

’split error’ = 0.1,<br />

’prop constant’ = 0.25<br />

Parameter<br />

º ClassifHandle (input control) ...................................................class box long<br />

Classificator’s handle number.<br />

º Flag (input control) ............................................................string const char *<br />

Name of the wanted parameter.<br />

Default Value : ’split error’<br />

Value Suggestions : Flag ¾’min samples for split’, ’split error’, ’prop constant’<br />

º Value (input control) .......................................................number double / long<br />

Value of the parameter.<br />

Default Value : 0.1<br />

read sampset returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

set class box param is local and processed completely exclusively without parallelization.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9<br />

Possible Predecessor Functions<br />

create class box, T enquire class box<br />

Possible Successor Functions<br />

T learn class box, test sampset box, write class box, close class box, clear sampset<br />

See Also<br />

T enquire class box, get class box param, T learn class box<br />

Tools<br />

Module<br />

test sampset box ( long ClassifHandle, long SampKey, double *Error )<br />

Classify a set of arrays.<br />

In contrast to learn sampset box there is not a learning here. Typically you use test sampset box to<br />

classify independent test data. Error gives you information about the applicability of the learned training set on<br />

new examples.<br />

Parameter<br />

º ClassifHandle (input control) ...................................................class box long<br />

Classificator’s handle number.<br />

º SampKey (input control) ..........................................................featureset long<br />

Key of the test data.<br />

º Error (output control) ..............................................................real double *<br />

Error during the assignment.<br />

Result<br />

test sampset box returns H MSG TRUE. An exception handling is raised, if if key SampKey does not exist<br />

or problems occur while opening the file.<br />

Parallelization Information<br />

test sampset box is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

create class box, T learn class box, set class box param<br />

Possible Successor Functions<br />

T enquire class box, T learn class box, write class box, close class box,<br />

clear sampset<br />

See Also<br />

T enquire class box, T learn class box, learn sampset box, read sampset<br />

Tools<br />

Module<br />

write class box ( long ClassifHandle, const char *FileName )<br />

Save the classificator in a file.<br />

write class box saves the classificator in a file. You may read the data by calling read class box.<br />

Attention<br />

If a file with this name exists, it is overwritten without a warning. The file can not be edited.<br />

Parameter<br />

º ClassifHandle (input control) ...................................................class box long<br />

Classificator’s handle number.<br />

º FileName (input control) ...................................................filename const char *<br />

Name of the file which contains the written data.<br />

Default Value : ’klassifikator1’<br />

<strong>HALCON</strong> 6.0


10 CHAPTER 1. CLASSIFICATION<br />

Result<br />

write class box returns H MSG TRUE. An exception handling is raised if it was not possible to open file<br />

FileName.<br />

Parallelization Information<br />

write class box is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

create class box, T enquire class box, T learn class box, test sampset box,<br />

write class box<br />

Possible Successor Functions<br />

close class box, clear sampset<br />

create class box, read class box<br />

Tools<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Chapter 2<br />

File<br />

2.1 Images<br />

read image ( Hobject *Image, const char *FileName )<br />

T read image ( Hobject *Image, Htuple FileName )<br />

Read an image with different file formats.<br />

The operator (T )read image reads the indicated image files from the background storage and generates the<br />

image. One or more files can be indicated. The region of the generated image object (= all pixels of the matrix) is<br />

maximal chosen.<br />

All images files written by the operator (T )write image (format ’ima’) have the extension ’.ima’. A description<br />

file can be available for every image in <strong>HALCON</strong> format (same file name with extension ’.exp’). The type of<br />

the pixel data (byte, int4, real) can also be taken from the description file. If this information is not available the<br />

type byte is used as presetting.<br />

Besides the <strong>HALCON</strong> format TIFF, GIF, BMP, JPEG, PCX, SUN-Raster, PGM, PPM, PBM and XWD files can<br />

also be read. The gray values of PBM images are set at the values 0 and 255. The file formats are either recognized<br />

by the extension (if indicated) or because of the internal structure of the files. If the extension is indicated the image<br />

can be found faster. In case of PGM, PPM and PBM the corresponding extension (e.g. ’pgm’) or the general value<br />

’pnm’ can be used. In case of TIFF ’tiff’ and ’tif’ are accepted. In case of colored images an image with three<br />

color channels (matrices) is created, the red channel being stored in the first, the blue channel in the second and<br />

the green channel in the third component (channel number).<br />

Image files are searched in the current directory (determined by the environment variable) and in the image directory<br />

of <strong>HALCON</strong> . The image directory of <strong>HALCON</strong> is preset at ’.’ and ’/usr/local/halcon/images’ in a UNIX<br />

environment and can be set via the operator set system. More than one image directory can be indicated. This<br />

is done by separating the individual directories by a colon.<br />

Furthermore the search path can be set via the environment variable <strong>HALCON</strong>IMAGES (same structure as ’image<br />

dir’). Example:<br />

setenv <strong>HALCON</strong>IMAGES "/usr/images:/usr/local/halcon/images"\\*<br />

<strong>HALCON</strong> also searches images in the subdirectory ”‘images”’ (Images for the program examples). The environment<br />

variable <strong>HALCON</strong>ROOT is used for the <strong>HALCON</strong> directory.<br />

Parameter<br />

º Image (output object) ...........................................image Hobject * : byte / int4 / real<br />

º FileName (input control) ...................................filename(-array) (Htuple .) const char *<br />

Default Value : ’fabrik’<br />

Value Suggestions : FileName ¾’monkey’, ’fabrik’, ’mreut’<br />

11


12 CHAPTER 2. FILE<br />

Example<br />

/* Reading an image: */<br />

read_image(&Image,"mreut") ;<br />

/* Reading 3 images into an image object: */<br />

Htuple Files ;<br />

create_tuple(&Files,3) ;<br />

set_s(Files,"house_red",0) ;<br />

set_s(Files,"house_green",1) ;<br />

set_s(Files,"house_blue",2) ;<br />

T_read_image(&Bildobjekt,Files) ;<br />

/* Setting of search path for images on ’/mnt/images’ and ’/home/images’:<br />

*/<br />

set_system("image_dir","/mnt/images:/home/images") ;<br />

Result<br />

If the parameters are correct the operator (T )read image returns the value H MSG TRUE. If the indicated<br />

files cannot be found (T )read image returns the value H MSG FAIL. Otherwise an exception handling is<br />

raised.<br />

Parallelization Information<br />

(T )read image is processed under mutual exclusion against itself and without parallelization.<br />

Possible Successor Functions<br />

disp image, threshold, regiongrowing, count channels, decompose3, class ndim norm,<br />

gauss image, fill interlace, zoom image size, zoom image factor, crop part,<br />

(T )write image, rgb1 to gray<br />

read sequence<br />

set system, (T )write image<br />

Image / region / XLD management<br />

Alternatives<br />

See Also<br />

Module<br />

read sequence ( Hobject *Image, long HeaderSize, long SourceWidth,<br />

long SourceHeight, long StartRow, long StartColumn, long DestWidth,<br />

long DestHeight, const char *PixelType, const char *BitOrder,<br />

const char *ByteOrder, const char *Pad, long Index, const char *FileName )<br />

Read images.<br />

The operator read sequence reads unformatted image data, from a file and returns a “suitable” image. The<br />

image data must be filled consecutively pixel by pixel and line by line.<br />

Any file headers (with the length HeaderSize bytes) are skipped. The parameters SourceWidth and<br />

SourceHeight indicate the size of the filled image. DestWidth and DestHeight indicate the size of the<br />

image. In the simplest case these parameters are the same. However, areas can also be read. The upper left corner<br />

of the required image area can be determined via StartRow and StartColumn.<br />

The pixel types ’bit’, ’byte’, ’short’ (16 bits, unsigned), ’signed short’ (16 bits, signed), ’long’ (32 bits, signed)<br />

and ’swapped long’ (32 bits, with swapped segments) are supported. Furthermore the operator read sequence<br />

enables the extraction of components of a RBG image, if a triple of three bytes (in the sequence “red”, “green”,<br />

“blue”) was filed in the image file. For the red component the pixel type ’r byte’ must be chosen, and correspondingly<br />

for the green and blue components ’g byte’ or ’b byte’, respectively.<br />

’MSBFirst’ (most significant bit first) or the inversion thereof (’LSBFirst’) can be chosen for the bit order<br />

(BitOrder). The byte orders (ByteOrder) ’MSBFirst’ (most significant byte first) or ’LSBFirst’, respectively,<br />

are processed analogously. Finally an alignment (Pad) can be set at the end of the line: ’byte’, ’short’ or<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


2.1. IMAGES 13<br />

’long’. If a whole image sequence is stored in the file a single image (beginning at Index 1) can be chosen via the<br />

parameter Index.<br />

Image files are searched in the current directory (determined by the operating system environment) and in the image<br />

directory of <strong>HALCON</strong> . The image directory of <strong>HALCON</strong> is preset as ’/bilder’ and ’/usr/local/halcon/images’ in a<br />

UNIX environment and can be set via the operator set system. More than one image directory can be indicated<br />

by separating the individual directories by blanks.<br />

Furthermore the search path can be set via the environment variable <strong>HALCON</strong>IMAGES (same structure as in<br />

’image dir’). Example:<br />

setenv <strong>HALCON</strong>IMAGES ”/usr/images:/usr/local/halcon/images”<br />

<strong>HALCON</strong> also searches the image in the sub-directory “images” (images for program examples). The environment<br />

variable <strong>HALCON</strong>ROOT is used for the <strong>HALCON</strong> directory.<br />

Parameter<br />

º Image (output object) ............................................................image Hobject *<br />

Image read.<br />

º HeaderSize (input control) .........................................................integer long<br />

Number of bytes for file header.<br />

Default Value : 0<br />

Typical Range of Values : 0 HeaderSize<br />

º SourceWidth (input control) .......................................................extent.x long<br />

Number of image columns of the filed image.<br />

Default Value : 512<br />

Typical Range of Values : 1 SourceWidth<br />

º SourceHeight (input control) ......................................................extent.y long<br />

Number of image lines of the filed image.<br />

Default Value : 512<br />

Typical Range of Values : 1 SourceHeight<br />

º StartRow (input control) ............................................................point.y long<br />

Starting point of image area (line).<br />

Default Value : 0<br />

Typical Range of Values : 0 StartRow<br />

Restriction : StartRow SourceHeight<br />

º StartColumn (input control) ........................................................point.x long<br />

Starting point of image area (column).<br />

Default Value : 0<br />

Typical Range of Values : 0 StartColumn<br />

Restriction : StartColumn SourceWidth<br />

º DestWidth (input control) ..........................................................extent.x long<br />

Number of image columns of output image.<br />

Default Value : 512<br />

Typical Range of Values : 1 DestWidth<br />

Restriction : DestWidth SourceWidth<br />

º DestHeight (input control) ........................................................extent.y long<br />

Number of image lines of output image.<br />

Default Value : 512<br />

Typical Range of Values : 1 DestHeight<br />

Restriction : DestHeight SourceHeight<br />

º PixelType (input control) .....................................................string const char *<br />

Type of pixel values.<br />

Default Value : ’byte’<br />

Value List : PixelType ¾’bit’, ’byte’, ’r byte’, ’g byte’, ’b byte’, ’short’, ’signed short’, ’long’,<br />

’swapped long’<br />

º BitOrder (input control) ......................................................string const char *<br />

Sequence of bits within one byte.<br />

Default Value : ’MSBFirst’<br />

Value List : BitOrder ¾’MSBFirst’, ’LSBFirst’<br />

<strong>HALCON</strong> 6.0


14 CHAPTER 2. FILE<br />

º ByteOrder (input control) .....................................................string const char *<br />

Sequence of bytes within one ’short’ unit.<br />

Default Value : ’MSBFirst’<br />

Value List : ByteOrder ¾’MSBFirst’, ’LSBFirst’<br />

º Pad (input control) .............................................................string const char *<br />

Data units within one image line (alignment).<br />

Default Value : ’byte’<br />

Value List : Pad ¾’byte’, ’short’, ’long’<br />

º Index (input control) ................................................................integer long<br />

Number of images in the file.<br />

Default Value : 1<br />

Typical Range of Values : 1 Index (lin)<br />

º FileName (input control) ...................................................filename const char *<br />

Name of input file.<br />

Result<br />

If the parameter values are correct the operator read sequence returns the value H MSG TRUE. If the file<br />

cannot be opened H MSG FAIL is returned. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

read sequence is processed under mutual exclusion against itself and without parallelization.<br />

Possible Successor Functions<br />

disp image, count channels, decompose3, (T )write image, rgb1 to gray<br />

(T )read image<br />

(T )read image<br />

Image / region / XLD management<br />

Alternatives<br />

See Also<br />

Module<br />

write image ( Hobject Image, const char *Format, long FillColor,<br />

const char *FileName )<br />

T write image ( Hobject Image, Htuple Format, Htuple FillColor,<br />

Htuple FileName )<br />

Write images in graphic formats.<br />

The operator (T )write image returns the indicated image (Image) in different image formats in files. Pixels<br />

outside the region receive the color defined by FillColor. For gray value images a value between 0 (black)<br />

and 255 (white) must be passed, with RGB color images the RGB values can be passed directly as a hexadecimal<br />

value: e.g., 0xffff00 for a yellow background (red=255, green=255, blue=0).<br />

The following formats are currently supported:<br />

’tiff’ TIFF format, 3-channel-images (RGB): 3 samples per pixel; other images (grayvalue images): 1 sample per<br />

pixel, 8 bits per sample, uncompressed,72 dpi; file extension: *.tiff<br />

’bmp’ Windows-BMP format, 3-channel-images (RGB): 3 bytes per pixel; other images (gray value image): 1<br />

byte per pixel; file extension: *.bmp<br />

’jpeg’ JPEG format, with lost of information; together with the format string the quality value determining the<br />

compression rate can be provided: e.g., ’jpeg 30’. Attention: images stored for being processed later should<br />

not be compressed with the jpeg format according to the lost of information.<br />

’ima’ The data is written binary line by line (without header or carriage return). The size of the image and the<br />

pixel type are stored in the description file ”’FileName.exp”’. byte, int4 and real images can be written.<br />

The file extension is: ’.ima’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


2.2. MISC 15<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Output image(s).<br />

º Format (input control) ...............................................string (Htuple .) const char *<br />

Graphic format.<br />

Default Value : ’tiff’<br />

Value List : Format ¾’tiff’, ’bmp’, ’jpeg’, ’ima’, ”jpeg 100”, ”jpeg 80”, ”jpeg 60”, ”jpeg 40”, ”jpeg 20”<br />

º FillColor (input control) .................................................integer (Htuple .) long<br />

Fill gray value for pixels not belonging to the image region.<br />

Default Value : 0<br />

Value Suggestions : FillColor ¾-1, 0, 255, ’0xff0000’, ’0xff00’<br />

º FileName (input control) ...................................filename(-array) (Htuple .) const char *<br />

Name of graphic file.<br />

Result<br />

If the parameter values are correct the operator (T )write image returns the value H MSG TRUE. Otherwise<br />

an exception handling is raised. If the file cannot be opened (T )write image returns H MSG FAIL.<br />

Parallelization Information<br />

(T )write image is processed under mutual exclusion against itself and without parallelization.<br />

open window, (T )read image<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

Module<br />

2.2 Misc<br />

file exists ( const char *FileName )<br />

Check whether file exists.<br />

The operator file exists checks whether the indicated file already exists. If this is the case, the operator<br />

file exists returns TRUE, otherwise FALSE.<br />

Parameter<br />

º FileName (input control) ...................................................filename const char *<br />

Name of file to be checked.<br />

Default Value : ’/bin/cc’<br />

Result<br />

The operator file exists returns the value H MSG TRUE (file exists) or H MSG FALSE (file does not exist).<br />

Parallelization Information<br />

file exists is reentrant and processed without parallelization.<br />

open file<br />

open file<br />

Basic operators<br />

Possible Successor Functions<br />

Alternatives<br />

Module<br />

T read world file ( Htuple FileName, Htuple *WorldTransformation )<br />

Read the geo coding from an ARC/INFO world file.<br />

<strong>HALCON</strong> 6.0


16 CHAPTER 2. FILE<br />

T read world file reads a geocoding from an ARC/INFO world file with the file name FileName<br />

and returns it as a homogeneous 2D transformation matrix in WorldTransformation. To find the file<br />

FileName, all directories contained in the <strong>HALCON</strong> system variable ’image dir’ (usually this is the content<br />

of the environment variable <strong>HALCON</strong>IMAGES) are searched (see (T )read image). This transformation<br />

matrix can be used to transform XLD contours to the world coordinate system before writing<br />

them with write contour xld arc info. If the matrix WorldTransformation is inverted by calling<br />

hom mat2d invert, the resulting matrix can be used to transform contours that have been read with<br />

read contour xld arc info to the image coordinate system.<br />

Parameter<br />

º FileName (input control) ...........................................filename Htuple . const char *<br />

Name of the ARC/INFO world file.<br />

º WorldTransformation (output control) .........................affine2d-array Htuple . double *<br />

Transformation matrix from image to world coordinates.<br />

Parameter Number : 6<br />

Result<br />

If the parameters are correct and the world file could be read, the operator T read world file returns the value<br />

H MSG TRUE. Otherwise an exception is raised.<br />

Parallelization Information<br />

T read world file is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

hom mat2d invert, affine trans contour xld, affine trans polygon xld<br />

See Also<br />

write contour xld arc info, read contour xld arc info, write polygon xld arc info,<br />

read polygon xld arc info<br />

Module<br />

Sub-pixel operators<br />

2.3 Region<br />

read region ( Hobject *Region, const char *FileName )<br />

Read binary images or <strong>HALCON</strong> regions.<br />

The operator read region reads regions from a binary file. The data is stored in packed form.<br />

Tiff: Binary Tiff images with extension ’tiff’ or ’tif’. The result is always ÓÒ region. The color black is used as<br />

foreground.<br />

BMP: Binary Windows bitmap images with extension ’bmp’. The result is always ÓÒ region. The color black is<br />

used as foreground.<br />

<strong>HALCON</strong> regions: File format of <strong>HALCON</strong> for regions. Several images can be stored (in one file) or read<br />

simultaneously via the operators write region and read region. All region files have the extension<br />

’.reg’, which is not indicated when reading or writing the file.<br />

A search path (’image dir’) can be defined analogous to the operator (T )read image.<br />

Parameter<br />

º Region (output object) ...................................................region(-array) Hobject *<br />

º FileName (input control) ...................................................filename const char *<br />

Example<br />

/* Reading of regions and giving them gray values. */<br />

read_image(&Img,"bild_test5") ;<br />

read_region(&Regs,"reg_test5") ;<br />

reduce_domain(Img,Regs,&Res) ;<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


2.4. TEXT 17<br />

Result<br />

If the parameter values are correct the operator read region returns the value H MSG TRUE. If the file cannot<br />

be opened H MSG FAIL is returned. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

read region is reentrant and processed without parallelization.<br />

(T )read image<br />

reduce domain, disp region<br />

write region, (T )read image<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

write region ( Hobject Region, const char *FileName )<br />

Write regions on file.<br />

The operator write region writes the regions of the input images (in runlength coding) to a binary file. The<br />

data is stored in packed form. The output data can be read via the operator read region. The file name is<br />

FileName.reg. The extension is not indicated.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Region of the images which are returned.<br />

º FileName (input control) ...................................................filename const char *<br />

Name of region file without extension.<br />

Default Value : ’/tmp/region’<br />

Example<br />

regiongrowing(Img,&Segmente,3,3,5,10) ;<br />

write_region(Segmente,"result1") ;<br />

Result<br />

If the parameter values are correct the operator write region returns the value H MSG TRUE. If the file cannot<br />

be opened H MSG FAIL is returned. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

write region is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

open window, (T )read image, read region, threshold, regiongrowing<br />

read region<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

2.4 Text<br />

close all files ( )<br />

Close all open files.<br />

close all files closes all open files.<br />

<strong>HALCON</strong> 6.0


18 CHAPTER 2. FILE<br />

Attention<br />

Since all files are closed by close all files all handles become invalid.<br />

Result<br />

If it is possible to close the files the operator close all files returns the value H MSG TRUE. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

close all files is local and processed completely exclusively without parallelization.<br />

close file<br />

Basic operators<br />

Alternatives<br />

Module<br />

close file ( long FileHandle )<br />

Closing a text file.<br />

The operator close file closes a file which was opened via the operator open file.<br />

Parameter<br />

º FileHandle (input control) .............................................................file long<br />

File handle.<br />

Example<br />

open_file("/tmp/data.txt","input",&FileHandle) ;<br />

/* ... */<br />

close_file(FileHandle) ;<br />

Result<br />

If the file handle is correct close file returns the value H MSG TRUE. Otherwise an exception handling is<br />

raised.<br />

Parallelization Information<br />

close file is local and processed completely exclusively without parallelization.<br />

open file<br />

open file<br />

Basic operators<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

fnew line ( long FileHandle )<br />

Create a line feed.<br />

The operator fnew line puts out a line feed into the output file. At the same time the output buffer is cleaned.<br />

Parameter<br />

º FileHandle (input control) .............................................................file long<br />

File handle.<br />

Example<br />

fwrite_string(FileHandle,"Good Morning") ;<br />

fnew_line(FileHandle) ;<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


2.4. TEXT 19<br />

Result<br />

If an output file is open and it can be written to the file the operator fnew line returns the value H MSG TRUE.<br />

Otherwise an exception handling is raised.<br />

Parallelization Information<br />

fnew line is reentrant and processed without parallelization.<br />

(T )fwrite string<br />

(T )fwrite string<br />

Basic operators<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

fread char ( long FileHandle, char *Char )<br />

Read a character from a text file.<br />

The operator fread char reads a character from the current input file. fread char returns the character<br />

sequence ’eof’. At the end of a line the value ’nl’ is returned.<br />

Parameter<br />

º FileHandle (input control) .............................................................file long<br />

File handle.<br />

º Char (output control) ................................................................string char *<br />

Read character or control string (’nl’,’eof’).<br />

Example<br />

do {<br />

fread_char(FileHandle,&Char) ;<br />

if (!strcmp(Char,"nl")) fnew_line(FileHandle) ;<br />

if (!strcmp(Char,"nl")) fwrite_string(FileHandle,Char)) ;<br />

} while(strcmp(Char,"eof")) ;<br />

Result<br />

If an input file is open the operator fread char returns H MSG TRUE. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

fread char is reentrant and processed without parallelization.<br />

open file<br />

close file<br />

fread string, read string<br />

open file, close file, fread string<br />

Basic operators<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

fread string ( long FileHandle, char *OutString, long *IsEOF )<br />

Read strings from a text file.<br />

The operator fread string reads a string from the current input file. A string begins with the first representable<br />

character: letters, numbers, additional characters (except blanks). A string ends when a blank or a line skip is<br />

<strong>HALCON</strong> 6.0


20 CHAPTER 2. FILE<br />

reached. Several successive line skips are ignored. If the end of the file is reached IsEOF return the value 1,<br />

otherwise 0.<br />

Parameter<br />

º FileHandle (input control) .............................................................file long<br />

File handle.<br />

º OutString (output control) .........................................................string char *<br />

Read character sequence.<br />

º IsEOF (output control) .............................................................integer long *<br />

Reached end of file.<br />

Example<br />

fwrite_string(FileHandle,"Please enter text and return: ..") ;<br />

fread_string(FileHandle,&String,&IsEOF) ;<br />

fwrite_string(FileHandle,"here it is again: ") ;<br />

fwrite_string(FileHandle,String) ;<br />

fnew_line(FileHandle) ;<br />

Result<br />

If a file is open and a suitable string is read fread string returns the value H MSG TRUE. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

fread string is reentrant and processed without parallelization.<br />

open file<br />

close file<br />

fread char, read string<br />

open file, close file, fread char<br />

Basic operators<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

fwrite string ( long FileHandle, const char *String )<br />

T fwrite string ( Htuple FileHandle, Htuple String )<br />

Write values in a text file.<br />

The operator (T )fwrite string puts out a string or numbers on the output file. The operator open file<br />

opens a file. The call set system (’flush file’, ) determines whether the output<br />

characters are put out directly on the output medium. If the value ’flush file’ is set to ’false’ the characters<br />

(especially in case of screen output) show up only after the operator fnew line is called.<br />

Strings as well as whole numbers and floating point numbers can be used as arguments. If more than one value<br />

serves as input the values are put out consecutively without blanks.<br />

Parameter<br />

º FileHandle (input control) ...................................................file (Htuple .) long<br />

File handle.<br />

º String (input control) ...........................string(-array) (Htuple .) const char * / long / double<br />

Values to be put out on the text file.<br />

Default Value : ’hallo’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


2.4. TEXT 21<br />

Example<br />

fwrite_string(FileHandle,"text with numbers: ") ;<br />

fwrite_string(FileHandle,"5") ;<br />

fwrite_string(FileHandle," and ") ;<br />

fwrite_string(FileHandle,"1.0") ;<br />

/* results in the following output: */<br />

/* ’text with numbers: 5 and 1.00000’ */<br />

/* Tupel Version */<br />

int i;<br />

double d;<br />

Htuple Tuple ;<br />

create_tuple(&Tuple,4) ;<br />

i = 5 ;<br />

d = 10.0 ;<br />

set_s(Tuple,"text with numbers: ",0) ;<br />

set_i(Tuple,i,1) ;<br />

set_s(Tuple," and ",2) ;<br />

set_d(Tuple,d,3) ;<br />

T_fwrite_string(FileHandle,HilfsTuple) ;<br />

Result<br />

If the writing procedure was carried out successfully the operator (T )fwrite string returns the value<br />

H MSG TRUE. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

(T )fwrite string is reentrant and processed without parallelization.<br />

open file<br />

close file<br />

write string<br />

open file, close file, set system<br />

Basic operators<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

open file ( const char *FileName, const char *FileType,<br />

long *FileHandle )<br />

Open text file.<br />

The operator open file opens a file. FileType determines whether this file is an input (’input’) or output<br />

file (’output’). Text files which can be accessed either by reading (’input’) or by writing (’output’) are created.<br />

For terminal input and output the file names ’standard’ (’input’ and ’output’) and’error’ (only ’output’) are<br />

reserved.<br />

Parameter<br />

º FileName (input control) ...................................................filename const char *<br />

Name of file to be opened.<br />

Default Value : ’standard’<br />

Value Suggestions : FileName ¾’standard’, ’error’, ”/tmp/dat.dat”<br />

<strong>HALCON</strong> 6.0


22 CHAPTER 2. FILE<br />

º FileType (input control) ......................................................string const char *<br />

Type of file.<br />

Default Value : ’output’<br />

Value List : FileType ¾’input’, ’output’<br />

º FileHandle (output control) ..........................................................file long *<br />

File handle.<br />

Example<br />

/* Creating of an outputfile with the name ’/tmp/log.txt’ and writing */<br />

/* of one string: */<br />

open_file("/tmp/log.txt","output",&FileHandle) ;<br />

fwrite_string(FileHandle,"these are the first and last lines") ;<br />

fnew_line(FileHandle) ;<br />

close_file(FileHandle);<br />

Result<br />

If the parameters are correct the operator open file returns the value H MSG TRUE. Otherwise an exception<br />

handling is raised.<br />

Parallelization Information<br />

open file is local and processed completely exclusively without parallelization.<br />

reset obj db<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

(T )fwrite string, fread char, fread string, close file<br />

See Also<br />

close file, (T )fwrite string, fread char, fread string<br />

Basic operators<br />

Module<br />

2.5 Tuple<br />

read tuple ( const char *FileName, double *Tuple )<br />

T read tuple ( Htuple FileName, Htuple *Tuple )<br />

Read a tuple from a file.<br />

The operator (T )read tuple reads the contents of FileName and converts it into Tuple. The file has to be<br />

generated by (T )write tuple.<br />

Parameter<br />

º FileName (input control) ..........................................filename (Htuple .) const char *<br />

Name of the file to be read.<br />

º Tuple (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double * / long * / char *<br />

Tuple with any kind of data.<br />

Result<br />

If the parameters are correct the operator (T )read tuple returns the value H MSG TRUE. If the file could not<br />

be opened (T )read tuple returns H MSG FAIL. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

(T )read tuple is reentrant and processed without parallelization.<br />

(T )fwrite string<br />

Alternatives<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


2.6. XLD 23<br />

See Also<br />

(T )write tuple, gnuplot plot ctrl, (T )write image, write region, open file<br />

Operators not requiring licensing<br />

Module<br />

write tuple ( double Tuple, const char *FileName )<br />

T write tuple ( Htuple Tuple, Htuple FileName )<br />

Writeatupletoafile.<br />

The operator (T )write tuple writes the contents of Tuple to a file. The data is written in an ASCII format.<br />

Therefore, the file can be exchanged between different architectures. There is no specific extension for this kind of<br />

file.<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double / long / const char *<br />

Tuple with any kind of data.<br />

º FileName (input control) ..........................................filename (Htuple .) const char *<br />

Name of the file to be written.<br />

Result<br />

If the parameters are correct the operator (T )write tuple returns the value H MSG TRUE. If the file could<br />

not be opened (T )write tuple returns H MSG FAIL. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

(T )write tuple is reentrant and processed without parallelization.<br />

(T )fwrite string<br />

Alternatives<br />

See Also<br />

(T )read tuple, (T )write image, write region, open file<br />

Operators not requiring licensing<br />

Module<br />

2.6 XLD<br />

read contour xld arc info ( Hobject *Contours, const char *FileName )<br />

Read XLD contours to a file in ARC/INFO generate format.<br />

read contour xld arc info reads the lines stored in ARC/INFO generate format in the file FileName,and<br />

returns them as XLD contours in Contours. To find the file FileName, all directories contained in the HAL-<br />

CON system variable ’image dir’ (usually this is the content of the environment variable <strong>HALCON</strong>IMAGES) are<br />

searched (see (T )read image). The returned contours are in world coordinates. They can be transformed to<br />

the image coordinate system with the operator affine trans contour xld. The necessary transformation<br />

matrix can be generated by using T read world file to read the transformation matrix from image to world<br />

coordinates, and inverting this matrix by calling hom mat2d invert.<br />

Parameter<br />

º Contours (output object) ...............................................xld cont(-array) Hobject *<br />

Read XLD contours.<br />

º FileName (input control) ...................................................filename const char *<br />

Name of the ARC/INFO file.<br />

<strong>HALCON</strong> 6.0


24 CHAPTER 2. FILE<br />

Example<br />

/* Read the transformation and invert it */<br />

read_world_file (’image.tfw’, WorldTransformation)<br />

hom_mat2d_invert (WorldTransformation, ImageTransformation)<br />

/* Read the image */<br />

read_image (Image, ’image.tif’)<br />

/* Read the line data */<br />

read_contour_xld_arc_info (LinesWorld, ’lines.gen’)<br />

/* Transform the line data to image coordinates */<br />

affine_trans_contour_xld (LinesWorld, Lines, ImageTransformation)<br />

Result<br />

If the parameters are correct and the file could be read, the operator read contour xld arc info returns the<br />

value H MSG TRUE. Otherwise an exception is raised.<br />

Parallelization Information<br />

read contour xld arc info is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

hom mat2d invert, affine trans contour xld<br />

See Also<br />

T read world file, write contour xld arc info, read polygon xld arc info<br />

Sub-pixel operators<br />

Module<br />

read polygon xld arc info ( Hobject *Polygons, const char *FileName )<br />

Read XLD polygons from a file in ARC/INFO generate format.<br />

read polygon xld arc info reads the lines stored in ARC/INFO generate format in the file FileName,and<br />

returns them as XLD polygons in Polygons. To find the file FileName, all directories contained in the HAL-<br />

CON system variable ’image dir’ (usually this is the content of the environment variable <strong>HALCON</strong>IMAGES) are<br />

searched (see (T )read image). The returned polygons are in world coordinates. They can be transformed to<br />

the image coordinate system with the operator affine trans polygon xld. The necessary transformation<br />

matrix can be generated by using T read world file to read the transformation matrix from image to world<br />

coordinates, and inverting this matrix by calling hom mat2d invert.<br />

Parameter<br />

º Polygons (output object) ..............................................xld poly(-array) Hobject *<br />

Read XLD polygons.<br />

º FileName (input control) ...................................................filename const char *<br />

Name of the ARC/INFO file.<br />

Example<br />

/* Read the transformation and invert it */<br />

read_world_file (’image.tfw’, WorldTransformation)<br />

hom_mat2d_invert (WorldTransformation, ImageTransformation)<br />

/* Read the image */<br />

read_image (Image, ’image.tif’)<br />

/* Read the line data */<br />

read_polygon_xld_arc_info (LinesWorld, ’lines.gen’)<br />

/* Transform the line data to image coordinates */<br />

affine_trans_polygon_xld (LinesWorld, Lines, ImageTransformation)<br />

Result<br />

If the parameters are correct and the file could be read, the operator read polygon xld arc info returns the<br />

value H MSG TRUE. Otherwise an exception is raised.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


2.6. XLD 25<br />

Parallelization Information<br />

read polygon xld arc info is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

hom mat2d invert, affine trans polygon xld<br />

See Also<br />

T read world file, write polygon xld arc info, read contour xld arc info<br />

Sub-pixel operators<br />

Module<br />

write contour xld arc info ( Hobject Contours, const char *FileName )<br />

Write XLD contours to a file in ARC/INFO generate format.<br />

write contour xld arc info writes the XLD contours Contours to an ARC/INFO generate format file<br />

with name FileName. If no absolute path is given in FileName, the output file is created in the current directory<br />

of the <strong>HALCON</strong> process. The contours must have been transformed to the world coordinate system with<br />

affine trans contour xld beforehand. The necessary transformation can be read from an ARC/INFO<br />

world file with T read world file.<br />

Parameter<br />

º Contours (input object) .................................................xld cont(-array) Hobject<br />

XLD contours to be written.<br />

º FileName (input control) ...................................................filename const char *<br />

Name of the ARC/INFO file.<br />

Example<br />

/* Read transformation and image */<br />

read_world_file (’image.tfw’, WorldTransformation)<br />

read_image (Image, ’image.tif’)<br />

/* Segment image */<br />

...<br />

/* Write result */<br />

affine_trans_contour_xld (Contours, ContoursWorld, WorldTransformation)<br />

write_contour_xld_arc_info (ContoursWorld, ’result.gen’)<br />

Result<br />

If the parameters are correct and the file could be written, the operator write contour xld arc info returns<br />

the value H MSG TRUE. Otherwise an exception is raised.<br />

Parallelization Information<br />

write contour xld arc info is reentrant and processed without parallelization.<br />

affine trans contour xld<br />

Possible Predecessor Functions<br />

See Also<br />

T read world file, read contour xld arc info, write polygon xld arc info<br />

Sub-pixel operators<br />

Module<br />

write polygon xld arc info ( Hobject Polygons, const char *FileName )<br />

Write XLD polygons to a file in ARC/INFO generate format.<br />

write polygon xld arc info writes the XLD polygons Polygons to an ARC/INFO generate format file<br />

with name FileName. If no absolute path is given in FileName, the output file is created in the current directory<br />

of the <strong>HALCON</strong> process. The polygons must have been transformed to the world coordinate system with<br />

<strong>HALCON</strong> 6.0


26 CHAPTER 2. FILE<br />

affine trans polygon xld beforehand. The necessary transformation can be read from an ARC/INFO<br />

world file with T read world file.<br />

Attention<br />

The XLD contours that are possibly referenced by Polygons are not stored in the ARC/INFO file, since this<br />

is not possible with the ARC/INFO generate file format. Therefore, when the polygons are read again using<br />

read polygon xld arc info, this information is lost, and no references to contours are generated for the<br />

polygons. Hence, operators that access the contours associated with a polygon, e.g., split contours xld<br />

will not work correctly.<br />

Parameter<br />

º Polygons (input object) .................................................xld poly(-array) Hobject<br />

XLD polygons to be written.<br />

º FileName (input control) ...................................................filename const char *<br />

Name of the ARC/INFO file.<br />

Example<br />

/* Read transformation and image */<br />

read_world_file (’image.tfw’, WorldTransformation)<br />

read_image (Image, ’image.tif’)<br />

/* Segment image */<br />

...<br />

/* Write result */<br />

affine_trans_polygon_xld (Polygons, PolygonsWorld, WorldTransformation)<br />

write_polygon_xld_arc_info (PolygonsWorld, ’result.gen’)<br />

Result<br />

If the parameters are correct and the file could be written, the operator write polygon xld arc info returns<br />

the value H MSG TRUE. Otherwise an exception is raised.<br />

Parallelization Information<br />

write polygon xld arc info is reentrant and processed without parallelization.<br />

affine trans polygon xld<br />

Possible Predecessor Functions<br />

See Also<br />

T read world file, read polygon xld arc info, write contour xld arc info<br />

Sub-pixel operators<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Chapter 3<br />

Filter<br />

3.1 Affine-Transformations<br />

T affine trans image ( Hobject Image, Hobject *ImageAffinTrans,<br />

Htuple HomMat2D, Htuple Interpolation, Htuple AdaptImageSize )<br />

Apply an arbitrary affine transformation to an image.<br />

T affine trans image applies an arbitrary affine transformation, i.e., scaling, rotation, translation, and<br />

skewing, to an image. The affine map is described by the transformation matrix given in HomMat2D<br />

, which is built up by using hom mat2d identity, hom mat2d scale, hom mat2d rotate, and<br />

hom mat2d translate. The components of the homogeneous transformation matrix are interpreted as follows:<br />

the row coordinate of the image corresponds to the Ü coordinate of the matrix, while the column coordinate<br />

of the image corresponds to the Ý coordinate of the matrix. This is necessary to obtain a right-handed coordinate<br />

system, which is assumed for the homogeneous transformation matrices, also for the image. In particular, by doing<br />

so roatations are performed in the correct direction. Note that the (Ü,Ý) order of the matrices quite naturally<br />

corresponds to the usual (row,column) order for coordinates in the image.<br />

The region of the input image is ignored, i.e., assumed to be the full rectangle of the image. The region of the<br />

resulting image is set to the transformed rectangle of the input image. If necessary, the resulting image is filled<br />

with zero (black) outside of the region of the original image.<br />

Generally, transformed points will lie between pixel coordinates. Therefore, an appropriate interpolation scheme<br />

has to be used. The interpolation can also be used to avoid aliasing effects for scaled images. The quality and<br />

speed of the interpolation can be set by the parameter Interpolation:<br />

none No interpolation: The gray value is determined from the nearest pixel’s gray value (possibly low quality,<br />

very fast).<br />

constant Use equally wighted interpolation between adjacent pixels (medium quality and run time).<br />

weighted Use Gaussian interpolation between adjacent pixels (best quality, slow).<br />

In addition, the system parameter ’int zooming’ (see set system) affects the accuracy of the transformation.<br />

If ’int zooming’ is set to ’true’, the transformation for byte and int2 images is carried out internally using fixed<br />

point arithmetic, leading to much shorter execution times. However, the accuracy of the transformed gray values<br />

is smaller in this case. For byte images, the differences to the more accurate calculation (using ’int zooming’ =<br />

’false’) is typically less than two gray levels. Correspondingly, for int2 images, the gray value differences are less<br />

than 1/128 times the dynamic gray value range of the image, i.e., they can be as large as 512 gray levels if the<br />

entire dynamic range of 16 bit is used. For real images, the parameter ’int zooming’ does not affect the accuracy,<br />

since the internal calculations are always done using floating point arithmetic.<br />

The size of the target image can be controled by the paramter AdaptImageSize: With value ’true’ the size will<br />

be adapted so that no clipping occures. With value ’false’ the target image has the same size as the input image.<br />

Attention<br />

The region of the input image is ignored.<br />

The components of the homogeneous transformation matrix are interpreted as follows: the row coordinate of the<br />

image corresponds to the Ü coordinate of the matrix, while the column coordinate of the image corresponds to the<br />

27


28 CHAPTER 3. FILTER<br />

Ý coordinate of the matrix. This is necessary to obtain a right-handed coordinate system, which is assumed for the<br />

homogeneous transformation matrices, also for the image. In particular, by doing so roatations are performed in<br />

the correct direction. Note that the (Ü,Ý) order of the matrices quite naturally corresponds to the usual (row,column)<br />

order for coordinates in the image.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / real<br />

Input image.<br />

º ImageAffinTrans (output object) . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / real<br />

Transformed image.<br />

º HomMat2D (input control) ...........................................affine2d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 6<br />

º Interpolation (input control) .......................................string Htuple . const char *<br />

Type of interpolation.<br />

Default Value : ’constant’<br />

Value List : Interpolation ¾’none’, ’constant’, ’weighted’<br />

º AdaptImageSize (input control) ......................................string Htuple . const char *<br />

Adaption of size of result image.<br />

Default Value : ’false’<br />

Value List : AdaptImageSize ¾’true’, ’false’<br />

Example<br />

/* Reduction of an image (512 x 512 Pixels) by 50%, rotation */<br />

/* by 180 degrees and translation to the upper-left corner: */<br />

hom_mat2d_identity(Matrix1)<br />

hom_mat2d_scale(Matrix1,0.5,0.5,256.0,256.0,Matrix2)<br />

hom_mat2d_rotate(Matrix2,3.14,256.0,256.0,Matrix3)<br />

hom_mat2d_translate(Matrix3,-128.0,-128.0,Matrix4,)<br />

affine_trans_image(Image,TransImage,Matrix4,1).<br />

/* Enlarging the part of an image in the interactively */<br />

/* chosen rectangular window sector: */<br />

draw_rectangle2(WindowHandle,L,C,Phi,L1,L2)<br />

hom_mat2d_identity(Matrix1)<br />

get_system(width,Width)<br />

get_system(height,Height)<br />

hom_mat2d_translate(Matrix1,Height/2.0-L,Width/2.0-C,Matrix2)<br />

hom_mat2d_rotate(Matrix2,3.14-Phi,Height/2.0,Width/2.0,Matrix3)<br />

hom_mat2d_scale(Matrix3,Height/(2.0*L2),Width/(2.0*L1),<br />

Height/2.0,Width/2.0,Matrix4)<br />

affine_trans_image(Image,Matrix4,TransImage,1).<br />

Result<br />

T affine trans image returns H MSG TRUE if all parameter values are correct. If the input is empty the<br />

behaviour can be set via set system(’no object result’,). If necessary, an exception handling<br />

is raised.<br />

Parallelization Information<br />

T affine trans image is reentrant and automatically parallelized (on tuple level, channel level).<br />

Possible Predecessor Functions<br />

hom mat2d identity, hom mat2d translate, hom mat2d rotate, hom mat2d scale<br />

Alternatives<br />

zoom image size, zoom image factor, mirror image, rotate image, affine trans region<br />

set part style<br />

See Also<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.1. AFFINE-TRANSFORMATIONS 29<br />

Image filters<br />

Module<br />

mirror image ( Hobject Image, Hobject *ImageMirror, const char *Mode )<br />

Mirror an image.<br />

mirror image reflects an image Image about one of three possible axes. If Mode is set to ’row’, it is reflected<br />

about the horizontal axis, if Mode is set to ’column’, about the vertical axis, and if Mode is set to ’main’, about<br />

the main diagonal Ü Ý.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Input image.<br />

º ImageMirror (output object) . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Reflected image.<br />

º Mode (input control) ............................................................string const char *<br />

Axis of reflection.<br />

Default Value : ’row’<br />

Value List : Mode ¾’row’, ’column’, ’main’<br />

Example<br />

read_image(&Image,"affe");<br />

disp_image(Image,WindowHandle);<br />

mirror_image(Image,&MirImage,"row");<br />

disp_image(MirImage,WindowHandle);<br />

Parallelization Information<br />

mirror image is reentrant and automatically parallelized (on tuple level, channel level).<br />

Alternatives<br />

hom mat2d rotate, T affine trans image, rotate image<br />

rotate image, hom mat2d rotate<br />

Image filters<br />

See Also<br />

Module<br />

polar trans image ( Hobject ImageXY, Hobject *ImagePolar, long Row,<br />

long Column, long Width, long Height )<br />

Transform an image to polar coordinates<br />

polar trans image transforms an image in cartesian coordinates to an image in polar coordinates. The size<br />

of the resulting image is selected with Width and Height. Width determines the angular resolution, while<br />

Height determines the resolution of the radius. Row and Column determine the center of the polar coordinate<br />

system in the original image ImageXY. This point is mapped to the upper row of ImagePolar.<br />

A point (x’,y’) in the result image corresponds to the point (x,y) in the original image in the following manner:<br />

Ü Ý ¼ Ó×´¾´Ü ¼ Ö×ÙÐØÛصµ · ÓÐÙÑÒÝ Ý ¼ ×Ò´¾´Ü ¼ Ö×ÙÐØÛصµ · ÊÓÛ <br />

Parameter<br />

º ImageXY (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte / int2<br />

Input image in cartesian coordinates.<br />

º ImagePolar (output object) . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Result image in polar coordinates.<br />

<strong>HALCON</strong> 6.0


30 CHAPTER 3. FILTER<br />

º Row (input control) ...................................................................point.y long<br />

Row coordinate of the center of the coordinate system.<br />

Default Value : 100<br />

Value Suggestions : Row ¾0, 10, 100, 200<br />

Typical Range of Values : 0 Row 512<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Column (input control) ...............................................................point.x long<br />

Column coordinate of the center of the coordinate system.<br />

Default Value : 100<br />

Value Suggestions : Column ¾0, 10, 100, 200<br />

Typical Range of Values : 0 Column 512<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the result image.<br />

Default Value : 314<br />

Value Suggestions : Width ¾100, 200, 157, 314, 512<br />

Typical Range of Values : 2 Width 512<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the result image.<br />

Default Value : 200<br />

Value Suggestions : Height ¾100, 128, 256, 512<br />

Typical Range of Values : 2 Height 512<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Example<br />

read_image(&Image,"affe");<br />

disp_image(Image,WindowHandle);<br />

polar_trans_image(Image,&PolarImage,100,100,314,200);<br />

disp_image(PolarImage,WindowHandle);<br />

Parallelization Information<br />

polar trans image is reentrant and automatically parallelized (on tuple level, channel level).<br />

T affine trans image<br />

Image filters<br />

Alternatives<br />

Module<br />

rotate image ( Hobject Image, Hobject *ImageRotate, double Phi,<br />

const char *Interpolation )<br />

Rotate an image about its center.<br />

rotate image rotates the image Image counterclockwise by Phi degrees about its center. This operator is<br />

much faster if Phi is a multiple of 90 degrees than the general operator T affine trans image. For rotations<br />

by 90, 180, and 270 degrees, the region is rotated accordingly. For all other rotations the region is set to the<br />

maximum region, i.e., to the extent of the resulting image. The effect of the parameter Interpolation is the<br />

same as in T affine trans image. It is ignored for rotations by 90, 180, and 270 degrees. The size of the<br />

resulting image is the same as that of the input image, with the exception of rotations by 90 and 270 degrees, where<br />

the width and height will be exchanged.<br />

Attention<br />

The angle Phi is given in degrees, not in radians.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.1. AFFINE-TRANSFORMATIONS 31<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Input image.<br />

º ImageRotate (output object) . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Rotated image.<br />

º Phi (input control) ........................................................angle.deg double / long<br />

Rotation angle.<br />

Default Value : 90<br />

Value Suggestions : Phi ¾90, 180, 270<br />

Typical Range of Values : 0 Phi 360<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.2<br />

º Interpolation (input control) ...............................................string const char *<br />

Type of interpolation.<br />

Default Value : ’constant’<br />

Value List : Interpolation ¾’none’, ’constant’, ’weighted’<br />

read_image(&Image,"affe");<br />

disp_image(Image,WindowHandle);<br />

rotate_image(Image,&RotImage,270);<br />

disp_image(RotImage,WindowHandle);<br />

Example<br />

Parallelization Information<br />

rotate image is reentrant and automatically parallelized (on tuple level, channel level).<br />

Alternatives<br />

hom mat2d rotate, T affine trans image<br />

mirror image<br />

Image filters<br />

See Also<br />

Module<br />

zoom image factor ( Hobject Image, Hobject *ImageZoomed,<br />

double ScaleWidth, double ScaleHeight, const char *Interpolation )<br />

Zoom an image by a given factor.<br />

zoom image factor scales the image Image by a factor of ScaleWidth in width and a factor<br />

ScaleHeight in height. The parameter Interpolation determines the type of interpolation used (see<br />

T affine trans image).<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Input image.<br />

º ImageZoomed (output object) . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Scaled image.<br />

º ScaleWidth (input control) ......................................................extent.x double<br />

Scale factor for the width of the image.<br />

Default Value : 0.5<br />

Value Suggestions : ScaleWidth ¾0.25, 0.5, 1.5, 2.0<br />

Typical Range of Values : 0.001 ScaleWidth 10.0<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.1<br />

<strong>HALCON</strong> 6.0


32 CHAPTER 3. FILTER<br />

º ScaleHeight (input control) .....................................................extent.y double<br />

Scale factor for the height of the image.<br />

Default Value : 0.5<br />

Value Suggestions : ScaleHeight ¾0.25, 0.5, 1.5, 2.0<br />

Typical Range of Values : 0.001 ScaleHeight 10.0<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.1<br />

º Interpolation (input control) ...............................................string const char *<br />

Type of interpolation.<br />

Default Value : ’constant’<br />

Value List : Interpolation ¾’none’, ’constant’, ’weighted’<br />

Example<br />

read_image(&Image,"affe");<br />

disp_image(Image,WindowHandle);<br />

zoom_image_factor(Image,&ZooImage,0,0.5,0.5);<br />

disp_image(ZooImage,WindowHandle);<br />

Parallelization Information<br />

zoom image factor is reentrant and automatically parallelized (on tuple level, channel level).<br />

Alternatives<br />

zoom image factor, T affine trans image, hom mat2d scale<br />

hom mat2d scale, T affine trans image<br />

Image filters<br />

See Also<br />

Module<br />

zoom image size ( Hobject Image, Hobject *ImageZoom, long Width,<br />

long Height, const char *Interpolation )<br />

Zoom an image to a given size.<br />

zoom image size scales the image Image to the size given by Width and Height.<br />

Interpolation determines the type of interpolation used (see T affine trans image).<br />

Parameter<br />

The parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Input image.<br />

º ImageZoom (output object) . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Scaled image.<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the resulting image.<br />

Default Value : 512<br />

Value Suggestions : Width ¾128, 256, 512<br />

Typical Range of Values : 2 Width 512<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the resulting image.<br />

Default Value : 512<br />

Value Suggestions : Height ¾128, 256, 512<br />

Typical Range of Values : 2 Height 512<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.2. ARITHMETIC 33<br />

º Interpolation (input control) ...............................................string const char *<br />

Type of interpolation.<br />

Default Value : ’constant’<br />

Value List : Interpolation ¾’none’, ’constant’, ’weighted’<br />

Example<br />

read_image(&Image,"affe");<br />

disp_image(Image,WindowHandle);<br />

zoom_image_size(Image,&ZooImage,0,200,200);<br />

disp_image(ZooImage,WindowHandle);<br />

Parallelization Information<br />

zoom image size is reentrant and automatically parallelized (on tuple level, channel level).<br />

Alternatives<br />

zoom image factor, T affine trans image, hom mat2d scale<br />

hom mat2d scale, T affine trans image<br />

Image filters<br />

See Also<br />

Module<br />

3.2 Arithmetic<br />

abs image ( Hobject Image, Hobject *ImageAbs )<br />

Calculate the absolute value (modulus) of an image.<br />

The operator abs image calculates the absolute gray values of images of any type and stores the result in<br />

ImageAbs. The power spectrum of complex images is calculated as a ’real’ image. The operator abs image<br />

generates a logical copy of unsigned images.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject :any<br />

Image(s) for which the absolute gray values are to be calculated.<br />

º ImageAbs (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * :any<br />

Result image(s).<br />

Example<br />

laws_int2(Image,&Texture,0,5);<br />

abs_image(Texture,Abs);<br />

Result<br />

The operator abs image returns the value H MSG TRUE. The behavior in case of empty input (no input images<br />

available) is set via the operator set system(’no object result’,)<br />

Parallelization Information<br />

abs image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

convert image type, power byte<br />

Image filters<br />

See Also<br />

Module<br />

add image ( Hobject Image1, Hobject Image2, Hobject *ImageResult,<br />

double Mult, double Add )<br />

Add two images.<br />

<strong>HALCON</strong> 6.0


34 CHAPTER 3. FILTER<br />

The operator add image adds two images. The gray values (½¾) of the input images (Image1 and Image2)<br />

are transformed as follows:<br />

¼ ´½ ·¾µ £ ÅÙÐØ · <br />

If an overflow or an underflow occurs the values are clipped. This is not the case with int2 images if Mult is equal<br />

to1andAdd is equal to 0. To reduce the runtime the underflow and overflow check is skipped. The resulting<br />

image is stored in ImageResult.<br />

It is possible to add byte images with int2 and int4 images. In this case the result will be of type int2 or int4<br />

respectively.<br />

Several images can be processed in one call. In this case both input parameters contain the same number of images<br />

which are then processed in pairs. An output image is generated for every pair.<br />

Please note that the runtime of the operator varies with different control parameters. For frequently used combinations<br />

special optimizations were used.<br />

Parameter<br />

º Image1 (input object) . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real / direction /<br />

cyclic / complex<br />

Image(s) 1.<br />

º Image2 (input object) . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real / direction /<br />

cyclic / complex<br />

Image(s) 2.<br />

º ImageResult (output object) . . (multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4 / real /<br />

direction / cyclic / complex<br />

Result image(s) by the addition.<br />

º Mult (input control) ........................................................number double / long<br />

Factor for gray value adaption.<br />

Default Value : 0.5<br />

Value Suggestions : Mult ¾0.2, 0.4, 0.6, 0.8, 1.0, 1.5, 2.0, 3.0, 5.0<br />

Typical Range of Values : -255.0 Mult 255.0<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.1<br />

º Add (input control) ..........................................................number double / long<br />

Value for gray value range adaption.<br />

Default Value : 0<br />

Value Suggestions : Add ¾0, 64, 128, 255, 512<br />

Typical Range of Values : -512.0 Add 512.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 1.0<br />

Example<br />

read_image(&Image0,"fabrik");<br />

disp_image(Image0,WindowHandle);<br />

read_image(&Image1,"Affe");<br />

disp_image(Image1,WindowHandle);<br />

add_image(Image0,Image1,&Result,2.0,10.0);<br />

disp_image(Result,WindowHandle);<br />

Result<br />

The operator add image returns the value H MSG TRUE if the parameters are correct. The behavior<br />

in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,) If necessary an exception handling is raised.<br />

Parallelization Information<br />

add image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

sub image, mult image<br />

sub image, mult image<br />

Alternatives<br />

See Also<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.2. ARITHMETIC 35<br />

Image filters<br />

Module<br />

div image ( Hobject Image1, Hobject Image2, Hobject *ImageResult,<br />

double Mult, double Add )<br />

Divide two images.<br />

The operator div image divides two images. The gray values (½¾) of the input images (Image1)aretransformed<br />

as follows:<br />

¼ ½¾ £ ÅÙÐØ · <br />

If an overflow or an underflow occurs the values are clipped.<br />

Several images can be processed in one call. In this case both input parameters contain the same number of images<br />

which are then processed in pairs. An output image is generated for every pair.<br />

Parameter<br />

º Image1 (input object) . . . .(multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real / complex<br />

Image(s) 1.<br />

º Image2 (input object) . . . .(multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real / complex<br />

Image(s) 2.<br />

º ImageResult (output object) . . (multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4 / real /<br />

complex<br />

Result image(s) by the division.<br />

º Mult (input control) ........................................................number double / long<br />

Factor for gray range adaption.<br />

Default Value : 255<br />

Value Suggestions : Mult ¾0.1, 0.2, 0.5, 1.0, 2.0, 3.0, 10, 100, 500, 1000<br />

Typical Range of Values : -1000 Mult 1000<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 1<br />

º Add (input control) ..........................................................number double / long<br />

Value for gray range adaption.<br />

Default Value : 0<br />

Value Suggestions : Add ¾0.0, 128.0, 256.0, 1025<br />

Typical Range of Values : -1000 Add 1000<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 1.0<br />

Example<br />

read_image(&Image0,"fabrik");<br />

disp_image(Image0,WindowHandle);<br />

read_image(&Image1,"Affe");<br />

disp_image(Image1,WindowHandle);<br />

div_image(Image0,Image1,&Result,2.0,10.0);<br />

disp_image(Result,WindowHandle);<br />

Result<br />

The operator div image returns the value H MSG TRUE if the parameters are correct. The behavior<br />

in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,) If necessary an exception handling is raised.<br />

Parallelization Information<br />

div image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

add image, sub image, mult image<br />

Alternatives<br />

<strong>HALCON</strong> 6.0


36 CHAPTER 3. FILTER<br />

add image, sub image, mult image<br />

Image filters<br />

See Also<br />

Module<br />

invert image ( Hobject Image, Hobject *ImageInvert )<br />

Invert an image.<br />

The operator invert image inverts the gray values of an image. For images of the ’byte’ and ’cyclic’ type the<br />

result is calculated as:<br />

Images of the ’direction’ type are transformed by<br />

¼ ¾ <br />

¼ ´ · ¼µ modulo ½¼<br />

In the case of signed types the values are negated. The resulting image has the same pixel type as the input image.<br />

Several images can be processed in one call. An output image is generated for every input image.<br />

Parameter<br />

º Image (input object) . . . . . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real / cyclic /<br />

direction<br />

Input image(s).<br />

º ImageInvert (output object) . . (multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4 / real /<br />

cyclic / direction<br />

Image(s) with inverted gray values.<br />

read_image(&Orig,"fabrik");<br />

invert_image(Orig,&Invert);<br />

disp_image(Invert,WindowHandle);<br />

Example<br />

Parallelization Information<br />

invert image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

watersheds<br />

scale image<br />

scale image, add image, sub image<br />

Image filters<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

max image ( Hobject Image1, Hobject Image2, Hobject *ImageMax )<br />

Calculate the maximum of two images pixel by pixel.<br />

max image calculates the maximum of the images Image1 and Image2 (pixel by pixel). The result is stored in<br />

the image ImageMax. The resulting image has the same pixel type as the input image. If several (pairs of) images<br />

are processed in one call, every i-th image from Image1 is compared to the i-th image from Image2. Thus the<br />

number of images in both input parameters must be the same. An output image is generated for every input pair.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.2. ARITHMETIC 37<br />

Attention<br />

The two input images must be of the same type and size.<br />

Parameter<br />

º Image1 (input object) . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real / direction /<br />

cyclic<br />

Image(s) 1.<br />

º Image2 (input object) . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real / direction /<br />

cyclic<br />

Image(s) 2.<br />

º ImageMax (output object) . . . . . . (multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4 / real /<br />

direction / cyclic<br />

Result image(s) by the maximization.<br />

read_image(&Bild1,"affe");<br />

read_image(&Bild2,"fabrik");<br />

max_image(Bild1,Bild2,&Max);<br />

disp_image(Max,WindowHandle);<br />

Example<br />

Result<br />

If the parameter values are correct the operator max image returns the value H MSG TRUE. The<br />

behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

max image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

max image<br />

min image<br />

Image filters<br />

Alternatives<br />

See Also<br />

Module<br />

min image ( Hobject Image1, Hobject Image2, Hobject *ImageMin )<br />

Calculate the minimum of two images pixel by pixel.<br />

The operator min image determines the minimum (pixel by pixel) of the images Image1 and Image2. The<br />

result is stored in the image ImageMin. The resulting image has the same pixel type as the input image. If several<br />

(pairs of) images are processed in one call, every i-th image from Image1 is compared to the i-th image from<br />

Image2. Thus the number of images in both input parameters must be the same. An output image is generated<br />

for every input pair.<br />

Parameter<br />

º Image1 (input object) . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real / direction /<br />

cyclic<br />

Image(s) 1.<br />

º Image2 (input object) . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real / direction /<br />

cyclic<br />

Image(s) 2.<br />

º ImageMin (output object) . . . . . . (multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4 / real /<br />

direction / cyclic<br />

Result image(s) by the minimization.<br />

Result<br />

If the parameter values are correct the operator min image returns the value H MSG TRUE. The<br />

<strong>HALCON</strong> 6.0


38 CHAPTER 3. FILTER<br />

behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,) If necessary an exception handling is raised.<br />

Parallelization Information<br />

min image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

gray erosion<br />

max image, min image<br />

Image filters<br />

Alternatives<br />

See Also<br />

Module<br />

mult image ( Hobject Image1, Hobject Image2, Hobject *ImageResult,<br />

double Mult, double Add )<br />

Multiply two images.<br />

mult image multiplies two images. The gray values (½¾) of the input images (Image1) aretransformedas<br />

follows:<br />

¼ ½ £ ¾ £ ÅÙÐØ · <br />

If an overflow or an underflow occurs the values are clipped.<br />

Several images can be processed in one call. In this case both input parameters contain the same number of images<br />

which are then processed in pairs. An output image is generated for every pair.<br />

Parameter<br />

º Image1 (input object) . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real / direction /<br />

cyclic / complex<br />

Image(s) 1.<br />

º Image2 (input object) . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real / direction /<br />

cyclic / complex<br />

Image(s) 2.<br />

º ImageResult (output object) . . (multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4 / real /<br />

direction / cyclic / complex<br />

Result image(s) by the product.<br />

º Mult (input control) ........................................................number double / long<br />

Factor for gray range adaption.<br />

Default Value : 0.005<br />

Value Suggestions : Mult ¾0.001, 0.01, 0.5, 1.0, 2.0, 3.0, 5.0, 10.0<br />

Typical Range of Values : -255.0 Mult 255.0<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.1<br />

º Add (input control) ..........................................................number double / long<br />

Value for gray range adaption.<br />

Default Value : 0<br />

Value Suggestions : Add ¾0.0, 128.0, 256.0<br />

Typical Range of Values : -512.0 Add 512.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 1.0<br />

Example<br />

read_image(&Image0,"fabrik");<br />

disp_image(Image0,WindowHandle);<br />

read_image(&Image1,"Affe");<br />

disp_image(Image1,WindowHandle);<br />

mult_image(Image0,Image1,&Result,2.0,10.0);<br />

disp_image(Result,WindowHandle);<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.2. ARITHMETIC 39<br />

Result<br />

The operator mult image returns the value H MSG TRUE if the parameters are correct. The behavior<br />

in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,) If necessary an exception handling is raised.<br />

Parallelization Information<br />

mult image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

add image, sub image, div image<br />

add image, sub image, div image<br />

Image filters<br />

Alternatives<br />

See Also<br />

Module<br />

scale image ( Hobject Image, Hobject *ImageScaled, double Mult,<br />

double Add )<br />

Scale the gray values of an image.<br />

The operator scale image scales the input images (Image) by the following transformation:<br />

¼ £ ÅÙÐØ · <br />

If an overflow or an underflow occurs the values are clipped.<br />

Parameter<br />

º Image (input object) . . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real / direction /<br />

cyclic / complex<br />

Image(s) whose gray values are to be scaled.<br />

º ImageScaled (output object) . . (multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4 / real /<br />

direction / cyclic / complex<br />

Result image(s) by the scale.<br />

º Mult (input control) ........................................................number double / long<br />

Scale factor.<br />

Default Value : 0.01<br />

Value Suggestions : Mult ¾0.001, 0.003, 0.005, 0.008, 0.01, 0.02, 0.03, 0.05, 0.08, 0.1, 0.5, 1.0<br />

Typical Range of Values : -255.0 Mult 255.0<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.1<br />

º Add (input control) ..........................................................number double / long<br />

Offset.<br />

Default Value : 0<br />

Value Suggestions : Add ¾0, 10, 50, 100, 200, 500<br />

Typical Range of Values : -512.0 Add 512.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 1.0<br />

Example<br />

/* simulation of invert for type ’byte’ */<br />

byte_invert(Hobject In, Hobject *out)<br />

{<br />

scale_image(In,Out,-1.0,255.0);<br />

}<br />

Result<br />

The operator scale image returns the value H MSG TRUE if the parameters are correct. The behavior<br />

in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,) Otherwise an exception treatment is carried out.<br />

<strong>HALCON</strong> 6.0


40 CHAPTER 3. FILTER<br />

Parallelization Information<br />

scale image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

min max gray<br />

mult image, add image, sub image<br />

min max gray<br />

Image filters<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

sub image ( Hobject ImageMinuend, Hobject ImageSubtrahend,<br />

Hobject *ImageSub, double Mult, double Add )<br />

Subtract two images.<br />

The operator sub image subtracts two images. The gray values (½¾) of the input images (ImageMinuend<br />

and ImageSubtrahend) are transformed as follows:<br />

¼ ´½ ¾µ £ ÅÙÐØ · <br />

If an overflow or an underflow occurs the values are clipped.<br />

Several images can be processed in one call. In this case both input parameters contain the same number of images<br />

which are then processed in pairs. An output image is generated for every pair.<br />

Parameter<br />

º ImageMinuend (input object) . . . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real /<br />

direction / cyclic / complex<br />

Minuend(s).<br />

º ImageSubtrahend (input object) (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real /<br />

direction / cyclic / complex<br />

Subtrahend(s).<br />

º ImageSub (output object) . . . . . . (multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4 / real /<br />

direction / cyclic / complex<br />

Result image(s) by the subtraction.<br />

º Mult (input control) ........................................................number double / long<br />

Correction factor.<br />

Default Value : 1.0<br />

Value Suggestions : Mult ¾0.0, 1.0, 2.0, 3.0, 4.0<br />

Typical Range of Values : -255.0 Mult 255.0<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.1<br />

º Add (input control) ..........................................................number double / long<br />

Correction value.<br />

Default Value : 128.0<br />

Value Suggestions : Add ¾0.0, 128.0, 256.0<br />

Typical Range of Values : -512.0 Add 512.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 1.0<br />

Example<br />

read_image(&Image0,"fabrik");<br />

disp_image(Image0,WindowHandle);<br />

read_image(&Image1,"Affe");<br />

disp_image(Image1,WindowHandle);<br />

sub_image(Image0,Image1,&Result,2.0,10.0);<br />

disp_image(Result,WindowHandle);<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.3. BIT 41<br />

Result<br />

The operator sub image returns the value H MSG TRUE if the parameters are correct. The behavior<br />

in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,) If necessary an exception handling is raised.<br />

Parallelization Information<br />

sub image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

dual threshold<br />

mult image, add image, sub image<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

add image, mult image, dyn threshold, check difference<br />

Image filters<br />

Module<br />

3.3 Bit<br />

bit and ( Hobject Image1, Hobject Image2, Hobject *ImageAnd )<br />

Bit-by-bit AND of all pixels of the input images.<br />

The operator bit and calculates the “and” of all pixels of the input images bit by bit. The semantics of the “and”<br />

operation corresponds to that of C for the respective types (signed char, unsigned char, short, int/long). The images<br />

must have the same size and pixel type. The pixels within the definition range of the image in the first parameter<br />

are processed.<br />

Several images can be processed in one call. In this case both input parameters contain the same number of images<br />

which are then processed in pairs. An output image is generated for every pair.<br />

Parameter<br />

º Image1 (input object) . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4<br />

Input image(s) 1.<br />

º Image2 (input object) . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4<br />

Input image(s) 2.<br />

º ImageAnd (output object) . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4<br />

Result image(s) by AND-operation.<br />

read_image(&Image0,"affe");<br />

disp_image(Image0,WindowHandle);<br />

read_image(&Image1,"fabrik");<br />

disp_image(Image1,WindowHandle);<br />

bit_and(Image0,Image1,&ImageBitA);<br />

disp_image(ImageBitA,WindowHandle);<br />

Example<br />

Result<br />

If the images are correct (type and number) the operator bit and returns the value H MSG TRUE.<br />

The behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,) If necessary an exception handling is raised.<br />

Parallelization Information<br />

bit and is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

bit mask, add image, max image<br />

bit mask, add image, max image<br />

Alternatives<br />

See Also<br />

<strong>HALCON</strong> 6.0


42 CHAPTER 3. FILTER<br />

Image filters<br />

Module<br />

bit lshift ( Hobject Image, Hobject *ImageLShift, long Shift )<br />

Left shift of all pixels of the image.<br />

The operator bit lshift calculates a “left shift” of all pixels of the input image bit by bit. The semantics of the<br />

“left shift” operation corresponds to that of C (“


3.3. BIT 43<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4<br />

Input image(s).<br />

º ImageMask (output object) . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4<br />

Result image(s) by combination with mask.<br />

º BitMask (input control) .............................................................integer long<br />

Bit field<br />

Default Value : 128<br />

Value List : BitMask ¾1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096<br />

Value Suggestions : BitMask ¾1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096<br />

Result<br />

If the images are correct (type) the operator bit mask returns the value H MSG TRUE. The behavior<br />

in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,) If necessary an exception handling is raised.<br />

Parallelization Information<br />

bit mask is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

threshold, bit or<br />

bit slice<br />

bit and, bit lshift<br />

Image filters<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

bit not ( Hobject Image, Hobject *ImageNot )<br />

Complement all bits of the pixels.<br />

The operator bit not calculates the “complement” of all pixels of the input image bit by bit. The semantics of<br />

the “complement” operation corresponds to that of C (“”) for the respective types (signed char, unsigned char,<br />

short, int/long). Only the pixels within the definition range of the image are processed.<br />

Several images can be processed in one call. An output image is generated for every input image.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4<br />

Input image(s).<br />

º ImageNot (output object) . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4<br />

Result image(s) by complement operation.<br />

read_image(&Image0,"affe");<br />

disp_image(Image0,WindowHandle);<br />

bit_not(Image0,&ImageBitN);<br />

disp_image(ImageBitN,WindowHandle);<br />

Example<br />

Result<br />

If the images are correct (type) the operator bit not returns the value H MSG TRUE. The behavior<br />

in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,) If necessary an exception handling is raised.<br />

Parallelization Information<br />

bit not is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

bit or, bit and, add image<br />

Alternatives<br />

<strong>HALCON</strong> 6.0


44 CHAPTER 3. FILTER<br />

bit slice, bit mask<br />

Image filters<br />

See Also<br />

Module<br />

bit or ( Hobject Image1, Hobject Image2, Hobject *ImageOr )<br />

Bit-by-bit OR of all pixels of the input images.<br />

The operator bit or calculates the “or” of all pixels of the input images bit by bit. The semantics of the<br />

“or”operation corresponds to that of C for the respective types (signed char, unsigned char, short, int/long). The<br />

images must have the same size and pixel type. The pixels within the definition range of the image in the first<br />

parameter are processed.<br />

Several images can be processed in one call. In this case both input parameters contain the same number of images<br />

which are then processed in pairs. An output image is generated for every pair.<br />

Parameter<br />

º Image1 (input object) . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4<br />

Input image(s) 1.<br />

º Image2 (input object) . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4<br />

Input image(s) 2.<br />

º ImageOr (output object) . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4<br />

Result image(s) by OR-operation.<br />

Example<br />

read_image(&Image0,"affe");<br />

disp_image(Image0,WindowHandle);<br />

read_image(&Image1,"fabrik");<br />

disp_image(Image1,WindowHandle);<br />

bit_or(Image0,Image1,&ImageBitO);<br />

disp_image(ImageBitO,WindowHandle);<br />

Result<br />

If the images are correct (type and number) the operator bit or returns the value H MSG TRUE.<br />

The behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,) If necessary an exception handling is raised.<br />

Parallelization Information<br />

bit or is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

bit and, add image<br />

bit xor, bit and<br />

Image filters<br />

Alternatives<br />

See Also<br />

Module<br />

bit rshift ( Hobject Image, Hobject *ImageRShift, long Shift )<br />

Right shift of all pixels of the image.<br />

The operator bit rshift calculates a “right shift” of all pixels of the input image bit by bit. The semantics of<br />

the “right shift” operation corresponds to that of C (“>>”) for the respective types (signed char, unsigned char,<br />

short, int/long). Only the pixels within the definition range of the image are processed.<br />

Several images can be processed in one call. An output image is generated for every input image.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.3. BIT 45<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4<br />

Input image(s).<br />

º ImageRShift (output object) . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4<br />

Result image(s) by shift operation.<br />

º Shift (input control) ................................................................integer long<br />

shift value<br />

Default Value : 3<br />

Value Suggestions : Shift ¾0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 30, 31<br />

Typical Range of Values : 0 Shift 31<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : ´Shift 1µ ´Shift 31µ<br />

Example<br />

bit_rshift(Int2Image,&ReducedInt2Image,8);<br />

convert_image_type(ReducedInt2Image,&ByteImage,"byte");<br />

Result<br />

If the images are correct (type) and Shift has a valid value the operator bit rshift returns the value<br />

H MSG TRUE. The behavior in case of empty input (no input images available) is set via the operator<br />

set system(’no object result’,) If necessary an exception handling is raised.<br />

Parallelization Information<br />

bit rshift is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

scale image<br />

bit lshift<br />

Image filters<br />

Alternatives<br />

See Also<br />

Module<br />

bit slice ( Hobject Image, Hobject *ImageSlice, long Bit )<br />

Extract a bit from the pixels.<br />

The operator bit slice extracts a bit level from the input image. The semantics of the “and” operation corresponds<br />

to that of C for the respective types (signed char, unsigned char, short, int/long). Only the pixels within the<br />

definition range of the image are processed.<br />

Several images can be processed in one call. An output image is generated for every input image.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int1 / int2 / int4<br />

Input image(s).<br />

º ImageSlice (output object) . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4<br />

Result image(s) by extraction.<br />

º Bit (input control) ...................................................................integer long<br />

Bit to be selected.<br />

Default Value : 8<br />

Value Suggestions : Bit ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 30, 32<br />

Typical Range of Values : 1 Bit 32<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : ´Bit 1µ ´Bit 32µ<br />

<strong>HALCON</strong> 6.0


46 CHAPTER 3. FILTER<br />

Example<br />

read_image(&ByteImage,"fabrik");<br />

for (bit=1; bit


3.4. COLOR 47<br />

Parallelization Information<br />

bit xor is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

bit or, bit and, add image<br />

bit or, bit and<br />

Image filters<br />

Alternatives<br />

See Also<br />

Module<br />

3.4 Color<br />

rgb1 to gray ( Hobject RGBImage, Hobject *GrayImage )<br />

Transform an RGB image into a gray scale image.<br />

rgb1 to gray transforms an RGB image into a gray scale image. The three channels of the RGB image are<br />

passed as the first three channels of the input image. The image is transformed according to the following formula:<br />

¼¾Ö ·¼ ·¼½ <br />

Parameter<br />

º RGBImage (input object) ........................................image(-array) Hobject : byte / int2<br />

Three-channel RBG image.<br />

º GrayImage (output object) ....................................image(-array) Hobject * : byte / int2<br />

Gray scale image.<br />

Example<br />

/* Tranformation from rgb to gray */<br />

read_image(Image,"patras") ;<br />

disp_color(Image,WindowHandle) ;<br />

rgb1_to_gray(Image,&GrayImage) ;<br />

disp_image(GrayImage,WindowHandle);<br />

Parallelization Information<br />

rgb1 to gray is reentrant and automatically parallelized (on tuple level, domain level).<br />

compose3<br />

trans from rgb, rgb3 to gray<br />

Image filters<br />

Possible Predecessor Functions<br />

Alternatives<br />

Module<br />

rgb3 to gray ( Hobject ImageRed, Hobject ImageGreen, Hobject ImageBlue,<br />

Hobject *ImageGray )<br />

Transform an RGB image to a gray scale image.<br />

rgb3 to gray transforms an RGB image into a gray scale image. The three channels of the RGB image are<br />

passed as three separate images. The image is transformed according to the following formula:<br />

¼¾Ö ·¼ ·¼½ <br />

<strong>HALCON</strong> 6.0


48 CHAPTER 3. FILTER<br />

Parameter<br />

º ImageRed (input object) ........................................image(-array) Hobject : byte / int2<br />

Input image (red channel).<br />

º ImageGreen (input object) ......................................image(-array) Hobject : byte / int2<br />

Input image (green channel).<br />

º ImageBlue (input object) .......................................image(-array) Hobject : byte / int2<br />

Input image (blue channel).<br />

º ImageGray (output object) ....................................image(-array) Hobject * : byte / int2<br />

Gray scale image.<br />

Example<br />

/* Tranformation from rgb to gray */<br />

read_image(Image,"patras") ;<br />

disp_color(Image,WindowHandle) ;<br />

decompose3(Image,&Rimage,&Gimage,&Bimage) ;<br />

rgb3_to_gray(Rimage,Gimage,Bimage,&GrayImage) ;<br />

disp_image(GrayImage,WindowHandle);<br />

Parallelization Information<br />

rgb3 to gray is reentrant and automatically parallelized (on tuple level, domain level).<br />

decompose3<br />

rgb1 to gray, trans from rgb<br />

Image filters<br />

Possible Predecessor Functions<br />

Alternatives<br />

Module<br />

trans from rgb ( Hobject ImageRed, Hobject ImageGreen,<br />

Hobject ImageBlue, Hobject *ImageResult1, Hobject *ImageResult2,<br />

Hobject *ImageResult3, const char *ColorSpace )<br />

Transform an image from the RGB color space to an arbitrary color space.<br />

trans from rgb transforms an image from the RGB color space to an arbitrary color space (ColorSpace).<br />

The three channels of the image are passed as three separate images on input and output.<br />

The following transformations are supported:<br />

’yiq’<br />

¼<br />

Á<br />

É<br />

½ ¼<br />

<br />

¼¾ ¼ ¼½<br />

¼ ¼¾ ¼¿¿¿<br />

¼¾¼ ¼¾¾ ¼¾<br />

½¼<br />

<br />

Ê <br />

<br />

½<br />

<br />

’argyb’<br />

’ciexyz’<br />

¼<br />

Ê<br />

<br />

¼<br />

<br />

<br />

½ ¼<br />

<br />

½ ¼<br />

<br />

¼¿¼ ¼ ¼½½<br />

¼¼ ¼¼ ¼¼¼<br />

¼¾ ¼¾ ¼¼<br />

¼ ¼¾ ¼½<br />

¼¾¾ ¼ ¼¼¾<br />

¼¼¾¼ ¼½½ ¼¼<br />

½¼<br />

<br />

½¼<br />

<br />

Ê <br />

<br />

Ê <br />

<br />

½<br />

<br />

½<br />

<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.4. COLOR 49<br />

’hls’<br />

’hsi’<br />

’hsv’<br />

’ihs’<br />

min = min(R,G,B)<br />

max = max(R,G,B)<br />

L = (min + max) / 2<br />

if (max == min)<br />

H = 0<br />

S = 0<br />

else<br />

if (L > 0.5)<br />

S = (max - min) / (2 - max - min)<br />

else<br />

S = (max - min) / (max + min)<br />

fi<br />

if (R == max)<br />

H = ((G - B) / (max - min)) * 60<br />

elif (G == max)<br />

H = (2 + (B - R) / (max - min)) * 60<br />

elif (B == max)<br />

H = (4 + (R - G) / (max - min)) * 60<br />

fi<br />

fi<br />

¼ ½<br />

Å ½<br />

Å ¾<br />

Á½<br />

¼<br />

À Ë<br />

Á<br />

¼<br />

<br />

<br />

<br />

Ô<br />

¾<br />

<br />

¼<br />

½ ¼<br />

<br />

Ô<br />

½<br />

<br />

Ô<br />

½<br />

¾<br />

½Ô<br />

¿<br />

½ Ô¿<br />

½<br />

½<br />

Ô<br />

½<br />

<br />

Ô<br />

½ <br />

¾<br />

<br />

Ô¿<br />

Ž<br />

ÖØÒ<br />

Ô Å¾<br />

Å ½¾ · Å ¾ ¾<br />

Á½ £ Ô ¿<br />

min = min(R,G,B)<br />

max = max(R,G,B)<br />

V = max<br />

if (max == min)<br />

S = 0<br />

H = 0<br />

else<br />

S = (max - min) / max<br />

if (R == max)<br />

H = ((G - B) / (max - min)) * 60<br />

elif (G == max)<br />

H = (2 + (B - R) / (max - min)) * 60<br />

elif (B == max)<br />

H = (4 + (R - G) / (max - min)) * 60<br />

fi<br />

fi<br />

¼<br />

Ê <br />

<br />

min = min(R,G,B)<br />

max = max(R,G,B)<br />

I = (R + G + B) / 3<br />

if (I == 0)<br />

H = 0<br />

S = 1<br />

else<br />

S = 1 - min / I<br />

if (S == 0)<br />

H = 0<br />

else<br />

A = (R + R - G - B) / 2<br />

B = (R - G) * (R - G) + (R - B) * (G - B)<br />

½<br />

<br />

½<br />

<br />

<strong>HALCON</strong> 6.0


50 CHAPTER 3. FILTER<br />

C = sqrt(B)<br />

if (C == 0)<br />

H = 0<br />

else<br />

H = acos(A / C)<br />

fi<br />

if (B > G)<br />

H = 2 * pi - H<br />

fi<br />

fi<br />

fi<br />

’isfeuklid’ min = min(R,G,B)<br />

max = max(R,G,B)<br />

I = sqrt(R * R + G * G + B * B) / sqrt(3)<br />

if (I == 0)<br />

S = 0<br />

F = 0<br />

else<br />

S = acos(max(1, (R + G + B) / (I * 3))) / (pi / 2)<br />

if (R == min)<br />

F = acos(max(1, B / sqrt(G * G + B * B)))<br />

/ (pi * 3 / 2) + 1 / 3<br />

elif (G == min)<br />

F = acos(max(1, R / sqrt(B * B + R * R)))<br />

/ (pi * 3 / 2) + 2 / 3<br />

else<br />

F = acos(max(1, G / sqrt(R * R + G * G)))<br />

/ (pi * 3 / 2)<br />

fi<br />

fi<br />

’isfdiff’ if (R >= B && B >= G)<br />

I = R<br />

S = R - G<br />

F = (R - B) / 6<br />

elif (R >= G && G >= B)<br />

I = R<br />

S = R - B<br />

F = (2 - (R - G)) / 6<br />

elif (G >= R && R >= B)<br />

I = G<br />

S = G - B<br />

F = (2 + (G - R)) / 6<br />

elif (G >= B && B >= R)<br />

I = G<br />

S = G - R<br />

F = (4 - (G - B)) / 6<br />

elif (B >= G && G >= R)<br />

I = B<br />

S = B - R<br />

F = (4 + (B - G)) / 6<br />

else<br />

I = B<br />

S = B - G<br />

F = (6 + (B - R)) / 6<br />

fi<br />

’cielab’<br />

¼<br />

<br />

<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15<br />

½ ¼<br />

<br />

¼ ¼¾ ¼½<br />

¼¾¾ ¼ ¼¼¾<br />

¼¼¾¼ ¼½½ ¼¼<br />

½¼<br />

<br />

Ê <br />

<br />

½


3.4. COLOR 51<br />

’i1i2i3’<br />

’ciexyz2’<br />

’ciexyz3’<br />

¼<br />

Á½<br />

Á¾<br />

Á¿<br />

¼<br />

<br />

<br />

¼<br />

<br />

<br />

½ ¼<br />

<br />

½<br />

<br />

¼<br />

<br />

½ ¼<br />

<br />

Ä ½½ £ ½ ¿ ½<br />

¼¼ £ <br />

½<br />

¿<br />

´<br />

¼<br />

¾¼¼ £ ´ ½ ¿<br />

<br />

½¼<br />

½ ¿ µ<br />

½<br />

¿<br />

¼¿¿¿ ¼¿¿¿ ¼¿¿¿<br />

½¼ ¼¼ ½¼<br />

¼ ½¼ ¼<br />

¼¾¼ ¼½¼ ¼½¼<br />

¼¿½¼ ¼¼ ¼½½¼<br />

¼¼¼¼ ¼¼ ½¼¾¼<br />

¼½ ¼½ ¼¾¼<br />

¼¾ ¼ ¼½½<br />

¼¼¼¼ ¼¼ ¼<br />

µ<br />

½¼<br />

<br />

½¼<br />

<br />

½¼<br />

<br />

Ê <br />

<br />

Ê <br />

<br />

Ê <br />

<br />

½<br />

<br />

½<br />

<br />

½<br />

<br />

If necessary, certain scalings are performed, e.g., for byte-images [0..1] -¿ [0..255]. In the explanation above all<br />

input and output values, including angles, are assumed to be in the range [0..1].<br />

Parameter<br />

º ImageRed (input object) ...............image(-array) Hobject : byte / int1 / int2 / int4 / real / complex<br />

Input image (red channel).<br />

º ImageGreen (input object) ............image(-array) Hobject : byte / int1 / int2 / int4 / real / complex<br />

Input image (green channel).<br />

º ImageBlue (input object) ..............image(-array) Hobject : byte / int1 / int2 / int4 / real / complex<br />

Input image (blue channel).<br />

º ImageResult1 (output object) . . . . . . image(-array) Hobject * : byte / int1 / int2 / int4 / real / complex<br />

Color-transformed output image (channel 1).<br />

º ImageResult2 (output object) . . . . . . image(-array) Hobject * : byte / int1 / int2 / int4 / real / complex<br />

Color-transformed output image (channel 1).<br />

º ImageResult3 (output object) . . . . . . image(-array) Hobject * : byte / int1 / int2 / int4 / real / complex<br />

Color-transformed output image (channel 1).<br />

º ColorSpace (input control) ...................................................string const char *<br />

Color space of the output image.<br />

Default Value : ’hsv’<br />

Value List : ColorSpace ¾’cielab’, ’hsv’, ’hsi’, ’yiq’, ’argyb’, ’ciexyz’, ’ciexyz2’, ’ciexyz3’, ’hls’, ’ihs’,<br />

’isfeuklid’, ’isfdiff’, ’i1i2i3’<br />

Example<br />

/* Tranformation from rgb to hsv and conversely */<br />

read_image(Image,"patras") ;<br />

disp_color(Image,WindowHandle) ;<br />

decompose3(Image,&Rimage,&Gimage,&Bimage) ;<br />

trans_from_rgb(Rimage,Gimage,Bimage,&Image1,&Image2,&Image3,"hsv") ;<br />

trans_to_rgb(Image1,Image2,Image3,&ImageRed,&ImageGreen,&ImageBlue,"hsv") ;<br />

compose3(ImageRed,ImageGreen,ImageBlue,&Multichannel) ;<br />

disp_color(Multichannel,WindowHandle);<br />

Result<br />

trans from rgb returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can be<br />

set via set system(’no object result’,). If necessary, an exception handling is raised.<br />

<strong>HALCON</strong> 6.0


52 CHAPTER 3. FILTER<br />

Parallelization Information<br />

trans from rgb is reentrant and automatically parallelized (on tuple level, domain level).<br />

decompose3<br />

compose3<br />

rgb1 to gray, rgb3 to gray<br />

trans to rgb<br />

Image filters<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

trans to rgb ( Hobject ImageInput1, Hobject ImageInput2,<br />

Hobject ImageInput3, Hobject *ImageRed, Hobject *ImageGreen,<br />

Hobject *ImageBlue, const char *ColorSpace )<br />

Transform an image from an arbitrary color space to the RGB color space.<br />

trans to rgb transforms an image from an arbitrary color space (ColorSpace) to the RGB color space. The<br />

three channels of the image are passed as three separate images on input and output.<br />

The following transformations are supported:<br />

’yiq’<br />

¼<br />

Ê <br />

<br />

½ ¼<br />

<br />

¼ ¼¾ ¼½<br />

¼ ¼¾¾¼ ¼¿¾<br />

¼ ½½¼½ ½¼<br />

½¼<br />

<br />

Á<br />

É<br />

½<br />

<br />

’argyb’<br />

¼<br />

Ê <br />

<br />

½ ¼<br />

<br />

½¼¼ ½¾ ¼¾¾<br />

½¼¼ ¼½ ¼¾¾<br />

½¼¼ ¼¾ ½<br />

½¼<br />

<br />

Ê<br />

<br />

½<br />

<br />

’ciexyz’<br />

¼<br />

Ê <br />

<br />

½ ¼<br />

<br />

¾¼ ½½ ¼¾<br />

½½½ ¾¼¾ ¼¼¿¿<br />

¼½¿ ¼¿¿¿ ½½¼<br />

½¼<br />

<br />

<br />

<br />

½<br />

<br />

’hls’ Hi = integer(H * 6)<br />

Hf = fraction(H * 6)<br />

if (L


3.4. COLOR 53<br />

’hsi’<br />

elif (Hi == 1)<br />

R = min + (1 - Hf) * (max - min)<br />

G = max<br />

B = min<br />

elif (Hi == 2)<br />

R = min<br />

G = max<br />

B = min + Hf * (max - min)<br />

elif (Hi == 3)<br />

R = min<br />

G = min + (1 - Hf) * (max - min)<br />

B = max<br />

elif (Hi == 4)<br />

R = min + Hf * (max - min)<br />

G = min<br />

B = max<br />

elif (Hi == 5)<br />

R = max<br />

G = min<br />

B = min + (1 - Hf) * (max - min)<br />

fi<br />

fi<br />

Å ½Ë £ ×Ò À<br />

Å ¾Ë £ Ó× À<br />

¼<br />

Ê <br />

<br />

½ ¼<br />

<br />

<br />

<br />

Á½ Á Ô<br />

¿<br />

Ô<br />

¾<br />

¼ <br />

Ô<br />

½ Ô¾<br />

½ Ô¿<br />

½<br />

<br />

½<br />

Ô<br />

<br />

½ Ô<br />

¾<br />

½<br />

Ô<br />

½<br />

¿<br />

<br />

<br />

Ô¿<br />

½<br />

¼<br />

Å ½<br />

Å ¾<br />

Á½<br />

½<br />

<br />

’hsv’ if (S == 0)<br />

if (H == 0)<br />

R = V<br />

G = V<br />

B = V<br />

else<br />

R = 0<br />

G = 0<br />

B = 0<br />

fi<br />

else<br />

Hi = integer(H)<br />

Hf = fraction(H)<br />

if (Hi == 0)<br />

R = V<br />

G = V * (1 - (S * (1 - Hf)))<br />

B = V * (1 - S)<br />

elif (Hi == 1)<br />

R = V * (1 - (S * Hf))<br />

G = V<br />

B = V * (1 - S)<br />

elif (Hi == 2)<br />

R = V * (1 - S)<br />

G = V<br />

B = V * (1 - (S * (1 - Hf)))<br />

elif (Hi == 3)<br />

<strong>HALCON</strong> 6.0


54 CHAPTER 3. FILTER<br />

fi<br />

R = V * (1 - S)<br />

G = V * (1 - (S * Hf))<br />

B = V<br />

elif (Hi == 4)<br />

R = V * (1 - (S * (1 - Hf)))<br />

G = V * (1 - S)<br />

B = V<br />

elif (Hi == 5)<br />

R = V<br />

G = V * (1 - S)<br />

B = V * (1 - (S * Hf))<br />

fi<br />

If necessary, certain scalings are performed, e.g., for byte-images [0..1] -¿ [0..255]. In the explanation above all<br />

input and output values, including angles, are assumed to be in the range [0..1].<br />

Parameter<br />

º ImageInput1 (input object) ...............................image(-array) Hobject : byte / int4 / real<br />

Input image (channel 1).<br />

º ImageInput2 (input object) ...............................image(-array) Hobject : byte / int4 / real<br />

Input image (channel 2).<br />

º ImageInput3 (input object) ...............................image(-array) Hobject : byte / int4 / real<br />

Input image (channel 3).<br />

º ImageRed (output object) ................................image(-array) Hobject * : byte / int4 / real<br />

Red channel.<br />

º ImageGreen (output object) .............................image(-array) Hobject * : byte / int4 / real<br />

Green channel.<br />

º ImageBlue (output object) ..............................image(-array) Hobject * : byte / int4 / real<br />

Blue channel.<br />

º ColorSpace (input control) ...................................................string const char *<br />

Color space of the input image.<br />

Default Value : ’hsv’<br />

Value List : ColorSpace ¾’hsi’, ’yiq’, ’argyb’, ’ciexyz’, ’hls’, ’hsv’<br />

Example<br />

/* Tranformation from rgb to hsv and conversely */<br />

read_image(Image,"patras") ;<br />

disp_color(Image,WindowHandle) ;<br />

decompose3(Image,&Rimage,&Gimage,&Bimage) ;<br />

trans_from_rgb(Rimage,Gimage,Bimage,&Image1,&Image2,&Image3,"hsv") ;<br />

trans_to_rgb(Image1,Image2,Image3,&ImageRed,&ImageGreen,&ImageBlue,"hsv") ;<br />

compose3(ImageRed,ImageGreen,ImageBlue,&Multichannel) ;<br />

disp_color(Multichannel,WindowHandle);<br />

Result<br />

trans to rgb returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can be<br />

set via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

trans to rgb is reentrant and automatically parallelized (on tuple level, domain level).<br />

decompose3<br />

compose3, disp color<br />

decompose3<br />

Image filters<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.5. EDGES 55<br />

3.5 Edges<br />

close edges ( Hobject Edges, Hobject EdgeImage, Hobject *RegionResult,<br />

long MinAmplitude )<br />

Close edge gaps using the edge amplitude image.<br />

close edges closes gaps in the output of an edge detector, and thus tries to produce complete object contours.<br />

This is done by examining the neighbors of each edge point to determine the point with maximum amplitude (i.e.,<br />

maximum gradient), and adding the point to the edge if its amplitude is larger than the minimum amplitude passed<br />

in MinAmplitude. This operator expects as input the edges (Edges) and amplitude image (EdgeImage)<br />

returned by typical edge operators, such as edges image or sobel amp. close edges does not take into<br />

account the edge directions that may be returned by an edge operator. Thus, in areas where the gradient is almost<br />

constant the edges may become rather “wiggly.”<br />

Parameter<br />

º Edges (input object) .......................................................region(-array) Hobject<br />

Region containing one pixel thick edges.<br />

º EdgeImage (input object) ...................................................image Hobject : byte<br />

Edge amplitude (gradient) image.<br />

º RegionResult (output object) ...........................................region(-array) Hobject *<br />

Region containing closed edges.<br />

º MinAmplitude (input control) ......................................................integer long<br />

Minimum edge amplitude.<br />

Default Value : 16<br />

Value Suggestions : MinAmplitude ¾5, 8, 10, 12, 16, 20, 25, 30, 40, 50<br />

Typical Range of Values : 1 MinAmplitude 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : MinAmplitude 0<br />

Example<br />

sobel_amp(Image,&EdgeAmp,"sum_abs",5);<br />

threshold(EdgeAmp,&EdgeRegion,40.0,255.0);<br />

skeleton(EdgeRegion,&ThinEdge);<br />

close_edge1(ThinEdge,EdgeAmp,&CloseEdges,15);<br />

skeleton(CloseEdges,&ThinCloseEdges);<br />

Result<br />

close edges returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can be set<br />

via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

close edges is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

edges image, sobel amp, threshold, skeleton<br />

skeleton<br />

Possible Successor Functions<br />

Alternatives<br />

close edges length, dilation1, closing<br />

gray skeleton<br />

Image filters<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


56 CHAPTER 3. FILTER<br />

close edges length ( Hobject Edges, Hobject Gradient,<br />

Hobject *ClosedEdges, long MinAmplitude, long MaxGapLength )<br />

Close edge gaps using the edge amplitude image.<br />

close edges length closes gaps in the output of an edge detector, and thus tries to produce complete object<br />

contours. This operator expects as input the edges (Edges) and amplitude image (Gradient) returned by typical<br />

edge operators, such as edges image or sobel amp.<br />

Contours are closed in two steps: First, one pixel wide gaps in the input contours are closed, and isolated points are<br />

eliminated. After this, open contours are extended by up to MaxGapLength points by adding edge points until<br />

either the contour is closed or no more significant edge points can be found. A gradient is regarded as significant if<br />

it is larger than MinAmplitude. The neighboring points examined as possible new edge points are the point in<br />

the direction of the contour and its two adjacent points in an 8-neighborhood. For each of these points, the sum of<br />

its gradient and the maximum gradient of that points three possible neighbors is calculated (look ahead of length<br />

1). The point with the maximum sum is then chosen as the new edge point.<br />

Attention<br />

In the current implementation MinAmplitude is ignored; any gradient value larger than zero is regarded as<br />

significant.<br />

Parameter<br />

º Edges (input object) .......................................................region(-array) Hobject<br />

Region containing one pixel thick edges.<br />

º Gradient (input object) .....................................................image Hobject : byte<br />

Edge amplitude (gradient) image.<br />

º ClosedEdges (output object) ............................................region(-array) Hobject *<br />

Region containing closed edges.<br />

º MinAmplitude (input control) ......................................................integer long<br />

Minimum edge amplitude.<br />

Default Value : 16<br />

Value Suggestions : MinAmplitude ¾5, 8, 10, 12, 16, 20, 25, 30, 40, 50<br />

Typical Range of Values : 1 MinAmplitude 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : MinAmplitude 0<br />

º MaxGapLength (input control) ......................................................integer long<br />

Maximal number of points by which edges are extended.<br />

Default Value : 3<br />

Value Suggestions : MaxGapLength ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 20, 30, 40, 50, 70, 100<br />

Typical Range of Values : 1 MaxGapLength 200<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : MaxGapLength 0<br />

Example<br />

sobel_amp(Image,&EdgeAmp,"sum_abs",5);<br />

threshold(EdgeAmp,&EdgeRegion,40.0,255.0);<br />

skeleton(EdgeRegion,&ThinEdge);<br />

close_edge2(ThinEdge,EdgeAmp,&CloseEdges,15,3);<br />

Result<br />

close edges length returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour<br />

can be set via set system(’no object result’,). If necessary, an exception handling is<br />

raised.<br />

Parallelization Information<br />

close edges length is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

edges image, sobel amp, threshold, skeleton<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.5. EDGES 57<br />

close edges, dilation1, closing<br />

Alternatives<br />

Bibliography<br />

M. Üsbeck: “Untersuchungen zur echtzeitfähigen Segmentierung”; Studienarbeit, Bayerisches Forschungszentrum<br />

für Wissensbasierte Systeme (FORWISS), Erlangen, 1993.<br />

Image filters<br />

Module<br />

derivate gauss ( Hobject Image, Hobject *DerivGauss, double Sigma,<br />

const char *Component )<br />

Convolve an image with derivatives of the Gaussian.<br />

derivate gauss convolves an image with the derivatives of a Gaussian and calculates various features derived<br />

thereof. Possible values for Component are:<br />

’none’ Smoothing only.<br />

’x’ First derivative along x.<br />

’y’ First derivative along y.<br />

’gradient’ Absolute value of the gradient.<br />

¼´Ü ݵ <br />

¼´Ü ݵ <br />

¼´Ü ݵ <br />

´Ü ݵ<br />

Ü<br />

´Ü ݵ<br />

Ý<br />

×<br />

´Ü ݵ ¾<br />

Ü<br />

´Ü ݵ ¾<br />

Ý<br />

’xx’ Second derivative along x.<br />

’yy’ Second derivative along y.<br />

’xy’ Second derivative along x and y.<br />

’xxx’ Third derivative along x.<br />

’yyy’ Third derivative along y.<br />

’xxy’ Third derivative along x, x and y.<br />

’xyy’ Third derivative along x, y and y.<br />

’det’ Determinant of the Hessian matrix:<br />

¼´Ü ݵ ¾ ´Ü ݵ<br />

Ü ¾<br />

¼´Ü ݵ ¾ ´Ü ݵ<br />

Ý ¾<br />

¼´Ü ݵ ¾ ´Ü ݵ<br />

ÜÝ<br />

¼´Ü ݵ ¿ ´Ü ݵ<br />

Ü ¿<br />

¼´Ü ݵ ¿ ´Ü ݵ<br />

Ý ¿<br />

¼´Ü ݵ ¿ ´Ü ݵ<br />

Ü ¾ Ý<br />

¼´Ü ݵ ¿ ´Ü ݵ<br />

ÜÝ ¾<br />

Ì ¾ ´Ü ݵ ¾ ´Ü ݵ<br />

Ü ¾ Ý ¾<br />

<br />

¾ ´Ü ݵ<br />

ÝÜ<br />

¾<br />

<strong>HALCON</strong> 6.0


58 CHAPTER 3. FILTER<br />

’laplace’ Laplace operator (trace of the Hessian matrix):<br />

’mean curvatue’ Mean curvature À<br />

ÌÊ ¾ ´Ü ݵ<br />

Ü ¾ · ¾ ´Ü ݵ<br />

Ý ¾<br />

´½ ·<br />

¾<br />

´½ ·<br />

´Ü ݵ¾<br />

µ ¾ ´Ü ݵ<br />

Ü Ý ¾<br />

´Ü ݵ<br />

Ü<br />

´Ü ݵ¾<br />

´½ ·<br />

Ü<br />

À · <br />

<br />

´Ü ݵ ¾ ´Ü ݵ<br />

Ý ÝÜ<br />

´Ü ݵ¾<br />

µ ¾ ´Ü ݵ<br />

Ý Ü ¾<br />

·<br />

À ½ ¾ ´ ÑÒ · ÑÜ µ<br />

´Ü ݵ¾<br />

µ ¿ ¾<br />

Ý<br />

’gauss curvatue’ Gaussian curvature Ã<br />

’eigenvalue1’ First eigenvalue<br />

à <br />

´½ · ´Üݵ¾<br />

Ü<br />

Ì<br />

· ´Üݵ¾<br />

Ý<br />

µ ¾<br />

’eigenvalue2’ Second eigenvalue<br />

<br />

<br />

½ ·<br />

¾ ´Üݵ<br />

Ü ¾<br />

×<br />

· ¾ ´Üݵ<br />

Ý ¾<br />

¾<br />

¾ ´¾ ´Ü ݵ ¾ ´Ü ݵ<br />

Ü ¾ Ý ¾<br />

¾ ´Ü ݵ ¾<br />

µ<br />

ÝÜ<br />

<br />

<br />

¾ <br />

¾ ´Üݵ<br />

Ü ¾<br />

’main1 curvature’ First principal curvature<br />

×<br />

’main2 curvature’ Second principal curvature<br />

· ¾ ´Üݵ<br />

Ý ¾<br />

¾<br />

¾ ´¾ ´Ü ݵ ¾ ´Ü ݵ<br />

Ü ¾ Ý ¾<br />

ÑÜ À ·<br />

Ô<br />

À<br />

¾<br />

Ã<br />

ÑÒ À<br />

Ô<br />

À<br />

¾<br />

Ã<br />

’kitchen rosenfeld’ Second derivative perpendicular to the gradient<br />

<br />

¾ ´Üݵ ´Üݵ ¾<br />

Ü ¾ Ý<br />

’2nd ddg’ Second derivative along the gradient<br />

<br />

¾ ´Üݵ ´Üݵ ¾<br />

Ü ¾ Ü<br />

· ¾ ´Üݵ ´Üݵ ¾<br />

Ý ¾<br />

´Üݵ ¾<br />

Ü<br />

Ü<br />

¾ ¾ ´Üݵ<br />

ÝÜ<br />

· ´Üݵ¾<br />

Ý<br />

·¾ ´Üݵ ´Üݵ<br />

Ü Ý<br />

´Üݵ ¾<br />

Ü<br />

¾ ´Üݵ<br />

ÝÜ<br />

· ´Üݵ¾<br />

Ý<br />

’de saint venant’ Second derivative along and perpendicular to the gradient<br />

<br />

´Üݵ<br />

Ü<br />

´Üݵ<br />

Ý<br />

´ ¾ ´Üݵ<br />

Ü ¾<br />

¾ ´Üݵ<br />

Ý ¾ µ ´ ´Üݵ¾<br />

Ü<br />

´Üݵ ¾<br />

Ü<br />

· ´Üݵ¾<br />

Ý<br />

¾ ´Ü ݵ ¾<br />

µ<br />

ÝÜ<br />

´Üݵ ¾<br />

Ü<br />

´Üݵ ¾<br />

Ý<br />

· ¾ ´Üݵ ´Üݵ ¾<br />

Ý ¾ Ý<br />

´Üݵ ¾<br />

Ý<br />

µ ¾ ´Üݵ<br />

ÜÝ<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.5. EDGES 59<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real<br />

Input image.<br />

º DerivGauss (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : real<br />

Filtered result image.<br />

º Sigma (input control) .................................................................real double<br />

Sigma of the Gaussian.<br />

Default Value : 1.0<br />

Value Suggestions : Sigma ¾0.7, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0<br />

Typical Range of Values : 0.2 Sigma 50.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Sigma 0.0<br />

º Component (input control) .....................................................string const char *<br />

Derivative or feature to be calculated.<br />

Default Value : ’x’<br />

Value List : Component ¾’none’, ’x’, ’y’, ’gradient’, ’xx’, ’yy’, ’xy’, ’xxx’, ’yyy’, ’xxy’, ’xyy’, ’det’,<br />

’mean curvature’, ’gauss curvature’, ’eigenvalue1’, ’eigenvalue2’, ’main1 curvature’, ’main2 curvature’,<br />

’kitchen rosenfeld’, ’zuniga haralick’, ”2nd ddg”, ’de saint venant’, ’area’, ’laplace’, ’gradient dir’,<br />

’eigenvec dir’<br />

read_image(&Image,"mreut");<br />

derivate_gauss(Image,&Gauss,3.0,"x");<br />

zero_crossing(Gauss,&ZeroCrossings);<br />

Example<br />

Parallelization Information<br />

derivate gauss is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

zero crossing, dual threshold<br />

Possible Successor Functions<br />

Alternatives<br />

laplace, laplace of gauss, gauss image, smooth image<br />

zero crossing, dual threshold<br />

See Also<br />

Bibliography<br />

K. Voss H. Süse; “Praktische Bildverarbeitung” Hanser Verlag; München, Wien; 1991; Seite 88.<br />

Image filters<br />

Module<br />

diff of gauss ( Hobject Image, Hobject *DiffOfGauss, double Sigma,<br />

double SigFactor )<br />

Approximate the LoG operator (Laplace of Gaussian).<br />

diff of gauss approximates the Laplace-of-Gauss operator by a difference of Gaussians. The standard deviations<br />

of these Gaussians can be calculated, according to Marr, from the Parameter Sigma of the LoG and the ratio<br />

of the two standard deviations (SigFactor)as:<br />

×ѽ <br />

Ö<br />

ËÑ<br />

¾ ÐÓ ´ ½<br />

Ë ØÓÖ µ<br />

ËØÓÖ ¾ ½<br />

×Ѿ <br />

×ѽ<br />

ËØÓÖ<br />

ÇÙ×× ´ÁÑ £ Ù××´×ѽµµ ´ÁÑ £ Ù××´×Ѿµµ<br />

<strong>HALCON</strong> 6.0


60 CHAPTER 3. FILTER<br />

For a ËØÓÖ ½, according to Marr, an approximation to the Mexican-Hat-Operator results. The resulting<br />

image is stored in DiffOfGauss.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Input image<br />

º DiffOfGauss (output object) . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * :int2<br />

LoG image.<br />

º Sigma (input control) .................................................................real double<br />

Smoothing parameter of the Laplace operator to approximate.<br />

Default Value : 3.0<br />

Value Suggestions : Sigma ¾2.0, 3.0, 4.0, 5.0<br />

Typical Range of Values : 0.2 Sigma 50.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Sigma 0.0<br />

º SigFactor (input control) ...........................................................real double<br />

Ratio of the standard deviations used (Marr recommends 1.6).<br />

Default Value : 1.6<br />

Typical Range of Values : 0.1 SigFactor 10.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : SigFactor 0.0<br />

Example<br />

read_image(&Image,"mreut");<br />

diff_of_gauss(Image,&Laplace,2.0,1.6);<br />

zero_crossing(Laplace,&ZeroCrossings);<br />

Complexity<br />

The execution time depends linearly on the number of pixels and the size of sigma.<br />

Result<br />

diff of gauss returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can be<br />

set via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

diff of gauss is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

zero crossing, dual threshold<br />

laplace, derivate gauss<br />

Possible Successor Functions<br />

Alternatives<br />

Bibliography<br />

D. Marr: “Vision (A computational investigation into human representation and processing of visual information)”;<br />

New York, W.H. Freeman and Company; 1982.<br />

Module<br />

Image filters<br />

edges image ( Hobject Image, Hobject *ImaAmp, Hobject *ImaDir,<br />

const char *Filter, double Alpha, const char *NMS, long Low, long High )<br />

Extract edges using Deriche, Lanser, Shen, or Canny filters.<br />

edges image detects step edges using recursively implemented filters (according to Deriche, Lanser and Shen)<br />

or the conventionally implemented “derivative of Gaussian” filter (using filter masks) proposed by Canny. Thus,<br />

the following edge operators are available:<br />

’deriche1’, ’lanser1’, ’deriche1 int4’, ’deriche2’, ’lanser2’, ’lanser2 int4’, ’shen’, ’mshen’, and ’canny’ (parameter<br />

Filter).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.5. EDGES 61<br />

The edge amplitudes (gradient magnitude) and directions are returned in ImaAmp and ImaDir, respectively. The<br />

edge operator ’lanser2’ is also available for int4-images, and returns the signed filter response instead of its absolute<br />

value. This behavior can be obtained for byte-images as well by selecting ’lanser2 int4’ as filter. This can be used<br />

to calculate the second derivative of an image by applying edges image (with parameter ’lanser2’) to the signed<br />

first derivative. Edge directions are stored in 2-degree steps, i.e., an edge direction of Ü degrees with respect to the<br />

horizontal axis is stored as ܾ in the edge direction image. Furthermore, the direction of the change of intensity<br />

is taken into account. Let Ü Ý ℄ denote the image gradient. Then the following edge directions are returned as<br />

Ö¾:<br />

intensity increase<br />

Ü Ý<br />

edge direction Ö<br />

from bottom to top ¼· ¼<br />

from lower right to upper left · ℄¼ ¼<br />

from right to left ·¼ ¼<br />

from upper right to lower left ·· ℄¼ ½¼<br />

from top to bottom ¼· ½¼<br />

from upper left to lower right · ℄½¼ ¾¼<br />

from left to right ·¼ ¾¼<br />

from lower left to upper right ℄¾¼ ¿¼<br />

Points with edge amplitude 0 are assigned the edge direction 255 (undefined direction).<br />

The “filter width” (i.e., the amount of smoothing) can be chosen arbitrarily, and can be estimated by calling<br />

T info edges for concrete values of the parameter Alpha. It decreases for increasing Alpha for the Deriche,<br />

Lanser and Shen filters and increases for the Canny filter, where it is the standard deviation of the Gaussian on<br />

which the Canny operator is based. “Wide” filters exhibit a larger invariance to noise, but also a decreased ability<br />

to detect small details. Non-recursive filters, such as the Canny filter, are realized using filter masks, and thus the<br />

execution time increases for increasing filter width. In contrast, the execution time for recursive filters does not<br />

depend on the filter width. Thus, arbitrary filter widths are possible using the Deriche, Lanser and Shen filters<br />

without increasing the run time of the operator. The resulting advantage in speed compared to the Canny operator<br />

naturally increases for larger filter widths. As border treatment, the recursive operators assume that the images to<br />

be zero outside of the image, while the Canny operator repeats the gray value at the image’s border. Comparable<br />

filter widths can be obtained by the following choices of Alpha:<br />

ÐÔ´¼ÐÒ×Ö½ ¼ µ ÐÔ´¼Ö½ ¼ µ¾<br />

ÐÔ´¼Ö¾ ¼ µ ÐÔ´¼Ö½ ¼ µ¾<br />

ÐÔ´¼ÐÒ×Ö¾ ¼ µ ÐÔ´¼Ö½ ¼ µ¾<br />

ÐÔ´¼×Ò ¼ µ ÐÔ´¼Ö½ ¼ µ¾<br />

ÐÔ´¼Ñ×Ò ¼ µ ÐÔ´¼Ö½ ¼ µ¾<br />

ÐÔ´¼Ù×× ¼ µ ½ÐÔ´¼Ö½ ¼ µ<br />

The originally proposed recursive filters (’deriche1’, ’deriche2’, ’shen’) return a biased estimate of the amplitude<br />

of diagonal edges. This bias is removed in the corresponding modified version of the operators (’lanser1’, ’lanser2’<br />

und ’mshen’), while maintaining the same execution speed.<br />

For relatively small filter widths (½½ ¢ ½½), i.e., for Alpha (’lanser2’ = 0.5), all filters yield similar results. Only for<br />

“wider” filters differences begin to appear: the Shen filters begin to yield qualitatively inferior results. However,<br />

they are the fastest of the implemented operators — closely followed by the Deriche operators.<br />

edges image optionally offers to apply a non-maximum-suppression (NMS = ’nms’/’inms’/’hvnms’; ’none’ if<br />

not desired) and hysteresis threshold operation (Low,High; at least one negative if not desired) to the resulting<br />

edge image. Conceptually, this corresponds to the following calls:<br />

nonmax suppression dir(...,NMS,...) º<br />

hysteresis threshold(...,Low,High,999,...)<br />

However, this calling sequence would return appropriately modified regions, whereas edges image marks suppressed<br />

edge points by 0 in the amplitude and 255 in the direction image, while leaving the region of the image<br />

unchanged.<br />

<strong>HALCON</strong> 6.0


62 CHAPTER 3. FILTER<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int4 / int2<br />

Input image.<br />

º ImaAmp (output object) . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int4 / int2<br />

Edge amplitude (gradient magnitude) image.<br />

º ImaDir (output object) .........................................image(-array) Hobject * : direction<br />

Edge direction image.<br />

º Filter (input control) .........................................................string const char *<br />

Edge operator to be applied.<br />

Default Value : ’lanser2’<br />

Value List : Filter ¾’deriche1’, ’lanser1’, ’deriche1 int4’, ’deriche2’, ’lanser2’, ’lanser2 int4’, ’shen’,<br />

’mshen’, ’canny’<br />

º Alpha (input control) .................................................................real double<br />

Filter parameter: small values result in strong smoothing, and thus less detail (opposite for ’canny’).<br />

Default Value : 0.5<br />

Value Suggestions : Alpha ¾0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 0.9, 1.1<br />

Typical Range of Values : 0.2 Alpha 50.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Alpha 0.0<br />

º NMS (input control) .............................................................string const char *<br />

Non-maximum suppression (’none’, if not desired).<br />

Default Value : ’nms’<br />

Value List : NMS ¾’nms’, ’inms’, ’hvnms’, ’none’<br />

º Low (input control) ...................................................................integer long<br />

Lower threshold for the hysteresis threshold operation (negative, if no thresholding is desired).<br />

Default Value : 20<br />

Value Suggestions : Low ¾5, 10, 15, 20, 25, 30, 40<br />

Typical Range of Values : 1 Low 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

Restriction : ´Low 1µ ´Low 0µ<br />

º High (input control) .................................................................integer long<br />

Upper threshold for the hysteresis threshold operation (negative, if no thresholding is desired).<br />

Default Value : 40<br />

Value Suggestions : High ¾10, 15, 20, 25, 30, 40, 50, 60, 70<br />

Typical Range of Values : 1 High 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

Restriction : ´´High 1µ ´High 0µµ ´High Lowµ<br />

Example<br />

read_image(&Image,"fabrik");<br />

edges_image(Image,&Amp,&Dir,"lanser2",0.5,"none",-1,-1);<br />

hysteresis_threshold(Amp,&Margin,20,30,30);<br />

Result<br />

edges image returns H MSG TRUE if all parameters are correct and no error occurs during execution. If the<br />

input is empty the behaviour can be set via set system(’no object result’,). If necessary,<br />

an exception handling is raised.<br />

Parallelization Information<br />

edges image is reentrant and automatically parallelized (on tuple level, channel level).<br />

T info edges<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

threshold, hysteresis threshold, close edges length<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.5. EDGES 63<br />

Alternatives<br />

sobel dir, frei dir, kirsch dir, prewitt dir, robinson dir<br />

See Also<br />

T info edges, nonmax suppression amp, hysteresis threshold, bandpass image<br />

Bibliography<br />

S.Lanser, W.Eckstein: “Eine Modifikation des Deriche-Verfahrens zur Kantendetektion”; 13. DAGM-Symposium,<br />

München; Informatik Fachberichte 290; Seite 151 - 158; Springer-Verlag; 1991.<br />

S.Lanser: “Detektion von Stufenkanten mittels rekursiver Filter nach Deriche”; Diplomarbeit; Technische Universität<br />

München, Institut für Informatik, Lehrstuhl Prof. Radig; 1991.<br />

J.Canny: “Finding Edges and Lines in Images”; Report, AI-TR-720; M.I.T. Artificial Intelligence Lab., Cambridge;<br />

1983.<br />

J.Canny: “A Computational Approach to Edge Detection”; IEEE Transactions on Pattern Analysis and Machine<br />

Intelligence; PAMI-8, vol. 6; S. 679-698; 1986.<br />

R.Deriche: “Using Canny’s Criteria to Derive a Recursively Implemented Optimal Edge Detector”; International<br />

Journal of Computer Vision; vol. 1, no. 2; S. 167-187; 1987.<br />

R.Deriche: “Optimal Edge Detection Using Recursive Filtering”; Proc. of the First International Conference on<br />

Computer Vision, London; S. 501-505; 1987.<br />

R.Deriche: “Fast Algorithms for Low-Level Vision”; IEEE Transactions on Pattern Analysis and Machine Intelligence;<br />

PAMI-12, no. 1; S. 78-87; 1990.<br />

S.Castan, J.Zhao und J.Shen: “Optimal Filter for Edge Detection Methods and Results”; Proc. of the First European<br />

Conference on Computer Vision, Antibes; Lecture Notes on computer Science; no. 427; S. 12-17; Springer-<br />

Verlag; 1990.<br />

Module<br />

Image filters<br />

edges sub pix ( Hobject Image, Hobject *Edges, const char *Filter,<br />

double Alpha, long Low, long High )<br />

Extract sub-pixel precise edges using Deriche, Lanser, Shen, or Canny filters.<br />

edges sub pix detects step edges using recursively implemented filters (according to Deriche, Lanser and Shen)<br />

or the conventionally implemented “derivative of Gaussian” filter (using filter masks) proposed by Canny. Thus,<br />

the following edge operators are available:<br />

’deriche1’, ’lanser1’, ’deriche1 int4’, ’deriche2’, ’lanser2’, ’lanser2 int4’, ’shen’, ’mshen’, and ’canny’<br />

(parameter Filter).<br />

The extracted edges are returned as sub-pixel precise XLD contours in Edges. For each edge point the following<br />

attributes are defined (see get contour attrib xld):<br />

’angle’ Edge direction (modulo )<br />

’response’ Edge amplitude (gradient magnitude)<br />

The “filter width” (i.e., the amount of smoothing) can be chosen arbitrarily, and can be estimated by calling<br />

T info edges for concrete values of the parameter Alpha. It decreases for increasing Alpha for the Deriche,<br />

Lanser and Shen filters and increases for the Canny filter, where it is the standard deviation of the Gaussian on<br />

which the Canny operator is based. “Wide” filters exhibit a larger invariance to noise, but also a decreased ability<br />

to detect small details. Non-recursive filters, such as the Canny filter, are realized using filter masks, and thus the<br />

execution time increases for increasing filter width. In contrast, the execution time for recursive filters does not<br />

depend on the filter width. Thus, arbitrary filter widths are possible using the Deriche, Lanser and Shen filters<br />

without increasing the run time of the operator. The resulting advantage in speed compared to the Canny operator<br />

naturally increases for larger filter widths. As border treatment, the recursive operators assume that the images to<br />

be zero outside of the image, while the Canny operator repeats the gray value at the image’s border. Comparable<br />

filter widths can be obtained by the following choices of Alpha:<br />

<strong>HALCON</strong> 6.0


64 CHAPTER 3. FILTER<br />

ÐÔ´¼ÐÒ×Ö½ ¼ µ ÐÔ´¼Ö½ ¼ µ¾<br />

ÐÔ´¼Ö¾ ¼ µ ÐÔ´¼Ö½ ¼ µ¾<br />

ÐÔ´¼ÐÒ×Ö¾ ¼ µ ÐÔ´¼Ö½ ¼ µ¾<br />

ÐÔ´¼×Ò ¼ µ ÐÔ´¼Ö½ ¼ µ¾<br />

ÐÔ´¼Ñ×Ò ¼ µ ÐÔ´¼Ö½ ¼ µ¾<br />

ÐÔ´¼Ù×× ¼ µ ½ÐÔ´¼Ö½ ¼ µ<br />

The originally proposed recursive filters (’deriche1’, ’deriche2’, ’shen’) return a biased estimate of the amplitude<br />

of diagonal edges. This bias is removed in the corresponding modified version of the operators (’lanser1’, ’lanser2’<br />

und ’mshen’), while maintaining the same execution speed.<br />

For relatively small filter widths (½½ ¢ ½½), i.e., for Alpha (’lanser2’ = 0.5), all filters yield similar results. Only for<br />

“wider” filters differences begin to appear: the Shen filters begin to yield qualitatively inferior results. However,<br />

they are the fastest of the implemented operators — closely followed by the Deriche operators.<br />

edges sub pix links the edge points into edges by using an algorithm similar to a hysteresis threshold operation,<br />

whichisalsousedinlines gauss. Points with an amplitude larger than High are immediately accepted as<br />

belonging to an edge, while points with an amplitude smaller than Low are rejected. All other points are accepted<br />

as edges if they are connected to accepted edge points (see also lines gauss and hysteresis threshold).<br />

Parameter<br />

º Image (input object) .........................................................image Hobject : byte<br />

Input image.<br />

º Edges (output object) ....................................................xld cont-array Hobject *<br />

Extracted edges.<br />

º Filter (input control) .........................................................string const char *<br />

Edge operator to be applied.<br />

Default Value : ’lanser2’<br />

Value List : Filter ¾’deriche1’, ’lanser1’, ’deriche2’, ’lanser2’, ’shen’, ’mshen’, ’canny’, ’sobel’<br />

º Alpha (input control) .................................................................real double<br />

Filter parameter: small values result in strong smoothing, and thus less detail (opposite for ’canny’).<br />

Default Value : 0.5<br />

Value Suggestions : Alpha ¾0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 0.9, 1.1<br />

Typical Range of Values : 0.2 Alpha 50.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Alpha 0.0<br />

º Low (input control) ...................................................................integer long<br />

Lower threshold for the hysteresis threshold operation.<br />

Default Value : 20<br />

Value Suggestions : Low ¾5, 10, 15, 20, 25, 30, 40<br />

Typical Range of Values : 1 Low 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

Restriction : Low 0<br />

º High (input control) .................................................................integer long<br />

Upper threshold for the hysteresis threshold operation.<br />

Default Value : 40<br />

Value Suggestions : High ¾10, 15, 20, 25, 30, 40, 50, 60, 70<br />

Typical Range of Values : 1 High 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

Restriction : ´High 0µ ´High Lowµ<br />

Example<br />

read_image(&Image,"fabrik");<br />

edges_sub_pix(Image,&Edges,"lanser2",0.5,20,40);<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.5. EDGES 65<br />

Result<br />

edges sub pix returns H MSG TRUE if all parameters are correct and no error occurs during execution. If the<br />

input is empty the behaviour can be set via set system(’no object result’,). If necessary,<br />

an exception handling is raised.<br />

Parallelization Information<br />

edges sub pix is reentrant and automatically parallelized (on tuple level).<br />

Alternatives<br />

sobel dir, frei dir, kirsch dir, prewitt dir, robinson dir, edges image<br />

See Also<br />

T info edges, hysteresis threshold, bandpass image, lines gauss, lines facet<br />

Bibliography<br />

S.Lanser, W.Eckstein: “Eine Modifikation des Deriche-Verfahrens zur Kantendetektion”; 13. DAGM-Symposium,<br />

München; Informatik Fachberichte 290; Seite 151 - 158; Springer-Verlag; 1991.<br />

S.Lanser: “Detektion von Stufenkanten mittels rekursiver Filter nach Deriche”; Diplomarbeit; Technische Universität<br />

München, Institut für Informatik, Lehrstuhl Prof. Radig; 1991.<br />

J.Canny: “Finding Edges and Lines in Images”; Report, AI-TR-720; M.I.T. Artificial Intelligence Lab., Cambridge;<br />

1983.<br />

J.Canny: “A Computational Approach to Edge Detection”; IEEE Transactions on Pattern Analysis and Machine<br />

Intelligence; PAMI-8, vol. 6; S. 679-698; 1986.<br />

R.Deriche: “Using Canny’s Criteria to Derive a Recursively Implemented Optimal Edge Detector”; International<br />

Journal of Computer Vision; vol. 1, no. 2; S. 167-187; 1987.<br />

R.Deriche: “Optimal Edge Detection Using Recursive Filtering”; Proc. of the First International Conference on<br />

Computer Vision, London; S. 501-505; 1987.<br />

R.Deriche: “Fast Algorithms for Low-Level Vision”; IEEE Transactions on Pattern Analysis and Machine Intelligence;<br />

PAMI-12, no. 1; S. 78-87; 1990.<br />

S.Castan, J.Zhao und J.Shen: “Optimal Filter for Edge Detection Methods and Results”; Proc. of the First European<br />

Conference on Computer Vision, Antibes; Lecture Notes on computer Science; no. 427; S. 12-17; Springer-<br />

Verlag; 1990.<br />

Module<br />

Sub-pixel operators<br />

frei amp ( Hobject Image, Hobject *ImageEdgeAmp )<br />

Detect edges (amplitude) using the Frei-Chen operator.<br />

frei amp calculates an approximation of the first derivative of the image data and is used as an edge detector.<br />

The filter is based on the following filter masks:<br />

<br />

½ ½ ½<br />

¼ ¼ ¼<br />

½ ½ ½<br />

<br />

½ ¼ ½<br />

½ ¼ ½<br />

½ ¼ ½<br />

The result image contains the maximum response of the masks and .<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Input image.<br />

º ImageEdgeAmp (output object) . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Edge amplitude (gradient magnitude) image.<br />

<strong>HALCON</strong> 6.0


66 CHAPTER 3. FILTER<br />

Example<br />

read_image(&Image,"fabrik");<br />

frei_amp(Image,&Frei_amp);<br />

threshold(Frei_amp,&Edges,128,255);<br />

Result<br />

frei amp always returns H MSG TRUE. If the input is empty the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

frei amp is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

Possible Predecessor Functions<br />

gauss image, sigma image, median image, smooth image<br />

Alternatives<br />

sobel amp, kirsch amp, prewitt amp, robinson amp, roberts<br />

bandpass image, laplace of gauss<br />

Image filters<br />

See Also<br />

Module<br />

frei dir ( Hobject Image, Hobject *ImageEdgeAmp, Hobject *ImageEdgeDir )<br />

Detect edges (amplitude and direction) using the Frei-Chen operator.<br />

frei dir calculates an approximation of the first derivative of the image data and is used as an edge detector.<br />

The filter is based on the following filter masks:<br />

<br />

Ô<br />

½ ¾ ½<br />

¼ ¼ ¼<br />

Ô<br />

½ ¾ ½<br />

<br />

½ ¼ ½<br />

Ô<br />

¾ ¼<br />

Ô<br />

¾<br />

½ ¼ ½<br />

The result image contains the maximum response of the masks and . The edge directions are returned in<br />

ImageEdgeDir, and are stored in 2-degree steps, i.e., an edge direction of Ü degrees with respect to the horizontal<br />

axis is stored as ܾ in the edge direction image. Furthermore, the direction of the change of intensity is taken into<br />

account. Let Ü Ý ℄ denote the image gradient. Then the following edge directions are returned as Ö¾:<br />

intensity increase<br />

Ü Ý<br />

edge direction Ö<br />

from bottom to top ¼· ¼<br />

from lower right to upper left · ℄¼ ¼<br />

from right to left ·¼ ¼<br />

from upper right to lower left ·· ℄¼ ½¼<br />

from top to bottom ¼· ½¼<br />

from upper left to lower right · ℄½¼ ¾¼<br />

from left to right ·¼ ¾¼<br />

from lower left to upper right ℄¾¼ ¿¼<br />

Points with edge amplitude 0 are assigned the edge direction 255 (undefined direction).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.5. EDGES 67<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Input image.<br />

º ImageEdgeAmp (output object) . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject * : byte<br />

Edge amplitude (gradient magnitude) image.<br />

º ImageEdgeDir (output object) . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : direction<br />

Edge direction image.<br />

Example<br />

read_image(&Image,"fabrik");<br />

frei_dir(Image,&Frei_dirA,&Frei_dirD);<br />

threshold(Frei_dirA,&Res,128,255);<br />

Result<br />

frei dir always returns H MSG TRUE. If the input is empty the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

frei dir is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

Possible Predecessor Functions<br />

gauss image, sigma image, median image, smooth image<br />

Possible Successor Functions<br />

hysteresis threshold, threshold, gray skeleton, nonmax suppression dir,<br />

close edges, close edges length<br />

Alternatives<br />

edges image, sobel dir, robinson dir, prewitt dir, kirsch dir<br />

bandpass image, laplace of gauss<br />

Image filters<br />

See Also<br />

Module<br />

highpass image ( Hobject Image, Hobject *Highpass, long Width,<br />

long Height )<br />

Extract high frequency components from an image.<br />

highpass image extracts high frequency components in an image by applying a linear filter with the following<br />

matrix (in case of a ¢ matrix):<br />

½ ½ ½ ½ ½ ½ ½<br />

½ ½ ½ ½ ½ ½ ½<br />

½ ½ ½ ¿ ½ ½ ½<br />

½ ½ ½ ½ ½ ½ ½<br />

½ ½ ½ ½ ½ ½ ½<br />

This corresponds to applying a mean operator (mean image), and then subtracting the original gray value. A<br />

value of 128 is added to the result, i.e., zero crossings occur for 128.<br />

This filter emphasizes high frequency components (edges and corners). The cutoff frequency is determined by the<br />

size (Height ¢ Width) of the filter matrix: the larger the matrix, the smaller the cutoff frequency is.<br />

At the image borders the pixels’ gray values are mirrored. In case of over- or underflow the gray values are clipped<br />

(255 and 0, resp.).<br />

Attention<br />

If even values are passed for Height or Width, the operator uses the next larger odd value instead. Thus, the<br />

center of the filter mask is always uniquely determined.<br />

<strong>HALCON</strong> 6.0


68 CHAPTER 3. FILTER<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Input image.<br />

º Highpass (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte<br />

High-pass-filtered result image.<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the filter mask.<br />

Default Value : 9<br />

Value Suggestions : Width ¾3, 5, 7, 9, 11, 13, 17, 21, 29, 41, 51, 73, 101<br />

Typical Range of Values : 3 Width 501<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : ´Width 3µ odd´Widthµ<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the filter mask.<br />

Default Value : 9<br />

Value Suggestions : Height ¾3, 5, 7, 9, 11, 13, 17, 21, 29, 41, 51, 73, 101<br />

Typical Range of Values : 3 Height 501<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : ´Height 3µ odd´Heightµ<br />

Example<br />

highpass_image(Image,&Highpass,7,5);<br />

threshold(Highpass,&Region,60.0,255.0);<br />

skeleton(Region,&Skeleton);<br />

Result<br />

highpass image returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can<br />

be set via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

highpass image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

threshold, skeleton<br />

Possible Successor Functions<br />

Alternatives<br />

mean image, sub image, convol image, bandpass image<br />

dyn threshold<br />

Image filters<br />

See Also<br />

Module<br />

T info edges ( Htuple Filter, Htuple Mode, Htuple Alpha, Htuple *Size,<br />

Htuple *Coeffs )<br />

Estimate the width of a filter in edges image.<br />

T info edges returns an estimate of the width of any of the filters used in edges image. To do so, the<br />

corresponding continuous impulse responses of the filters are sampled until the first filter coefficient is smaller than<br />

five percent of the largest coefficient. Alpha is the filter parameter (see edges image). Seven edge operators<br />

are supported (parameter Filter):<br />

’deriche1’, ’lanser1’, ’deriche2’, ’lanser2’, ’shen’, ’mshen’ und ’canny’.<br />

The parameter Mode (’edge’/’smooth’) is used to determine whether the corresponding edge or smoothing operator<br />

is to be sampled. The Canny operator (which uses the Gaussian for smoothing) is implemented using conventional<br />

filter masks, while all other filters are implemented recursively. Therefore, for the Canny filter the coefficients of<br />

the one-dimensional impulse responses ´Òµ with Ò ¼ are returned in Coeffs in addition to the filter width.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.5. EDGES 69<br />

Parameter<br />

º Filter (input control) .................................................string Htuple . const char *<br />

Name of the edge operator.<br />

Default Value : ’lanser2’<br />

Value List : Filter ¾’deriche1’, ’lanser1’, ’deriche2’, ’lanser2’, ’shen’, ’mshen’, ’canny’<br />

º Mode (input control) ....................................................string Htuple . const char *<br />

1D edge filter (’edge’) or 1D smoothing filter (’smooth’).<br />

Default Value : ’edge’<br />

Value List : Mode ¾’edge’, ’smooth’<br />

º Alpha (input control) .........................................................real Htuple . double<br />

Filter parameter: small values result in strong smoothing, and thus less detail (opposite for ’canny’).<br />

Default Value : 0.5<br />

Typical Range of Values : 0.2 Alpha 50.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Alpha 0.0<br />

º Size (output control) .......................................................integer Htuple . long *<br />

Filter width in pixels.<br />

º Coeffs (output control) ..............................................integer-array Htuple . long *<br />

For Canny filters: Coefficients of the “positive” half of the 1D impulse response.<br />

Example<br />

read_image(&Image,"fabrik");<br />

info_edges("lanser2","edge",0.5,Size,Coeffs) ;<br />

edges_image(Image,&Amp,&Dir,"lanser2",0.5,"none",-1,-1);<br />

hysteresis_threshold(Amp,&Margin,20,30,30);<br />

Result<br />

T info edges returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can be<br />

set via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

T info edges is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

edges image, threshold, skeleton<br />

edges image<br />

Image filters<br />

See Also<br />

Module<br />

kirsch amp ( Hobject Image, Hobject *ImageEdgeAmp )<br />

Detect edges (amplitude) using the Kirsch operator.<br />

kirsch amp calculates an approximation of the first derivative of the image data and is used as an edge detector.<br />

The filter is based on the following filter masks:<br />

¿ ¿ <br />

¿ ¼ <br />

¿ ¿ <br />

¿ <br />

¿ ¼ <br />

¿ ¿ ¿<br />

<br />

¿ ¼ ¿<br />

¿ ¿ ¿<br />

<strong>HALCON</strong> 6.0


70 CHAPTER 3. FILTER<br />

¿<br />

¼ ¿<br />

¿ ¿ ¿<br />

¿ ¿<br />

¼ ¿<br />

¿ ¿<br />

¿ ¿ ¿<br />

¼ ¿<br />

¿<br />

¿ ¿ ¿<br />

¿ ¼ ¿<br />

<br />

¿ ¿ ¿<br />

¿ ¼ <br />

¿ <br />

The result image contains the maximum response of all masks.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Input image.<br />

º ImageEdgeAmp (output object) ...............................image(-array) Hobject * : byte / int2<br />

Edge amplitude (gradient magnitude) image.<br />

read_image(&Image,"fabrik");<br />

kirsch_amp(Image,&Kirsch_amp);<br />

threshold(Kirsch_amp,&Edges,128,255);<br />

Example<br />

Result<br />

kirsch amp always returns H MSG TRUE. If the input is empty the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

kirsch amp is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

Possible Predecessor Functions<br />

gauss image, sigma image, median image, smooth image<br />

Alternatives<br />

sobel amp, frei amp, prewitt amp, robinson amp, roberts<br />

bandpass image, laplace of gauss<br />

Image filters<br />

See Also<br />

Module<br />

kirsch dir ( Hobject Image, Hobject *ImageEdgeAmp,<br />

Hobject *ImageEdgeDir )<br />

Detect edges (amplitude and direction) using the Kirsch operator.<br />

kirsch dir calculates an approximation of the first derivative of the image data and is used as an edge detector.<br />

The filter is based on the following filter masks:<br />

¿ ¿ <br />

¿ ¼ <br />

¿ ¿ <br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.5. EDGES 71<br />

¿ <br />

¿ ¼ <br />

¿ ¿ ¿<br />

<br />

¿ ¼ ¿<br />

¿ ¿ ¿<br />

¿<br />

¼ ¿<br />

¿ ¿ ¿<br />

¿ ¿<br />

¼ ¿<br />

¿ ¿<br />

¿ ¿ ¿<br />

¼ ¿<br />

¿<br />

¿ ¿ ¿<br />

¿ ¼ ¿<br />

<br />

¿ ¿ ¿<br />

¿ ¼ <br />

¿ <br />

The result image contains the maximum response of all masks. The edge directions are returned in<br />

ImageEdgeDir, andarestoredasܾ. They correspond to the direction of the mask yielding the maximum<br />

response.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Input image.<br />

º ImageEdgeAmp (output object) . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject * : byte<br />

Edge amplitude (gradient magnitude) image.<br />

º ImageEdgeDir (output object) . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : direction<br />

Edge direction image.<br />

Example<br />

read_image(&Image,"fabrik");<br />

kirsch_dir(Image,&Kirsch_dirA,&Kirsch_dirD);<br />

threshold(Kirsch_dirA,&Res,128,255);<br />

Result<br />

kirsch dir always returns H MSG TRUE. If the input is empty the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

kirsch dir is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

Possible Predecessor Functions<br />

gauss image, sigma image, median image, smooth image<br />

Possible Successor Functions<br />

hysteresis threshold, threshold, gray skeleton, nonmax suppression dir,<br />

close edges, close edges length<br />

Alternatives<br />

edges image, sobel dir, robinson dir, prewitt dir, frei dir<br />

bandpass image, laplace of gauss<br />

Image filters<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


72 CHAPTER 3. FILTER<br />

laplace ( Hobject Image, Hobject *ImageLaplace, const char *FilterType,<br />

long Size, const char *NeighbourhoodType )<br />

Calculate the Laplace operator by using finite differences.<br />

laplace filters the input images Image using a Laplace operator. Depending on the parameter<br />

NeighbourhoodType the following simple approximations of the Laplace operator are used:<br />

’n 4’<br />

’n 8’<br />

’n 8 isotrop’<br />

½<br />

½ ½<br />

½<br />

½ ½ ½<br />

½ ½<br />

½ ½ ½<br />

½¼ ¾¾ ½¼<br />

¾¾ ½¾ ¾¾<br />

½¼ ¾¾ ½¼<br />

The filter ’n 8’ corresponds to the filter mask used in highpass image(OR3,3). For a Laplace operator with<br />

size ¿ ¢ ¿, the corresponding filter is applied directly, while for larger filter sizes (Size = 5,7,9 and 11) the input<br />

image is first smoothed using a Gaussian filter of the selected size. Therefore,<br />

laplace(O:R:int4,S,N:)<br />

for Size is equivalent to<br />

gauss image(O:G:S:) º<br />

laplace(G:R:int4,3,N:).<br />

laplace either returns the absolute value of the Laplace filtered image (FilterType ’abs’) in a byte-image or<br />

the signed result (FilterType ’int4’) in an int4-image.<br />

laplace is only implemented for byte-images.<br />

Attention<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Input image.<br />

º ImageLaplace (output object) . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int4<br />

Laplace-filtered result images.<br />

º FilterType (input control) ...................................................string const char *<br />

Calculate the absolute value of the filter to a byte-image or the signed result to an int4-image.<br />

Default Value : ’int4’<br />

Value List : FilterType ¾’abs’, ’int4’<br />

º Size (input control) .................................................................integer long<br />

Size of filter mask.<br />

Default Value : 3<br />

Value List : Size ¾3, 5, 7, 9, 11<br />

º NeighbourhoodType (input control) ..........................................string const char *<br />

Neighborhood used in the Laplace operator<br />

Default Value : ’n 8 isotrop’<br />

Value List : NeighbourhoodType ¾’n 4’, ’n 8’, ’n 8 isotrop’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.5. EDGES 73<br />

Example<br />

read_image(&Image,"mreut");<br />

laplace(Image,&Laplace,"int4",3,"n_8_isotrop");<br />

zero_crossing(Laplace,&ZeroCrossings);<br />

Result<br />

laplace returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can be set via<br />

set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

laplace is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

zero crossing, dual threshold<br />

diff of gauss, laplace of gauss<br />

highpass image, edges image<br />

Image filters<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

laplace of gauss ( Hobject Image, Hobject *ImageLaplace, double Sigma )<br />

LoG-Operator (Laplace of Gaussian).<br />

laplace of gauss calculates the Laplace-of-Gaussian operator, i.e., the Laplace operator on a Gaussian<br />

smoothed image, for arbitrary smoothing parameters Sigma. The Laplace operator is given by:<br />

¡´Ü ݵ ¾ ´Ü ݵ<br />

Ü ¾ · ¾ ´Ü ݵ<br />

Ý ¾<br />

The derivatives in laplace of gauss are calculated by appropriate derivatives of the Gaussian, resulting in the<br />

following formula for the convolution mask:<br />

¡ ´Ü ݵ <br />

<br />

½ ܾ · Ý ¾<br />

ܾ · Ý ¾<br />

¾ ¾ ¾ ½ ÜÔ<br />

¾ ¾<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real<br />

Input image.<br />

º ImageLaplace (output object) . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * :int2<br />

Laplace filtered image.<br />

º Sigma (input control) .......................................................number double / long<br />

Smoothing parameter of the Gaussian.<br />

Default Value : 2.0<br />

Value Suggestions : Sigma ¾0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 7.0<br />

Typical Range of Values : 0.2 Sigma 20.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Sigma 0.0<br />

<br />

<strong>HALCON</strong> 6.0


74 CHAPTER 3. FILTER<br />

Example<br />

read_image(&Image,"mreut");<br />

laplace_of_gauss(Image,&Laplace,2.0);<br />

zero_crossing(Laplace,&ZeroCrossings);<br />

Parallelization Information<br />

laplace of gauss is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

zero crossing, dual threshold<br />

Possible Successor Functions<br />

Alternatives<br />

laplace, diff of gauss, derivate gauss<br />

derivate gauss<br />

Image filters<br />

See Also<br />

Module<br />

prewitt amp ( Hobject Image, Hobject *ImageEdgeAmp )<br />

Detect edges (amplitude) using the Prewitt operator.<br />

prewitt amp calculates an approximation of the first derivative of the image data and is used as an edge detector.<br />

The filter is based on the following filter masks:<br />

<br />

½ ½ ½<br />

¼ ¼ ¼<br />

½ ½ ½<br />

<br />

½ ¼ ½<br />

½ ¼ ½<br />

½ ¼ ½<br />

The result image contains the maximum response of the masks and .<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Input image.<br />

º ImageEdgeAmp (output object) . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Edge amplitude (gradient magnitude) image.<br />

read_image(&Image,"fabrik");<br />

prewitt_amp(Image,&Prewitt);<br />

threshold(Prewitt,&Edges,128,255);<br />

Example<br />

Result<br />

prewitt amp always returns H MSG TRUE. If the input is empty the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

prewitt amp is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

Possible Predecessor Functions<br />

gauss image, sigma image, median image, smooth image<br />

Possible Successor Functions<br />

threshold, gray skeleton, nonmax suppression amp, close edges, close edges length<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.5. EDGES 75<br />

Alternatives<br />

sobel amp, kirsch amp, frei amp, robinson amp, roberts<br />

bandpass image, laplace of gauss<br />

Image filters<br />

See Also<br />

Module<br />

prewitt dir ( Hobject Image, Hobject *ImageEdgeAmp,<br />

Hobject *ImageEdgeDir )<br />

Detect edges (amplitude and direction) using the Prewitt operator.<br />

prewitt dir calculates an approximation of the first derivative of the image data and is used as an edge detector.<br />

The filter is based on the following filter masks:<br />

<br />

<br />

½ ½ ½<br />

¼ ¼ ¼<br />

½ ½ ½<br />

½ ¼ ½<br />

½ ¼ ½<br />

½ ¼ ½<br />

The result image contains the maximum response of the masks and . The edge directions are returned in<br />

ImageEdgeDir, and are stored in 2-degree steps, i.e., an edge direction of Ü degrees with respect to the horizontal<br />

axis is stored as ܾ in the edge direction image. Furthermore, the direction of the change of intensity is taken into<br />

account. Let Ü Ý ℄ denote the image gradient. Then the following edge directions are returned as Ö¾:<br />

intensity increase<br />

Ü Ý<br />

edge direction Ö<br />

from bottom to top ¼· ¼<br />

from lower right to upper left · ℄¼ ¼<br />

from right to left ·¼ ¼<br />

from upper right to lower left ·· ℄¼ ½¼<br />

from top to bottom ¼· ½¼<br />

from upper left to lower right · ℄½¼ ¾¼<br />

from left to right ·¼ ¾¼<br />

from lower left to upper right ℄¾¼ ¿¼<br />

Points with edge amplitude 0 are assigned the edge direction 255 (undefined direction).<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Input image.<br />

º ImageEdgeAmp (output object) . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject * : byte<br />

Edge amplitude (gradient magnitude) image.<br />

º ImageEdgeDir (output object) . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : direction<br />

Edge direction image.<br />

Example<br />

read_image(&Image,"fabrik");<br />

prewitt_dir(Image,&PrewittA,&PrewittD);<br />

threshold(PrewittA,&Edges,128,255);<br />

Result<br />

prewitt dir always returns H MSG TRUE. If the input is empty the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

<strong>HALCON</strong> 6.0


76 CHAPTER 3. FILTER<br />

Parallelization Information<br />

prewitt dir is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

Possible Predecessor Functions<br />

gauss image, sigma image, median image, smooth image<br />

Possible Successor Functions<br />

hysteresis threshold, threshold, gray skeleton, nonmax suppression dir,<br />

close edges, close edges length<br />

Alternatives<br />

edges image, sobel dir, robinson dir, frei dir, kirsch dir<br />

bandpass image, laplace of gauss<br />

Image filters<br />

See Also<br />

Module<br />

roberts ( Hobject Image, Hobject *ImageRoberts, const char *FilterType )<br />

Detect edges using the Roberts filter.<br />

roberts calculates the first derivative of an image and is used as an edge operator. If the following mask describes<br />

a part of the image,<br />

<br />

<br />

<br />

<br />

the different filter types are defined as follows:<br />

’roberts max’ ÑÜ´ µ<br />

’gradient max’<br />

ÑÜ´ · ´ · µ · ´ · µµ<br />

’gradient sum’<br />

· ´ · µ · · ´ · µ<br />

If an overflow occurs the result is clipped. The result of the operator is stored at the pixel with the coordinates of<br />

“”.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Input image.<br />

º ImageRoberts (output object) . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Roberts-filtered result images.<br />

º FilterType (input control) ...................................................string const char *<br />

Filter type.<br />

Default Value : ’gradient sum’<br />

Value List : FilterType ¾’roberts max’, ’gradient max’, ’gradient sum’<br />

Example<br />

read_image(&Image,"fabrik");<br />

roberts(Image,&Roberts,"roberts_max");<br />

threshold(Roberts,&Margin,128.0,255.0);<br />

Result<br />

roberts returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can be set via<br />

set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

roberts is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

gauss image<br />

Possible Predecessor Functions<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.5. EDGES 77<br />

threshold, skeleton<br />

Possible Successor Functions<br />

Alternatives<br />

edges image, sobel amp, frei amp, kirsch amp, prewitt amp<br />

See Also<br />

laplace, highpass image, bandpass image<br />

Image filters<br />

Module<br />

robinson amp ( Hobject Image, Hobject *ImageEdgeAmp )<br />

Detect edges (amplitude) using the Robinson operator.<br />

robinson amp calculates an approximation of the first derivative of the image data and is used as an edge<br />

detector. In robinson amp the following four of the originally proposed eight ¿ ¢ ¿ filter masks are convolved<br />

with the image. The other four masks are obtained by a multiplication by -1. All masks contain only the values<br />

0,1,-1,2,-2.<br />

½ ¼ ½<br />

¾ ¼ ¾<br />

½ ¼ ½<br />

¾ ½ ¼<br />

½ ¼ ½<br />

¼ ½ ¾<br />

¼ ½ ¾<br />

½ ¼ ½<br />

¾ ½ ¼<br />

½ ¾ ½<br />

¼ ¼ ¼<br />

½ ¾ ½<br />

The result image contains the maximum response of all masks.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Input image.<br />

º ImageEdgeAmp (output object) . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Edge amplitude (gradient magnitude) image.<br />

Example<br />

read_image(&Image,"fabrik");<br />

robinson_amp(Image,&Robinson_amp);<br />

threshold(Robinson_amp,&Edges,128,255);<br />

Result<br />

robinson amp always returns H MSG TRUE. If the input is empty the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

robinson amp is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

Possible Predecessor Functions<br />

gauss image, sigma image, median image, smooth image<br />

Alternatives<br />

sobel amp, frei amp, prewitt amp, robinson amp, roberts<br />

<strong>HALCON</strong> 6.0


78 CHAPTER 3. FILTER<br />

bandpass image, laplace of gauss<br />

Image filters<br />

See Also<br />

Module<br />

robinson dir ( Hobject Image, Hobject *ImageEdgeAmp,<br />

Hobject *ImageEdgeDir )<br />

Detect edges (amplitude and direction) using the Robinson operator.<br />

robinson dir calculates an approximation of the first derivative of the image data and is used as an edge<br />

detector. In robinson amp the following four of the originally proposed eight ¿ ¢ ¿ filter masks are convolved<br />

with the image. The other four masks are obtained by a multiplication by -1. All masks contain only the values<br />

0,1,-1,2,-2.<br />

½ ¼ ½<br />

¾ ¼ ¾<br />

½ ¼ ½<br />

¾ ½ ¼<br />

½ ¼ ½<br />

¼ ½ ¾<br />

¼ ½ ¾<br />

½ ¼ ½<br />

¾ ½ ¼<br />

½ ¾ ½<br />

¼ ¼ ¼<br />

½ ¾ ½<br />

The result image contains the maximum response of all masks. The edge directions are returned in<br />

ImageEdgeDir, andarestoredasܾ. They correspond to the direction of the mask yielding the maximum<br />

response.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Eingabebild.<br />

º ImageEdgeAmp (output object) . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject * : byte<br />

Edge amplitude (gradient magnitude) image.<br />

º ImageEdgeDir (output object) . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : direction<br />

Edge direction image.<br />

Example<br />

read_image(&Image,"fabrik");<br />

robinson_dir(Image,&Robinson_dirA,&Robinson_dirD);<br />

threshold(Robinson_dirA,&Res,128,255);<br />

Result<br />

robinson dir always returns H MSG TRUE. If the input is empty the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

robinson dir is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

Possible Predecessor Functions<br />

gauss image, sigma image, median image, smooth image<br />

Possible Successor Functions<br />

hysteresis threshold, threshold, gray skeleton, nonmax suppression dir,<br />

close edges, close edges length<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.5. EDGES 79<br />

Alternatives<br />

edges image, sobel dir, kirsch dir, prewitt dir, frei dir<br />

bandpass image, laplace of gauss<br />

Image filters<br />

See Also<br />

Module<br />

sobel amp ( Hobject Image, Hobject *EdgeAmplitude,<br />

const char *FilterType, long Size )<br />

Detect edges (amplitude) using the Sobel operator.<br />

sobel amp calculates first derivative of an image and is used as an edge detector. The filter is based on the<br />

following filter masks:<br />

<br />

<br />

½ ¾ ½<br />

¼ ¼ ¼<br />

½ ¾ ½<br />

½ ¼ ½<br />

¾ ¼ ¾<br />

½ ¼ ½<br />

These masks are used differently, according to the selected filter type. (In the following, und denote the results<br />

of convolving an image with und for one particular pixel.)<br />

’sum sqrt’<br />

’sum abs’<br />

’thin sum abs’<br />

’thin max abs’<br />

’x’<br />

’y’<br />

Ô<br />

¾ · ¾<br />

´ · µ¾<br />

´ØÒ´µ ·ØÒ´µµ¾<br />

ÑÜ´ØÒ´µ ØÒ´µµ<br />

<br />

<br />

Here, ØҴܵ is equal to Ü for a vertical maximum (mask A) and a horizontal maximum (mask B), respectively,<br />

and 0 otherwise. Thus, for ’thin sum abs’ and ’thin max abs’ the gradient image is thinned. In the case of byte<br />

images for ’x’ and ’y’ the value 127 is added to the result to avoid under flows. For a Sobel operator with size<br />

¿ ¢ ¿, the corresponding filters and are applied directly, while for larger filter sizes (Size = 5,7,9 and 11) the<br />

input image is first smoothed using a Gaussian filter of size Size-2. Therefore,<br />

sobel amp(I:E,Dir:FilterTyp,S:)<br />

for Size 3 is equivalent to<br />

gauss image(I:G:S-2) º<br />

sobel amp(G:E:FilterType,3:).<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Input image.<br />

º EdgeAmplitude (output object) . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Edge amplitude (gradient magnitude) image.<br />

º FilterType (input control) ...................................................string const char *<br />

Filter type.<br />

Default Value : ’sum abs’<br />

Value List : FilterType ¾’sum abs’, ’thin sum abs’, ’thin max abs’, ’sum sqrt’, ’x’, ’y’<br />

º Size (input control) .................................................................integer long<br />

Size of filter mask.<br />

Default Value : 3<br />

Value List : Size ¾3, 5, 7, 9, 11, 13<br />

<strong>HALCON</strong> 6.0


80 CHAPTER 3. FILTER<br />

Example<br />

read_image(&Image,"fabrik");<br />

sobel_amp(Image,&Amp,"sum_abs",3);<br />

threshold(Amp,&Edg,128.0,255.0);<br />

Result<br />

sobel amp returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can be set via<br />

set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

sobel amp is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

Possible Predecessor Functions<br />

gauss image, mean image, anisotrope diff, sigma image<br />

Possible Successor Functions<br />

threshold, nonmax suppression amp, gray skeleton<br />

Alternatives<br />

frei amp, roberts, kirsch amp, prewitt amp, robinson amp<br />

See Also<br />

laplace, highpass image, bandpass image<br />

Image filters<br />

Module<br />

sobel dir ( Hobject Image, Hobject *EdgeAmplitude,<br />

Hobject *EdgeDirection, const char *FilterType, long Size )<br />

Detect edges (amplitude and direction) using the Sobel operator.<br />

sobel dir calculates first derivative of an image and is used as an edge detector. The filter is based on the<br />

following filter masks:<br />

<br />

½ ¾ ½<br />

¼ ¼ ¼<br />

½ ¾ ½<br />

<br />

½ ¼ ½<br />

¾ ¼ ¾<br />

½ ¼ ½<br />

These masks are used differently, according to the selected filter type. (In the following, und denote the results<br />

of convolving an image with und for one particular pixel.)<br />

’sum sqrt’<br />

’sum abs’<br />

Ô<br />

¾ · ¾<br />

´ · µ¾<br />

For a Sobel operator with size ¿ ¢ ¿, the corresponding filters and are applied directly, while for larger filter<br />

sizes (Size = 5,7,9 and 11) the input image is first smoothed using a Gaussian filter of size Size-2. Therefore,<br />

sobel dir(I:Amp,Dir:FilterTyp,S:)<br />

for Size 3 is equivalent to<br />

gauss image(I:G:S-2) º<br />

sobel dir(G:Amp,Dir:FilterType,3:).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.5. EDGES 81<br />

The edge directions are returned in EdgeDirection, and are stored in 2-degree steps, i.e., an edge direction of Ü<br />

degrees with respect to the horizontal axis is stored as ܾ in the edge direction image. Furthermore, the direction<br />

of the change of intensity is taken into account. Let Ü Ý ℄ denote the image gradient. Then the following edge<br />

directions are returned as Ö¾:<br />

intensity increase<br />

Ü Ý<br />

edge direction Ö<br />

from bottom to top ¼· ¼<br />

from lower right to upper left · ℄¼ ¼<br />

from right to left ·¼ ¼<br />

from upper right to lower left ·· ℄¼ ½¼<br />

from top to bottom ¼· ½¼<br />

from upper left to lower right · ℄½¼ ¾¼<br />

from left to right ·¼ ¾¼<br />

from lower left to upper right ℄¾¼ ¿¼<br />

Points with edge amplitude 0 are assigned the edge direction 255 (undefined direction).<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Input image.<br />

º EdgeAmplitude (output object) . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Edge amplitude (gradient magnitude) image.<br />

º EdgeDirection (output object) . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : direction<br />

Edge direction image.<br />

º FilterType (input control) ...................................................string const char *<br />

Filter type.<br />

Default Value : ’sum abs’<br />

Value List : FilterType ¾’sum abs’, ’sum sqrt’<br />

º Size (input control) .................................................................integer long<br />

Size of filter mask.<br />

Default Value : 3<br />

Value List : Size ¾3, 5, 7, 9, 11, 13<br />

Example<br />

read_image(&Image,"fabrik");<br />

sobel_dir(Image,&Amp,&Dir,"sum_abs",3);<br />

threshold(Amp,&Edg,128.0,255.0);<br />

Result<br />

sobel dir returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can be set via<br />

set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

sobel dir is reentrant and automatically parallelized (on tuple level, channel level).<br />

Possible Predecessor Functions<br />

gauss image, mean image, anisotrope diff, sigma image<br />

Possible Successor Functions<br />

nonmax suppression dir, hysteresis threshold, threshold<br />

Alternatives<br />

edges image, frei dir, kirsch dir, prewitt dir, robinson dir<br />

See Also<br />

roberts, laplace, highpass image, bandpass image<br />

Image filters<br />

Module<br />

<strong>HALCON</strong> 6.0


82 CHAPTER 3. FILTER<br />

3.6 Enhancement<br />

emphasize ( Hobject Image, Hobject *ImageEmphasize, long MaskWidth,<br />

long MaskHeight, double Factor )<br />

Enhance contrast of the image.<br />

The operator emphasize emphasizes high frequency areas of the image (edges and corners). The resulting<br />

images appears sharper.<br />

First the procedure carries out a filtering with the low pass (mean image). The resulting gray values (Ö×) are<br />

calculated from the obtained gray values (ÑÒ) and the original gray values (ÓÖ) as follows:<br />

Ö× ÖÓÙÒ´´ÓÖ ÑÒµ £ ØÓÖµ ·ÓÖ<br />

Factor serves as measurement of the increase in contrast. The division frequency is determined via the size of<br />

the filter matrix: The larger the matrix, the lower the disivion frequency.<br />

As an edge treatment the gray values are mirrored at the edges of the image. Overflow and/or underflow of gray<br />

values is clipped (255 or 0, respectively).<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image to be enhanced.<br />

º ImageEmphasize (output object) . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte<br />

contrast enhanced image.<br />

º MaskWidth (input control) ..........................................................extent.x long<br />

Width of low pass mask.<br />

Default Value : 7<br />

Value Suggestions : MaskWidth ¾3, 5, 7, 9, 11, 15, 21, 25, 31, 39<br />

Typical Range of Values : 3 MaskWidth 201<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

º MaskHeight (input control) ........................................................extent.y long<br />

Height of the low pass mask.<br />

Default Value : 7<br />

Value Suggestions : MaskHeight ¾3, 5, 7, 9, 11, 15, 21, 25, 31, 39<br />

Typical Range of Values : 3 MaskHeight 201<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

º Factor (input control) ...............................................................real double<br />

Intensity of contrast emphasis.<br />

Default Value : 1.0<br />

Value Suggestions : Factor ¾0.3, 0.5, 0.7, 1.0, 1.4, 1.8, 2.0<br />

Typical Range of Values : 0.0 Factor 20.0 (sqrt)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.2<br />

Restriction : ´0 Factorµ ´Factor 20µ<br />

read_image(&Image,"meer_rot");<br />

disp_image(Image,WindowHandle);<br />

draw_region(&Region,WindowHandle);<br />

reduce_domain(Image,Region,&Mask);<br />

emphasize(Mask,&Sharp,7,7,2.0);<br />

disp_image(Sharp,WindowHandle);<br />

Example<br />

Result<br />

If the parameter values are correct the operator emphasize returns the value H MSG TRUE The<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.6. ENHANCEMENT 83<br />

behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

emphasize is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

disp image<br />

Possible Successor Functions<br />

Alternatives<br />

mean image, sub image, laplace, add image<br />

mean image, highpass image<br />

Image filters<br />

See Also<br />

Module<br />

equ histo image ( Hobject Image, Hobject *ImageEquHisto )<br />

Histogram linearisation of images<br />

The operator equ histo image enhances the contrast. The starting point is the histogram of the input images.<br />

The following simple gray value transformation ´µ is carried out:<br />

´µ ¾<br />

<br />

ܼ<br />

´Üµ describes the relative frequency of the occurrence of the gray value Ü. This transformation linearises the<br />

cumulative histogram. Maxima in the original histogram are ”‘spreaded”’ and thus the contrast in image regions<br />

with these frequently occuring gray values is increased. Supposedly homogenous regions receive more easily<br />

visible structures. On the other hand, of course, the noise in the image increases correspondlingly. Minima in the<br />

original histogram are dually ”‘compressed”’. The transformed histogram contains gaps, but the remaining gray<br />

values used occur approximately at the same frequency (”‘histogram equalization”’).<br />

Attention<br />

The operator equ histo image primarily serves for optical processing of images for a human viewer. For<br />

example, the (local) contrast spreading can lead to a detection of fictitious edges.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image to be enhanced.<br />

º ImageEquHisto (output object) . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte<br />

Image with linearized gray values.<br />

Parallelization Information<br />

equ histo image is reentrant and automatically parallelized (on tuple level, channel level).<br />

disp image<br />

´Üµ<br />

Possible Successor Functions<br />

Alternatives<br />

scale image, scale image max, illuminate<br />

scale image<br />

See Also<br />

Bibliography<br />

R.C. Gonzales, P. Wintz: ”‘Digital Image Processing”’; Second edition; Addison Wesley; 1987.<br />

Image filters<br />

Module<br />

<strong>HALCON</strong> 6.0


84 CHAPTER 3. FILTER<br />

illuminate ( Hobject Image, Hobject *ImageIlluminate, long MaskWidth,<br />

long MaskHeight, double Factor )<br />

Illuminate image.<br />

The operator illuminate enhances contrast. Very dark parts of the image are ”‘illuminated”’ more strongly,<br />

very light ones are ”‘darkened”’. If ÓÖ is the original gray value and ÑÒ is the corresponding gray value of<br />

the low pass filtered image detected via the operators mean image and filter size MaskHeight x MaskWidth,<br />

the resulting gray value is ÒÛ:<br />

ÒÛ ÖÓÙÒ´´½¾ ÑÒµ £ ØÓÖ · ÓÖµ<br />

The low pass should have rather large dimensions (30 x 30 to 200 x 200). Reasonable parameter combinations<br />

might be:<br />

Å×ÀØ Å×ÏØ ØÓÖ<br />

¼ ¼ ¼<br />

½¼¼ ½¼¼ ¼<br />

½¼ ½¼ ¼<br />

i.e. the larger the low pass mask is chosen, the larger Factor should be as well.<br />

The following ”‘spotlight effect”’ should be noted: If, for example, a dark object is in front of a light wall the object<br />

as well as the wall, which is already light in the immediate proximity of the object contours, are lightened by the<br />

operator illuminate. This corresponds roughly to the effect that is produced when the object is illuminated by<br />

a strong spotlight. The same applies to light objects in front of a darker background. In this case, however, the<br />

fictitious ”‘spotlight”’ darkens objects.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image to be enhanced.<br />

º ImageIlluminate (output object) . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject * : byte<br />

”‘Illuminated”’ image.<br />

º MaskWidth (input control) ..........................................................extent.x long<br />

Width of low pass mask.<br />

Default Value : 101<br />

Value Suggestions : MaskWidth ¾31, 41, 51, 71, 101, 121, 151, 201<br />

Typical Range of Values : 3 MaskWidth 299<br />

Minimal Value Step : 2<br />

Recommended Value Step : 10<br />

º MaskHeight (input control) ........................................................extent.y long<br />

Height of low pass mask.<br />

Default Value : 101<br />

Value Suggestions : MaskHeight ¾31, 41, 51, 71, 101, 121, 151, 201<br />

Typical Range of Values : 3 MaskHeight 299<br />

Minimal Value Step : 2<br />

Recommended Value Step : 10<br />

º Factor (input control) ...............................................................real double<br />

Scales the ”‘correction gray value”’ added to the original gray values.<br />

Default Value : 0.7<br />

Value Suggestions : Factor ¾0.3, 0.5, 0.7, 1.0, 1.5, 2.0, 3.0, 5.0<br />

Typical Range of Values : 0.0 Factor 5.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.2<br />

Restriction : ´0 Factorµ ´Factor 5µ<br />

Example<br />

read_image(&Image,"fabrik");<br />

disp_image(Image,WindowHandle);<br />

illuminate(Image,&Better,40,40,0.55);<br />

disp_image(Better,WindowHandle);<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.7. FFT 85<br />

Result<br />

If the parameter values are correct the operator illuminate returns the value H MSG TRUE The<br />

behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

illuminate is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

disp image<br />

Possible Successor Functions<br />

Alternatives<br />

scale image max, equ histo image, mean image, sub image<br />

emphasize, gray histo<br />

Image filters<br />

See Also<br />

Module<br />

scale image max ( Hobject Image, Hobject *ImageScaleMax )<br />

Maximum gray value spreading in the value range 0 bis 255.<br />

The operator scale image max calculates the minimum and maximum and scales the image to the maximum<br />

value range of a byte image. This way the dynamics (value range) is fully exploited. The number of different gray<br />

scales does not change, but in general the visual impression is enhanced. The gray values of images of the real,<br />

int2 and int4 type are scaled to the range 0 to 255 and returned as byte images.<br />

The output always is an image of the type byte.<br />

Attention<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2 / int4 / real<br />

Image to be scaled.<br />

º ImageScaleMax (output object) ...................................image(-array) Hobject * : byte<br />

contrast enhanced image.<br />

Parallelization Information<br />

scale image max is reentrant and automatically parallelized (on tuple level, channel level).<br />

disp image<br />

Possible Successor Functions<br />

Alternatives<br />

equ histo image, scale image, illuminate, convert image type<br />

min max gray, gray histo<br />

Image filters<br />

See Also<br />

Module<br />

3.7 FFT<br />

convol fft ( Hobject ImageFFT, Hobject ImageFilter,<br />

Hobject *ImageConvol )<br />

Convolve an image with a byte-mask in the frequency domain.<br />

convol fft convolves two (Fourier-transformed) images in the frequency domain, i.e., the pixels of the complex<br />

image ImageFFT are multiplied by the corresponding pixels of the filter ImageFilter. This image is a byteimage<br />

in which 0 corresponds to complete suppression of a frequency, and 255 corresponds to no suppression. The<br />

result image is of type ’complex’.<br />

<strong>HALCON</strong> 6.0


86 CHAPTER 3. FILTER<br />

Attention<br />

The filtering is always done on the entire image, i.e., the region of the image is ignored.<br />

Parameter<br />

º ImageFFT (input object) ..........................................image(-array) Hobject : complex<br />

Complex input image.<br />

º ImageFilter (input object) ................................................image Hobject : byte<br />

Filter in frequency domain.<br />

º ImageConvol (output object) ..................................image(-array) Hobject * : complex<br />

Result of applying the filter.<br />

Example<br />

my_highpass(Hobject Image, Hobject *Result, int frequency, int size)<br />

{<br />

Hobject FFT, Highpass, FFTConvol;<br />

fft_image(Image,&FFT);<br />

gen_highpass(&Highpass,frequency,size);<br />

convol_fft(FFT,Highpass,&FFTConvol);<br />

clear_obj(Highpass); clear_obj(FFT);<br />

fft_image_inv(FFTConvol,Result);<br />

clear_obj(FFTConvol);<br />

}<br />

Result<br />

convol fft returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can be set<br />

via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

convol fft is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

fft image, fft generic, gen highpass, gen lowpass, gen bandpass, gen bandfilter<br />

Possible Successor Functions<br />

power byte, power real, power ln, fft image inv, fft generic<br />

convol gabor<br />

Alternatives<br />

See Also<br />

gen gabor, gen highpass, gen lowpass, gen bandpass, convol gabor, fft image inv<br />

Image filters<br />

Module<br />

convol gabor ( Hobject ImageFFT, Hobject GaborFilter,<br />

Hobject *ImageResultGabor, Hobject *ImageResultHilbert )<br />

Convolve an image with a Gabor filter in the frequency domain.<br />

convol gabor convolves a Fourier-transformed image with a Gabor filter GaborFilter (see gen gabor)<br />

and its Hilbert transform in the frequency domain. The result image is of type ’complex’.<br />

Attention<br />

The filtering is always done on the entire image, i.e., the region of the image is ignored.<br />

Parameter<br />

º ImageFFT (input object) ..........................................image(-array) Hobject : complex<br />

Input image.<br />

º GaborFilter (input object) ................................................image Hobject : byte<br />

Gabor/Hilbert-Filter.<br />

º ImageResultGabor (output object) ...........................image(-array) Hobject * : complex<br />

Result of the Gabor filter.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.7. FFT 87<br />

º ImageResultHilbert (output object) .........................image(-array) Hobject * : complex<br />

Result of the Hilbert filter.<br />

Example<br />

fft_image(Image,&FFT);<br />

gen_gabor(&Filter,1.4,0.4,1.0,1.5,512);<br />

convol_gabor(FFT,Filter,&Gabor,&Hilbert);<br />

fft_image_inv(Gabor,&GaborInv);<br />

fft_image_inv(Hilbert,&HilbertInv);<br />

energy_gabor(GaborInv,HilbertInv,&Energy);<br />

Result<br />

convol gabor returns H MSG TRUE if all images are of correct type. If the input is empty the behaviour can<br />

be set via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

convol gabor is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

fft image, fft generic, gen gabor<br />

Possible Successor Functions<br />

power byte, power real, power ln, fft image inv, fft generic<br />

convol fft<br />

convol image<br />

Image filters<br />

Alternatives<br />

See Also<br />

Module<br />

energy gabor ( Hobject ImageGabor, Hobject ImageHilbert,<br />

Hobject *Energy )<br />

Calculate the energy of a two-channel image.<br />

energy gabor calculates the local contrast (Energy) of the two input images. The energy of the resulting<br />

image is then defined as<br />

ÒÖÝ channel1 ¾ · channel2 ¾<br />

<br />

Often the calculation of the energy is preceded by the convolution of an image with a Gabor filter and the<br />

Hilbert transform of the Gabor filter (see convol gabor). In this case, the first channel of the image passed<br />

to energy gabor is the Gabor-filtered image, transformed back into the spatial domain (see fft image inv),<br />

and the second channel the result of the convolution with the Hilbert transform, also transformed back into the<br />

spatial domain. The local energy is a measure for the local contrast of structures (e.g., edges and lines) in the<br />

image.<br />

Parameter<br />

º ImageGabor (input object) ......................................image(-array) Hobject : byte / real<br />

1st channel of input image (usually: Gabor image).<br />

º ImageHilbert (input object) ...................................image(-array) Hobject : byte / real<br />

2nd channel of input image (usually: Hilbert image).<br />

º Energy (output object) .............................................image(-array) Hobject * : real<br />

Image containing the local energy.<br />

Example<br />

<strong>HALCON</strong> 6.0


88 CHAPTER 3. FILTER<br />

fft_image(Image,&FFT);<br />

gen_gabor(&Filter,1.4,0.4,1.0,1.5,512);<br />

convol_gabor(FFT,Filter,&Gabor,&Hilbert);<br />

fft_image_inv(Gabor,&GaborInv);<br />

fft_image_inv(Hilbert,&HilbertInv);<br />

energy_gabor(GaborInv,HilbertInv,&Energy);<br />

Result<br />

energy gabor returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can be<br />

set via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

energy gabor is reentrant and automatically parallelized (on tuple level, domain level).<br />

Possible Predecessor Functions<br />

gen gabor, convol gabor, fft image inv<br />

Image filters<br />

Module<br />

fft generic ( Hobject Image, Hobject *ImageFFT, const char *Direction,<br />

long Exponent, const char *Norm, const char *Mode )<br />

Compute the fast Fourier transform of an image.<br />

fft generic computes the fast Fourier transform of the input image Image. Because several definitions of the<br />

forward and reverse transforms exist in the literature, this operator allows the user to select the most convenient<br />

definition.<br />

The general definition of a Fourier transform is as follows:<br />

´Ñ Òµ <br />

Å<br />

½<br />

¼<br />

Æ<br />

½<br />

м<br />

×¾´ÑÅ·ÐÒƵ ´ е<br />

Opinions vary on whether the sign × in the exponent should be set to ½ or ½ for the forward transform, i.e. the<br />

for going to the frequency domain. There is also disagreement on the magnitude of the normalizing factor . This<br />

is Ôsometimes set to ½ for the forward transform, sometimes to ÅÆ, and sometimes (in case of the unitary FFT) to<br />

ÅÆ. Especially in image processing applications the DC term is shifted to the center of the image.<br />

fft generic allows to select these choices individually. The parameter Direction allows to select the logical<br />

direction of the FFT. (This parameter is not unnecessary; it is needed to discern how to shift the image if the<br />

DC term should rest in the center of the image.) Possible values are ’to freq’ and ’from freq’. The parameter<br />

Exponent is used to determine the sign of the exponent. It can be set to ½ or ½. The normalizing factor can be<br />

set with Norm, and can take on the values ’none’, ’sqrt’ and ’n’. The parameter Mode determines the location of<br />

the DC term of the FFT. It can be set to ’dc center’ or ’dc edge’.<br />

In any case, the user must ensure the consistent use of the parameters. This means that the normalizing factors<br />

used for the forward and bacward transform must yield ÅÆ when multiplied, the exponents must be of opposite<br />

sign, and Mode must be equal for both transforms.<br />

A consistent combination is, for example (’to freq’,-1,’n’,’dc edge’) for the forward transform and<br />

(’from freq’,1,’none’,’dc edge’) for the reverse transform. In this case, the FFT can be interpreted as interpolation<br />

with trigonometric basis functions. Another useful combination is (’to freq’,1,’sqrt’,’dc center’) and<br />

(’from freq’,-1,’sqrt’,’dc center’).<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject :any<br />

Input image.<br />

º ImageFFT (output object) ......................................image(-array) Hobject * : complex<br />

Fourier-transformed image.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.7. FFT 89<br />

º Direction (input control) .....................................................string const char *<br />

Calculate forward or reverse transform.<br />

Default Value : ’to freq’<br />

Value List : Direction ¾’to freq’, ’from freq’<br />

º Exponent (input control) ............................................................integer long<br />

Sign of the exponent.<br />

Default Value : 1<br />

Value List : Exponent ¾-1, 1<br />

º Norm (input control) ............................................................string const char *<br />

Normalizing factor of the transform.<br />

Default Value : ’sqrt’<br />

Value List : Norm ¾’none’, ’sqrt’, ’n’<br />

º Mode (input control) ............................................................string const char *<br />

Location of the DC term in the frequency domain.<br />

Default Value : ’dc center’<br />

Value List : Mode ¾’dc center’, ’dc edge’<br />

Example<br />

/* simulation of fft */<br />

my_fft(Hobject In, Hobject *Out)<br />

{<br />

fft_generic(In,Out,’to_freq’,1,’sqrt’,’dc_center’);<br />

}<br />

/* simulation of fft_image_inv */<br />

my_fft_image_inv(Hobject In, Hobject *Out)<br />

{<br />

Hobject Tmp;<br />

fft_generic(In,&Tmp,’from_freq’,1,’sqrt’,’dc_center’);<br />

convert_image_type(Tmp,Out,"byte");<br />

clear_obj(Tmp);<br />

}<br />

Result<br />

fft generic returns H MSG TRUE if the input image is of correct type, its width and height are a power<br />

of 2, and all parameters are correct. If the input is empty the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

fft generic is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

convol fft, convol gabor, convert image type, power byte, power real, power ln,<br />

phase deg, phase rad, energy gabor<br />

fft image, fft image inv<br />

Image filters<br />

Alternatives<br />

Module<br />

fft image ( Hobject Image, Hobject *ImageFFT )<br />

Compute the fast Fourier transform of an image.<br />

fft image calculates the Fourier transform of the input image (Image), i.e., it transforms the image into the<br />

frequency domain. The algorithm used is the fast Fourier transform. This corresponds to the call<br />

fft generic(Image,ImageFFT,’to freq’,1,’n’,’dc center’)<br />

<strong>HALCON</strong> 6.0


90 CHAPTER 3. FILTER<br />

The result image is of type ’complex’.<br />

Attention<br />

The filtering is always done on the entire image, i.e., the region of the image is ignored. The images must be<br />

quadratic and the width and height must be a power of 2.<br />

Parameter<br />

º Image (input object) .............................................image(-array) Hobject : byte / real<br />

Input image.<br />

º ImageFFT (output object) ......................................image(-array) Hobject * : complex<br />

Fourier-transformed image.<br />

Example<br />

fft_image(Image,&FFT);<br />

gen_gabor(&Filter,1.4,0.4,1.0,1.5,512);<br />

convol_gabor(FFT,Filter,&Gabor,&Hilbert);<br />

fft_image_inv(Gabor,&GaborInv);<br />

fft_image_inv(Hilbert,&HilbertInv);<br />

energy_gabor(GaborInv,HilbertInv,&Energy);<br />

Result<br />

fft image returns H MSG TRUE if the input image is of correct type and its width and height are a power of<br />

2. If the input is empty the behaviour can be set via set system(’no object result’,). If<br />

necessary, an exception handling is raised.<br />

Parallelization Information<br />

fft image is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

convol fft, convol gabor, convert image type, power byte, power real, power ln,<br />

phase deg, phase rad<br />

fft generic<br />

fft image inv<br />

Image filters<br />

Alternatives<br />

See Also<br />

Module<br />

fft image inv ( Hobject Image, Hobject *ImageFFTInv )<br />

Compute the inverse fast Fourier transform of an image.<br />

fft image inv calculates the inverse Fourier transform of the input image (Image), i.e., it transforms the<br />

image back into the spatial domain. This corresponds to the call<br />

fft generic(Image,ImageFFT,’from freq’,-1,’sqrt’,’dc center’)<br />

convert image type(ImageFFT,ImageFFTInv,’byte’) .<br />

The result image is of type ’byte’.<br />

Attention<br />

The filtering is always done on the entire image, i.e., the region of the image is ignored. The images must be<br />

quadratic and the width and height must be a power of 2.<br />

Parameter<br />

º Image (input object) ..............................................image(-array) Hobject : complex<br />

Input image.<br />

º ImageFFTInv (output object) ......................................image(-array) Hobject * : byte<br />

Inverse-Fourier-transformed image.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.7. FFT 91<br />

Example<br />

fft_image(Image,&FFT);<br />

gen_gabor(&Filter,1.4,0.4,1.0,1.5,512);<br />

convol_gabor(FFT,Filter,&Gabor,&Hilbert);<br />

fft_image_inv(Gabor,&GaborInv);<br />

fft_image_inv(Hilbert,&HilbertInv);<br />

energy_gabor(GaborInv,HilbertInv,&Energy);<br />

Result<br />

fft image inv returns H MSG TRUE if the input image is of correct type and its width and height are a power<br />

of 2. If the input is empty the behaviour can be set via set system(’no object result’,).<br />

If necessary, an exception handling is raised.<br />

Parallelization Information<br />

fft image inv is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

convol fft, convol gabor, fft image<br />

Possible Successor Functions<br />

convert image type, energy gabor<br />

fft generic<br />

fft image, fft generic, energy gabor<br />

Image filters<br />

Alternatives<br />

See Also<br />

Module<br />

gen bandfilter ( Hobject *ImageFilter, double MinFrequency,<br />

double MaxFrequency, long Size )<br />

Generate an ideal band filter.<br />

gen bandfilter generates an ideal band filter in the frequency domain. The DC term is assumed to lie in the<br />

center of the image. The parameters MinFrequency and MaxFrequency determine the cutoff frequencies of<br />

the filter (in pixels). The resulting image contains an annulus with the value 0, and the value 255 outside of this<br />

annulus.<br />

Parameter<br />

º ImageFilter (output object) .............................................image Hobject * : byte<br />

Band filter in the frequency domain.<br />

º MinFrequency (input control) .......................................................real double<br />

Minimum frequency.<br />

Default Value : 20<br />

Value Suggestions : MinFrequency ¾10, 20, 30, 40, 50, 60, 70, 100<br />

Typical Range of Values : 1 MinFrequency<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : MinFrequency 0<br />

º MaxFrequency (input control) .......................................................real double<br />

Maximum frequency.<br />

Default Value : 40<br />

Value Suggestions : MaxFrequency ¾10, 20, 30, 40, 50, 60, 70, 100<br />

Typical Range of Values : 1 MaxFrequency<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : MaxFrequency 0<br />

<strong>HALCON</strong> 6.0


92 CHAPTER 3. FILTER<br />

º Size (input control) .................................................................integer long<br />

Size (dimension) of the image (filter).<br />

Default Value : 512<br />

Value List : Size ¾8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192<br />

Example<br />

my_lowpass(Hobject Image, Hobject *Result)<br />

{<br />

Hobject FFT, Bandpass, FFTConvol;<br />

fft_image(Image,&FFT);<br />

gen_bandfilter(&Bandpass,20,40,512);<br />

convol_fft(FFT,Bandpass,&FFTConvol);<br />

clear_obj(Bandpass); clear_obj(FFT);<br />

fft_image_inv(FFTConvol,Result);<br />

clear_obj(FFTConvol);<br />

}<br />

Result<br />

gen bandfilter returns H MSG TRUE if all parameters are correct. If necessary, an exception handling is<br />

raised.<br />

Parallelization Information<br />

gen bandfilter is reentrant and processed without parallelization.<br />

convol fft<br />

gen circle, paint region<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

gen highpass, gen lowpass, gen bandpass<br />

Image filters<br />

Module<br />

gen bandpass ( Hobject *ImageBandpass, double MinFrequency,<br />

double MaxFrequency, long Size )<br />

Generate an ideal bandpass filter.<br />

gen bandpass generates an ideal bandpass filter in the frequency domain. The DC term is assumed to lie in the<br />

center of the image. The parameters MinFrequency and MaxFrequency determine the cutoff frequencies of<br />

the filter (in pixels). The resulting image contains an annulus with the value 255, and the value 0 outside of this<br />

annulus.<br />

Parameter<br />

º ImageBandpass (output object) ..........................................image Hobject * : byte<br />

Bandpass filter in the frequency domain.<br />

º MinFrequency (input control) .......................................................real double<br />

Minimum frequency.<br />

Default Value : 20<br />

Value Suggestions : MinFrequency ¾10, 20, 30, 40, 50, 60, 70, 100<br />

Typical Range of Values : 1 MinFrequency 200<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : MinFrequency 0<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.7. FFT 93<br />

º MaxFrequency (input control) .......................................................real double<br />

Maximum frequency.<br />

Default Value : 40<br />

Value Suggestions : MaxFrequency ¾10, 20, 30, 40, 50, 60, 70, 100<br />

Typical Range of Values : 1 MaxFrequency 200<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : MaxFrequency 0<br />

º Size (input control) .................................................................integer long<br />

Size (dimension) of the image (filter).<br />

Default Value : 512<br />

Value List : Size ¾8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192<br />

Example<br />

my_lowpass(Hobject Image, Hobject *Result)<br />

{<br />

Hobject FFT, Bandpass, FFTConvol;<br />

fft(Image,&FFT);<br />

gen_bandpass(&Bandpass,20,40,512);<br />

convol_fft(FFT,Bandpass,&FFTConvol);<br />

clear_obj(Bandpass); clear_obj(FFT);<br />

fft_image_inv(FFTConvol,Result);<br />

clear_obj(FFTConvol);<br />

}<br />

Result<br />

gen bandpass returns H MSG TRUE if all parameters are correct. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

gen bandpass is reentrant and processed without parallelization.<br />

convol fft<br />

gen circle, paint region<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

gen highpass, gen lowpass, gen bandfilter<br />

Image filters<br />

Module<br />

gen filter mask ( Hobject *ImageFilter, const char *FileName,<br />

double Scale, long Size )<br />

Store a filter mask in the spatial domain as a real-image.<br />

gen filter mask stores a filter mask in the spatial domain as a real-image. The center of the filter mask lies in<br />

the center of the resulting image. The parameter Scale determines by which amount the values of the filter mask<br />

are multiplied (this results in larger values of the Fourier transform of the filter). The file format of the filter mask<br />

file is described with the operator convol image. Example filter masks can be found in the directory “filter” in<br />

the <strong>HALCON</strong> home directory. This operator is useful for visualizing the frequency response of filter masks (by<br />

applying a Fourier transform to the result image of this operator).<br />

Parameter<br />

º ImageFilter (output object) .......................................image(-array) Hobject * : real<br />

Filter in the spatial domain.<br />

º FileName (input control) ......................................................string const char *<br />

File name of the filter mask.<br />

Default Value : ’sobel’<br />

Value Suggestions : FileName ¾’laplace4’, ’laplace8’, ’lowpass 3 3’<br />

<strong>HALCON</strong> 6.0


94 CHAPTER 3. FILTER<br />

º Scale (input control) .................................................................real double<br />

Scaling factor.<br />

Default Value : 1.0<br />

Value Suggestions : Scale ¾0.3, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0<br />

Typical Range of Values : 0.001 Scale 10.0<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.1<br />

Restriction : Scale 0.0<br />

º Size (input control) .................................................................integer long<br />

Size (dimension) of the image (filter).<br />

Default Value : 512<br />

Value List : Size ¾8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192<br />

Example<br />

gen_filter_mask(&Filter,"lowpass_3_3",1.0,512);<br />

fft_image(Filter,&FilterFFT);<br />

set_paint(WindowHandle,"3D-plot_hidden");<br />

disp_image(FilterFFT,WindowHandle);<br />

Parallelization Information<br />

gen filter mask is reentrant and processed without parallelization.<br />

fft image, fft generic<br />

convol image<br />

Image filters<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

gen gabor ( Hobject *ImageFilter, double Angle, double Frequency,<br />

double Bandwidth, double Orientation, long Size )<br />

Generate a Gabor filter.<br />

gen gabor generates a Gabor filter with a user-definable bandpass frequency range and sign for the Hilbert<br />

transformation. This is done by calculating a symmetrical filter in the frequency domain, which can be adapted by<br />

the parameters Angle, Frequency, Bandwidth und Orientation such that a certain frequency band and<br />

a certain direction range in the spatial domain is filtered out in the frequency domain.<br />

The parameters Frequency (central frequency = distance from the DC term) and Orientation (direction)<br />

determine the center of the filter. Larger values of Frequency result in higher frequencies being passed. A value<br />

of 0 for Orientation generates a horizontally oriented “crescent” (the bulge of the crescent points upward).<br />

Higher values of Orientation result in the counterclockwise rotation of the crescent.<br />

The parameters Angle and Bandwidth are used to determine the range of frequencies and angles being passed<br />

by the filter. The larger Angle is, the smaller the range of angles passed by the filter gets (because the “crescent”<br />

gets narrower). The larger Bandwidth is, the smaller the frequency band being passed gets (because the<br />

“crescent” gets thinner).<br />

The resulting image is a byte-image, containing the Gabor filter in the upper half of the image (symmetry of<br />

the Gabor filter), and the corresponding sign values needed for the calculation of the Hilbert transform, which is<br />

needed to compute the local energy of the image, in the lower half of the image.<br />

Parameter<br />

º ImageFilter (output object) ......................................image(-array) Hobject * : byte<br />

Gabor filter (and sign values).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.7. FFT 95<br />

º Angle (input control) .................................................................real double<br />

Angle range, inversely proportional to the range of orientations.<br />

Default Value : 1.4<br />

Value Suggestions : Angle ¾1.0, 1.2, 1.4, 1.6, 2.0, 2.5, 3.0, 5.0, 6.0, 10.0, 20.0, 30.0, 50.0, 70.0, 100.0<br />

Typical Range of Values : 1.0 Angle 500.0<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.1<br />

º Frequency (input control) ...........................................................real double<br />

Distance of the center of the filter to the DC term.<br />

Default Value : 0.4<br />

Value Suggestions : Frequency ¾0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.50, 0.55, 0.60,<br />

0.65, 0.699<br />

Typical Range of Values : 0.0 Frequency 0.7<br />

Minimal Value Step : 0.00001<br />

Recommended Value Step : 0.005<br />

º Bandwidth (input control) ...........................................................real double<br />

Bandwith range, inversely proportional to the range of frequencies being passed.<br />

Default Value : 1.0<br />

Value Suggestions : Bandwidth ¾0.1, 0.3, 0.7, 1.0, 1.5, 2.0, 3.0, 5.0, 7.0, 10.0, 15.0, 20.0, 30.0, 50.0<br />

Typical Range of Values : 0.05 Bandwidth 100.0<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.1<br />

º Orientation (input control) .........................................................real double<br />

Angle of the principal orientation being passed.<br />

Default Value : 1.5<br />

Value Suggestions : Orientation ¾0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8,<br />

3.0, 3.14<br />

Typical Range of Values : 0.0 Orientation 3.1416<br />

Minimal Value Step : 0.0001<br />

Recommended Value Step : 0.05<br />

º Size (input control) .................................................................integer long<br />

Size (dimension) of the image (filter).<br />

Default Value : 512<br />

Value List : Size ¾8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192<br />

Example<br />

fft_image(Image,&FFT);<br />

gen_gabor(&Filter,1.4,0.4,1.0,1.5,512);<br />

convol_gabor(FFT,Filter,&Gabor,&Hilbert);<br />

fft_image_inv(Gabor,&GaborInv);<br />

fft_image_inv(Hilbert,&HilbertInv);<br />

energy_gabor(GaborInv,HilbertInv,&Energy);<br />

Result<br />

gen gabor returns H MSG TRUE if all parameters are correct. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

gen gabor is reentrant and processed without parallelization.<br />

fft image, fft generic<br />

convol gabor<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

gen bandpass, gen bandfilter, gen highpass, gen lowpass<br />

fft image inv, energy gabor<br />

Image filters<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


96 CHAPTER 3. FILTER<br />

gen highpass ( Hobject *ImageHighpass, double Frequency, long Size )<br />

Generate an ideal highpass filter.<br />

gen highpass generates an ideal highpass filter in the frequency domain. The DC term is assumed to lie in<br />

the center of the image. The parameter Frequency determines the cutoff frequency of the filter (in pixels). The<br />

resulting image contains a circle of radius Frequency with the value 0, and the value 255 outside of this circle.<br />

Parameter<br />

º ImageHighpass (output object) ..........................................image Hobject * : byte<br />

Highpass filter in the frequency domain.<br />

º Frequency (input control) ...........................................................real double<br />

Cutoff frequency.<br />

Default Value : 20<br />

Value Suggestions : Frequency ¾10, 20, 30, 40, 50, 60, 70, 100<br />

Typical Range of Values : 1 Frequency 200<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : Frequency 0<br />

º Size (input control) .................................................................integer long<br />

Size (dimension) of the image (filter).<br />

Default Value : 512<br />

Value List : Size ¾16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192<br />

Example<br />

my_highpass(Hobject Image, Hobject *Result, int frequency, int size)<br />

{<br />

Hobject FFT, Highpass, FFTConvol;<br />

fft_image(Image,&FFT);<br />

gen_highpass(&Highpass,frequency,size);<br />

convol_fft(FFT,Highpass,&FFTConvol);<br />

clear_obj(Highpass); clear_obj(FFT);<br />

fft_image_inv(FFTConvol,Result);<br />

clear_obj(FFTConvol);<br />

}<br />

Result<br />

gen highpass returns H MSG TRUE if all parameters are correct. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

gen highpass is reentrant and processed without parallelization.<br />

convol fft<br />

gen circle, paint region<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

convol fft, gen lowpass, gen bandpass, gen bandfilter<br />

Image filters<br />

Module<br />

gen lowpass ( Hobject *ImageLowpass, double Frequency, long Size )<br />

Generate an ideal lowpass filter.<br />

gen lowpass generates an ideal lowpass filter in the frequency domain. The DC term is assumed to lie in the<br />

center of the image. The parameter Frequency determines the cutoff frequency of the filter (in pixels). The<br />

resulting image contains a circle of radius Frequency with the value 255, and the value 0 outside of this circle.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.7. FFT 97<br />

Parameter<br />

º ImageLowpass (output object) ............................................image Hobject * : byte<br />

Highpass filter in the frequency domain.<br />

º Frequency (input control) ...........................................................real double<br />

Cutoff frequency.<br />

Default Value : 20<br />

Value Suggestions : Frequency ¾10, 20, 30, 40, 50, 60, 70, 100<br />

Typical Range of Values : 1 Frequency 200<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Size (input control) .................................................................integer long<br />

Size (dimension) of the image (filter).<br />

Default Value : 512<br />

Value List : Size ¾16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192<br />

Example<br />

my_lowpass(Hobject Image, Hobject *Result, int frequency, int size)<br />

{<br />

Hobject FFT, Lowpass, FFTConvol;<br />

fft(Image,&FFT);<br />

gen_lowpass(&Lowpass,frequency,size);<br />

convol_fft(FFT,Lowpass,&FFTConvol);<br />

clear_obj(Lowpass); clear_obj(FFT);<br />

fft_image_inv(FFTConvol,Result);<br />

clear_obj(FFTConvol);<br />

}<br />

Result<br />

gen lowpass returns H MSG TRUE if all parameters are correct. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

gen lowpass is reentrant and processed without parallelization.<br />

convol fft<br />

gen circle, paint region<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

gen highpass, gen bandpass, gen bandfilter<br />

Image filters<br />

Module<br />

gen sin bandpass ( Hobject *ImageFilter, double Frequency, long Size )<br />

Generate a bandpass filter with sinusoidal shape.<br />

gen sin bandpass generates a rotationally invariant bandpass filter with the response being a sinusoidal function<br />

in the frequency domain. The maximum of the sine (255) is determined by Frequency (distance from the<br />

DC term in pixels). The filter is always zero for the DC term, rises with the sine function up to Frequency,and<br />

drops for higher frequencies accordingly. The range of the sine used is from ¼ to . All other points are set to zero.<br />

Parameter<br />

º ImageFilter (output object) ......................................image(-array) Hobject * : byte<br />

Bandpass filter as image in the frequency domain.<br />

<strong>HALCON</strong> 6.0


98 CHAPTER 3. FILTER<br />

º Frequency (input control) ...........................................................real double<br />

Distance of the filter’s maximum from the DC term.<br />

Default Value : 20<br />

Value Suggestions : Frequency ¾0.0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 80, 100, 150, 200<br />

Typical Range of Values : 0.0 Frequency 1000<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

º Size (input control) .................................................................integer long<br />

Size (dimension) of the image (filter).<br />

Default Value : 512<br />

Value List : Size ¾8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192<br />

Result<br />

gen sin bandpass returns H MSG TRUE if all parameters are correct. If necessary, an exception handling is<br />

raised.<br />

Parallelization Information<br />

gen sin bandpass is reentrant and processed without parallelization.<br />

fft image, fft generic<br />

convol fft<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

gen std bandpass, gen bandpass, gen bandfilter, gen highpass, gen lowpass<br />

fft image inv<br />

Image filters<br />

See Also<br />

Module<br />

gen std bandpass ( Hobject *ImageFilter, double Frequency, double Sigma,<br />

long Size, const char *Mode )<br />

Generate a bandpass filter with Gaussian or sinusoidal shape.<br />

gen std bandpass generates a rotationally invariant bandpass filter with the response being determined by<br />

the parameters Frequency and Sigma: Frequency determines the location of the maximum response with<br />

respect to the DC term, while Sigma determines the width of the frequency band that passes the filter. For Mode<br />

= ’gauss’, a Gaussian response is generated with Sigma being the standard deviation. For Mode = ’sin’, asine<br />

function is generated with the maximum at Frequency and the extent Sigma.<br />

Parameter<br />

º ImageFilter (output object) ......................................image(-array) Hobject * : byte<br />

Bandpass filter as image in the frequency domain.<br />

º Frequency (input control) ...........................................................real double<br />

Distance of the filter’s maximum from the DC term.<br />

Default Value : 20<br />

Value Suggestions : Frequency ¾0.0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 80, 100, 150, 200<br />

Typical Range of Values : 0.0 Frequency 1000<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

º Sigma (input control) .................................................................real double<br />

Bandwidth of the filter (standard deviation).<br />

Default Value : 1.0<br />

Value Suggestions : Sigma ¾0.1, 0.3, 0.7, 1.0, 1.5, 2.0, 3.0, 5.0, 7.0, 10.0, 15.0, 20.0, 30.0, 50.0<br />

Typical Range of Values : 0.05 Sigma 100.0<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.1<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.7. FFT 99<br />

º Size (input control) .................................................................integer long<br />

Size (dimension) of the image (filter).<br />

Default Value : 512<br />

Value List : Size ¾8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192<br />

º Mode (input control) ............................................................string const char *<br />

Filter type.<br />

Default Value : ’sin’<br />

Value List : Mode ¾’sin’, ’gauss’<br />

Result<br />

gen std bandpass returns H MSG TRUE if all parameters are correct. If necessary, an exception handling is<br />

raised.<br />

Parallelization Information<br />

gen std bandpass is reentrant and processed without parallelization.<br />

fft image, fft generic<br />

convol fft<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

gen sin bandpass, gen bandpass, gen bandfilter, gen highpass, gen lowpass<br />

fft image inv<br />

Image filters<br />

See Also<br />

Module<br />

phase deg ( Hobject ImageComplex, Hobject *ImagePhase )<br />

Return the phase of a complex image in degrees.<br />

phase deg computes the phase of a complex image in degrees. The following formula is used:<br />

Ô× <br />

½¼ØÒ ½´ÑÒÖÝÔÖØÖÐÔÖص<br />

<br />

<br />

Parameter<br />

º ImageComplex (input object) ....................................image(-array) Hobject : complex<br />

Input image in frequency domain.<br />

º ImagePhase (output object) ...................................image(-array) Hobject * : direction<br />

Phase of the image in degrees.<br />

read_image(&Image,"affe");<br />

disp_image(Image,WindowHandle);<br />

fft_image(Image,&FFT);<br />

phase_deg(FFT,&Phase);<br />

disp_image(Phase,WindowHandle);<br />

Example<br />

Result<br />

phase deg returns H MSG TRUE if the image is of correct type. If the input is empty the behaviour can be set<br />

via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

phase deg is reentrant and automatically parallelized (on tuple level, domain level).<br />

fft image, fft generic<br />

Possible Predecessor Functions<br />

<strong>HALCON</strong> 6.0


100 CHAPTER 3. FILTER<br />

disp image<br />

phase rad<br />

fft image inv<br />

Image filters<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

phase rad ( Hobject ImageComplex, Hobject *ImagePhase )<br />

Return the phase of a complex image in radians.<br />

phase rad computes the phase of a complex image in radians. The following formula is used:<br />

Ô× ØÒ ½´ÑÒÖÝÔÖØÖÐÔÖص <br />

Parameter<br />

º ImageComplex (input object) ....................................image(-array) Hobject : complex<br />

Input image in frequency domain.<br />

º ImagePhase (output object) ........................................image(-array) Hobject * : real<br />

Phase of the image in radians.<br />

Example<br />

read_image(&Image,"affe");<br />

disp_image(Image,WindowHandle);<br />

fft_image(Image,&FFT);<br />

phase_rad(FFT,&Phase);<br />

disp_image(Phase,WindowHandle);<br />

Result<br />

phase rad returns H MSG TRUE if the image is of correct type. If the input is empty the behaviour can be set<br />

via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

phase rad is reentrant and automatically parallelized (on tuple level, domain level).<br />

fft image, fft generic<br />

disp image<br />

phase deg<br />

fft image inv<br />

Image filters<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

power byte ( Hobject Image, Hobject *PowerByte )<br />

Return the power spectrum of a complex image.<br />

power byte computes the power spectrum from the real and imaginary parts of a Fourier-transformed image<br />

(see fft image), i.e., the modulus of the frequencies. The result image is of type ’byte’. The following formula<br />

is used:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.7. FFT 101<br />

Ô<br />

ÖÐÔÖؾ · ÑÒÖÝÔÖØ ¾<br />

<br />

Parameter<br />

º Image (input object) ..............................................image(-array) Hobject : complex<br />

Input image in frequency domain.<br />

º PowerByte (output object) .........................................image(-array) Hobject * : byte<br />

Power spectrum of the input image.<br />

Example<br />

read_image(&Image,"affe");<br />

disp_image(Image,WindowHandle);<br />

fft_image(Image,&FFT);<br />

power_byte(FFT,&Power);<br />

disp_image(Power,WindowHandle);<br />

Result<br />

power byte returns H MSG TRUE if the image is of correct type. If the input is empty the behaviour can be set<br />

via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

power byte is reentrant and automatically parallelized (on tuple level, domain level).<br />

Possible Predecessor Functions<br />

fft image, fft generic, convol fft, convol gabor<br />

disp image<br />

Possible Successor Functions<br />

Alternatives<br />

abs image, convert image type, power real, power ln<br />

fft image<br />

Image filters<br />

See Also<br />

Module<br />

power ln ( Hobject Image, Hobject *ImageResult )<br />

Return the power spectrum of a complex image.<br />

power ln computes the power spectrum from the real and imaginary parts of a Fourier-transformed image (see<br />

fft image), i.e., the modulus of the frequencies. Additionally, the natural logarithm is applied to the result. The<br />

result image is of type ’real’. The following formula is used:<br />

ÐÒ<br />

Ô<br />

ÖÐÔÖؾ · ÑÒÖÝÔÖØ ¾ <br />

Parameter<br />

º Image (input object) ..............................................image(-array) Hobject : complex<br />

Input image in frequency domain.<br />

º ImageResult (output object) .......................................image(-array) Hobject * : real<br />

Power spectrum of the input image.<br />

Example<br />

read_image(&Image,"affe");<br />

disp_image(Image,WindowHandle);<br />

fft_image(Image,&FFT);<br />

power_real(FFT,&Power);<br />

disp_image(Power,WindowHandle);<br />

<br />

<strong>HALCON</strong> 6.0


102 CHAPTER 3. FILTER<br />

Result<br />

power ln returns H MSG TRUE if the image is of correct type. If the input is empty the behaviour can be set<br />

via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

power ln is reentrant and automatically parallelized (on tuple level, domain level).<br />

Possible Predecessor Functions<br />

fft image, fft generic, convol fft, convol gabor<br />

Possible Successor Functions<br />

disp image, convert image type, scale image<br />

Alternatives<br />

abs image, convert image type, power real, power byte<br />

fft image, fft generic<br />

Image filters<br />

See Also<br />

Module<br />

power real ( Hobject Image, Hobject *ImageResult )<br />

Return the power spectrum of a complex image.<br />

power real computes the power spectrum from the real and imaginary parts of a Fourier-transformed image<br />

(see fft image), i.e., the modulus of the frequencies. The result image is of type ’real’. The following formula<br />

is used:<br />

Ô<br />

ÖÐÔÖؾ · ÑÒÖÝÔÖØ ¾ <br />

Parameter<br />

º Image (input object) ..............................................image(-array) Hobject : complex<br />

Input image in frequency domain.<br />

º ImageResult (output object) .......................................image(-array) Hobject * : real<br />

Power spectrum of the input image.<br />

Example<br />

read_image(&Image,"affe");<br />

disp_image(Image,WindowHandle);<br />

fft_image(Image,&FFT);<br />

power_real(FFT,&Power);<br />

disp_image(Power,WindowHandle);<br />

Result<br />

power real returns H MSG TRUE if the image is of correct type. If the input is empty the behaviour can be set<br />

via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

power real is reentrant and automatically parallelized (on tuple level, domain level).<br />

Possible Predecessor Functions<br />

fft image, fft generic, convol fft, convol gabor<br />

Possible Successor Functions<br />

disp image, convert image type, scale image<br />

Alternatives<br />

abs image, convert image type, power byte, power ln<br />

fft image<br />

Image filters<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.8. LINES 103<br />

3.8 Lines<br />

bandpass image ( Hobject Image, Hobject *ImageBandpass,<br />

const char *FilterType )<br />

Edge extraction using bandpass filters.<br />

bandpass image serves as an edge filter. It applies a linear filter with the following convolution mask to<br />

Image:<br />

FilterType: ’lines’<br />

In contrast to the edge operator sobel amp this filter detects lines instead of edges, i.e., two closely adjacent<br />

edges.<br />

¼ ¾ ¾ ¾ ¼<br />

¾ ¼ ¿ ¼ ¾<br />

¾ ¿ ½¾ ¿ ¾<br />

¾ ¼ ¿ ¼ ¾<br />

¼ ¾ ¾ ¾ ¼<br />

At the border of the image the gray values are mirrored. Over- and underflows of gray values are clipped to the<br />

interval [0,255]. The resulting images are returned in ImageBandpass.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Input images.<br />

º ImageBandpass (output object) . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte<br />

Bandpass-filtered images.<br />

º FilterType (input control) ...................................................string const char *<br />

Filter type: currently only ’lines’ is supported.<br />

Default Value : ’lines’<br />

Value List : FilterType ¾’lines’<br />

Example<br />

bandpass_image(Image,&LineImage,"lines");<br />

threshold(LineImage,&Lines,60.0,255.0);<br />

skeleton(Lines,&ThinLines);<br />

Result<br />

bandpass image returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can<br />

be set via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

bandpass image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

threshold, skeleton<br />

Possible Successor Functions<br />

Alternatives<br />

convol image, topographic sketch, (T )texture laws<br />

highpass image, gray skeleton<br />

Image filters<br />

See Also<br />

Module<br />

lines facet ( Hobject Image, Hobject *Lines, long MaskSize, double Low,<br />

double High, const char *LightDark )<br />

Detection of lines using the facet model.<br />

<strong>HALCON</strong> 6.0


104 CHAPTER 3. FILTER<br />

The operator lines facet can be used to extract lines (curvilinear structures) from the image Image. The<br />

extracted lines are returned in Lines as sub-pixel precise XLD-contours. The parameter LightDark determines,<br />

whether bright or dark lines are extracted.<br />

The extraction is done by using the facet model, i.e., a least squares fit, to determine the parameters of a quadratic<br />

polynomial in x and y for each point of the image. The parameter MaskSize determines the size of the window<br />

used for the least squares fit. Larger values of MaskSize lead to a larger smoothing of the image, but can<br />

lead to worse localization of the line. The parameters of the polynomial are used to calculate the line direction<br />

for each pixel. Pixels which exhibit a local maximum in the second directional derivative perpendicular to the<br />

line direction are marked as line points. The line points found in this manner are then linked to contours. This<br />

is done by immediately accepting line points that have a second derivative larger than High. Points that have<br />

a second derivative smaller than Low are rejected. All other line points are accepted if they are connected to<br />

accepted points by a connected path. This is similar to a hysteresis threshold operation with infinite path length (see<br />

hysteresis threshold). However, this function is not used internally since it does not allow the extraction<br />

of sub-pixel precise contours.<br />

The gist of how to select the thresholds in the description of lines gauss also holds for this operator. A value<br />

of Sigma = 1.5 there roughly corresponds to a MaskSize of 5 here.<br />

The extracted lines are returned in a topologically sound data structure in Lines. This means that lines are<br />

correctly split at junction points.<br />

Attention<br />

The smaller the filter size MaskSize is chosen, the more short, fragmented lines will be extracted. This can lead<br />

to considerably longer execution times.<br />

Parameter<br />

º Image (input object) ......................singlechannel-image Hobject : byte / int1 / int2 / int4 / real<br />

Input image.<br />

º Lines (output object) ....................................................xld cont-array Hobject *<br />

Extracted lines.<br />

º MaskSize (input control) ............................................................integer long<br />

Size of the facet model mask.<br />

Default Value : 5<br />

Value List : MaskSize ¾3, 5, 7, 9, 11<br />

º Low (input control) ..........................................................number double / long<br />

Lower threshold for the hysteresis threshold operation.<br />

Default Value : 3<br />

Value Suggestions : Low ¾0, 0.5, 1, 2, 3, 4, 5, 8, 10<br />

Typical Range of Values : 0 Low 20<br />

Recommended Value Step : 0.5<br />

Restriction : Low 0<br />

º High (input control) ........................................................number double / long<br />

Upper threshold for the hysteresis threshold operation.<br />

Default Value : 8<br />

Value Suggestions : High ¾0, 0.5, 1, 2, 3, 4, 5, 8, 10, 12, 15, 18, 20, 25<br />

Typical Range of Values : 0 High 35<br />

Recommended Value Step : 0.5<br />

Restriction : ´High 0µ ´High Lowµ<br />

º LightDark (input control) .....................................................string const char *<br />

Extract bright or dark lines.<br />

Default Value : ’light’<br />

Value List : LightDark ¾’dark’, ’light’<br />

Example<br />

/* Detection of lines in an aerial image */<br />

read_image(&Image,"mreut4_3");<br />

lines_facet(Image:&Lines:5,3,8,"light");<br />

disp_xld(Lines,WindowHandle);<br />

Result<br />

lines facet returns H MSG TRUE if all parameters are correct and no error occurs during execution. If the<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.8. LINES 105<br />

input is empty the behaviour can be set via set system(’no object result’,). If necessary,<br />

an exception handling is raised.<br />

Parallelization Information<br />

lines facet is reentrant and automatically parallelized (on tuple level).<br />

gen polygons xld<br />

lines gauss<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

bandpass image, dyn threshold, topographic sketch<br />

Bibliography<br />

A. Busch: ”‘Fast Recognition of Lines in Digital Images Without User-Supplied Parameters”’. In H. Ebner, C.<br />

Heipke, K.Eder, eds., ”‘Spatial Information from Digital Photogrammetry and Computer Vision”’, International<br />

Archives of Photogrammetry and Remote Sensing, Vol. 30, Part 3/1, pp. 91-97, 1994.<br />

Module<br />

Sub-pixel operators<br />

lines gauss ( Hobject Image, Hobject *Lines, double Sigma, double Low,<br />

double High, const char *LightDark, const char *ExtractWidth,<br />

const char *CorrectPositions, const char *CompleteJunctions )<br />

Detect lines and their width.<br />

The operator lines gauss can be used to extract lines (curvilinear structures) from the image Image. Theextracted<br />

lines are returned in Lines as sub-pixel precise XLD-contours. The parameter LightDark determines,<br />

whether bright or dark lines are extracted. If ExtractWidth is set to ’true’ the line width is extracted for each<br />

line point. If CorrectPositions is set to ’true’, lines gauss compensates the effect of asymmetrical lines<br />

(lines having different contrast on each side of the line), and corrects the position and width of the line. This parameter<br />

is only meaningful if ExtractWidth=’true’. Because the line extractor is unable to extract certain junctions<br />

because of differential geometric reasons, it tries to extract these by different means if CompleteJunctions is<br />

set to ’true’.<br />

The extraction is done by using partial derivatives of a Gaussian smoothing kernel to determine the parameters<br />

of a quadratic polynomial in x and y for each point of the image. The parameter Sigma determines the amount<br />

of smoothing to be performed. Larger values of Sigma lead to a larger smoothing of the image, but can lead<br />

to worse localization of the line. Generally, the localization will be much better than that of lines returned by<br />

lines facet with comparable parameters. The parameters of the polynomial are used to calculate the line<br />

direction for each pixel. Pixels which exhibit a local maximum in the second directional derivative perpendicular<br />

to the line direction are marked as line points. The line points found in this manner are then linked to contours.<br />

This is done by immediately accepting line points that have a second derivative larger than High. Points that<br />

have a second derivative smaller than Low are rejected. All other line points are accepted if they are connected to<br />

accepted points by a connected path. This is similar to a hysteresis threshold operation with infinite path length (see<br />

hysteresis threshold). However, this function is not used internally since it does not allow the extraction<br />

of sub-pixel precise contours.<br />

For the choice of the thresholds High and Low one has to keep in mind that the second directional derivative<br />

depends on the amplitude and width of the line as well as the choice of Sigma. The value of the second derivative<br />

depends linearly on the amplitude, i.e., the larger the amplitude, the larger the response. For the width of the<br />

line there is an approximately inverse exponential dependence: The wider the line is, the smaller the response<br />

gets. This holds analogously for the dependence on Sigma: ThelargerSigma is chosen, the smaller the second<br />

derivative will be. This means that for larger smoothing correspondingly smaller values for High and Low have<br />

to be chosen. Two examples help to illustrate this: If 5 pixel wide lines with an amplitude larger than 100 are to be<br />

extracted from an image with a smoothing of Sigma =1.5,High should be chosen larger than 14. If, on the other<br />

hand, 10 pixel wide lines with an amplitude larger than 100 and a Sigma = 3 are to be detected, High should be<br />

chosen larger than 3.5. For the choice of Low values between 0.25 High and 0.5 High are appropriate.<br />

The extracted lines are returned in a topologically sound data structure in Lines. This means that lines are<br />

correctly split at junction points.<br />

<strong>HALCON</strong> 6.0


106 CHAPTER 3. FILTER<br />

lines gauss defines the following attributes for each line point if ExtractWidth was set to ’false’:<br />

’angle’ The angle of the direction perpendicular to the line<br />

’response’ The magnitude of the second derivative<br />

If ExtractWidth was set to ’true’ and CorrectPositions to ’false’, the following attributes are defined<br />

in addition to the above ones:<br />

’width left’ The line width to the left of the line<br />

’width right’ The line width to the right of the line<br />

Finally, if CorrectPositions was set to ’true’, additionally the following attributes are defined:<br />

’asymmetry’ The asymmetry of the line point<br />

’contrast’ The contrast of the line point<br />

Here, the asymmetry is positive if the asymmetric part, i.e., the part with the weaker gradient, is on the right side of<br />

the line, while it is negative if the asymmetric part is on the left side of the line. All these attributes can be queried<br />

via the operator get contour attrib xld.<br />

Attention<br />

In general, but in particular if the line width is to be extracted, ËÑ Û Ô ¿ should be selected, where Û is<br />

the width (half the diameter) of the lines in the image. As the lowest allowable value ËÑ Û¾ must be<br />

selected. If, for example, lines with a width of 4 pixels (diameter 8 pixels) are to be extracted, ËÑ ¾¿ should<br />

be selected.<br />

Parameter<br />

º Image (input object) ......................singlechannel-image Hobject : byte / int1 / int2 / int4 / real<br />

Input image.<br />

º Lines (output object) ....................................................xld cont-array Hobject *<br />

Extracted lines.<br />

º Sigma (input control) .......................................................number double / long<br />

Amount of Gaussian smoothing to be applied.<br />

Default Value : 1.5<br />

Value Suggestions : Sigma ¾1, 1.2, 1.5, 1.8, 2, 2.5, 3, 4, 5<br />

Typical Range of Values : 0.7 Sigma 20<br />

Recommended Value Step : 0.1<br />

º Low (input control) ..........................................................number double / long<br />

Lower threshold for the hysteresis threshold operation.<br />

Default Value : 3<br />

Value Suggestions : Low ¾0, 0.5, 1, 2, 3, 4, 5, 8, 10<br />

Typical Range of Values : 0 Low 20<br />

Recommended Value Step : 0.5<br />

Restriction : Low 0<br />

º High (input control) ........................................................number double / long<br />

Upper threshold for the hysteresis threshold operation.<br />

Default Value : 8<br />

Value Suggestions : High ¾0, 0.5, 1, 2, 3, 4, 5, 8, 10, 12, 15, 18, 20, 25<br />

Typical Range of Values : 0 High 35<br />

Recommended Value Step : 0.5<br />

Restriction : ´High 0µ ´High Lowµ<br />

º LightDark (input control) .....................................................string const char *<br />

Extract bright or dark lines.<br />

Default Value : ’light’<br />

Value List : LightDark ¾’dark’, ’light’<br />

º ExtractWidth (input control) .................................................string const char *<br />

Should the line width be extracted?<br />

Default Value : ’true’<br />

Value List : ExtractWidth ¾’true’, ’false’<br />

º CorrectPositions (input control) ...........................................string const char *<br />

Should the line position and width be corrected?<br />

Default Value : ’true’<br />

Value List : CorrectPositions ¾’true’, ’false’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.9. MATCH 107<br />

º CompleteJunctions (input control) ..........................................string const char *<br />

Should junctions be added where they cannot be extracted?<br />

Default Value : ’true’<br />

Value List : CompleteJunctions ¾’true’, ’false’<br />

Example<br />

/* Detection of lines in an aerial image */<br />

read_image(&Image,"mreut4_3");<br />

lines_gauss(Image:&Lines:1.5,3,8,"light","true","true","true");<br />

disp_xld(Lines,WindowHandle);<br />

Result<br />

lines gauss returns H MSG TRUE if all parameters are correct and no error occurs during execution. If the<br />

input is empty the behaviour can be set via set system(’no object result’,). If necessary,<br />

an exception handling is raised.<br />

Parallelization Information<br />

lines gauss is reentrant and automatically parallelized (on tuple level).<br />

gen polygons xld<br />

lines facet<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

bandpass image, dyn threshold, topographic sketch<br />

Bibliography<br />

C. Steger: “Extracting Curvilinear Structures: A Differential Geometric Approach”. In B. Buxton, R. Cipolla, eds.,<br />

“Fourth European Conference on Computer Vision”, Lecture Notes in Computer Science, Volume 1064, Springer<br />

Verlag, pp. 630-641, 1996.<br />

C. Steger: “Extraction of Curved Lines from Images”. In “13th International Conference on Pattern Recognition”,<br />

Volume II, pp. 251-255, 1996.<br />

C. Steger: “An Unbiased Detector of Curvilinear Structures”. Technical Report FGBV-96-03, Forschungsgruppe<br />

Bildverstehen (FG BV), Informatik IX, Technische Universit”at M”unchen, July 1996.<br />

Module<br />

Sub-pixel operators<br />

3.9 Match<br />

adapt template ( Hobject Image, long TemplateID )<br />

Adapting a template to the size of an image.<br />

The operator adapt template serves to adapt a template which has been created by create template to<br />

the size of an image. The operator adapt template can be called before the template is used with images of<br />

another size, or if the image used to create the template had another size. If it is not called explicitly it will be<br />

called internally each time another image size is used. The contents of the image is hereby irrelevant; only the<br />

width of Image will be considered.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Image which determines the size of the later matching.<br />

º TemplateID (input control) ........................................................template long<br />

Template number.<br />

<strong>HALCON</strong> 6.0


108 CHAPTER 3. FILTER<br />

Result<br />

If the parameter values are correct, the operator adapt template returns the value H MSG TRUE. If necessary,<br />

an exception handling is raised.<br />

Parallelization Information<br />

adapt template is processed under mutual exclusion against itself and without parallelization.<br />

Possible Predecessor Functions<br />

create template, create template rot, read template<br />

Possible Successor Functions<br />

set reference template, (T )best match, fast match, (T )fast match mg,<br />

set offset template, best match mg, best match pre mg, (T )best match rot,<br />

(T )best match rot mg<br />

Module<br />

Template matching<br />

best match ( Hobject Image, long TemplateID, double MaxError,<br />

const char *SubPixel, double *Row, double *Column, double *Error )<br />

T best match ( Hobject Image, Htuple TemplateID, Htuple MaxError,<br />

Htuple SubPixel, Htuple *Row, Htuple *Column, Htuple *Error )<br />

Searching the best matching of a template and an image.<br />

The operator (T )best match performs a matching of the template of TemplateID and Image. Hereby<br />

the template will be moved over the points of Image so that the template will lie always inside Image.<br />

(T )best match works similar to fast match, with the exception, that each time a better match is found<br />

the value of MaxError is internally updated to a lower value to reduce runtime.<br />

With regard to the parameter SubPixel, the position will be indicated by subpixel accuracy. The matching<br />

criterion (“displaced frame difference”) is defined as follows:<br />

È<br />

ÙÚ ÁÑÖÓÛ Ù ÓÐ Ú℄ ÌÑÔÐØÁÙ Ú℄<br />

ÖÖÓÖÖÓÛ ÓÐ℄ <br />

Ö´Ì ÑÔÐØÁµ<br />

The runtime of the operator depends on the size of the domain of Image. Therefore it is important to restrict the<br />

domain as far as possible, i.e. to apply the operator only in a very confined “region of interest”. The parameter<br />

MaxError determines the maximal error which the searched position is allowed to have at most. The lower this<br />

value is, the faster the operator runs.<br />

Row and Column return the position of the best match, whereby Error indicates the average difference of the<br />

grayvalues. If no position with an error below MaxError was found the position ´¼ ¼µ and a matching result of<br />

¾ for Error are returned. In this case MaxError has to be set larger.<br />

The maximum error of the position (without noise) is ¼½ pixel. The average error is ¼¼¿ pixel.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Input image inside of which the pattern has to be found.<br />

º TemplateID (input control) ..............................................template (Htuple .) long<br />

Template number.<br />

º MaxError (input control) ...................................................real (Htuple .) double<br />

Maximum average difference of the grayvalues.<br />

Default Value : 20<br />

Value Suggestions : MaxError ¾0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 15, 17, 20, 30, 40, 50, 0, 70<br />

Typical Range of Values : 0 MaxError 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 3<br />

º SubPixel (input control) .............................................string (Htuple .) const char *<br />

Subpixel accuracy in case of ’true’.<br />

Default Value : ’false’<br />

Value List : SubPixel ¾’true’, ’false’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.9. MATCH 109<br />

º Row (output control) .............................................point.y(-array) (Htuple .) double *<br />

Row position of the best match.<br />

º Column (output control) .........................................point.x(-array) (Htuple .) double *<br />

Column position of the best match.<br />

º Error (output control) .............................................real(-array) (Htuple .) double *<br />

Average divergence of the grayvalues of the best match.<br />

Result<br />

If the parameter values are correct, the operator (T )best match returns the value H MSG TRUE.<br />

If the input is empty (no input images are available) the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

(T )best match is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

create template, read template, set offset template, set reference template,<br />

adapt template, draw region, draw rectangle1, reduce domain<br />

Alternatives<br />

fast match, (T )fast match mg, best match mg, best match pre mg, (T )best match rot,<br />

(T )best match rot mg, exhaustive match, exhaustive match mg<br />

Template matching<br />

Module<br />

best match mg ( Hobject Image, long TemplateID, double MaxError,<br />

const char *SubPixel, long NumLevels, long WhichLevels, double *Row,<br />

double *Column, double *Error )<br />

Searching the best grayvalue matches in a pyramid.<br />

best match mg applies gray value matching using an image pyramid. best match mg works analogously<br />

to (T )best match, but it is faster due to the use of a pyramid. Input is an image with an optionally reduced<br />

domain. The paramter MaxError specifies the maximum error for template matching. Using smaller values<br />

results in a reduced runtime but it is possible that the pattern might be missed. The value of MaxError has to set<br />

larger compared with (T )best match, because the error is at higher levels of the pyramid often increased.<br />

SubPixel specifies if the result is calculated with sub pixel accuracy or not. A value of 1 for SubPixel results<br />

in an operator similar to (T )best match, i.e. only the original gray values are used. For values larger than 1,<br />

the algorithm starts at the lowest resultion and searches for a position with the lowest matching error. At the next<br />

higher resolution this position is refined. This is continued up to the maximum resolution (WhichLevels = ’all’).<br />

As an alternative Method the mode WhichLevels with value ’original’ can be used. In this case not only the<br />

position with the lowest error but all points below MaxError are analysed further on in the next higher resolution.<br />

This method is slower but it is more stable and the possibilty to miss the correct position is very low. In this case<br />

it is often possible to start with a lower resolution (higher level in Pyramid, i.e. larger value for NumLevels)<br />

which leads to a reduced runtime. Besides the values ’all’ and ’original’ for WhichLevels you can specify<br />

the pyramid level explicitly where to switch between a “match all” and the ”best match”. Here 0 corresponds to<br />

’original’ and NumLevels - 1 is equivalent to ’all’. A value in between is in most cases a good compromise<br />

between speed and a stable detection. A larger value for WhichLevels results in a reduced runtime, a smaller<br />

value results in a more stable detection. The value of NumLevels has to equal or smaller than the value used to<br />

create the template.<br />

The position of the found matching position is returned in Row and Column. The corresponding error is given<br />

in Error. If no point below MaxError is found a value of 255 for Error and 0 for Row and Column is<br />

returned. If the desired object is missed (no object found or wrong position) you have to set MaxError higher or<br />

WhichLevels lower. Check also if the illumination has changed (see set offset template).<br />

The maximum error of the position (without noise) is ¼½ pixel. The average error is ¼¼¿ pixel.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Input image inside of which the pattern has to be found.<br />

<strong>HALCON</strong> 6.0


110 CHAPTER 3. FILTER<br />

º TemplateID (input control) ........................................................template long<br />

Template number.<br />

º MaxError (input control) .............................................................real double<br />

Maximal average difference of the grayvalues.<br />

Default Value : 30<br />

Value Suggestions : MaxError ¾0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 15, 17, 20, 30, 40, 50, 60, 70<br />

Typical Range of Values : 0 MaxError 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 3<br />

º SubPixel (input control) ......................................................string const char *<br />

Exactness in subpixels in case of ’true’.<br />

Default Value : ’false’<br />

Value List : SubPixel ¾’true’, ’false’<br />

º NumLevels (input control) ...........................................................integer long<br />

Number of the used resolution levels.<br />

Default Value : 4<br />

Value List : NumLevels ¾1, 2, 3, 4, 5, 6<br />

º WhichLevels (input control) ...........................................integer long / const char *<br />

Resolution level up to which the method “best match” is used.<br />

Default Value : 2<br />

Value Suggestions : WhichLevels ¾’all’, ’original’, 0, 1, 2, 3, 4, 5, 6<br />

º Row (output control) ..............................................................point.y double *<br />

Row position of the best match.<br />

º Column (output control) ..........................................................point.x double *<br />

Column position of the best match.<br />

º Error (output control) ..............................................................real double *<br />

Average divergence of the grayvalues in the best match.<br />

Result<br />

If the parameter values are correct, the operator best match mg returns the value H MSG TRUE.<br />

If the input is empty (no input images are available) the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

best match mg is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

create template, read template, adapt template, draw region, draw rectangle1,<br />

reduce domain, set reference template, set offset template<br />

Alternatives<br />

fast match, (T )fast match mg, (T )best match, best match pre mg, (T )best match rot,<br />

(T )best match rot mg, exhaustive match, exhaustive match mg<br />

Template matching<br />

Module<br />

best match pre mg ( Hobject ImagePyramid, long TemplateID,<br />

double MaxError, const char *SubPixel, long NumLevels, long WhichLevels,<br />

double *Row, double *Column, double *Error )<br />

Searching the best grayvalue matches in a pre generated pyramid.<br />

best match pre mg applies gray value matching using an image pyramid. best match pre mg works analogously<br />

to best match mg, but it makes use of pre calculated pyramid which has to be generated beforehand<br />

using gen gauss pyramid. This reduces runtime if more than one match has to be done or the pyramid has be<br />

used otherwise. The pyramid has to be generated using the zooming factor 0.5 and the mode ’constant’.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.9. MATCH 111<br />

Parameter<br />

º ImagePyramid (input object) ..........................................image-array Hobject : byte<br />

Image pyramid inside of which the pattern has to be found.<br />

º TemplateID (input control) ........................................................template long<br />

Template number.<br />

º MaxError (input control) .............................................................real double<br />

Maximal average difference of the grayvalues.<br />

Default Value : 30<br />

Value Suggestions : MaxError ¾0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 15, 17, 20, 30, 40, 50, 60, 70<br />

Typical Range of Values : 0 MaxError 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 3<br />

º SubPixel (input control) ......................................................string const char *<br />

Exactness in subpixels in case of ’true’.<br />

Default Value : ’false’<br />

Value List : SubPixel ¾’true’, ’false’<br />

º NumLevels (input control) ...........................................................integer long<br />

Number of the used resolution levels.<br />

Default Value : 3<br />

Value List : NumLevels ¾1, 2, 3, 4, 5, 6<br />

º WhichLevels (input control) ...........................................integer long / const char *<br />

Resolution level up to which the method “best match” is used.<br />

Default Value : ’original’<br />

Value Suggestions : WhichLevels ¾’all’, ’original’, 0, 1, 2, 3, 4, 5, 6<br />

º Row (output control) ..............................................................point.y double *<br />

Row position of the best match.<br />

º Column (output control) ..........................................................point.x double *<br />

Column position of the best match.<br />

º Error (output control) ..............................................................real double *<br />

Average divergence of the grayvalues in the best match.<br />

Result<br />

If the parameter values are correct, the operator best match pre mg returns the value H MSG TRUE.<br />

If the input is empty (no input images are available) the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

best match pre mg is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

gen gauss pyramid, create template, read template, adapt template, draw region,<br />

draw rectangle1, reduce domain, set reference template<br />

Alternatives<br />

fast match, (T )fast match mg, exhaustive match, exhaustive match mg<br />

Template matching<br />

Module<br />

best match rot ( Hobject Image, long TemplateID, double AngleStart,<br />

double AngleExtend, double MaxError, const char *SubPixel, double *Row,<br />

double *Column, double *Angle, double *Error )<br />

T best match rot ( Hobject Image, Htuple TemplateID, Htuple AngleStart,<br />

Htuple AngleExtend, Htuple MaxError, Htuple SubPixel, Htuple *Row,<br />

Htuple *Column, Htuple *Angle, Htuple *Error )<br />

Searching the best matching of a template and an image with rotation.<br />

The operator (T )best match rot performs a matching of the template of TemplateID and Image.<br />

It works similar to (T )best match with the extension that the pattern can be rotated. The parameters<br />

<strong>HALCON</strong> 6.0


112 CHAPTER 3. FILTER<br />

AngleStart and AngleExtend define the maximum rotation of the pattern: AngleStart specifies the maximum<br />

counter clockwise rotation and AngleExtend the maximum clockwise rotation relative to this angle. Both<br />

values have to smaller or equal to the values used for the creation of the pattern (see create template rot).<br />

In addition to (T )best match (T )best match rot returns the rotion angle of the pattern in Angle (radiant).<br />

The accuracy of this angle depends on the parameter AngleStep of create template rot. In the case<br />

of SubPixel = ’true’ the position and the angle are calculated with “sub pixel” accuracy.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Input image inside of which the pattern has to be found.<br />

º TemplateID (input control) ..............................................template (Htuple .) long<br />

Template number.<br />

º AngleStart (input control) ...........................................angle.rad (Htuple .) double<br />

Smallest Rotation auf the pattern.<br />

Default Value : -0.39<br />

Value Suggestions : AngleStart ¾-3.14, -1.57, -0.79, -0.39, -0.20, 0.0<br />

º AngleExtend (input control) ..........................................angle.rad (Htuple .) double<br />

Maximum positive Extention of AngleStart.<br />

Default Value : 0.79<br />

Value Suggestions : AngleExtend ¾6.28, 3.14, 1.57, 0.79, 0.39<br />

Restriction : AngleExtend 0<br />

º MaxError (input control) ...................................................real (Htuple .) double<br />

Maximum average difference of the grayvalues.<br />

Default Value : 30<br />

Value Suggestions : MaxError ¾0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 15, 17, 20, 30, 40, 50, 60, 70<br />

Typical Range of Values : 0 MaxError 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 3<br />

º SubPixel (input control) .............................................string (Htuple .) const char *<br />

Subpixel accuracy in case of ’true’.<br />

Default Value : ’false’<br />

Value List : SubPixel ¾’true’, ’false’<br />

º Row (output control) .............................................point.y(-array) (Htuple .) double *<br />

Row position of the best match.<br />

º Column (output control) .........................................point.x(-array) (Htuple .) double *<br />

Column position of the best match.<br />

º Angle (output control) ........................................angle.rad(-array) (Htuple .) double *<br />

Rotation angle of pattern.<br />

º Error (output control) .............................................real(-array) (Htuple .) double *<br />

Average divergence of the grayvalues of the best match.<br />

Result<br />

If the parameter values are correct, the operator (T )best match rot returns the value H MSG TRUE.<br />

If the input is empty (no input images are available) the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

(T )best match rot is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

create template rot, read template, set offset template, set reference template,<br />

adapt template, draw region, draw rectangle1, reduce domain<br />

(T )best match rot mg<br />

(T )best match, best match mg<br />

Template matching<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.9. MATCH 113<br />

best match rot mg ( Hobject Image, long TemplateID, double AngleStart,<br />

double AngleExtend, double MaxError, const char *SubPixel, long NumLevels,<br />

double *Row, double *Column, double *Angle, double *Error )<br />

T best match rot mg ( Hobject Image, Htuple TemplateID,<br />

Htuple AngleStart, Htuple AngleExtend, Htuple MaxError, Htuple SubPixel,<br />

Htuple NumLevels, Htuple *Row, Htuple *Column, Htuple *Angle,<br />

Htuple *Error )<br />

Searching the best matching of a template and a pyramid with rotation.<br />

The operator (T )best match rot mg performs a matching of the template of TemplateID and Image.<br />

It works similar to best match mg with the extension that the pattern can be rotated analogously to<br />

(T )best match rot. The parameters AngleStart and AngleExtend define the maximum rotation of<br />

the pattern: AngleStart specifies the maximum counter clockwise rotation and AngleExtend the maximum<br />

clockwise rotation relative to this angle. Both values have to smaller or equal to the values used for the creation<br />

of the pattern (see create template rot). In addition to best match mg (T )best match rot mg<br />

returns the rotion angle of the pattern in Angle (radiant).<br />

The value of MaxError has to set larger compared with (T )best match rot, because the error is at higher<br />

levels of the pyramid often increased.<br />

In the case of SubPixel = ’true’ the position and the angle are calculated with “sub pixel” accuracy.<br />

The value of NumLevels has to equal or smaller than the value used to create the template.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Input image inside of which the pattern has to be found.<br />

º TemplateID (input control) ..............................................template (Htuple .) long<br />

Template number.<br />

º AngleStart (input control) ...........................................angle.rad (Htuple .) double<br />

Smallest Rotation auf the pattern.<br />

Default Value : -0.39<br />

Value Suggestions : AngleStart ¾-3.14, -1.57, -0.79, -0.39, -0.20, 0.0<br />

º AngleExtend (input control) ..........................................angle.rad (Htuple .) double<br />

Maximum positive Extention of AngleStart.<br />

Default Value : 0.79<br />

Value Suggestions : AngleExtend ¾6.28, 3.14, 1.57, 0.79, 0.39<br />

Restriction : AngleExtend 0<br />

º MaxError (input control) ...................................................real (Htuple .) double<br />

Maximum average difference of the grayvalues.<br />

Default Value : 40<br />

Value Suggestions : MaxError ¾0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 15, 17, 20, 30, 40, 50, 60, 70<br />

Typical Range of Values : 0 MaxError 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º SubPixel (input control) .............................................string (Htuple .) const char *<br />

Subpixel accuracy in case of ’true’.<br />

Default Value : ’false’<br />

Value List : SubPixel ¾’true’, ’false’<br />

º NumLevels (input control) .................................................integer (Htuple .) long<br />

Number of the used resolution levels.<br />

Default Value : 3<br />

Value List : NumLevels ¾1, 2, 3, 4, 5, 6<br />

º Row (output control) .............................................point.y(-array) (Htuple .) double *<br />

Row position of the best match.<br />

º Column (output control) .........................................point.x(-array) (Htuple .) double *<br />

Column position of the best match.<br />

º Angle (output control) ........................................angle.rad(-array) (Htuple .) double *<br />

Rotation angle of pattern.<br />

<strong>HALCON</strong> 6.0


114 CHAPTER 3. FILTER<br />

º Error (output control) .............................................real(-array) (Htuple .) double *<br />

Average divergence of the grayvalues of the best match.<br />

Result<br />

If the parameter values are correct, the operator (T )best match rot mg returns the value H MSG TRUE.<br />

If the input is empty (no input images are available) the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

(T )best match rot mg is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

create template rot, set reference template, set offset template, adapt template,<br />

draw region, draw rectangle1, reduce domain<br />

(T )best match rot, best match mg<br />

fast match<br />

Template matching<br />

Alternatives<br />

See Also<br />

Module<br />

clear template ( long TemplateID )<br />

Deallocation of the memory of a template.<br />

The operator clear template deallocates the memory of a template which has been created by<br />

create template or create template rot. After execution of the operator clear template the template<br />

can no longer be used. The value of TemplateID is not valid. However, the number can be used again by<br />

further calls of create template or create template rot.<br />

Parameter<br />

º TemplateID (input control) ........................................................template long<br />

Template number.<br />

Result<br />

If the number of the template is valid, the operator clear template returns the value H MSG TRUE. If necessary<br />

an exception handling will be raised.<br />

Parallelization Information<br />

clear template is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

create template, create template rot, read template, write template<br />

Template matching<br />

Module<br />

corner response ( Hobject Image, Hobject *ImageCorner, long Size,<br />

double Weight )<br />

Searching corners in images.<br />

The operator corner response helps to extract grayvalue corners in an image. The formula for the calculation<br />

is as follows:<br />

Ê´Ü Ýµ ´Ü ݵ ¡ ´Ü ݵ ¾´Ü ݵ Ï Ø ¡ ´´Ü ݵ ·´Ü ݵµ ¾<br />

´Ü ݵ Ï ´Ù Úµ £ ´Ö Ü Á´Ü ݵµ ¾<br />

´Ü ݵ Ï ´Ù Úµ £ ´Ö Ý Á´Ü ݵµ ¾<br />

´ ݵ Ï ´Ù Úµ £ ´Ö Ü Á´Ü ÝµÖ Ý Á´Ü ݵµ<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.9. MATCH 115<br />

whereby Á is the input image and Ê the output image of the filtering. The operator gauss image is used for<br />

smoothing (Ï ), the operator sobel amp is used for calculating the derivative (Ö).<br />

The corner response function is invariant with regard to rotation. In order to achieve a suitable dependency of<br />

the function Ê´Ü Ýµ of the local gradient, the parameter Weight has to be set to 0.04. Thereby only grayvalue<br />

corners will return positive values for Ê´Ü Ýµ, while straight edges will receive negative values (due to clipping<br />

they are set to 0).<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Input image.<br />

º ImageCorner (output object) . . . . . . . . . . . . . . . . . . . . . . . . . .multichannel-image(-array) Hobject * : byte<br />

Result of the filtering.<br />

Parameter Number : ImageCorner Image<br />

º Size (input control) .................................................................integer long<br />

Desired filtersize of the graymask.<br />

Default Value : 3<br />

Value List : Size ¾3, 5, 7, 9, 11<br />

º Weight (input control) ...............................................................real double<br />

Weighting.<br />

Default Value : 0.04<br />

Typical Range of Values : 0.0 Weight 0.3<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.01<br />

Example<br />

read_image(&Fabrik,"fabrik");<br />

corner_response(Fabrik,&CornerResponse,3,0.04);<br />

local_max(CornerResponse,&LocalMax);<br />

disp_image(Fabrik,WindowHandle);<br />

set_color(WindowHandle,"red");<br />

disp_region(LocalMax,WindowHandle);<br />

Parallelization Information<br />

corner response is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

local max, threshold<br />

gauss image, sobel amp<br />

Possible Successor Functions<br />

See Also<br />

Bibliography<br />

C.G. Harris, M.J. Stephens, “A combined corner and edge detector”’; Proc. of the 4th Alvey Vision Conference;<br />

August 1988; pp. 147-152.<br />

H. Breit, “Bestimmung der Kameraeigenbewegung und Gewinnung von Tiefendaten aus monokularen Bildfolgen”;<br />

Diplomarbeit am Lehrstuhl f”ur Nachrichtentechnik der TU M”unchen; 30. September 1990.<br />

Module<br />

Image filters<br />

create template ( Hobject Template, long FirstError, long NumLevel,<br />

const char *Optimize, const char *GrayValues, long *TemplateID )<br />

Preparing a pattern for template matching.<br />

The operator create template preprocesses a pattern (Template),whichispassedasanimage,forthe<br />

template matching. After the transformation, a number (TemplateID) is assigned to the template for being used<br />

in the further process. The shape and the size of Template can be chosen arbitrarily. You have to be aware, that<br />

the matching is only applied to that part of an image where Template fits completely into the image.<br />

<strong>HALCON</strong> 6.0


116 CHAPTER 3. FILTER<br />

The template has be chosen such that it contains no pixels of the (changing) background. Here you can make<br />

use of the artitrary shape of a template which is not restricted to a rectangle. To create a template you can use<br />

segmentation operators like threshold. In the case of sub pixel accurate matching Template has in addition<br />

to be one pixel smaller than the pattern (i.e. one pixel border to the changing background). This can be done e.g.<br />

by applying the operator erosion circle.<br />

The parameter NumLevel specifies the number of pyramid levels (NumLevel = 1 means only original gray<br />

values) which can be used for matching. The number of levels used later for matching will be below or equal this<br />

value. If the pattern becomes to small due to zooming, the maximum number of pyramid levels is automatically<br />

reduced (without error message).<br />

The parameter GrayValues defines, wheter the original gray values (’original’, ’normalized) or the edge amplitude<br />

(’gradient’, ’sobel’) is used. With ’original’ the sum of the differences is used as feature which is very<br />

stable and fast if there is no change in illumination. ’normalized is used if the illumination changes. The method<br />

is a bit slower and not quite as stable. If there is no change in illumination the mode ’original’ should be used.<br />

The edge amplitude is another method to be invariant to changes in illumination. The disadvantage is the increased<br />

execution time and the higher sensitivity to changes in the shape of the pattern. The mode ’gradient’ is slighy<br />

faster but more sensitive to noise.<br />

The maximum error for matching has typically to be chosen higher when using the edge amplitude. The mode<br />

chosen by GrayValues leads automatically to calling the appropriate filter during matching — if necessary.<br />

As an alternative to the gradient approach the operator set offset template can be used, if the change in<br />

illumination is known.<br />

The parameter Optimize specifies if the pattern has to optimized for runtime. This optimization results in a<br />

longer time to create the template but reduces the time for matching. In addition the optimization leads to a more<br />

stable matching, i.e., the possibilty to miss good matches is reduced. The optimization process selects the most<br />

stable and significant gray values to be tested first during the matching process. Using this technique a wrong<br />

match can be eliminated very early.<br />

The reference position for the template is its center of gravity. I.e. if you apply the template to the original<br />

image the center of gravity is returned. This default reference can be adapted using the operator<br />

set reference template.<br />

In sub pixel mode a special position correction is calculated which is added after each matching: The template is<br />

applied to the original image and the difference between the found position and the center of gravity is used as a<br />

correction vector. This is important for patterns in a textured context or for asymetric pattern. For most templates<br />

this correction vector is near null.<br />

If the pattern is no longer used, it has to be freed by the operator clear template in order to deallocate the<br />

memory.<br />

Before the use of the template, which is stored independently of the image size, it can be adapted explicitly to the<br />

size of a definite image size by using adapt template.<br />

Parameter<br />

º Template (input object) .....................................................image Hobject : byte<br />

Input image whose domain will be processed for the pattern matching.<br />

º FirstError (input control) .........................................................integer long<br />

Not jet in use.<br />

Default Value : 255<br />

Value List : FirstError ¾255<br />

º NumLevel (input control) ............................................................integer long<br />

Maximal number of pyramid levels.<br />

Default Value : 4<br />

Value List : NumLevel ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10<br />

º Optimize (input control) ......................................................string const char *<br />

Kind of optimizing.<br />

Default Value : ’sort’<br />

Value List : Optimize ¾’none’, ’sort’<br />

º GrayValues (input control) ...................................................string const char *<br />

Kind of grayvalues.<br />

Default Value : ’original’<br />

Value List : GrayValues ¾’original’, ’normalized’, ’gradient’, ’sobel’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.9. MATCH 117<br />

º TemplateID (output control) .....................................................template long *<br />

Template number.<br />

Result<br />

If the parameters are valid, the operator create template returns the value H MSG TRUE. If necessary an<br />

exception handling will be raised.<br />

Parallelization Information<br />

create template is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

draw region, reduce domain, threshold<br />

Possible Successor Functions<br />

adapt template, set reference template, clear template, write template,<br />

set offset template, (T )best match, best match mg, fast match, (T )fast match mg<br />

create template rot, read template<br />

Template matching<br />

Alternatives<br />

Module<br />

create template rot ( Hobject Template, long NumLevel,<br />

double AngleStart, double AngleExtend, double AngleStep,<br />

const char *Optimize, const char *GrayValues, long *TemplateID )<br />

Preparing a pattern for template matching with rotation.<br />

The operator create template rot preprocesses a pattern, which is passed as an image, for the template<br />

matching. An extension to create template the matching can applied to rotated patterns. The parameters<br />

AngleStart and AngleExtend define the maximum rotation of the pattern: AngleStart specifies the<br />

maximum counter clockwise rotation and AngleExtend the maximum clockwise rotation relative to this angle.<br />

Therefore AngleExtend has to be smaller than ¾. With the parameter AngleStep the maximum angle<br />

resolution (on the highest resolution level) can be specified.<br />

You have to be aware, that all possible rotations are calculated beforehand to reduce runtime during matching. This<br />

leads to a higher execution time for create template rot and high memory requirements for the template.<br />

The amount of memory depends on the parameters AngleExtend and AngleStep. The number of pyramid<br />

levels can be neglected. If is the number of pixels of Template, the memory Å needed for the template in<br />

byte is about:<br />

£ ½¾ £ ÒÐÜØÒ<br />

Å <br />

ÒÐËØÔ<br />

After the transformation, a number (TemplateID) is assigned to the template for being used in the further<br />

process.<br />

A description of the other parameters can be found at the operator create template.<br />

Attention<br />

You have to be aware, that depending on the resolution a large number of pre calculated patterns have to be created<br />

which might result in a large amount of memory needed.<br />

Parameter<br />

º Template (input object) .....................................................image Hobject : byte<br />

Input image whose domain will be processed for the pattern matching.<br />

º NumLevel (input control) ............................................................integer long<br />

Maximal number of pyramid levels.<br />

Default Value : 4<br />

Value List : NumLevel ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10<br />

º AngleStart (input control) .....................................................angle.rad double<br />

Smallest Rotation of the pattern.<br />

Default Value : -0.39<br />

Value Suggestions : AngleStart ¾-3.14, -1.57, -0.79, -0.39, -0.20, 0.0<br />

<strong>HALCON</strong> 6.0


118 CHAPTER 3. FILTER<br />

º AngleExtend (input control) ....................................................angle.rad double<br />

Maximum positive Extention of AngleStart.<br />

Default Value : 0.79<br />

Value Suggestions : AngleExtend ¾6.28, 3.14, 1.57, 0.79, 0.39<br />

Restriction : AngleExtend 0<br />

º AngleStep (input control) ......................................................angle.rad double<br />

Step rate (angle precition) of matching.<br />

Default Value : 0.0982<br />

Value Suggestions : AngleStep ¾0.3927, 0.1963, 0.0982, 0.0491, 0.0245<br />

Restriction : AngleStep 0<br />

º Optimize (input control) ......................................................string const char *<br />

Kind of optimizing.<br />

Default Value : ’sort’<br />

Value List : Optimize ¾’none’, ’sort’<br />

º GrayValues (input control) ...................................................string const char *<br />

Kind of grayvalues.<br />

Default Value : ’original’<br />

Value List : GrayValues ¾’original’, ’normalized’, ’gradient’, ’sobel’<br />

º TemplateID (output control) .....................................................template long *<br />

Template number.<br />

Result<br />

If the parameters are valid, the operator create template rot returns the value H MSG TRUE. If necessary<br />

an exception handling will be raised.<br />

Parallelization Information<br />

create template rot is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

draw region, reduce domain, threshold<br />

Possible Successor Functions<br />

(T )best match rot, (T )best match rot mg, adapt template, set reference template,<br />

clear template, set offset template, write template<br />

create template<br />

Template matching<br />

Alternatives<br />

Module<br />

exhaustive match ( Hobject Image, Hobject RegionOfInterest,<br />

Hobject ImageTemplate, Hobject *ImageMatch, const char *Mode )<br />

Matching of a template and an image.<br />

The operator exhaustive match matches ImageTemplate and Image within the region of interest<br />

RegionOfInterest. Hereby the ImageTemplate will be moved over all points of Image which lie within<br />

the RegionOfInterest. With regard to the parameter Mode, a matching criterion will be calculated. The<br />

result values will be stored in ImageMatch.<br />

The following matching criteria (Mode) are available:<br />

’norm correlation’<br />

ÁÑÅØ℄℄ ¾ ¡<br />

ÕÈ<br />

È<br />

ÙÚ ´ÁÑ Ù℄ Ú℄ ¡ ÁÑÌÑÔÐØÐ<br />

Ù℄ Ú℄µ<br />

ÙÚ ´ÁÑ Ù℄ Ú℄¾ µ ¡ È ÙÚ ´ÁÑÌÑÔÐØÐ Ù℄ Ú℄¾ µ<br />

whereby ℄℄ indicates the grayvalue in the th column and th row of the image . ´Ð µ is the centre of<br />

the region of ImageTemplate. Ù and Ú are chosen so that all points of the template will be reached, <br />

run accross the RegionOfInterest. At the image frame only those parts of ImageTemplate will be<br />

considered which lie inside the image (i.e. Ù and Ú will be restricted correspondingly). Range of values: 0 -<br />

255 (best fit).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.9. MATCH 119<br />

’dfd’ Calculating the average “displaced frame difference”:<br />

È<br />

ÙÚ ÁÑ Ù℄ Ú℄ ÁÑÌÑÔÐØÐ Ù℄ Ú℄<br />

ÁÑÅØ℄℄ <br />

Ê´ÁÑÌ ÑÔÐص<br />

The terms are the same as in ’norm correlation’. AREA ( X ) means the area of the region X. Range of value<br />

0 (best fit) - 255.<br />

To calculate the normalized correlation as well as the “displaced frame difference” is (with regard to the<br />

area of ImageTemplate) very time consuming. Therefore it is important to restrict the input region<br />

(RegionOfInterest if possible, i.e. to apply the filter only in a very confined “region of interest”.<br />

As far as quality is concerned, both modes return comparable results, whereby the mode ’dfd’ is faster by a factor<br />

of about 3.5.<br />

Parameter<br />

º Image (input object) .........................................................image Hobject : byte<br />

Input image.<br />

º RegionOfInterest (input object) ...............................................region Hobject<br />

Area to be searched in the input image.<br />

º ImageTemplate (input object) ..............................................image Hobject : byte<br />

This area will be “matched” by Image within the RegionOfInterest.<br />

º ImageMatch (output object) .....................................................image Hobject *<br />

Result image: values of the matching criterion.<br />

º Mode (input control) ............................................................string const char *<br />

Desired matching criterion.<br />

Default Value : ’dfd’<br />

Value List : Mode ¾’norm correlation’, ’dfd’<br />

Example<br />

read_image(&Image,"monkey");<br />

disp_image(Image,WindowHandle);<br />

/* mark one eye */<br />

draw_rectangle2(WindowHandle,&Row,&Column,&Phi,&Length1,&Length2);<br />

gen_rectangle2(&Rectangle,Row,Column,Phi,Length1,Length2);<br />

reduce_domain(Image,Rectangle,&Template);<br />

exhaustive_match(Image,Image,Template,&ImageMatch,’dfd’);<br />

invert_image(ImageMatch,&ImageInvert);<br />

local_max(ImageInvert,&Maxima);<br />

union1(Maxima,&AllMaxima);<br />

add_channels(AllMaxima,ImageInvert,&FitMaxima);<br />

threshold(FitMaxima,&BestFit,230.0,255.0);<br />

disp_region(BestFit,WindowHandle);<br />

Result<br />

If the parameter values are correct, the operator exhaustive match returns the value H MSG TRUE.<br />

If the input is empty (no input images are available) the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

exhaustive match is reentrant and automatically parallelized (on tuple level).<br />

draw region, draw rectangle1<br />

local max, threshold<br />

exhaustive match mg<br />

Image filters<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

Module<br />

<strong>HALCON</strong> 6.0


120 CHAPTER 3. FILTER<br />

exhaustive match mg ( Hobject Image, Hobject ImageTemplate,<br />

Hobject *ImageMatch, const char *Mode, long Level, long Threshold )<br />

Matching a template and an image in a resolution pyramid.<br />

The operator exhaustive match mg is an additional option for the operator exhaustive match performing<br />

a matching of the image Image and the template ImageTemplate. Hereby ImageTemplate will be<br />

moved over all points of the region of Image, a matching criterion will be calculated with regard to the parameter<br />

Mode and the result values will be stored in ImageMatch.<br />

Of images having been filtered this way, normally only those areas with good matching results are of interest. The<br />

size of the area to be searched, i.e. the region of the input image Image, determines decisively the runtime of<br />

the matching filter. Therefore it is recommendable to use at first exhaustive match mg with reduced image<br />

resolution in order to determine a “region of interest” in which good matching results can be expected; then in this<br />

restricted area only the real matching (see also exhaustive match) will be executed with normal resolution.<br />

Hereby the Gauss-pyramids of Image and ImageTemplate will be composed (in particular the corresponding<br />

regions will be transformed as well). Then on each level of the resolution pyramids - starting with the startlevel<br />

Level - the matching inside the current “region of interest” will be executed. Whereby the “region of interest” on<br />

the startlevel is equivalent to the region of the input image Image. After the filtering, a new “region of interest” is<br />

determined with the help of a threshold operation and will be transformed on the next resolution level:<br />

threshold(..0,Threshold..), if Mode = ’dfd’<br />

threshold(..Threshold,255..), if Mode = ’crosscorrelation’<br />

The final matching in the determined “region of interest” will then be calculated with the highest resolution (Level<br />

0). The output image ImageMatch includes the corresponding filter result and the final “region of interest”, which<br />

is determined on the result image with the help of a threshold operation.<br />

The operator exhaustive match mg therefore is not simply a filter, but can also be considered as a member of<br />

the class of region transformations.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Input image.<br />

º ImageTemplate (input object) ..............................................image Hobject : byte<br />

The domain of this image will be matched with Image.<br />

º ImageMatch (output object) ........................................image(-array) Hobject * : byte<br />

Result image and result region: values of the matching criterion within the determined “region of interest”.<br />

Parameter Number : ImageMatch Image<br />

º Mode (input control) ............................................................string const char *<br />

Desired matching criterion.<br />

Default Value : ’dfd’<br />

Value List : Mode ¾’crosscorrelation’, ’dfd’<br />

º Level (input control) ................................................................integer long<br />

Startlevel in the resolution pyramid (highest resolution: Level 0).<br />

Default Value : 1<br />

Value List : Level ¾0, 1, 2, 3, 4, 5, 6, 7, 8<br />

Restriction : ´Level ld´width´Imageµµµ ´Level ld´height´Imageµµµ<br />

º Threshold (input control) ...........................................................integer long<br />

Threshold to determine the “region of interest”.<br />

Default Value : 30<br />

Value Suggestions : Threshold ¾5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95,<br />

100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 205,<br />

210, 215, 220, 225, 230, 235, 240, 245, 250<br />

Typical Range of Values : 0 Threshold 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

read_image(&Image,"monkey");<br />

disp_image(Image,WindowHandle);<br />

Example<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.9. MATCH 121<br />

draw_rectangle2(WindowHandle,&Row,&Column,&Phi,&Length1,&Length2);<br />

gen_rectangle2(&Rectangle,Row,Column,Phi,Length1,Length2);<br />

reduce_domain(Image,Rectangle,&Template);<br />

exhaustive_match_mg(Image,Template,&ImageMatch,’dfd’1,30);<br />

invert_image(ImageMatch,&ImageInvert);<br />

local_max(ImageInvert,&BestFit);<br />

disp_region(BestFit,WindowHandle);<br />

Result<br />

If the parameter values are correct, the operator exhaustive match mg returns the value H MSG TRUE.<br />

If the input is empty (no input images are available) the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

exhaustive match mg is reentrant and automatically parallelized (on tuple level).<br />

draw region, draw rectangle1<br />

threshold, local max<br />

exhaustive match<br />

gen gauss pyramid<br />

Image filters<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

fast match ( Hobject Image, Hobject *Matches, long TemplateID,<br />

double MaxError )<br />

Searching all good matches of a template and an image.<br />

The operator fast match performs a matching of the template of TemplateID and Image. Hereby the<br />

template will be moved over the points of Image so that the template always lies completely inside of Image.<br />

The matching criterion (“displaced frame difference”) is defined as follows:<br />

È<br />

ÙÚ ÁÑÖÓÛ Ù ÓÐ Ú℄ ÌÑÔÐØÁÙ Ú℄<br />

ÖÖÓÖÖÓÛ ÓÐ℄ <br />

Ö´Ì ÑÔÐØÁµ<br />

The difference between fast match and exhaustive match is that the matching for one position is stopped<br />

if the error is to high. This leads to a reduced runtime but one might miss correct matches. The runtime of the<br />

operator depends mainly on the size of the domain of Image. Therefore it is important to restrict the domain as<br />

far as possible, i.e. to apply the operator only in a very confined “region of interest”. The parameter MaxError<br />

determines the maximal error which the searched position is allowed to show. The lower this value is, the faster<br />

the operator runs.<br />

All points which show a matching error smaller than MaxError will be returned in the output region Matches.<br />

This region can be used for further processing. For example by using a connection and (T )best match to<br />

find all the matching objects. If no point has a match error below MaxError the empty region (i.e no points) is<br />

returned.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Input image inside of which the pattern has to be found.<br />

º Matches (output object) ..................................................region(-array) Hobject *<br />

All points whose error lies below a certain threshold.<br />

º TemplateID (input control) ........................................................template long<br />

Template number.<br />

<strong>HALCON</strong> 6.0


122 CHAPTER 3. FILTER<br />

º MaxError (input control) .............................................................real double<br />

Maximal average difference of the grayvalues.<br />

Default Value : 20<br />

Value Suggestions : MaxError ¾0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 15, 17, 20, 30<br />

Typical Range of Values : 0 MaxError 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Result<br />

If the parameter values are correct, the operator fast match returns the value H MSG TRUE. If<br />

the input is empty (no input images are available) the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

fast match is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

create template, read template, adapt template, draw region, draw rectangle1,<br />

reduce domain<br />

Possible Successor Functions<br />

connection, (T )best match<br />

Alternatives<br />

(T )best match, best match mg, (T )fast match mg, exhaustive match,<br />

exhaustive match mg<br />

Module<br />

Template matching<br />

fast match mg ( Hobject Image, Hobject *Matches, long TemplateID,<br />

double MaxError, long NumLevel )<br />

T fast match mg ( Hobject Image, Hobject *Matches, Htuple TemplateID,<br />

Htuple MaxError, Htuple NumLevel )<br />

Searching all good grayvalue matches in a pyramid.<br />

The operator (T )fast match mg like the operator fast match performs a matching of the template of<br />

TemplateID and Image. In contrast to fast match, however, the search for good matches starts in scaled<br />

down images (pyramid). The number of levels of the pyramid will be determined by NumLevel. Hereby the<br />

value 1 indicates that no pyramid will be used. In this case the operator (T )fast match mg is equivalent to<br />

the operator fast match. The value 2 triggers the search in the image with half the framesize. The search for<br />

all those points showing an error small enough in the scaled down image (error smaller than MaxError) will be<br />

refined at the corresponding positions in the original image (Image).<br />

The runtime of matching dependends on the parameter MaxError: the larger the value the longer is the processing<br />

time, because more points of the pattern have to be tested. If MaxError is to low the pattern will not be found.<br />

The value has therefore to be optimized for every application.<br />

NumLevel indicates the number of levels of the pyramid, including the original image. Optionally a second value<br />

can be given. This value specifies the number (0..n) of the lowest level which is used the the matching. The region<br />

found up to this level will then be zoomed to the size of the original level. This can used to increase the runtime in<br />

the case that the accuracy does not have to be so high.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Input image inside of which the pattern has to be found.<br />

º Matches (output object) ..................................................region(-array) Hobject *<br />

All points which have an error below a certain threshold.<br />

º TemplateID (input control) ..............................................template (Htuple .) long<br />

Template number.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.9. MATCH 123<br />

º MaxError (input control) ...................................................real (Htuple .) double<br />

Maximal average difference of the grayvalues.<br />

Default Value : 30<br />

Value Suggestions : MaxError ¾0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 15, 17, 20, 30, 40, 50, 60, 70<br />

Typical Range of Values : 0 MaxError 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 3<br />

º NumLevel (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Number of levels in the pyramid.<br />

Default Value : 3<br />

Value List : NumLevel ¾1, 2, 3, 4, 5, 6, 7, 8<br />

Result<br />

If the parameter values are correct, the operator (T )fast match mg returns the value H MSG TRUE.<br />

If the input is empty (no input images are available) the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

(T )fast match mg is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

create template, read template, adapt template, draw region, draw rectangle1,<br />

reduce domain<br />

Alternatives<br />

(T )best match, best match mg, fast match, exhaustive match, exhaustive match mg<br />

Template matching<br />

Module<br />

fill dvf ( Hobject Image, Hobject *ImageExpanded, long Width,<br />

long Height, long Iterations )<br />

Expansion of a displacement vector field onto undefined areas.<br />

The operator fill dvf calculates a value for each undefined point in a displacement vector field by averaging its<br />

neighbors. The dimension of the neighborhod will be determined by the parameters Width and Height. Asthe<br />

gaps may be larger than the masks, the filter may be used iteratively (Iterations). Correctly defined values in<br />

the input image will not be modified.<br />

Parameter<br />

º Image (input object) ...................................................image(-array) Hobject : dvf<br />

Input image.<br />

º ImageExpanded (output object) ....................................image(-array) Hobject * : dvf<br />

Result of adding the points which are missing.<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the filtermask.<br />

Default Value : 5<br />

Value Suggestions : Width ¾3, 5, 7, 9, 11, 15<br />

Typical Range of Values : 3 Width 201<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the filtermask.<br />

Default Value : 5<br />

Value Suggestions : Height ¾3, 5, 7, 9, 11, 13, 15<br />

Typical Range of Values : 3 Height 201<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

<strong>HALCON</strong> 6.0


124 CHAPTER 3. FILTER<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 3<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15<br />

Typical Range of Values : 1 Iterations 100<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Parallelization Information<br />

fill dvf is reentrant and automatically parallelized (on tuple level, domain level).<br />

(T )optical flow match<br />

Image filters<br />

Possible Predecessor Functions<br />

Module<br />

gen gauss pyramid ( Hobject Image, Hobject *ImagePyramid,<br />

const char *Mode, double Scale )<br />

Calculating a Gauss pyramid.<br />

The operator gen gauss pyramid calculates a pyramid of scaled down images. The scale by which the next<br />

image will be reduced is determined by the parameter Scale. For instance, a value of 0.5 for Scale will shorten<br />

the edge length of Image by 50%. This is exactly equivalent to the “normal” pyramid.<br />

The parameter Mode determines the way of averaging. For a more detailed description concerning this parameter<br />

see also T affine trans image. In the case that Scale is equal 0.5 there are the additional modes ’min’ and<br />

’max’ available. In this case the minimum or the maximum of the four neighboring pixels is selected.<br />

Please note that each level will be returned as an individual image, i.e. as one iconic objekt, with one matrix and<br />

its own domain. If a multichannel image is needed as a result, the operator image to channels has to be used.<br />

A single level or more than one level can be selected by using select obj respectively copy obj.<br />

Parameter<br />

º Image (input object) .........................................................image Hobject : byte<br />

Input image.<br />

º ImagePyramid (output object) ......................................image-array Hobject * : byte<br />

Output images.<br />

Parameter Number : ImagePyramid Image<br />

º Mode (input control) ............................................................string const char *<br />

Kind of filtermask.<br />

Default Value : ’weighted’<br />

Value List : Mode ¾’none’, ’constant’, ’weighted’, ’min’, ’max’<br />

º Scale (input control) .................................................................real double<br />

Factor for scaling down.<br />

Default Value : 0.5<br />

Value Suggestions : Scale ¾0.2, 0.3, 0.4, 0.5, 0.6<br />

Typical Range of Values : 0.1 Scale 0.9<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : ´0.1 Scaleµ ´Scale 0.9µ<br />

Example<br />

gen_gauss_pyramid(Image,Pyramid,"weighted",0.5);<br />

count_obj(Pyramid,&num);<br />

for (i=1; i


3.9. MATCH 125<br />

Parallelization Information<br />

gen gauss pyramid is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

image to channels, count obj, select obj, copy obj<br />

zoom image size, zoom image factor<br />

T affine trans image<br />

Image filters<br />

Alternatives<br />

See Also<br />

Module<br />

monotony ( Hobject Image, Hobject *ImageMonotony )<br />

Calculating the monotony operation.<br />

The operator monotony calculates the monotony operator. Thereby the points which are strictly smaller than the<br />

current grayvalue will be counted in the 8 neighborhood. This number will be entered into the output imaged.<br />

If there is a strict maximum, the value 8 is returned; in case of a minimum or a plateau, the value 0 will be returned.<br />

A ridge or a slope will return the corresponding intermediate values.<br />

The monotony operator is often used to prepare matching operations as it is invariant with regard to lightness<br />

modifications.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Input image.<br />

º ImageMonotony (output object) . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Result of the monotony operator.<br />

Parameter Number : ImageMonotony Image<br />

/* searching the strict maximums */<br />

gauss_image(Image,&Gauss,5);<br />

monotony(Gauss,&Monotony);<br />

threshold(Monotony,Maxima,8.0,8.0);<br />

Example<br />

Parallelization Information<br />

monotony is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

Possible Predecessor Functions<br />

gauss image, median image, mean image, smooth image, invert image<br />

Possible Successor Functions<br />

threshold, exhaustive match, disp image<br />

Alternatives<br />

local max, topographic sketch, corner response<br />

Image filters<br />

Module<br />

<strong>HALCON</strong> 6.0


126 CHAPTER 3. FILTER<br />

optical flow match ( Hobject Image1, Hobject Image2,<br />

Hobject *VectorField, const char *Mode, long Threshold, long Step,<br />

long SizeWindow, long SizeSearch, long Weights )<br />

T optical flow match ( Hobject Image1, Hobject Image2,<br />

Hobject *VectorField, Htuple Mode, Htuple Threshold, Htuple Step,<br />

Htuple SizeWindow, Htuple SizeSearch, Htuple Weights )<br />

Calculating the Displacement vector field by correlation methods.<br />

The operator (T )optical flow match determines a displacement vector field (DVF) with the help of correlation<br />

methods. Simple- and multichannel Images may be used. A window of the size SizeWindow will be<br />

moved inside a mask of the size SizeSearch over a second image and there the grayvalues will be compared<br />

with the ones from the first image. The correlation showing the slightest error will determine the vector. In case<br />

of two vectors having the same weighting, the shorter vector will be prefered. After having processed one image<br />

point, the next image point at a distance of Step will be selected. It is therefore not guaranteed to get a dense<br />

displacement vector field.<br />

The parameter Threshold specifies the maximal divergence of previously estimated correlations and the best<br />

estimation of a displacement vector.<br />

The method used by the operator is determined by the parameter Mode. The follwing values for Mode can be<br />

selected:<br />

’dfd’ Calculation of displaced frame difference.<br />

’dfd norm’ Calculation of displaced frame difference normalized by the mean value of the matching windows.<br />

If the image has more than one channel the parameter Weights indicates the weighting of the individual channels.<br />

For each channel one weight factor must be passed.<br />

For the parameters SizeWindow, SizeSearch and Step optionally two values can be passed: The first value<br />

indicates hereby the width (respectively the row), the second value the height (respectively the column).<br />

Parameter<br />

º Image1 (input object) ................................................image(-array) Hobject : byte<br />

First input image (optionally with more than one channel).<br />

º Image2 (input object) ................................................image(-array) Hobject : byte<br />

Second input image (optionally with more than one channel).<br />

Parameter Number : Image2 Image1<br />

º VectorField (output object) .......................................image(-array) Hobject * : dvf<br />

Displacement vector field to be calculated.<br />

Parameter Number : VectorField Image1<br />

º Mode (input control) ..................................................string (Htuple .) const char *<br />

Kind of correlation.<br />

Default Value : ’dfd’<br />

Value List : Mode ¾’dfd’, ’dfd norm’<br />

º Threshold (input control) .................................................integer (Htuple .) long<br />

Maximal divergence of the previously estimated correlations and the best estimate of a displacement vector.<br />

Default Value : 10<br />

Value Suggestions : Threshold ¾1, 2, 3, 4, 5, 7, 10, 12, 15, 17, 20<br />

Typical Range of Values : 1 Threshold 300<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

º Step (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Step width.<br />

Default Value : 10<br />

Value Suggestions : Step ¾1, 2, 3, 5, 7, 10, 15, 20, 30, 50<br />

Typical Range of Values : 1 Step 300<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.9. MATCH 127<br />

º SizeWindow (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Size of the correlation window.<br />

Default Value : 11<br />

Value Suggestions : SizeWindow ¾3, 5, 7, 9, 11, 15, 20, 30<br />

Typical Range of Values : 1 SizeWindow 30<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

º SizeSearch (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Size of the area to be searched.<br />

Default Value : 20<br />

Value Suggestions : SizeSearch ¾3, 5, 7, 10, 20, 30, 40, 50, 60<br />

Typical Range of Values : 1 SizeSearch 60<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

º Weights (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Weighting of the channels.<br />

Default Value : 1<br />

Value Suggestions : Weights ¾1, 3, 5, 7, 10<br />

Typical Range of Values : 1 Weights 10<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Example<br />

read_image(&B1,"image1") ;<br />

mean(B1,&L1,16,16) ;<br />

read_image(&B2,"image2") ;<br />

mean_image(B2,&L2,16,16) ;<br />

optical_flow_match(L1,L2,VVF,’dfd’,10,10,11,20,1) ;<br />

disp_image(B1,WindowHandle) ;<br />

set_color(WindowHandle,"red") ;<br />

disp_image(VVF,WindowHandle) ;<br />

Parallelization Information<br />

(T )optical flow match is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

mean image, gauss image, smooth image<br />

fill dvf<br />

dvf to int1, dvf to hom mat2d<br />

Image filters<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

read template ( const char *FileName, long *TemplateID )<br />

Reading a template from file.<br />

The operator read template reads a matching template from file which has been written with<br />

write template.<br />

Parameter<br />

º FileName (input control) ...................................................filename const char *<br />

file name.<br />

º TemplateID (output control) .....................................................template long *<br />

Template number.<br />

<strong>HALCON</strong> 6.0


128 CHAPTER 3. FILTER<br />

Result<br />

If the file name is valid, the operator read template returns the value H MSG TRUE. If necessary an exception<br />

handling will be raised.<br />

Parallelization Information<br />

read template is local and processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

adapt template, set reference template, set offset template, (T )best match,<br />

fast match, (T )best match rot<br />

Template matching<br />

Module<br />

set offset template ( long TemplateID, long GrayOffset )<br />

Gray value offset for template.<br />

set offset template adds a gray value offset to the template to eliminate gray value changes in the image.<br />

The parameter GrayOffset specifies a difference relative to the gray values of the pattern when it was<br />

created with create template (not relative to the last call of set offset template). The values of<br />

GrayOffset has to be chosen according to the gray values of the image: A brighter image results in a positive<br />

value, a darker image results in a negative value. set offset template has to be called each time the<br />

gray values of the image changes. The gray values can be meassured in a reference area using intensity or<br />

min max gray<br />

Parameter<br />

º TemplateID (input control) ........................................................template long<br />

Template number.<br />

º GrayOffset (input control) .........................................................number long<br />

Offset of gray values.<br />

Default Value : 0<br />

Value Suggestions : GrayOffset ¾-10,-5,-2,-1,0,1,2,5,10<br />

Typical Range of Values : -255 GrayOffset 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Result<br />

If the parameter values are correct, the operator set offset template returns the value H MSG TRUE. If<br />

necessary, an exception handling is raised.<br />

Parallelization Information<br />

set offset template is processed under mutual exclusion against itself and without parallelization.<br />

Possible Predecessor Functions<br />

create template, adapt template, read template<br />

Possible Successor Functions<br />

(T )best match, best match mg, (T )best match rot, fast match, (T )fast match mg<br />

Template matching<br />

Module<br />

set reference template ( long TemplateID, double Row, double Column )<br />

Define reference position for a matching template.<br />

set reference template allows to define a new reference position for a template. As default after calling<br />

create template or create template rot the center of gravity of the template is used. Using<br />

set reference template the reference position can be redefined. In the case of the center of gravity as<br />

reference the vector ´¼ ¼µ is returned after matching for a null translation of the pattern relative to the image.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.10. MISC 129<br />

Parameter<br />

º TemplateID (input control) ........................................................template long<br />

Template number.<br />

º Row (input control).................................................................point.y double<br />

<strong>Reference</strong> position of template (row).<br />

º Column (input control) ............................................................point.x double<br />

<strong>Reference</strong> position of template (column).<br />

Result<br />

If the parameter values are correct, the operator set reference template returns the value H MSG TRUE.<br />

If necessary, an exception handling is raised.<br />

Parallelization Information<br />

set reference template is processed under mutual exclusion against itself and without parallelization.<br />

Possible Predecessor Functions<br />

create template, create template rot, read template, adapt template<br />

Possible Successor Functions<br />

(T )best match, best match mg, (T )best match rot, fast match, (T )fast match mg<br />

Template matching<br />

Module<br />

write template ( long TemplateID, const char *FileName )<br />

Writing a template to file.<br />

The operator write template writes a matching template to file which can be read again with<br />

read template.<br />

Parameter<br />

º TemplateID (input control) ........................................................template long<br />

Template number.<br />

º FileName (input control) ...................................................filename const char *<br />

file name.<br />

Result<br />

If the file name is valid (permission to write), the operator write template returns the value H MSG TRUE.<br />

If necessary an exception handling will be raised.<br />

Parallelization Information<br />

write template is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

create template, create template rot<br />

Template matching<br />

Module<br />

3.10 Misc<br />

convol image ( Hobject Image, Hobject *ImageResult,<br />

const char *FileName, long Margin )<br />

Convolve an image with an arbitrary filter mask.<br />

convol image convolves the input image Image with an arbitrary linear filter. The corresponding filter matrix<br />

is stored in a file named FileName. Several options for the treatment at the image’s borders can be chosen<br />

(Margin):<br />

¼ ¾ Gray values are assumed constant outside of the image (with the given gray value).<br />

<strong>HALCON</strong> 6.0


130 CHAPTER 3. FILTER<br />

-1 The border’s gray values are continued.<br />

-2 The border’s gray values are continued cyclically.<br />

-3 The gray values are mirrored along the image borders.<br />

All image points are convolved with the filter mask. If an overflow or underflow occurs, the resulting gray value is<br />

clipped (to 0 or 255, respectively). The filter mask is contained in a file with the following structure:<br />

Mask size<br />

Inverse weight of the mask<br />

Matrix<br />

The first line contains the size of the filter mask, given as two numbers separated by white space (e.g., 3 3 for<br />

¿ ¢ ¿). Here, the first number defines the height of the filter mask, while the second number defines its width. The<br />

next line contains the inverse weight of the mask, i.e., the number by which the convolution of a particular image<br />

point is divided. The remaining lines contain the filter mask as integer numbers (separated by white space), one<br />

line of the mask per line in the file. The file must have the extension “.fil”. This extension must not be passed to<br />

the operator.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image to be convolved.<br />

º ImageResult (output object) . . . . . . . . . . . . . . . . . . . . . . . . . .multichannel-image(-array) Hobject * : byte<br />

Convolved result image.<br />

º FileName (input control) ......................................................string const char *<br />

Name of the file containing the filter mask.<br />

Default Value : ’filter’<br />

º Margin (input control) ...............................................................integer long<br />

Border treatment: 0...255 (constant), -1 (continue border’s gray value), -2 (continue cyclically), -3 (mirror<br />

gray values).<br />

Default Value : -3<br />

Typical Range of Values : -3 Margin 255<br />

Parallelization Information<br />

convol image is reentrant and automatically parallelized (on tuple level, channel level).<br />

Image filters<br />

Module<br />

expand domain gray ( Hobject InputImage, Hobject *ExpandedImage,<br />

long ExpansionRange )<br />

Expand the domain of an image and set the gray values in the expanded domain.<br />

expand domain gray expands the border gray values of the domain outwards. The width of the expansion<br />

is set by the parameter ExpansionRange. All filters in <strong>HALCON</strong> use gray values of the pixels outside the<br />

domain depending on the filter width. This may lead to undesirable side effects especially in the border region<br />

of the domain. For example, if the foreground (domain) and the background of the image differ strongly in<br />

brightness, the result of a filter operation may lead to undesired darkening or brightening at the border of the<br />

domain. In order to avoid this drawback, the domain is expanded by expand domain gray in a preliminary<br />

stage, copying the gray values of the border pixels to the outside of the domain. In addition, the domain itself<br />

is also expanded to reflect the newly set pixels. Therefore, in many cases it is reasonable to reduce the domain<br />

again (reduce domain or change domain)afterusingexpand domain gray and call the filter operation<br />

afterwards. ExpansionRange should be set to the half of the filter width.<br />

Parameter<br />

º InputImage (input object) ......................................image(-array) Hobject : byte / int2<br />

Input image with domain to be expanded.<br />

º ExpandedImage (output object) ..............................image(-array) Hobject * : byte / int2<br />

Output image with new gray values in the expanded domain.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.10. MISC 131<br />

º ExpansionRange (input control) ....................................................integer long<br />

Radius of the gray value expansion, measured in pixels.<br />

Default Value : 2<br />

Value Suggestions : ExpansionRange ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16<br />

Restriction : ExpansionRange 1<br />

Example<br />

read_image(Fabrik, ’fabrik.tif’);<br />

gen_rectangle2(Rectangle_Label,243,320,-1.55,62,28);<br />

reduce_domain(Fabrik, Rectangle_Label, Fabrik_Label);<br />

/* Character extraction without gray value expansion: */<br />

mean_image(Fabrik_Label,Label_Mean_normal,31,31);<br />

dyn_threshold(Fabrik_Label,Label_Mean_normal,Characters_normal,10,’dark’);<br />

dev_display(Fabrik);<br />

dev_display(Characters_normal);<br />

/* The characters in the border region are not extracted ! */<br />

stop();<br />

/* Character extraction with gray value expansion: */<br />

expand_domain_gray(Fabrik_Label, Label_expanded,15);<br />

reduce_domain(Label_expanded,Rectangle_Label, Label_expanded_reduced);<br />

mean_image(Label_expanded_reduced,Label_Mean_expanded,31,31);<br />

dyn_threshold(Fabrik_Label,Label_Mean_expanded,Characters_expanded,10,’dark’);<br />

dev_display(Fabrik);<br />

dev_display(Characters_expanded);<br />

/* Now, even in the border region the characters are recognized */<br />

Complexity<br />

Let Ä the perimeter of the domain. Then the runtime complexity is approximately Ǵĵ £ ÜÔÒ×ÓÒÊÒ.<br />

Result<br />

expand domain gray returns H MSG TRUE if all parameters are correct. If necessary, an exception handling<br />

is raised.<br />

Parallelization Information<br />

expand domain gray is reentrant and automatically parallelized (on tuple level).<br />

reduce domain<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, mean image, dyn threshold<br />

reduce domain, mean image<br />

Image filters<br />

See Also<br />

Module<br />

gray inside ( Hobject Image, Hobject *ImageDist )<br />

Calculate the lowest possible gray value on an arbitrary path to the image border for each point in the image.<br />

gray inside determines the “cheapest” path to the image border for each point in the image, i.e., the path on<br />

which the lowest gray values have to be overcome. The resulting image contains the difference of the gray value<br />

of the particular point and the maximum gray value on the path. Bright areas in the result image therefore signify<br />

that these areas (which are typically dark in the original image) are surrounded by bright areas. Dark areas in the<br />

result image signify that there are only small gray value differences between them and the image border (which<br />

doesn’t mean that they are surrounded by dark areas; a small “gap” of dark values suffices). The value 0 (black) in<br />

the result image signnifies that only darker or equally bright pixels exist on the path to the image border.<br />

The operator is implemented by first segmenting into basins and watersheds the image using the watersheds<br />

operator. If the image is regarded as a gray value mountain range, basins are the places where water accumulates<br />

<strong>HALCON</strong> 6.0


132 CHAPTER 3. FILTER<br />

and the mountain ridges are the watersheds. Then, the watersheds are distributed to adjacent basins, thus leaving<br />

only basins. The border of the domain (region) of the original image is now searched for the lowest gray value,<br />

and the region in which it resides is given its result values. If the lowest gray value resides on the image border,<br />

all result values can be calculated immediately using the gray value differences to the darkest point. If the smalles<br />

found gray value lies in the interior of a basin, the lowest possible gray value has to be determined from the already<br />

processed adjacent basins in order to compute the new values. An 8-neighborhood is used to determine adjacency.<br />

The found region is subtracted from the regions yet to process, and the whole process is repeated. Thus, the image<br />

is “stripped” form the outside.<br />

Analogously to watersheds, it is advisable to apply a smoothing operation before calling watersheds, e.g.,<br />

gauss image, in order to reduce the amount of regions that result from the watershed algorithm, and thus to<br />

speed up the processing time.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image being processed.<br />

º ImageDist (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * :int2<br />

Result image.<br />

Example<br />

read_image(Image,"coin");<br />

gauss_image(Image,&GaussImage,11);<br />

open_window (0,0,512,512,0,"visible","",&WindowHandle);<br />

gray_inside(GaussImage,Result);<br />

disp_image(Result,WindowHandle);<br />

gray inside always returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

gray inside is reentrant and automatically parallelized (on tuple level, channel level).<br />

Possible Predecessor Functions<br />

gauss image, smooth image, mean image, median image<br />

Possible Successor Functions<br />

select shape, area center, count obj<br />

watersheds<br />

Image filters<br />

See Also<br />

Module<br />

gray skeleton ( Hobject Image, Hobject *GraySkeleton )<br />

Thinning of gray value images.<br />

gray skeleton applies a gray value thinning operation to the input image Image. Figuratively, the gray<br />

value “mountain range” is reduced to its ridge lines by setting the gray value of “hillsides” to the gray value<br />

at the corresponding valley bottom. The resulting ridge lines are at most two pixels wide. This operator is especially<br />

useful for thinning edge images, and is thus an alternative to nonmax suppression amp. In contrast<br />

to nonmax suppression amp, gray skeleton preserves contours, but is much slower. In contrast to<br />

skeleton, this operator changes the gray values of an image while leaving its region unchanged.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image to be thinned.<br />

º GraySkeleton (output object) . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject * : byte<br />

Thinned image.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.10. MISC 133<br />

Example<br />

/* Seeking leafs of a tree in an aerial picture: */<br />

read_image(&Image,"wald1");<br />

gray_skeleton(Image&,Skelett);<br />

mean_image(Skelett,&MeanSkelett,7,7);<br />

dyn_threshold(Skelett,MeanSkelett,&Leafs,3.0,"light");<br />

Result<br />

gray skeleton returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can be<br />

set via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

gray skeleton is reentrant and automatically parallelized (on tuple level, channel level).<br />

mean image<br />

Possible Successor Functions<br />

Alternatives<br />

nonmax suppression amp, nonmax suppression dir, local max<br />

skeleton, gray dilation rect<br />

Image filters<br />

See Also<br />

Module<br />

T lut trans ( Hobject Image, Hobject *ImageResult, Htuple Lut )<br />

Transform an image with a gray-value look-up-table<br />

T lut trans transforms an image Image by using a gray value look-up-table Lut. This table acts as a transformation<br />

function.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image whose gray values are to be transformed.<br />

º ImageResult (output object) . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte<br />

Transformed image.<br />

º Lut (input control) .....................................................integer-array Htuple . long<br />

Table containing the transformation.<br />

/* To get the inverse of an image: */<br />

Htuple lut;<br />

read_image(&Image,"wald1");<br />

creat_tuple(&lut,256);<br />

for (i=0; i


134 CHAPTER 3. FILTER<br />

T principal comp ( Hobject MultichannelImage, Hobject *PCAImage,<br />

Htuple *InfoPerComp )<br />

Compute the principal components of multi-channel images.<br />

T principal comp does a principal components analysis of multi-channel images. This is useful for images<br />

obtained, e.g., with the thematic mapper of the Landsat satellite. Because the spectral bands are highly correlated it<br />

is desirable to transform them to uncorrelated images. This can be used to save storage, since the bands containing<br />

little information can be discarded, and with respect to a later classification step.<br />

The operator T principal comp takes a (multi-channel) image MultichannelImage and transforms it<br />

to the output image PCAImage, which contains the same number of channels, using the principal components<br />

analysis. The parameter InfoPerComp contains the relative information content of each output channel.<br />

Parameter<br />

º MultichannelImage (input object) . . . . . . .multichannel-image Hobject : byte / int1 / int2 / int4 / real<br />

Multi-channel input image.<br />

º PCAImage (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . multichannel-image Hobject * : real<br />

Multi-channel ouput image.<br />

º InfoPerComp (output control) ........................................real-array Htuple . double *<br />

Information content of each output channel.<br />

Result<br />

The operator T principal comp returns the value H MSG TRUE if the parameters are correct. Otherwise an<br />

exception is raised.<br />

Parallelization Information<br />

T principal comp is reentrant and processed without parallelization.<br />

Image filters<br />

Module<br />

symmetry ( Hobject Image, Hobject *ImageSymmetry, long MaskSize,<br />

double Direction, double Exponent )<br />

Symmentry of gray values along a row.<br />

symmetry calculates the symmetry along a line. For each pixel the gray values of both sides of the line are<br />

compared: The absolut value of the differences of gray values with same distance to the pixel is computed. Each<br />

of these differences is weighted by the exponent (after division by 255) and the summed up.<br />

×ÝÑ ¾<br />

¾<br />

Å×ËÞ<br />

Å×ËÞ<br />

<br />

½<br />

´µ ´ µ<br />

¾<br />

ÜÔÓÒÒØ<br />

Pixels with a high symmetry have large gray values.<br />

Attention<br />

Currently only horizontal search lines are implemented<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Input image.<br />

º ImageSymmetry (output object) . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte<br />

Symmetry image.<br />

º MaskSize (input control) ...........................................................number long<br />

Extension of search area.<br />

Default Value : 40<br />

Value Suggestions : MaskSize ¾3, 5, 7, 10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 100, 120, 140, 180<br />

Typical Range of Values : 3 MaskSize 1000<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.10. MISC 135<br />

º Direction (input control) ........................................................number double<br />

Angle of test direction.<br />

Default Value : 0.0<br />

Value Suggestions : Direction ¾0.0<br />

Typical Range of Values : 0.0 Direction 0.0<br />

º Exponent (input control) .........................................................number double<br />

Exponent for weighting.<br />

Default Value : 0.5<br />

Value Suggestions : Exponent ¾0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 0.8, 0.9, 1.0<br />

Typical Range of Values : 0.05 Exponent 1.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : ´0 Exponentµ ´Exponent 1µ<br />

Example<br />

read_image(Image,’monkey’)<br />

symmetry(Image,ImageSymmetry,70,0.0,0.5)<br />

threshold(ImageSymmetry,SymmPoints,170,255)<br />

Result<br />

If the parameter values are correct the operator symmetry returns the value H MSG TRUE The behavior<br />

in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

symmetry is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

threshold<br />

Image filters<br />

Possible Successor Functions<br />

Module<br />

topographic sketch ( Hobject Image, Hobject *Sketch )<br />

Compute the topographic primal sketch of an image.<br />

topographic sketch computes the topographic primal sketch of the input image Image. This is done by<br />

approximating the image locally by a bicubic polynomial (“facet model”). It serves to calculate the first and<br />

second partial derivatives of the image, and thus to classify the image into 11 classes. These classes are coded in<br />

the output image Sketch as numbers from 1 to 11. The classes are as follows:<br />

Peak 1<br />

Pit 2<br />

Ridge 3<br />

Ravine 4<br />

Saddle 5<br />

Flat 6<br />

Hillside Slope 7<br />

Hillside Convex 8<br />

Hillside Concave 9<br />

Hillside Saddle 10<br />

Hillside Inflection 11<br />

In order to obtain the separate classes as regions, a threshold operation has to be applied to the result image with<br />

the appropriate thresholds.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image for which the topographic primal sketch is to be computed.<br />

º Sketch (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte<br />

Label image containing the 11 classes.<br />

<strong>HALCON</strong> 6.0


136 CHAPTER 3. FILTER<br />

Example<br />

/* To extract the Ridges from a Image */<br />

read_image(&Image,"sinus");<br />

topographic_sketch(Image,&Sketch);<br />

threshold(Sketch,&Ridges,3.0,3.0);<br />

Complexity<br />

Let Ò be the number of pixels in the image. Then Ç´Òµ operations are performed.<br />

Result<br />

topographic sketch returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour<br />

can be set via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

topographic sketch is reentrant and automatically parallelized (on tuple level, channel level).<br />

threshold<br />

Possible Successor Functions<br />

Bibliography<br />

R. Haralick, L. Shapiro: “Computer and Robot Vision, Volume I”; Reading, Massachusetts, Addison-Wesley;<br />

1992; Kapitel 8.13.<br />

Module<br />

Image filters<br />

3.11 Noise<br />

T add noise distribution ( Hobject Image, Hobject *ImageNoise,<br />

Htuple Distribution )<br />

Add noise to an image.<br />

T add noise distribution adds noise distributed according to Distribution to the image Image. Resulting<br />

gray values are clipped to the range [0,255].<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Input image.<br />

º ImageNoise (output object) . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Noisy image.<br />

Parameter Number : ImageNoise Image<br />

º Distribution (input control) ............................distribution.values-array Htuple . double<br />

Noise distribution.<br />

Parameter Number : 513<br />

Example<br />

read_image(&Image,"fabrik");<br />

disp_image(Image,WindowHandle);<br />

set_d(PerSalt,30.0,0);<br />

set_d(PerPepper,30.0,0);<br />

T_sp_distribution(PerSalt,PerPepper,&Dist);<br />

T_add_noise_distribution(Image,&ImageNoise,Dist);<br />

disp_image(ImageNoise,WindowHandle);<br />

Result<br />

T add noise distribution returns H MSG TRUE if all parameters are correct. If the input is empty the<br />

behaviour can be set via set system(’no object result’,). If necessary, an exception handling<br />

is raised.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.11. NOISE 137<br />

Parallelization Information<br />

T add noise distribution is reentrant and automatically parallelized (on tuple level, channel level, domain<br />

level).<br />

Possible Predecessor Functions<br />

T gauss distribution, T sp distribution, T noise distribution mean<br />

add noise white<br />

Alternatives<br />

See Also<br />

T sp distribution, T gauss distribution, T noise distribution mean, add noise white<br />

Image filters<br />

Module<br />

add noise white ( Hobject Image, Hobject *ImageNoise, double Amp )<br />

Add noise to an image.<br />

add noise white adds noise to the image Image. The noise is white noise, equally distributed in the interval<br />

[-Amp,Amp], and is generated by using the C function “drand48” with an initial time dependent seed. Resulting<br />

gray values are clipped to the range [0,255].<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Input image.<br />

º ImageNoise (output object) . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Noisy image.<br />

Parameter Number : ImageNoise Image<br />

º Amp (input control) ...................................................................real double<br />

Maximum noise amplitude.<br />

Default Value : 60.0<br />

Value Suggestions : Amp ¾1.0, 2.0, 5.0, 10.0, 20.0, 40.0, 60.0, 90.0<br />

Typical Range of Values : 1.0 Amp 1000.0<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : Amp 0<br />

Example<br />

read_image(&Image,"fabrik");<br />

disp_image(Image,WindowHandle);<br />

add_noise_white(Image,&ImageNoise,90.0);<br />

disp_image(ImageNoise,WindowHandle);<br />

Result<br />

add noise white returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can<br />

be set via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

add noise white is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

T add noise distribution<br />

Alternatives<br />

See Also<br />

T add noise distribution, T noise distribution mean, T gauss distribution,<br />

T sp distribution<br />

Module<br />

Image filters<br />

<strong>HALCON</strong> 6.0


138 CHAPTER 3. FILTER<br />

T gauss distribution ( Htuple Sigma, Htuple *Distribution )<br />

Generate a Gaussian noise distribution.<br />

T gauss distribution generates a Gaussian noise distribution. The parameter Sigma determines<br />

the noise’s standard deviation. Usually, the result Distribution is used as input for the operator<br />

T add noise distribution.<br />

Parameter<br />

º Sigma (input control) .........................................................real Htuple . double<br />

Standard deviation of the Gaussian noise distribution.<br />

Default Value : 2.0<br />

Value Suggestions : Sigma ¾1.5, 2.0, 3.0, 5.0, 10.0<br />

Typical Range of Values : 0.0 Sigma 100.0<br />

Minimal Value Step : 0.1<br />

Recommended Value Step : 1.0<br />

º Distribution (output control) ..........................distribution.values-array Htuple . double *<br />

Resulting Gaussian noise distribution.<br />

Parameter Number : 513<br />

Example<br />

read_image(&Image,"fabrik");<br />

disp_image(Image,WindowHandle);<br />

set_d(Sigma,30.0,0);<br />

T_gauss_distribution(Sigma,&Dist);<br />

T_add_noise_distribution(Image,&ImageNoise,Dist);<br />

disp_image(ImageNoise,WindowHandle);<br />

Parallelization Information<br />

T gauss distribution is reentrant and processed without parallelization.<br />

T add noise distribution<br />

Possible Successor Functions<br />

Alternatives<br />

T sp distribution, T noise distribution mean<br />

See Also<br />

T sp distribution, add noise white, T noise distribution mean<br />

Image filters<br />

Module<br />

T noise distribution mean ( Hobject ConstRegion, Hobject Image,<br />

Htuple FilterSize, Htuple *Distribution )<br />

Determine the noise distribution of an image.<br />

T noise distribution mean calculates the noise distribution in a region of the image Image. The parameter<br />

ConstRegion determines a region of the image with approximately constant gray values. Ideally, the<br />

changes in gray values should only be caused by noise in this region. From this region the noise distribution is<br />

determined by using the mean image operator to smooth the image, and to use the gray value differences in this<br />

area as an estimate for the noise distribution, which is returned in Distribution.<br />

Attention<br />

It is important to ensure that the region ConstRegion is not too close to a large gradient in the image, because<br />

the gradient values are then used for calculating the mean. This means the the distance of ConstRegion must<br />

be at least as large as the filter size FilterSize used for calculating the mean.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.11. NOISE 139<br />

Parameter<br />

º ConstRegion (input object) ...............................................region(-array) Hobject<br />

Region from which the noise distribution is to be estimated.<br />

º Image (input object) .........................................................image Hobject : byte<br />

Corresponding image.<br />

º FilterSize (input control) .................................................integer Htuple . long<br />

Size of the mean filter.<br />

Default Value : 21<br />

Value Suggestions : FilterSize ¾5, 11, 15, 21, 31, 51, 101<br />

Typical Range of Values : 3 FilterSize 501 (lin)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

º Distribution (output control) ..........................distribution.values-array Htuple . double *<br />

Noise distribution of all input regions.<br />

Parallelization Information<br />

T noise distribution mean is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

draw region, gen circle, gen ellipse, gen rectangle1, gen rectangle2, threshold,<br />

erosion circle, gauss image, smooth image, sub image<br />

Possible Successor Functions<br />

T add noise distribution, disp distribution<br />

mean image, T gauss distribution<br />

Image filters<br />

See Also<br />

Module<br />

T sp distribution ( Htuple PercentSalt, Htuple PercentPepper,<br />

Htuple *Distribution )<br />

Generate a salt-and-pepper noise distribution.<br />

T sp distribution generates a noise distribution with the values 0 and 255. The parameters PercentSalt<br />

and PercentPepper determine the percentage of white and black noise pixels, respectively. The sum of these<br />

parameters must be smaller than 100. Usually, the result Distribution is used as input for the operator<br />

T add noise distribution.<br />

Parameter<br />

º PercentSalt (input control) .......................................number Htuple . double / long<br />

Percentage of salt (white noise pixels).<br />

Default Value : 5.0<br />

Value Suggestions : PercentSalt ¾1.0, 2.0, 5.0, 7.0, 10.0, 15.0, 20.0, 30.0<br />

Typical Range of Values : 0.0 PercentSalt 100.0<br />

Minimal Value Step : 0.1<br />

Recommended Value Step : 1.0<br />

Restriction : ´0.0 PercentSaltµ ´PercentSalt 100.0µ<br />

º PercentPepper (input control) ....................................number Htuple . double / long<br />

Percentage of pepper (black noise pixels).<br />

Default Value : 5.0<br />

Value Suggestions : PercentPepper ¾1.0, 2.0, 5.0, 7.0, 10.0, 15.0, 20.0, 30.0<br />

Typical Range of Values : 0.0 PercentPepper 100.0<br />

Minimal Value Step : 0.1<br />

Recommended Value Step : 1.0<br />

Restriction : ´0.0 PercentPepperµ ´PercentPepper 100.0µ<br />

º Distribution (output control) ..........................distribution.values-array Htuple . double *<br />

Resulting noise distribution.<br />

Parameter Number : 513<br />

<strong>HALCON</strong> 6.0


140 CHAPTER 3. FILTER<br />

Example<br />

read_image(&Image,"fabrik");<br />

disp_image(Image,WindowHandle);<br />

create_tuple(&PerSalt,1);<br />

set_d(PerSalt,30.0,0);<br />

create_tuple(&PerPepper,1);<br />

set_d(PerPepper,30.0,0);<br />

T_sp_distribution(PerSalt,PerPepper,&Dist);<br />

T_add_noise_distribution(Image,&ImageNoise,Dist);<br />

disp_image(ImageNoise,WindowHandle);<br />

Parallelization Information<br />

T sp distribution is reentrant and processed without parallelization.<br />

T add noise distribution<br />

Possible Successor Functions<br />

Alternatives<br />

T gauss distribution, T noise distribution mean<br />

See Also<br />

T gauss distribution, T noise distribution mean, add noise white<br />

Image filters<br />

Module<br />

3.12 Smoothing<br />

anisotrope diff ( Hobject Image, Hobject *ImageAniso, long Percent,<br />

long Mode, long Iteration, long neighborhoodType )<br />

Smooth an image by edge-preserving anisotropic diffusion.<br />

The operator anisotrope diff carries out an iterative, anisotropic smoothing process on the mathematical<br />

basis of physical diffusion. In analogy to the physical diffusion process describing the concentration balance<br />

between molecules dependent on the density gradient, the diffusion filter carries out a smoothing of the gray<br />

values dependent on the local gray value gradients.<br />

For iterative calculation of the gray value of a pixel the gray value differences in relation to the four or eight<br />

neighbors, respectively, are used. These gray value differences, however, are evaluated differently, i.e., a nonlinear<br />

diffusion process is carried out.<br />

The evaluation is carried out by using a diffusion function (two different functions were implemented, namely<br />

Mode = 1 and/or 2), which — depending on the gradient — ensures that within homogenous regions the smoothing<br />

is stronger than over the margins of regions so that the edges remain sharp. The diffusion function is adjusted to<br />

the noise ratio of the image by a histogram analysis in the gradient image (according to Canny). A high value for<br />

Percent increases the smoothing effect but blurs the edges a little more (values from 80 - 90 percent are typical).<br />

The parameter Iteration determines the number of iterations (typically 3–7).<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image to be smoothed.<br />

º ImageAniso (output object) . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte<br />

Smoothed image.<br />

º Percent (input control) .............................................................integer long<br />

For histogram analysis; higher values increase the smoothing effect, typically: 80-90.<br />

Default Value : 80<br />

Value Suggestions : Percent ¾65, 70, 75, 80, 85, 90<br />

Typical Range of Values : 50 Percent 100<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.12. SMOOTHING 141<br />

º Mode (input control) .................................................................integer long<br />

Selection of diffusion function.<br />

Default Value : 1<br />

Value List : Mode ¾1, 2<br />

º Iteration (input control) ...........................................................integer long<br />

Number of iterations, typical values: 3-7.<br />

Default Value : 5<br />

Value Suggestions : Iteration ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10<br />

Typical Range of Values : 1 Iteration 30<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º neighborhoodType (input control) .................................................integer long<br />

Reqired neighborhood type.<br />

Default Value : 8<br />

Value List : neighborhoodType ¾4, 8<br />

Example<br />

read_image(&Image,"fabrik");<br />

anisotrope_diff(Image,&Aniso,80,1,5,8);<br />

sub_image(Image,Aniso,&Sub,2.0,127.0);<br />

disp_image(Sub,WindowHandle);<br />

For each pixel: Ç´ÁØÖØÓÒ× £ ½µ.<br />

Complexity<br />

Result<br />

If the parameter values are correct the operator anisotrope diff returns the value H MSG TRUE.<br />

The behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

anisotrope diff is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

read image, grab image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

regiongrowing, threshold, sub image, dyn threshold, auto threshold<br />

sigma image, rank image<br />

Alternatives<br />

See Also<br />

smooth image, gauss image, sigma image, rank image, eliminate min max<br />

Bibliography<br />

P. Perona, J. Malik: “Scale-space and edge detection using anisotropic diffusion”, IEEE transaction on pattern<br />

analysis and machine intelligence, Vol. 12, No. 7, July 1990.<br />

Module<br />

Image filters<br />

eliminate min max ( Hobject Image, Hobject *filteredImage,<br />

long MaskWidth, long MaskHeight, double Gap, long Mode )<br />

Smooth an image in the spatial domain to suppress noise.<br />

eliminate min max smooths an image by replacing gray values with neighboring mean values, or local minima/maxima.<br />

In order to prevent edges and lines from being smoothed, only those gray values that represent local<br />

minima or maxima are replaced (if there is a line or edge within an image there will be at least one neighboring<br />

pixel with a comparable gray value). Gap controls the strictness of replacment: Only gray values that exceed all<br />

other values within their local neighborhood more than Gap and all values that fall below their neighboring more<br />

than Gap are replaced: ´Ü ݵ represents a Æ ¢ Å sized rectangular neighborhood of an pixel at position ´Ü ݵ,<br />

containing all pixels within the neighborhood except the pixel itself;<br />

<strong>HALCON</strong> 6.0


142 CHAPTER 3. FILTER<br />

¯ if ÖÝÚÐÙ´Ü Ýµ Ô · ÑÜÑÙÑ´´Ü ݵµ then replacement;<br />

¯ else if ÖÝÚÐÙ´Ü Ýµ ·Ô ÑÒÑÙÑ´´Ü ݵµ then replacement;<br />

¯ else adopt ÖÝÚÐÙ´Ü Ýµ without change;<br />

Mode specifies how to perform the new value in case of a replacement.<br />

ÅÓ ½ replace a local maximum with next minor local maximum and replace a local minimum with<br />

next bigger local minimum<br />

ÅÓ ¾ replace with mean value of all pixels within the local neighborhood (including the replaced<br />

pixel)<br />

ÅÓ ¿ replace with median value of all pixels within the local neighborhood (including the replaced<br />

pixel (this is default and used if Mode has got any other value than 1 or 2)<br />

MaskWidth and MaskHeight specifiy the width and height of the rectangular neighborhood. Border treatment:<br />

Pixels outside the image border are not considered (e.g.: With a local ¿ ¢ ¿-mask the neighborhood of a pixel at<br />

´¼ ¼µ reduces to the pixels at ´½ ¼µ ´¼ ½µ and ´½ ½µ).<br />

Attention<br />

eliminate min max only can work on byte images (<strong>HALCON</strong> image type BYTE IMAGE). If MaskWidth<br />

or MaskHeight is an even number, it is replaced by the next higher odd number (this allows the unique extraction<br />

of the center of the filter mask). Width/height of the mask may not exceed the image width/height.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image Hobject : byte<br />

Image to smooth.<br />

º filteredImage (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image Hobject * : byte<br />

Smoothed image.<br />

º MaskWidth (input control) ..........................................................extent.x long<br />

Width of filter mask.<br />

Default Value : 3<br />

Value Suggestions : MaskWidth ¾3, 5, 7, 9<br />

Typical Range of Values : 3 MaskWidth width(Image)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskWidthµ<br />

º MaskHeight (input control) ........................................................extent.y long<br />

Height of filter mask.<br />

Default Value : 3<br />

Value Suggestions : MaskHeight ¾3, 5, 7, 9<br />

Typical Range of Values : 3 MaskHeight width(Image)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskWidthµ<br />

º Gap (input control) ................................................................number double<br />

Gap between local maximum/minimum and all other gray values of the neighborhood.<br />

Default Value : 1.0<br />

Value Suggestions : Gap ¾1.0, 2.0, 5.0, 10.0<br />

º Mode (input control) .................................................................integer long<br />

Replacement rule (1 = next minimum/maximum, 2 = average, 3 =median).<br />

Default Value : 3<br />

Value List : Mode ¾1, 2, 3<br />

Result<br />

eliminate min max returns H MSG TRUE if all parameters are correct.<br />

eliminate min max returns with an error message.<br />

If the input is empty<br />

Parallelization Information<br />

eliminate min max is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

Possible Successor Functions<br />

wiener filter, wiener filter ni<br />

See Also<br />

mean sp, mean image, median image, median weighted, gauss image, smooth image<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.12. SMOOTHING 143<br />

Bibliography<br />

M. Imme:“A Noise Peak Elimination Filter”; S. 204-211 in CVGIP Graphical Models and Image Processing, Vol.<br />

53, No. 2, March 1991<br />

M. L”uckenhaus:“Grundlagen des Wiener-Filters und seine Anwendung in der Bildanalyse”; Diplomarbeit; Technische<br />

Universit”at M”unchen, Institut f”ur Informatik; Lehrstuhl Prof. Radig; 1995.<br />

Module<br />

Image filters<br />

eliminate sp ( Hobject Image, Hobject *ImageFillSP, long MaskWidth,<br />

long MaskHeight, long MinThresh, long MaxThresh )<br />

Replace values outside of thresholds with average value.<br />

The operator eliminate sp replaces all gray values outside the indicated gray value intervals (MinThresh to<br />

MaxThresh) with the neighboring mean values. Only those neighboring pixels which also fall within the gray<br />

value interval are used for averaging. If no such pixel is present in the vicinity the original gray value is used. The<br />

gray values in the input image falling within the gray value interval are also adopted without change.<br />

Attention<br />

If even values instead of odd values are given for MaskHeight or MaskWidth, the routine uses the next larger<br />

odd values instead (this way the center of the filter mask is always explicitly determined).<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Input image.<br />

º ImageFillSP (output object) . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte<br />

Smoothed image.<br />

º MaskWidth (input control) ..........................................................extent.x long<br />

Width of filter mask.<br />

Default Value : 3<br />

Value Suggestions : MaskWidth ¾3, 5, 7, 9, 11<br />

Typical Range of Values : 3 MaskWidth 512 (lin)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskWidthµ<br />

º MaskHeight (input control) ........................................................extent.y long<br />

Height of filter mask.<br />

Default Value : 3<br />

Value Suggestions : MaskHeight ¾3, 5, 7, 9, 11<br />

Typical Range of Values : 3 MaskHeight 512 (lin)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskHeightµ<br />

º MinThresh (input control) ...........................................................integer long<br />

Minimum gray value.<br />

Default Value : 1<br />

Value Suggestions : MinThresh ¾1, 5, 7, 9, 11, 15, 23, 31, 43, 61, 101<br />

Typical Range of Values : 0 MinThresh 254 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º MaxThresh (input control) ...........................................................integer long<br />

Maximum gray value.<br />

Default Value : 254<br />

Value Suggestions : MaxThresh ¾5, 7, 9, 11, 15, 23, 31, 43, 61, 101, 200, 230, 250, 254<br />

Typical Range of Values : 1 MaxThresh 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : MinThresh MaxThresh<br />

<strong>HALCON</strong> 6.0


144 CHAPTER 3. FILTER<br />

Example<br />

read_image(&Image,"meer_rot");<br />

disp_image(Image,WindowHandle);<br />

eliminate_sp(Image,&ImageMeansp,3,3,101,201);<br />

disp_image(ImageMeansp,WindowHandle);<br />

Parallelization Information<br />

eliminate sp is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

disp image<br />

Possible Successor Functions<br />

Alternatives<br />

mean sp, mean image, median image, eliminate min max<br />

See Also<br />

gauss image, smooth image, anisotrope diff, sigma image, eliminate min max<br />

Image filters<br />

Module<br />

fill interlace ( Hobject ImageCamera, Hobject *ImageFilled,<br />

const char *Mode )<br />

Interpolate 2 video half images.<br />

The operator fill interlace calculates an interpolated full image or removes odd/even lines from a video<br />

image composed of two half images. If an image is recorded with a video camera it consists of two half images<br />

recorded at different times but stored in one image in the digital form. This can lead to several errors in further<br />

processing. In order to reduce these errors the video image is modified. Every second line is re-calculated or<br />

removed. The parameter Mode determines whether this must be done for even (’even’, ’rmeven’) or odd (’odd’,<br />

’rmodd’) line numbers. If you choose ’even’ or ’odd’ the gray values in the generated lines are calculated as mean<br />

values from the direct neighbors above or below the current pixel, respectively. If you choose ’rmeven’ or ’rmodd’<br />

the even or odd lines numbers are removed (in that case the resulting image is only half as high as the input image).<br />

The value ’switch’ for Mode cause the odd and even lines to be exchanged.<br />

Parameter<br />

º ImageCamera (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte<br />

Gray image consisting of two half images.<br />

º ImageFilled (output object) . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte<br />

Full image with interpolated/removed lines.<br />

º Mode (input control) ............................................................string const char *<br />

Instruction whether even or odd lines should be replaced/removed.<br />

Default Value : ’odd’<br />

Value List : Mode ¾’odd’, ’even’, ’rmodd’, ’rmeven’, ’switch’<br />

Example<br />

read_image(&Image,"video_bild");<br />

fill_interlace(Image,&New,"odd");<br />

sobel_amp(New,&Sobel,"sum_abs",3);<br />

For each pixel: Ç´¾µ.<br />

Complexity<br />

Result<br />

If the parameter values are correct the operator fill interlace returns the value H MSG TRUE.<br />

The behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

fill interlace is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.12. SMOOTHING 145<br />

read image, grab image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

sobel amp, edges image, regiongrowing, diff of gauss, threshold, dyn threshold,<br />

auto threshold, mean image, gauss image, anisotrope diff, sigma image, median image<br />

median image, gauss image, crop part<br />

Image filters<br />

See Also<br />

Module<br />

gauss image ( Hobject Image, Hobject *ImageGauss, long Size )<br />

Smooth using discrete gauss functions.<br />

The operator gauss image smoothes images using the discrete Gaussian. The smoothing effect increases with<br />

increasing filter size. The following filter sizes (Size) are supported (the sigma value of the gauss function is<br />

indicated in brackets):<br />

3 (0.81)<br />

5 (0.93)<br />

7 (1.50)<br />

9 (2.00)<br />

11 (2.45)<br />

For margin control the gray values of the images are reflected at the image borders.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int4 / int2<br />

Image to be smoothed.<br />

º ImageGauss (output object) . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int4 / int4<br />

Filtered image.<br />

º Size (input control) .................................................................integer long<br />

Required filter size.<br />

Default Value : 5<br />

Value List : Size ¾3, 5, 7, 9, 11<br />

Example<br />

gauss_image(Input,&Gauss,7,);<br />

regiongrowing(Gauss,&Segments,7,7,5,100,);<br />

For each pixel: Ç´ËÞ £ ¾µ.<br />

Complexity<br />

Result<br />

If the parameter values are correct the operator gauss image returns the value H MSG TRUE. The<br />

behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

gauss image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

read image, grab image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

regiongrowing, threshold, sub image, dyn threshold, auto threshold<br />

smooth image, derivate gauss<br />

Alternatives<br />

<strong>HALCON</strong> 6.0


146 CHAPTER 3. FILTER<br />

See Also<br />

mean image, anisotrope diff, sigma image, gen lowpass<br />

Image filters<br />

Module<br />

T info smooth ( Htuple Filter, Htuple Alpha, Htuple *Size,<br />

Htuple *Coeffs )<br />

Information on smoothing filter smooth image.<br />

The operator T info smooth returns an estimation of the width of the smoothing filters used in routine<br />

smooth image. For this purpose the underlying continuous impulse answers of Filter are scanned until a<br />

filter coefficient is smaller than five percent of the maximum coefficient (at the origin). Alpha is the filter parameter<br />

(see smooth image). Currently four filters are supported (parameter Filter):<br />

’deriche1’, ’deriche2’, ’shen’ und ’gauss’.<br />

The gauss filter was conventionally implemented with filter masks (the other three are recursive filters). In the case<br />

of the gauss filter the filter coefficients (of the one-dimensional impulse answer ´Òµ with Ò ¼) are returned in<br />

Coeffs in addition to the filter size.<br />

Parameter<br />

º Filter (input control) .................................................string Htuple . const char *<br />

Name of required filter.<br />

Default Value : ’deriche2’<br />

Value List : Filter ¾’deriche1’, ’deriche2’, ’shen’, ’gauss’<br />

º Alpha (input control) .........................................................real Htuple . double<br />

Filter parameter: small values effect strong smoothing (reversed in case of ’gauss’).<br />

Default Value : 0.5<br />

Value Suggestions : Alpha ¾0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 7.0, 10.0<br />

Typical Range of Values : 0.01 Alpha 50.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Alpha 0.0<br />

º Size (output control) .......................................................integer Htuple . long *<br />

Width of filter is approx. size x size pixels.<br />

º Coeffs (output control) ..............................................integer-array Htuple . long *<br />

In case of gauss filter: coeffients of the “positive” half of the 1D impulse answer.<br />

Example<br />

info_smooth(’deriche2’,0.5,Size,Coeffs);<br />

smooth_image(Input,&Smooth,’deriche2’,7);<br />

Result<br />

If the parameter values are correct the operator T info smooth returns the value H MSG TRUE. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

T info smooth is reentrant and processed without parallelization.<br />

read image<br />

smooth image<br />

smooth image<br />

Image filters<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.12. SMOOTHING 147<br />

mean image ( Hobject Image, Hobject *ImageMean, long MaskWidth,<br />

long MaskHeight )<br />

Smooth by averaging.<br />

The operator mean image carries out a linear smoothing with the gray values of all input images (Image). The<br />

filter matrix consists of ones (evaluated equally) and has the size Å×ÀØ ¢ Å×ÏØ. The result of the<br />

convolution is divided by Å×ÀØ¢ Å×ÏØ. For margin control the gray values are reflected at the image<br />

edges.<br />

Attention<br />

If even values instead of odd values are given for MaskHeight or MaskWidth, the routine uses the next larger<br />

odd values instead (this way the center of the filter mask is always explicitly determined).<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2 / int4 / real / dvf<br />

Image to be smoothed.<br />

º ImageMean (output object) . . . . . . (multichannel-)image(-array) Hobject * : byte / int2 / int4 / real / dvf<br />

Smoothed image.<br />

º MaskWidth (input control) ..........................................................extent.x long<br />

Width of filter mask.<br />

Default Value : 9<br />

Value Suggestions : MaskWidth ¾3, 5, 7, 9, 11, 15, 23, 31, 43, 61, 101<br />

Typical Range of Values : 3 MaskWidth 501<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskWidthµ<br />

º MaskHeight (input control) ........................................................extent.y long<br />

Height of filter mask.<br />

Default Value : 9<br />

Value Suggestions : MaskHeight ¾3, 5, 7, 9, 11, 15, 23, 31, 43, 61, 101<br />

Typical Range of Values : 3 MaskHeight 501<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskHeightµ<br />

read_image(&Image,"fabrik");<br />

mean_image(Image,&Mean,3,3);<br />

disp_image(Mean,WindowHandle);<br />

Example<br />

Complexity<br />

For each pixel: O(15).<br />

Result<br />

If the parameter values are correct the operator mean image returns the value H MSG TRUE. The<br />

behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

mean image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

dyn threshold, regiongrowing<br />

gauss image, smooth image<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

anisotrope diff, sigma image, convol image, gen lowpass<br />

Image filters<br />

Module<br />

<strong>HALCON</strong> 6.0


148 CHAPTER 3. FILTER<br />

mean n ( Hobject Image, Hobject *ImageMean )<br />

Average gray values over several channels.<br />

The operator mean n generates the pixel-by-pixel mean value of all channels . For each coordinate point the sum<br />

of all gray values at this coordinate is calculated. The result is the mean of the gray values (sum divided by the<br />

number of channels). The output image has one channel.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . multichannel-image(-array) Hobject : byte / real<br />

Multichannel gray image.<br />

º ImageMean (output object) ......................singlechannel-image(-array) Hobject * : byte / real<br />

Result of averaging.<br />

Example<br />

compose3(Channel1,Channel2,Channel3,&MultiChannel);<br />

mean_n(MultiChannel,&Mean);<br />

Parallelization Information<br />

mean n is reentrant and automatically parallelized (on tuple level, domain level).<br />

Possible Predecessor Functions<br />

compose2, compose3, compose4, add channels<br />

disp image<br />

count channels<br />

Image filters<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

mean sp ( Hobject Image, Hobject *ImageSPMean, long MaskWidth,<br />

long MaskHeight, long MinThresh, long MaxThresh )<br />

Suppress salt and pepper noise.<br />

The operator mean sp carries out a smoothing by averaging the values. Only the gray values within the interval<br />

from MinThresh to MaxThresh are averaged. Gray values which are too light or too dark are ignored during<br />

summation. If no gray value lies within the default interval during summation the original gray value is adopted.<br />

If the thresholds are set at 0 or 255, respectively, the operator mean sp behaves like mean image except for the<br />

running time.<br />

The operator mean sp is used to suppress extreme gray values (salt and pepper noise = white and black dots).<br />

Attention<br />

If even values instead of odd values are given for MaskHeight or MaskWidth, the routine uses the next larger<br />

odd values instead (this way the center of the filter mask is always explicitly determined).<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Input image.<br />

º ImageSPMean (output object) . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte<br />

Smoothed image.<br />

º MaskWidth (input control) ..........................................................extent.x long<br />

Width of filter mask.<br />

Default Value : 3<br />

Value Suggestions : MaskWidth ¾3, 5, 7, 9, 11<br />

Typical Range of Values : 3 MaskWidth 512 (lin)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskWidthµ<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.12. SMOOTHING 149<br />

º MaskHeight (input control) ........................................................extent.y long<br />

Height of filter mask.<br />

Default Value : 3<br />

Value Suggestions : MaskHeight ¾3, 5, 7, 9, 11<br />

Typical Range of Values : 3 MaskHeight 512 (lin)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskHeightµ<br />

º MinThresh (input control) ...........................................................integer long<br />

Minimum gray value.<br />

Default Value : 1<br />

Value Suggestions : MinThresh ¾1, 5, 7, 9, 11, 15, 23, 31, 43, 61, 101<br />

Typical Range of Values : 0 MinThresh 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º MaxThresh (input control) ...........................................................integer long<br />

Maximum gray value.<br />

Default Value : 254<br />

Value Suggestions : MaxThresh ¾5, 7, 9, 11, 15, 23, 31, 43, 61, 101, 200, 230, 250, 254<br />

Typical Range of Values : 0 MaxThresh 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : MinThresh MaxThresh<br />

Example<br />

read_image(&Image,"meer_rot");<br />

disp_image(Image,WindowHandle);<br />

mean_sp(Image,&ImageMeansp,3,3,101,201);<br />

disp_image(ImageMeansp,WindowHandle);<br />

Parallelization Information<br />

mean sp is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

disp image<br />

Possible Successor Functions<br />

Alternatives<br />

mean image, median image, median separate, eliminate min max<br />

See Also<br />

anisotrope diff, sigma image, gauss image, smooth image, eliminate min max<br />

Image filters<br />

Module<br />

median image ( Hobject Image, Hobject *ImageMedian,<br />

const char *MaskType, long Radius, long Margin )<br />

Median filtering with different rank masks.<br />

The operator median image carries out a non-linear smoothing of the gray values of all input images (Image).<br />

The shift mask (MaskType) is transmitted in the form of an object (more precisely: its region). Several margin<br />

controls can be chosen for filtering (Margin):<br />

0...255 Pixels outside of the image edges are assumued<br />

constant (with the indicated gray value).<br />

-1 Continuation of edge pixels.<br />

-2 Cyclic continuation of image edges.<br />

-3 Reflection of pixels at the image edges.<br />

<strong>HALCON</strong> 6.0


150 CHAPTER 3. FILTER<br />

The indicated mask (= region of the mask image) is put over the image to be filtered in such a way that the center<br />

of the mask touches all pixels of the objects once. For each of these pixels all neighboring pixels covered by the<br />

mask are sorted in an ascending sequence according to their gray values. Thus, each of these sorted gray value<br />

sequences contains exactly as many gray values as the mask has pixels. From these sequences the median is<br />

selected and entered as resulting gray value at the corresponding output image.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image to be filtered.<br />

º ImageMedian (output object) . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte<br />

Median filtered image.<br />

º MaskType (input control) ......................................................string const char *<br />

Type of median mask.<br />

Default Value : ’circle’<br />

Value List : MaskType ¾’circle’, ’rectangle’<br />

º Radius (input control) ...............................................................integer long<br />

Radius of median mask.<br />

Default Value : 1<br />

Value Suggestions : Radius ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 15, 19, 25, 31, 39, 47, 59<br />

Typical Range of Values : 1 Radius 101<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

º Margin (input control) ...............................................................integer long<br />

Margin control: 0...255 (constant), -1 (edge pixels continued), -2 (cyclic continuation), -3 (reflection).<br />

Default Value : -3<br />

Typical Range of Values : -3 Margin 255<br />

Example<br />

read_image(&Image,"fabrik");<br />

median_image(Image,&Median,"circle",3,-1);<br />

disp_image(MedianWeighted,WindowHandle);<br />

For each pixel: O( Ô Ö´Å×ÌÝÔµ £ ).<br />

Complexity<br />

Result<br />

If the parameter values are correct the operator median image returns the value H MSG TRUE. The<br />

behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

median image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

read image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

threshold, dyn threshold, regiongrowing<br />

rank image<br />

Alternatives<br />

See Also<br />

gen circle, gen rectangle1, gray erosion rect, gray dilation rect<br />

Bibliography<br />

R. Haralick, L. Shapiro; “Computer and Robot Vision”; Addison-Wesley, 1992, Seite 318-319<br />

Image filters<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.12. SMOOTHING 151<br />

median separate ( Hobject Image, Hobject *ImageSMedian, long MaskWidth,<br />

long MaskHeight, long Margin )<br />

Separated median filtering with rectangle masks.<br />

The operator median separate carries out a variation of the median filtering: First two auxiliary images are<br />

created. The first one originates from a median filtering with a horizontal mask with a height of one pixel and the<br />

width MaskWidth followed by filtering with a mask with the height MaskHeight. The second auxiliary image<br />

is created by filtering with the same masks, but with a reversed sequence of the operation: first the vertical, then<br />

the horizontal mask. The output image results from averaging the two auxiliary images pixel by pixel.<br />

The operator median separate is clearly faster than the normal operator median image because both masks<br />

are one pixel wide, facilitating a very effecient processing. The runtime is practically ÒÔÒÒØ of the size of<br />

the mask. For example, the operator median separate can be well used after texture filters, where large masks<br />

are needed.<br />

The filter can also be used several times in a row in order to enhance the smoothing.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image to be filtered.<br />

º ImageSMedian (output object) . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject * : byte<br />

Median filtered image.<br />

º MaskWidth (input control) ..........................................................extent.x long<br />

Width of rank mask.<br />

Default Value : 25<br />

Value Suggestions : MaskWidth ¾1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 27, 43, 51, 67, 91, 121, 151<br />

Typical Range of Values : 1 MaskWidth 401<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

º MaskHeight (input control) ........................................................extent.y long<br />

Height of rank mask.<br />

Default Value : 25<br />

Value Suggestions : MaskHeight ¾1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 27, 43, 51, 67, 91, 121, 151<br />

Typical Range of Values : 1 MaskHeight 401<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

º Margin (input control) ...............................................................integer long<br />

Margin control: 0...255 (constant), -1 (edge pixels continued), -2 (cyclic continuation), -3 (reflection).<br />

Default Value : -3<br />

Typical Range of Values : -3 Margin 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Example<br />

read_image(&Image,"fabrik");<br />

median_separate(Image,&MedianSeparate,5,5,3);<br />

disp_image(MedianSeparate,WindowHandle);<br />

Complexity<br />

For each pixel: O(¼).<br />

Parallelization Information<br />

median separate is reentrant and automatically parallelized (on tuple level, channel level).<br />

Possible Predecessor Functions<br />

(T )texture laws, sobel amp, deviation image<br />

Possible Successor Functions<br />

learn ndim norm, learn ndim box, median separate, regiongrowing, auto threshold<br />

median image<br />

Alternatives<br />

<strong>HALCON</strong> 6.0


152 CHAPTER 3. FILTER<br />

rank image<br />

See Also<br />

Bibliography<br />

R. Haralick, L. Shapiro; “Computer and Robot Vision”; Addison-Wesley, 1992, Seite 319<br />

Image filters<br />

Module<br />

median weighted ( Hobject Image, Hobject *ImageWMedian,<br />

const char *MaskType, long MaskSize )<br />

Weighted median filtering with different rank masks.<br />

The operator median weighted calculates the median of the gray values within a local environment. In<br />

contrast to median image, which uses all gray values within the environment exactly once, the operator<br />

median weighted weights all gray values several times depending on their position. A gray value is received<br />

into the field to be sorted several times according to its weighting. The following masks are available:<br />

’gauss’ (MaskSize =3)<br />

’inner’ (MaskSize =3)<br />

½ ¾ ½<br />

¾ ¾<br />

½ ¾ ½<br />

½ ½ ½<br />

½ ¿ ½<br />

½ ½ ½<br />

The operator median weighted means that, contrary to median image, gray value corners remain.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Image to be filtered.<br />

º ImageWMedian (output object) . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte / int2<br />

Median filtered image.<br />

º MaskType (input control) ......................................................string const char *<br />

Type of median mask.<br />

Default Value : ’inner’<br />

Value List : MaskType ¾’inner’, ’gauss’<br />

º MaskSize (input control) ............................................................integer long<br />

mask size.<br />

Default Value : 3<br />

Value List : MaskSize ¾3<br />

Example<br />

read_image(&Image,"fabrik");<br />

median_weighted(Image,&MedianWeighted,"gauss",3);<br />

disp_image(MedianWeighted,WindowHandle);<br />

Complexity<br />

For each pixel: O(ÐÓ´Ö´Å×ÌÝÔµµÖ´Å×ÌÝÔµ).<br />

Parallelization Information<br />

median weighted is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

read image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

threshold, dyn threshold, regiongrowing<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.12. SMOOTHING 153<br />

Alternatives<br />

median image, trimmed mean, sigma image<br />

Bibliography<br />

R. Haralick, L. Shapiro; “Computer and Robot Vision”; Addison-Wesley, 1992, Seite 319<br />

Image filters<br />

Module<br />

midrange image ( Hobject Image, Hobject Mask, Hobject *ImageMidrange,<br />

long Margin )<br />

Calculate the average of maximum and minimum inside any mask.<br />

The operator midrange image forms the average of maximum and minimum inside the indicated mask in the<br />

whole image. Several margin controls (Margin) can be chosen for filtering:<br />

0...255 Pixels outside of the image edges are assumued<br />

constant (with the indicated gray value).<br />

-1 Continuation of edge pixels.<br />

-2 Cyclic continuation of image edges.<br />

-3 Reflection of pixels at the image edges.<br />

The indicated mask (= region of the mask image) is put over the image to be filtered in such a way that the center<br />

of the mask touches all pixels once.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image to be filtered.<br />

º Mask (input object) ..........................................................region Hobject : byte<br />

Region serving as filter mask.<br />

º ImageMidrange (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . multichannel-image(-array) Hobject *<br />

Filtered output image.<br />

º Margin (input control) ...............................................................integer long<br />

Margin control: 0...255 (constant), -1 (edge pixels continued), -2 (cyclic continuation), -3 (reflection).<br />

Default Value : -3<br />

Typical Range of Values : -3 Margin 255<br />

Example<br />

read_image(&Image,"fabrik");<br />

draw_region(&Region,WindowHandle);<br />

midrange_image(Image,Region,&Midrange,-3,);<br />

disp_image(Midrange,WindowHandle);<br />

For each pixel: O( Ô Ö´Å×µ £ ).<br />

Complexity<br />

Result<br />

If the parameter values are correct the operator midrange image returns the value H MSG TRUE.<br />

The behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

midrange image is reentrant and automatically parallelized (on tuple level, channel level).<br />

Possible Predecessor Functions<br />

read image, draw region, gen circle, gen rectangle1<br />

Possible Successor Functions<br />

threshold, dyn threshold, regiongrowing<br />

<strong>HALCON</strong> 6.0


154 CHAPTER 3. FILTER<br />

sigma image<br />

Alternatives<br />

See Also<br />

gen circle, gen rectangle1, gray erosion rect, gray dilation rect, gray range rect<br />

Bibliography<br />

R. Haralick, L. Shapiro; “Computer and Robot Vision”; Addison-Wesley, 1992, Seite 319<br />

Image filters<br />

Module<br />

rank image ( Hobject Image, Hobject Mask, Hobject *ImageRank, long Rank,<br />

long Margin )<br />

Smooth an image with an arbitrary rank mask.<br />

The operator rank image carries out a non-linear smoothing of the gray values of all input images (Image).<br />

The shift mask (Mask) is transmitted in the form of a region. The rank gray value (Rank) within the shift mask is<br />

calculated for all pixels. Several margin controls can be chosen for filtering (Margin):<br />

0...255 Pixels outside of the image edges are assumued<br />

constant (with the indicated gray value).<br />

-1 Continuation of edge pixels.<br />

-2 Cyclic continuation of image edges.<br />

-3 Reflection of pixels at the image edges.<br />

The indicated mask is put over the image to be filtered in such a way that the center of the mask touches all pixels<br />

once. For each of these pixels all neighboring pixels covered by the mask are sorted in an ascending sequence<br />

according to their gray values. Thus, each of these sorted gray value sequences contains exactly as many gray<br />

values as the mask has pixels. From these sequences the n-largest element (= Rank) is selected and entered as<br />

resulting gray value at the corresponding output image.<br />

If Rank is set to the median the well known median filter is applied. For Mask images can be created e.g., via<br />

the operators gen circle or gen rectangle1. IfRank is applied to 1 or the area of Mask, respectively, the<br />

effect is the same as in case of gray erosion rect or gray dilation rect.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . multichannel-image(-array) Hobject : byte<br />

Image to be filtered.<br />

º Mask (input object) ..........................................................region Hobject : byte<br />

Region serving as filter mask.<br />

º ImageRank (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .multichannel-image(-array) Hobject *<br />

Filtered image.<br />

º Rank (input control) .................................................................integer long<br />

Rank of the output gray value in the sorted sequence of input gray values inside the filter mask. Typical value<br />

(median): area(mask) / 2.<br />

Default Value : 5<br />

Value Suggestions : Rank ¾1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31<br />

Typical Range of Values : 1 Rank 512<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

º Margin (input control) ...............................................................integer long<br />

Margin control: 0...255 (constant), -1 (edge pixels continued), -2 (cyclic continuation), -3 (reflection).<br />

Default Value : -3<br />

Typical Range of Values : -3 Margin 255<br />

read_image(&Image,"fabrik");<br />

Example<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.12. SMOOTHING 155<br />

draw_region(&Region,WindowHandle);<br />

rank_image(Image,Region,&ImageRank,5,-3,);<br />

disp_image(ImageRank,WindowHandle);<br />

For each pixel: O( Ô Ö´Å×µ £ ).<br />

Complexity<br />

Result<br />

If the parameter values are correct the operator rank image returns the value H MSG TRUE. The<br />

behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

rank image is reentrant and automatically parallelized (on tuple level, channel level).<br />

Possible Predecessor Functions<br />

read image, draw region, gen circle, gen rectangle1<br />

Possible Successor Functions<br />

threshold, dyn threshold, regiongrowing<br />

sigma image<br />

Alternatives<br />

See Also<br />

gen circle, gen rectangle1, gray erosion rect, gray dilation rect<br />

Bibliography<br />

R. Haralick, L. Shapiro; “Computer and Robot Vision”; Addison-Wesley, 1992, Seite 318-320<br />

Image filters<br />

Module<br />

sigma image ( Hobject Image, Hobject *ImageSigma, long MaskHeight,<br />

long MaskWidth, long Sigma )<br />

Non-linear smoothing with the sigma filter.<br />

The operator sigma image carries out a non-linear smoothing of the gray values of all input images (Image).<br />

All pixels are checked in a rectangular window (MaskHeight ¢ MaskWidth). All pixels of the window which<br />

differ from the current pixel by less than Sigma are used for calculating the new pixel, which is the average of the<br />

chosen pixels. If all differences are larger than Sigma the gray value is adapted unchanged.<br />

Attention<br />

The filter is implemented for images of the ’byte’ type only. If even values instead of odd values are given for<br />

MaskHeight or MaskWidth, the routine uses the next larger odd values instead (this way the center of the filter<br />

mask is always explicitly determined).<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte / int1 / int2 / int4 / real<br />

Image to be smoothed.<br />

º ImageSigma (output object) . . . . (multichannel-)image(-array) Hobject * : byte / int1 / int2 / int4 / real<br />

Smoothed image.<br />

º MaskHeight (input control) ........................................................extent.y long<br />

Height of the mask (number of lines).<br />

Default Value : 5<br />

Value Suggestions : MaskHeight ¾3, 5, 7, 9, 11, 13, 15<br />

Typical Range of Values : 3 MaskHeight 101<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskHeightµ<br />

<strong>HALCON</strong> 6.0


156 CHAPTER 3. FILTER<br />

º MaskWidth (input control) ..........................................................extent.x long<br />

Width of the mask (number of columns).<br />

Default Value : 5<br />

Value Suggestions : MaskWidth ¾3, 5, 7, 9, 11, 13, 15<br />

Typical Range of Values : 3 MaskWidth 101<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskWidthµ<br />

º Sigma (input control) ................................................................integer long<br />

Max. deviation to the average.<br />

Default Value : 3<br />

Value Suggestions : Sigma ¾3, 5, 7, 9, 11, 20, 30, 50<br />

Typical Range of Values : 0 Sigma 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

Example<br />

read_image(&Image,"fabrik");<br />

sigma_image(Image,&ImageSigma,5,5,3);<br />

disp_image(ImageSigma,WindowHandle);<br />

Complexity<br />

For each pixel: O(MaskHeight¢ MaskWidth).<br />

Result<br />

If the parameter values are correct the operator sigma image returns the value H MSG TRUE. The<br />

behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

sigma image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

read image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

threshold, dyn threshold, regiongrowing<br />

anisotrope diff, rank image<br />

smooth image, gauss image, mean image<br />

Alternatives<br />

See Also<br />

Bibliography<br />

R. Haralick, L. Shapiro; “Computer and Robot Vision”; Addison-Wesley, 1992, Seite 325<br />

Image filters<br />

Module<br />

smooth image ( Hobject Image, Hobject *ImageSmooth, const char *Filter,<br />

double Alpha )<br />

Smooth an image using recursive filters.<br />

smooth image smooths gray images using recursive filters originally developed by Deriche and Shen and using<br />

the non-recursive Gaussian filter. The following filters can be choosen via the parameter Filter:<br />

’deriche1’, ’deriche2’, ’shen’ und ’gauss’.<br />

The “filter width” (i.e., the range of the filter and thereby result of the filter) can be of any size. In the case that the<br />

Deriche or Shen is choosen it decreases by increasing the filter parameter Alpha and increases in the case of the<br />

Gauss filter (and Alpha corresponds to the standard deviation of the Gaussian function). An approximation of the<br />

appropiate size of the filterwidth Alpha is performed by the operator T info smooth.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.12. SMOOTHING 157<br />

Non-recursive filters like the Gaussian filter are often implemented using filter-masks. In this case the runtime<br />

of the operator increases with increasing size of the filter mask. The runtime of the recursive filters remains<br />

constant; except the margin control becomes a little bit more time consuming. The Gaussian filter becomes slow in<br />

comparison to the recursive ones but is in contrast to them isotropic (the filter ’deriche2’ is only weakly direction<br />

sensitive). A comparable result of the smoothing is achieved by choosing the following values for the parameter:<br />

ÐÔ´¼Ö¾ ¼ µ ÐÔ´¼Ö½ ¼ µ<br />

¾<br />

ÐÔ´¼×Ò ¼ µ ÐÔ´¼Ö½ ¼ µ<br />

¾<br />

ÐÔ´¼Ù×× ¼ µ<br />

<br />

Parameter<br />

½<br />

ÐÔ´¼Ö½ ¼ µ<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image to be smoothed.<br />

º ImageSmooth (output object) . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject * : byte<br />

Smoothed image.<br />

º Filter (input control) .........................................................string const char *<br />

Filter.<br />

Default Value : ’deriche2’<br />

Value List : Filter ¾’deriche1’, ’deriche2’, ’shen’, ’gauss’<br />

º Alpha (input control) .................................................................real double<br />

Filterparameter: small values cause strong smoothing (vice versa by using bei ’gauss’).<br />

Default Value : 0.5<br />

Value Suggestions : Alpha ¾0.1, 0.2, 0.3, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 7.0, 10.0<br />

Typical Range of Values : 0.01 Alpha 50.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Alpha 0<br />

Example<br />

info_smooth(’deriche2’,0.5,Size,Coeffs);<br />

smooth_image(Input,&Smooth,’deriche2’,7);<br />

Result<br />

If the parameter values are correct the operator smooth image returns the value H MSG TRUE. The<br />

behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

smooth image is reentrant and automatically parallelized (on tuple level, channel level).<br />

read image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

threshold, dyn threshold, regiongrowing<br />

Alternatives<br />

gauss image, mean image, derivate gauss<br />

See Also<br />

T info smooth, median image, sigma image, anisotrope diff<br />

Bibliography<br />

R.Deriche: “Fast Algorithms for Low-Level Vision”; IEEE Transactions on Pattern Analysis and Machine Intelligence;<br />

PAMI-12, no. 1; S. 78-87; 1990.<br />

Module<br />

Image filters<br />

<strong>HALCON</strong> 6.0


158 CHAPTER 3. FILTER<br />

trimmed mean ( Hobject Image, Hobject Mask, Hobject *ImageTMean,<br />

long Number, long Margin )<br />

Smooth an image with an arbitrary rank mask.<br />

The operator trimmed mean carries out a non-linear smoothing of the gray values of all input images (Image).<br />

The shift mask (Mask) is transmitted in the form of a region. The average of Number gray values located near<br />

the median is calculated. Several margin controls can be chosen for filtering (Margin):<br />

0...255 Pixels outside of the image edges are assumued<br />

constant (with the indicated gray value).<br />

-1 Continuation of edge pixels.<br />

-2 Cyclic continuation of image edges.<br />

-3 Reflection of pixels at the image edges.<br />

The indicated mask (= region of the mask image) is put over the image to be filtered in such a way that the center<br />

of the mask touches all pixels once. For each of these pixels all neighboring pixels covered by the mask are sorted<br />

in an ascending sequence according to their gray values. Thus, each of these sorted gray value sequences contains<br />

exactly as many gray values as the mask has pixels. If F is the surface of the mask the average of these sequences<br />

is calculated as follows: The first (F - Number)/2 gray values are ignored. Then the following Number gray values<br />

are summed up and divided by Number. Again the remaining (F - Number)/2 gray values are ignored.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . multichannel-image(-array) Hobject : byte<br />

Image to be filtered.<br />

º Mask (input object) ................................................................region Hobject<br />

Image whose region serves as filter mask.<br />

º ImageTMean (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . multichannel-image(-array) Hobject * : byte<br />

Filtered output image.<br />

º Number (input control) ...............................................................integer long<br />

Number of averaged pixels. Typical value: Surface(Mask) / 2.<br />

Default Value : 5<br />

Value Suggestions : Number ¾1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31<br />

Typical Range of Values : 1 Number 401<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

º Margin (input control) ...............................................................integer long<br />

Margin control: 0...255 (constant), -1 (edge pixels continued), -2 (cyclic continuation), -3 (reflection).<br />

Default Value : -3<br />

Typical Range of Values : -3 Margin 255<br />

Example<br />

read_image(&Image,"fabrik");<br />

draw_region(&Region,WindowHandle);<br />

trimmed_mean(Image,Region,&TrimmedMean,5,-3,);<br />

disp_image(TrimmedMean,WindowHandle);<br />

For each pixel: O( Ô Ö´Å×µ £ ).<br />

Complexity<br />

Result<br />

If the parameter values are correct the operator trimmed mean returns the value H MSG TRUE. The<br />

behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

trimmed mean is reentrant and automatically parallelized (on tuple level, channel level).<br />

Possible Predecessor Functions<br />

read image, draw region, gen circle, gen rectangle1<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.13. TEXTURE 159<br />

Possible Successor Functions<br />

threshold, dyn threshold, regiongrowing<br />

Alternatives<br />

sigma image, median weighted, median image<br />

See Also<br />

gen circle, gen rectangle1, gray erosion rect, gray dilation rect<br />

Bibliography<br />

R. Haralick, L. Shapiro; “Computer and Robot Vision”; Addison-Wesley, 1992, Seite 320<br />

Image filters<br />

Module<br />

3.13 Texture<br />

deviation image ( Hobject Image, Hobject *ImageDeviation, long Width,<br />

long Height )<br />

Calculate the standard deviation of gray values within rectangular windows.<br />

deviation image calculates the standard deviation of gray values in the image Image within a rectangular<br />

mask of size (Height, Width). The resulting image is returned in ImageDeviation. For byte images, the<br />

result is multiplied by 2. If the parameters Height and Width are even, they are changed to the next larger odd<br />

value. At the image borders the gray values are mirrored.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int4 / real / int2<br />

Image for which the standard deviation is to be calculated.<br />

º ImageDeviation (output object) ..................image(-array) Hobject * : byte / int4 / real / int2<br />

Image containing the standard deviation.<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the mask in which the standard deviation is calculated.<br />

Default Value : 11<br />

Value List : Width ¾3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25<br />

Restriction : ´3 Widthµ odd´Widthµ<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the mask in which the standard deviation is calculated.<br />

Default Value : 11<br />

Value List : Height ¾3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25<br />

Restriction : ´3 Heightµ odd´Heightµ<br />

Example<br />

read_image(&Image,"fabrik");<br />

disp_image(Image,WindowHandle);<br />

deviation_image(Image,&Deviation,9,9);<br />

disp_image(Deviation,WindowHandle);<br />

Result<br />

deviation image returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can<br />

be set via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

deviation image is reentrant and automatically parallelized (on tuple level, channel level).<br />

disp image<br />

entropy image, entropy gray<br />

Possible Successor Functions<br />

Alternatives<br />

<strong>HALCON</strong> 6.0


160 CHAPTER 3. FILTER<br />

See Also<br />

convol image, (T )texture laws, intensity<br />

Image filters<br />

Module<br />

entropy image ( Hobject Image, Hobject *ImageEntropy, long Width,<br />

long Height )<br />

Calculate the entropy of gray values within a rectangular window.<br />

entropy image calculates the entropy of gray values in the image Image within a rectangular mask of size<br />

(Height, Width). The resulting image is returned in ImageEntropy, in which the entropy is multiplied by<br />

32. If the parameters Height and Width are even, they are changed to the next larger odd value. At the image<br />

borders the gray values are mirrored.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image for which the entropy is to be calculated.<br />

º ImageEntropy (output object) . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject * : byte<br />

Entropy image.<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the mask in which the entropy is calculated.<br />

Default Value : 9<br />

Value List : Width ¾3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25<br />

Value Suggestions : Width ¾3, 5, 7, 9, 11, 13, 15<br />

Restriction : ´3 Widthµ odd´Widthµ<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the mask in which the entropy is calculated.<br />

Default Value : 9<br />

Value List : Height ¾3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25<br />

Value Suggestions : Height ¾3, 5, 7, 9, 11, 13, 15<br />

Restriction : ´3 Heightµ odd´Heightµ<br />

read_image(&Image,"fabrik");<br />

disp_image(Image,WindowHandle);<br />

entropy_image(Image,&Entropy1,9,9);<br />

disp_image(Entropy1,WindowHandle);<br />

Example<br />

Result<br />

entropy image returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can be<br />

set via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

entropy image is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

disp image<br />

entropy gray<br />

energy gabor, entropy gray<br />

Image filters<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.13. TEXTURE 161<br />

texture laws ( Hobject Image, Hobject *ImageTexture,<br />

const char *FilterTypes, long Shift, long FilterSize )<br />

T texture laws ( Hobject Image, Hobject *ImageTexture,<br />

Htuple FilterTypes, Htuple Shift, Htuple FilterSize )<br />

Filter an image using a Laws texture filter.<br />

(T )texture laws applies one or more texture transformations (according to Laws) to an image. This is done<br />

by convolving the input image with one (or more) filter masks. The filters are:<br />

9 different 3x3 matrices obtainable from the following three vectors:<br />

l ½ ¾ ½℄<br />

e ½ ¼ ½℄<br />

s ½ ¾ ½℄<br />

25 different 5x5 matrices obtainable from the following five vectors:<br />

l ½ ½℄<br />

e ½ ¾ ¼ ¾ ½℄<br />

s ½ ¼ ¾ ¼ ½℄<br />

r ½ ½℄<br />

w ½ ¾ ¼ ¾ ½℄<br />

36 different 7x7 matrices obtainable from the following six vectors:<br />

l ½ ½ ¾¼ ½ ½℄<br />

e ½ ¼ ½℄<br />

s ½ ¾ ½ ½ ¾ ½℄<br />

r ½ ¾ ½ ½ ¾ ½℄<br />

w ½ ¼ ¿ ¼ ¿ ¼ ½℄<br />

o ½ ½ ¾¼ ½ ½℄<br />

For most of the filters the resulting gray values must be modified by a Shift. This makes the different textures in<br />

the output image more comparable to each other, provided suitable filters are used.<br />

The name of the filter is composed of the letters of the two vectors used, where the first letter denotes convolution<br />

in the column direction while the second letter denotes convolution in the row direction.<br />

If more than one filter type is passed, a multi-channel image is returned for each (single-channel) input image, with<br />

each channel corresponding to a particular filter.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject : byte / int2<br />

Images to which the texture transformation is to be applied.<br />

º ImageTexture (output object) . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject * : byte<br />

Texture images.<br />

º FilterTypes (input control) ..................................string(-array) (Htuple .) const char *<br />

Desired filters (name or number).<br />

Default Value : ’el’<br />

Value Suggestions : FilterTypes ¾’ll’, ’le’, ’ls’, ’lr’, ’lw’, ’lo’, ’el’, ’ee’, ’es’, ’er’, ’ew’, ’eo’, ’sl’, ’se’,<br />

’ss’, ’sr’, ’sw’, ’so’, ’rl’, ’re’, ’rs’, ’rr’, ’rw’, ’ro’, ’wl’, ’we’, ’ws’, ’wr’, ’ww’, ’wo’, ’ol’, ’oe’, ’os’, ’or’, ’ow’,<br />

’oo’<br />

º Shift (input control) ......................................................integer (Htuple .) long<br />

Shift to reduce the gray value dynamics.<br />

Default Value : 2<br />

Value List : Shift ¾0, 1, 2, 3, 4, 5, 6, 7, 8, 9<br />

º FilterSize (input control) ................................................integer (Htuple .) long<br />

Size of the filter kernel.<br />

Default Value : 5<br />

Value List : FilterSize ¾3, 5, 7<br />

<strong>HALCON</strong> 6.0


162 CHAPTER 3. FILTER<br />

Example<br />

/* 2 dimensional pixel classification */<br />

read_image(&Image,"combine");<br />

open_window(0,0,-1,-1,"root","visible","",&WindowHandle);<br />

disp_image(Image,WindowHandle);<br />

texture_laws(Image,&Texture1,"es",2,5);<br />

texture_laws(Image,&Texture2,"le",2,5);<br />

mean_image(Texture1,&H1,51,51);<br />

mean_image(Texture2,&H2,51,51);<br />

fwrite_string(FileId,"mark desired image section");<br />

fnew_line(FileId);<br />

set_color(WindowHandle,"green");<br />

draw_region(&Region,WindowHandle);<br />

reduce_domain(H1,Region,&Foreground1);<br />

reduce_domain(H2,Region&,Foreground2);<br />

histo_2dim(Region,Foreground1,Foreground2,&Histo);<br />

threshold(Histo,&Characteristic_area,1.0,1000000.0);<br />

set_color(WindowHandle,"blue");<br />

disp_region(Characteristic_area,WindowHandle);<br />

class_2dim(H1,H2,Characteristic_area,&Seg,4,5:);<br />

set_color(WindowHandle,"red");<br />

disp_region(Seg,WindowHandle);<br />

Result<br />

(T )texture laws returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can<br />

be set via set system(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

(T )texture laws is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

Possible Successor Functions<br />

mean image, gauss image, median image, histo 2dim, learn ndim norm, learn ndim box,<br />

threshold<br />

Alternatives<br />

convol image<br />

See Also<br />

class 2dim sup, class ndim norm<br />

Bibliography<br />

Laws, K.I. “Textured image segmentation”; Ph.D. dissertation, Dept. of Engineering, Univ. Southern California,<br />

1980<br />

Module<br />

Image filters<br />

3.14 Wiener-Filter<br />

gen psf defocus ( Hobject *Psf, long PSFwidth, long PSFheight,<br />

double Blurring )<br />

Generate an impulse response of an uniform out-of-focus blurring.<br />

gen psf defocus generates an impulse response (spatial domain) of an uniform out-of-focus blurring and<br />

writes it into an image of <strong>HALCON</strong> image type ’real’. Blurring specifies the extent of blurring by defining<br />

the ”‘blur radius”’ (out-of-focus blurring maps each image pixel on a small circle with a radius of Blurring<br />

- specified in ”‘number of pixels”’). If specified less than zero, the absolute value of Blurring is used. The<br />

result image of gen psf defocus encloses an spatial domain impulse response of the specified blurring. Its<br />

representation presumes the origin in the upper left corner. This results in the following disposition of an ÆÜÅ<br />

sized image:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.14. WIENER-FILTER 163<br />

¯ first rectangle (”‘upper left”’): (image coordinates Ü ¼´Æ¾µ ½, Ý ¼´Å¾µ ½µ<br />

- conforms to the fourth quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü ¼Æ¾ and Ý ¼ ž<br />

¯ second rectangle (”‘upper right”’): (image coordinates Ü Æ¾Æ ½, Ý ¼´Å¾µ ½µ<br />

- conforms to the third quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü Æ¾ ½ and Ý ½ ž<br />

¯ third rectangle (”‘lower left”’): (image coordinates Ü ¼´Æ¾µ ½, Ý Å¾Å ½µ<br />

- conforms to the first quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü ½Æ¾ and Ý Å¾¼<br />

¯ fourth rectangle (”‘lower right”’): (image coordinates Ü Æ¾Æ ½, Ý Å¾Å ½µ<br />

- conforms to the second quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü Æ¾ ½ und Ý Å¾½<br />

This representation conforms to that of the impulse response parameter of the <strong>HALCON</strong>-operator<br />

wiener filter. So one can use gen psf defocus to generate an impulse response for Wiener filtering.<br />

Parameter<br />

º Psf (output object) ........................................................image Hobject * : real<br />

Impuls response of uniform out-of-focus blurring.<br />

º PSFwidth (input control) ............................................................integer long<br />

Width of result image.<br />

Default Value : 256<br />

Value Suggestions : PSFwidth ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 PSFwidth<br />

º PSFheight (input control) ...........................................................integer long<br />

Height of result image.<br />

Default Value : 256<br />

Value Suggestions : PSFheight ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 PSFheight<br />

º Blurring (input control) .............................................................real double<br />

Degree of Blurring.<br />

Default Value : 5.0<br />

Value Suggestions : Blurring ¾1.0, 5.0, 10.0, 15.0, 18.0<br />

Result<br />

gen psf defocus returns H MSG TRUE if all parameters are correct.<br />

Parallelization Information<br />

gen psf defocus is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

simulate motion, gen psf motion<br />

Possible Successor Functions<br />

simulate defocus, wiener filter, wiener filter ni<br />

See Also<br />

simulate defocus, gen psf motion, simulate motion, wiener filter, wiener filter ni<br />

Bibliography<br />

Reginald L. Lagendijk, Jan Biemond: Iterative Identification and Restoration of Images, Kluwer Academic Publishers<br />

Boston/Dordrecht/London, 1991<br />

M. L”uckenhaus:”‘Grundlagen des Wiener-Filters und seine Anwendung in der Bildanalyse”’; Diplomarbeit;<br />

Technische Universit”at M”unchen, Institut f”ur Informatik; Lehrstuhl Prof. Radig; 1995.<br />

Module<br />

Wiener filter<br />

gen psf motion ( Hobject *Psf, long PSFwidth, long PSFheight,<br />

double Blurring, long Angle, long Type )<br />

Generate an impulse response of a (linearly) motion blurring.<br />

<strong>HALCON</strong> 6.0


164 CHAPTER 3. FILTER<br />

gen psf motion generates an impulse response (spatial domain) of a blurring caused by a relative motion<br />

between the object and the camera during exposure. The generated impulse response is output into an image<br />

of <strong>HALCON</strong> image type ’real’. PSFwidth and PSFheight define the width and height of the ouput image.<br />

The blurring motion moves along an even. Angle fixes its direction by specifying the angle between the motion<br />

direction and the x-axis (anticlockwise, measured in degrees). To specify different velocity behaviour five PSF<br />

prototypes can be generated. Type switches between the following prototypes:<br />

1. reverse ramp (crude model for acceleration)<br />

2. reverse trapezoid (crude model for high acceleration)<br />

3. square pulse (exact model for constant velocity), this is default<br />

4. forward trapezoid (crude model for deceleration)<br />

5. forward ramp (crude model for high deceleration)<br />

The blurring affects all part of the image uniformly. Blurring controls the extent of blurring. It specifies the<br />

number of pixels (lying one after another) that are affetcetd by the blurring. This number is determined by velocity<br />

of the motion and exposure time. If Blurring is a negative number, an adequate blurring in reverse direction<br />

is simulated. If Angle is a negative number, it is interpreted clockwise. If Angle exceeds 360 or falls below<br />

-360, it is transformed modulo(360) in an adequate number between ¼¿¼℄ resp. ¿¼¼℄. The result image<br />

of gen psf motion encloses an spatial domain impulse response of the specified blurring. Its representation<br />

presumes the origin in the upper left corner. This results in the following disposition of an ÆÜÅ sized image:<br />

¯ first rectangle (”‘upper left”’): (image coordinates Ü ¼´Æ¾µ ½, Ý ¼´Å¾µ ½µ<br />

- conforms to the fourth quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü ¼Æ¾ and Ý ¼ ž<br />

¯ second rectangle (”‘upper right”’): (image coordinates Ü Æ¾Æ ½, Ý ¼´Å¾µ ½µ<br />

- conforms to the third quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü Æ¾ ½ and Ý ½ ž<br />

¯ third rectangle (”‘lower left”’): (image coordinates Ü ¼´Æ¾µ ½, Ý Å¾Å ½µ<br />

- conforms to the first quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü ½Æ¾ and Ý Å¾¼<br />

¯ fourth rectangle (”‘lower right”’): (image coordinates Ü Æ¾Æ ½, Ý Å¾Å ½µ<br />

- conforms to the second quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü Æ¾ ½ und Ý Å¾½<br />

This representation conforms to that of the impulse response parameter of the <strong>HALCON</strong>-operator<br />

wiener filter. So one can use gen psf motion to generate an impulse response for Wiener filtering a<br />

motion blurred image.<br />

Parameter<br />

º Psf (output object) ........................................................image Hobject * : real<br />

Impulse response of motion-blur.<br />

º PSFwidth (input control) ............................................................integer long<br />

Width of impulse response image.<br />

Default Value : 256<br />

Value Suggestions : PSFwidth ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 PSFwidth<br />

º PSFheight (input control) ...........................................................integer long<br />

Height of impulse response image.<br />

Default Value : 256<br />

Value Suggestions : PSFheight ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 PSFheight<br />

º Blurring (input control) .............................................................real double<br />

Degree of motion-blur.<br />

Default Value : 20.0<br />

Value Suggestions : Blurring ¾5.0, 10.0, 20.0, 30.0, 40.0<br />

º Angle (input control) ................................................................integer long<br />

Angle between direction of motion and x-axis (anticlockwise).<br />

Default Value : 0<br />

Value Suggestions : Angle ¾0, 45, 90, 180, 270<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.14. WIENER-FILTER 165<br />

º Type (input control) .................................................................integer long<br />

PSF protoype resp. type of motion.<br />

Default Value : 3<br />

Value List : Type ¾1, 2, 3, 4, 5<br />

Result<br />

gen psf motion returns H MSG TRUE if all parameters are correct.<br />

Parallelization Information<br />

gen psf motion is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen psf motion, simulate defocus, gen psf defocus<br />

Possible Successor Functions<br />

simulate motion, wiener filter, wiener filter ni<br />

See Also<br />

simulate motion, simulate defocus, gen psf defocus, wiener filter, wiener filter ni<br />

Bibliography<br />

Anil K. Jain:Fundamentals of Digital Image Processing, Prentice-Hall International Inc., Englewood Cliffs, New<br />

Jersey, 1989<br />

M. L”uckenhaus:”‘Grundlagen des Wiener-Filters und seine Anwendung in der Bildanalyse”’; Diplomarbeit;<br />

Technische Universit”at M”unchen, Institut f”ur Informatik; Lehrstuhl Prof. Radig; 1995.<br />

Kha-Chye Tan, Hock Lim, B. T. G. Tan:”‘Restoration of Real-World Motion-Blurred Images”’;S. 291-299 in:<br />

CVGIP Graphical Models and Image Processing, Vol. 53, No. 3, May 1991<br />

Module<br />

Wiener filter<br />

simulate defocus ( Hobject Image, Hobject *DefocusedImage,<br />

double Blurring )<br />

Simulate an uniform out-of-focus blurring of an image.<br />

simulate defocus simulates out-of-focus blurring of an image. All parts of the image are blurred uniformly.<br />

Blurring specifies the extent of blurring by defining the ”‘blur radius”’ (out-of-focus blurring maps each image<br />

pixel on a small circle with a radius of Blurring - specified in ”‘number of pixels”’). If specified less than null,<br />

the absolute value of Blurring is used. Simulation of blurring is done by a convolution of the image with a<br />

blurring specific impulse response. The convolution is realized by multiplication in the Fourier domain.<br />

Attention<br />

As the simulation of the blurring is realized based on the Fourier transform, image height and width must be a<br />

power of 2, e.g. 128, 128, 256, 512,...<br />

Parameter<br />

º Image (input object) .........................................................image Hobject :any<br />

Image to blur.<br />

º DefocusedImage (output object) .........................................image Hobject * : real<br />

Blurred image.<br />

º Blurring (input control) .............................................................real double<br />

Degree of blurring.<br />

Default Value : 5.0<br />

Value Suggestions : Blurring ¾1.0, 5.0, 10.0, 15.0, 18.0<br />

Result<br />

simulate defocus returns H MSG TRUE if all parameters are correct.<br />

simulate defocus returns with an error message.<br />

Parallelization Information<br />

simulate defocus is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen psf defocus, simulate motion, gen psf motion<br />

If the input is empty<br />

<strong>HALCON</strong> 6.0


166 CHAPTER 3. FILTER<br />

Possible Successor Functions<br />

wiener filter, wiener filter ni<br />

See Also<br />

gen psf defocus, simulate motion, gen psf motion<br />

Bibliography<br />

Reginald L. Lagendijk, Jan Biemond: Iterative Identification and Restoration of Images, Kluwer Academic Publishers<br />

Boston/Dordrecht/London, 1991<br />

M. L”uckenhaus:”‘Grundlagen des Wiener-Filters und seine Anwendung in der Bildanalyse”’; Diplomarbeit;<br />

Technische Universit”at M”unchen, Institut f”ur Informatik; Lehrstuhl Prof. Radig; 1995.<br />

Module<br />

Wiener filter<br />

simulate motion ( Hobject Image, Hobject *MovedImage, double Blurring,<br />

long Angle, long Type )<br />

Simulation of (linearly) motion blur.<br />

simulate motion simulates blurring caused by a relative motion between the object and the camera during<br />

exposure. The simulated motion moves along an even. Angle fixes its direction by specifying the angle between<br />

the motion direction and the x-axis (anticlockwise, measured in degrees). Simulation is done by a convolution of<br />

the image with a blurring specific impulse response. The convolution is realized by multiplication in the Fourier<br />

domain. simulate motion offers five protoypes of impulse responses conforming to different acceleration<br />

behaviours. Type allows to choose one of the following PSF prototypes:<br />

1. reverse ramp (crude model for acceleration)<br />

2. reverse trapezoid (crude model for high acceleration)<br />

3. square pulse (exact model for constant velocity), this is default<br />

4. forward trapezoid (crude model for deceleration)<br />

5. forward ramp (crude model for high deceleration)<br />

The simulated blurring affects all part of the image uniformly. Blurring controls the extent of blurring. It<br />

specifies the number of pixels (lying one after another) that are affetcetd by the blurring. This number is determined<br />

by velocity of the motion and exposure time. If Blurring is a negative number, an adequate blurring in reverse<br />

direction is simulated. If Angle is a negative number, it is interpreted clockwise. If Angle exceeds 360 or falls<br />

below -360, it is transformed modulo(360) in an adequate number between ¼¿¼℄ resp. ¿¼¼℄.<br />

Attention<br />

As the simulation of the blurring is realized based on the Fourier transform, image height and width must be a<br />

power of 2, e.g. 128, 128, 256, 512,...<br />

Parameter<br />

º Image (input object) .........................................................image Hobject :any<br />

imagetobeblurred.<br />

º MovedImage (output object) ...............................................image Hobject * : real<br />

motion blurred image.<br />

º Blurring (input control) .............................................................real double<br />

extent of blurring.<br />

Default Value : 20.0<br />

Value Suggestions : Blurring ¾5.0, 10.0, 20.0, 30.0, 40.0<br />

º Angle (input control) ................................................................integer long<br />

Angle between direction of motion and x-axis (anticlockwise).<br />

Default Value : 0<br />

Value Suggestions : Angle ¾0, 45, 90, 180, 270<br />

º Type (input control) .................................................................integer long<br />

impulse response of motion blur.<br />

Default Value : 3<br />

Value List : Type ¾1, 2, 3, 4, 5<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.14. WIENER-FILTER 167<br />

Result<br />

simulate motion returns H MSG TRUE if all parameters are correct. If the input is empty<br />

simulate motion returns with an error message.<br />

Parallelization Information<br />

simulate motion is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen psf motion, gen psf motion<br />

Possible Successor Functions<br />

simulate defocus, wiener filter, wiener filter ni<br />

See Also<br />

gen psf motion, simulate defocus, gen psf defocus<br />

Bibliography<br />

Anil K. Jain:Fundamentals of Digital Image Processing, Prentice-Hall International Inc., Englewood Cliffs, New<br />

Jersey, 1989<br />

M. L”uckenhaus:”‘Grundlagen des Wiener-Filters und seine Anwendung in der Bildanalyse”’; Diplomarbeit;<br />

Technische Universit”at M”unchen, Institut f”ur Informatik; Lehrstuhl Prof. Radig; 1995.<br />

Kha-Chye Tan, Hock Lim, B. T. G. Tan:”‘Restoration of Real-World Motion-Blurred Images”’;S. 291-299 in:<br />

CVGIP Graphical Models and Image Processing, Vol. 53, No. 3, May 1991<br />

Module<br />

Wiener filter<br />

wiener filter ( Hobject Image, Hobject Psf, Hobject FilteredImage,<br />

Hobject *RestoredImage )<br />

Image restoration by Wiener filtering.<br />

wiener filter produces an estimate of the original image (= image without noise and blurring) by minimizing<br />

the mean square error between estimated and original image. wiener filter can be used to restore images<br />

corrupted by noise and/or blurring (e.g. motion blur, atmospheric turbulence or out-of-focus blur). Method and<br />

realisation of this restoration technique bases on the following model: The corrupted image is interpreted as the<br />

output of a (disturbed) linear system. Functionality of a linear system is determined by its specific impuls response.<br />

So the convolution of original image and impulse response results in the corrupted image. The specific impulse<br />

response describes image acquisition and the occured degradations. In the presence of additive noise an additional<br />

noise term must be considered. So the corrupted image can be modeled as the result of<br />

ÓÒÚÓÐÙØÓÒ´ÑÔÙÐ× Ö×ÔÓÒ× ÓÖÒРѵ℄ · ÒÓ× ØÖÑ<br />

The noise term encloses two different terms describing image-dependent and image-independent noise. According<br />

to this model, two terms must be known for restoration by Wiener filtering:<br />

1. degradation-specific impulse response<br />

2. noise term<br />

So wiener filter needs a smoothed version of the input image to estimate the power spectral density of<br />

noise and original image. One can use one of the smoothing <strong>HALCON</strong>-filters (e.g. eliminate min max)to<br />

get this version. wiener filter needs further the impulse response that describes the specific degradation.<br />

This impulse response (represented in spatial domain) must fit into an image of <strong>HALCON</strong> image type ’real’.<br />

There exist two <strong>HALCON</strong>-operators for generation of an impulse response for motion blur and out-of-focus (see<br />

gen psf motion, gen psf defocus). The representation of the impulse response presumes the origin in the<br />

upper left corner. This results in the following disposition of an ÆÜÅ sized image:<br />

¯ first rectangle (”‘upper left”’): (image coordinates Ü ¼´Æ¾µ ½, Ý ¼´Å¾µ ½µ<br />

- conforms to the fourth quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü ¼Æ¾ and Ý ¼ ž<br />

¯ second rectangle (”‘upper right”’): (image coordinates Ü Æ¾Æ ½, Ý ¼´Å¾µ ½µ<br />

- conforms to the third quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü Æ¾ ½ and Ý ½ ž<br />

<strong>HALCON</strong> 6.0


168 CHAPTER 3. FILTER<br />

¯ third rectangle (”‘lower left”’): (image coordinates Ü ¼´Æ¾µ ½, Ý Å¾Å ½µ<br />

- conforms to the first quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü ½Æ¾ and Ý Å¾¼<br />

¯ fourth rectangle (”‘lower right”’): (image coordinates Ü Æ¾Æ ½, Ý Å¾Å ½µ<br />

- conforms to the second quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü Æ¾ ½ und Ý Å¾½<br />

As the Wiener filter is realized using the Fourier transform, only images with height and width fitting a power of 2<br />

can be processed. wiener filter works as follows:<br />

¯ estimation of the power spectrum density of the original image by using the smoothed version of the corrupted<br />

image,<br />

¯ estimation of the power spectrum density of each pixel by subtracting smoothed version from unsmoothed<br />

version,<br />

¯ building the Wiener filter kernel with the quotient of power spectrum densities of noise and original image<br />

and with the impulse response,<br />

¯ processing the convolution of image and Wiener filter frequency response.<br />

The result image has got image type ’real’.<br />

Attention<br />

Psf must be of image type ’real’ and conform to Image and FilteredImage in image width and height.<br />

Parameter<br />

º Image (input object) .........................................................image Hobject :any<br />

Corrupted image.<br />

º Psf (input object) ............................................................image Hobject : real<br />

impulse response (PSF) of degradation (in spatial domain).<br />

º FilteredImage (input object) ..............................................image Hobject :any<br />

Smoothed version of corrupted image.<br />

º RestoredImage (output object) ...........................................image Hobject * : real<br />

Restored image.<br />

Example<br />

/* Restoration of a noisy image (size=256x256), that was blurred by motion*/<br />

Hobject object;<br />

Hobject restored;<br />

Hobject psf;<br />

Hobject noisefiltered;<br />

/* 1. Generate a Point-Spread-Function for a motion-blur with */<br />

/* parameter a=10 and direction along the x-axis */<br />

gen_psf(&psf,256,256,10,0,3);<br />

/* 2. Noisefiltering of the image */<br />

median_image(object,&noisefiltered,"circle",2,0);<br />

/* 3. Wiener-filtering */<br />

wiener_filter(object,psf,noisefiltered,&restored);<br />

Result<br />

wiener filter returns H MSG TRUE if all parameters are correct. If the input is empty wiener filter<br />

returns with an error message.<br />

Parallelization Information<br />

wiener filter is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen psf motion, simulate motion, simulate defocus, gen psf defocus<br />

wiener filter ni<br />

Alternatives<br />

See Also<br />

simulate motion, gen psf motion, simulate defocus, gen psf defocus<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.14. WIENER-FILTER 169<br />

Bibliography<br />

M. L”uckenhaus:”‘Grundlagen des Wiener-Filters und seine Anwendung in der Bildanalyse”’; Diplomarbeit;<br />

Technische Universit”at M”unchen, Institut f”ur Informatik; Lehrstuhl Prof. Radig; 1995<br />

Azriel Rosenfeld, Avinash C. Kak: Digital Picture Processing, Computer Science and Aplied Mathematics, Academic<br />

Press New York/San Francisco/London 1982<br />

Module<br />

Wiener filter<br />

wiener filter ni ( Hobject Image, Hobject Psf, Hobject NoiseRegion,<br />

Hobject *RestoredImage, long MaskWidth, long MaskHeight )<br />

Image restoration by Wiener filtering.<br />

wiener filter ni (ni = noise-estimation integrated) produces an estimate of the original image (= image<br />

without noise and blurring) by minimizing the mean square error between estimated and original image.<br />

wiener filter can be used to restore images corrupted by noise and/or blurring (e.g. motion blur, atmospheric<br />

turbulence or out-of-focus blur). Method and realisation of this restoration technique bases on the following model:<br />

The corrupted image is interpreted as the output of a (disturbed) linear system. Functionality of a linear system is<br />

determined by its specific impuls response. So the convolution of original image and impulse response results in<br />

the corrupted image. The specific impulse response describes image acquisition and the occured degradations. In<br />

the presence of additive noise an additional noise term must be considered. So the corrupted image can be modeled<br />

as the result of<br />

ÓÒÚÓÐÙØÓÒ´ÑÔÙÐ× Ö×ÔÓÒ× ÓÖÒРѵ℄ · ÒÓ× ØÖÑ<br />

The noise term encloses two different terms describing image-dependent and image-independent noise. According<br />

to this model, two terms must be known for restoration by Wiener filtering:<br />

1. degradation-specific impulse response<br />

2. noise term<br />

wiener filter ni estimates the noise term as follows: The user defines a region that is suitable for noise<br />

estimation within the image (homogeneous as possible, as edges or textures aggravate noise estimation). After<br />

smoothing within this region by an (unweighted) median filter and subtracting smoothed version from unsmoothed,<br />

the average noise amplitude of the region is processed within wiener filter ni. This amplitude together with<br />

the average gray value within the region allows estimating the quotient of the power spectral densities of noise and<br />

original image (in contrast to wiener filter wiener filter ni assumes a rather constant quotient within<br />

the whole image). The user can define width and height of the rectangular (median-)filter mask to influence the<br />

noise estimation (MaskWidth, MaskHeight). wiener filter ni needs further the impulse response that<br />

describes the specific degradation. This impulse response (represented in spatial domain) must fit into an image<br />

of <strong>HALCON</strong> image type ’real’. There exist two <strong>HALCON</strong>-operators for generation of an impulse response for<br />

motion blur and out-of-focus (see gen psf motion, gen psf defocus). The representation of the impulse<br />

response presumes the origin in the upper left corner. This results in the following disposition of an ÆÜÅ sized<br />

image:<br />

¯ first rectangle (”‘upper left”’): (image coordinates Ü ¼´Æ¾µ ½, Ý ¼´Å¾µ ½µ<br />

- conforms to the fourth quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü ¼Æ¾ and Ý ¼ ž<br />

¯ second rectangle (”‘upper right”’): (image coordinates Ü Æ¾Æ ½, Ý ¼´Å¾µ ½µ<br />

- conforms to the third quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü Æ¾ ½ and Ý ½ ž<br />

¯ third rectangle (”‘lower left”’): (image coordinates Ü ¼´Æ¾µ ½, Ý Å¾Å ½µ<br />

- conforms to the first quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü ½Æ¾ and Ý Å¾¼<br />

¯ fourth rectangle (”‘lower right”’): (image coordinates Ü Æ¾Æ ½, Ý Å¾Å ½µ<br />

- conforms to the second quadrant of the Cartesian coordinate system, encloses values of the impulse response<br />

at position Ü Æ¾ ½ und Ý Å¾½<br />

<strong>HALCON</strong> 6.0


170 CHAPTER 3. FILTER<br />

As the Wiener filter is realized using the Fourier transform, only images with height and width fitting a power of 2<br />

can be processed. wiener filter works as follows:<br />

¯ estimating the quotient of the power spectrum densities of noise and original image,<br />

¯ building the Wiener filter kernel with the quotient of power spectrum densities of noise and original image<br />

and with the impulse response,<br />

¯ processing the convolution of image and Wiener filter frequency response.<br />

The result image has got image type ’real’.<br />

Attention<br />

Psf must be of image type ’real’ and conform to Image in width and height. The Region used for noise estimation<br />

must lie completely within the image. If MaskWidth or MaskHeight is an even number, it is replaced by the<br />

next higher odd number (this allows the unique extraction of the center of the filter mask). Width/height of the<br />

mask may not exceed the image width/height or be less than null.<br />

Parameter<br />

º Image (input object) .........................................................image Hobject :any<br />

Corrupted image.<br />

º Psf (input object) ............................................................image Hobject : real<br />

impulse response (PSF) of degradation (in spatial domain).<br />

º NoiseRegion (input object) ......................................................region Hobject<br />

Region for noise estimation.<br />

º RestoredImage (output object) ...........................................image Hobject * : real<br />

Restored image.<br />

º MaskWidth (input control) ...........................................................integer long<br />

Width of filter mask.<br />

Default Value : 3<br />

Value Suggestions : MaskWidth ¾3, 5, 7, 9<br />

Typical Range of Values : 0 MaskWidth width(Image)<br />

º MaskHeight (input control) .........................................................integer long<br />

Height of filter mask.<br />

Default Value : 3<br />

Value Suggestions : MaskHeight ¾3, 5, 7, 9<br />

Typical Range of Values : 0 MaskHeight height(Image)<br />

Example<br />

/* Restoration of a noisy image (size=256x256), that was blurred by motion*/<br />

Hobject object;<br />

Hobject restored;<br />

Hobject psf;<br />

Hobject noise_region;<br />

/* 1. Generate a Point-Spread-Function for a motion-blur with */<br />

/* parameter a=10 and direction of the x-axis */<br />

gen_psf(&psf,256,256,10,0,3);<br />

/* 2. Segmentation of a region for the noise-estimation */<br />

open_window(0,0,256,256,0,"visible",&WindowHandle);<br />

disp_image(object,WindowHandle);<br />

draw_region(&noise_region,draw_region);<br />

/* 3. Wiener-filtering */<br />

wiener_filter_ni(object,psf,noise_region,&restored,3,3);<br />

Result<br />

wiener filter ni returns H MSG TRUE if all parameters are correct. If the input is empty<br />

wiener filter ni returns with an error message.<br />

Parallelization Information<br />

wiener filter ni is reentrant and processed without parallelization.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


3.14. WIENER-FILTER 171<br />

Possible Predecessor Functions<br />

gen psf motion, simulate motion, simulate defocus, gen psf defocus<br />

wiener filter<br />

Alternatives<br />

See Also<br />

simulate motion, gen psf motion, simulate defocus, gen psf defocus<br />

Bibliography<br />

M. L”uckenhaus:”‘Grundlagen des Wiener-Filters und seine Anwendung in der Bildanalyse”’; Diplomarbeit;<br />

Technische Universit”at M”unchen, Institut f”ur Informatik; Lehrstuhl Prof. Radig; 1995<br />

Azriel Rosenfeld, Avinash C. Kak: Digital Picture Processing, Computer Science and Aplied Mathematics, Academic<br />

Press New York/San Francisco/London 1982<br />

Module<br />

Wiener filter<br />

<strong>HALCON</strong> 6.0


172 CHAPTER 3. FILTER<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Chapter 4<br />

Graphics<br />

4.1 Drawing<br />

drag region1 ( Hobject SourceRegion, Hobject *DestinationRegion,<br />

long WindowHandle )<br />

Interactive moving of a region.<br />

drag region1 is used to move a region on the display by mouse. Calling drag region1 turns the region<br />

visible as soon as the left mouse button is pressed. Therefore the region’s edges are displayed only. As representation<br />

mode the mode ’not’ (see set draw) is used during procedure’s permanence. During the movement<br />

the cursor resides in the region’s barycenter. If you move the mouse with pressed left mouse button, the depicted<br />

region follows - delayed - this movement. If you press the right mouse button you terminate drag region1.<br />

The depicted region disappears from the display. Output is a region which corresponds to the last position on the<br />

display. You may pass even several regions at once. Procedure affine trans image moves the gray values.<br />

Attention<br />

Gray values of regions are not moved. With moving the input region it is not sure whether the gray values of the<br />

output regions are filled reasonable. This may occur if the gray values of the input regions do not comprise the<br />

whole image.<br />

Parameter<br />

º SourceRegion (input object) ...............................................region-array Hobject<br />

Regions to move.<br />

º DestinationRegion (output object) ......................................region-array Hobject *<br />

Moved Regions.<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

Example<br />

draw_region(&Obj,WindowHandle) ;<br />

drag_region1(Obj,&New,WindowHandle) ;<br />

disp_region(New,WindowHandle) ;<br />

position(Obj,_,Row1,Column1,_,_,_,_) ;<br />

position(New,_,Row2,Column2,_,_,_,_) ;<br />

disp_arrow(WindowHandle,Row1,Column1,Row2,Column2,1.0) ;<br />

fwrite_string("Transformation: ") ;<br />

fwrite_string(Row2-Row1) ;<br />

fwrite_string(", ") ;<br />

fwrite_string(Column2-Column1) ;<br />

fnew_line() ;<br />

Result<br />

drag region1 returns H MSG TRUE, if a region is entered, the window is valid and the needed drawing mode<br />

173


174 CHAPTER 4. GRAPHICS<br />

(see set insert) is available. If necessary, an exception handling is raised. You may determine the behavior<br />

after an empty input with set system(’no object result’,).<br />

Parallelization Information<br />

drag region1 is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, disp region, set colored, set line width, set draw, set insert<br />

get mposition, move region<br />

Alternatives<br />

See Also<br />

set insert, set draw, affine trans image<br />

System<br />

Module<br />

drag region2 ( Hobject SourceRegion, Hobject *DestinationRegion,<br />

long WindowHandle, long Row, long Column )<br />

Interactive movement of a region with fixpoint specification.<br />

You use drag region2 to move a region on the display by mouse. It corresponds to the procedure<br />

drag region1 with the difference, that the position of the mouse cursor can be determined.<br />

Attention<br />

Gray values of the regions are not moved. With moving the input region it is not sure whether the gray values of<br />

the output regions are filled reasonable. This may occur if the gray values of the input regions do not comprise the<br />

whole image.<br />

Parameter<br />

º SourceRegion (input object) ...............................................region-array Hobject<br />

Regions to move.<br />

º DestinationRegion (output object) ......................................region-array Hobject *<br />

Moved regions.<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Row (input control) ...................................................................point.y long<br />

Row index of the reference point.<br />

Default Value : 100<br />

Value Suggestions : Row ¾0, 64, 128, 256, 512<br />

Typical Range of Values : 0 Row 1024<br />

º Column (input control) ...............................................................point.x long<br />

Column index of the reference point.<br />

Default Value : 100<br />

Value Suggestions : Column ¾0, 64, 128, 256, 512<br />

Typical Range of Values : 0 Column 1024<br />

Result<br />

drag region2 returns H MSG TRUE, if a region is entered, the window is valid and the needed drawing mode<br />

(see set insert) is available. If necessary, an exception handling is raised. You may determine the behavior<br />

after an empty input with set system(’no object result’,).<br />

Parallelization Information<br />

drag region2 is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, disp region, set colored, set line width, set draw, set insert,<br />

affine trans image<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.1. DRAWING 175<br />

Alternatives<br />

get mposition, move region, drag region1, drag region3<br />

See Also<br />

set insert, set draw, affine trans image<br />

System<br />

Module<br />

drag region3 ( Hobject SourceRegion, Hobject MaskRegion,<br />

Hobject *DestinationRegion, long WindowHandle, long Row, long Column )<br />

Interactive movement of a region with restriction of positions.<br />

You use drag region3 to move a region on the display by mouse. It corresponds to the procedure<br />

drag region2 with the enhancement, that all points are specified which can be entered by mouse. If you<br />

move the mouse outside of this area (MaskRegion), the region on the point with the smallest distance inside<br />

MaskRegion will be displayed.<br />

Attention<br />

The region’s gray values are not moved. With moving the input region it is not sure whether the gray values of<br />

the output regions are filled reasonable. This may occur if the gray values of the input regions do not comprise the<br />

whole image.<br />

Parameter<br />

º SourceRegion (input object) ...............................................region-array Hobject<br />

Regions to move.<br />

º MaskRegion (input object) ..................................................region-array Hobject<br />

Points on which it is allowed for a region to move.<br />

º DestinationRegion (output object) ......................................region-array Hobject *<br />

Moved regions.<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Row (input control) ...................................................................point.y long<br />

Row index of the reference point.<br />

Default Value : 100<br />

Value Suggestions : Row ¾0, 64, 128, 256, 512<br />

Typical Range of Values : 0 Row 1024<br />

º Column (input control) ...............................................................point.x long<br />

Column index of the reference point.<br />

Default Value : 100<br />

Value Suggestions : Column ¾0, 64, 128, 256, 512<br />

Typical Range of Values : 0 Column 1024<br />

Result<br />

drag region3 returns H MSG TRUE, if a region is entered, if the window is valid and the needed drawing<br />

mode (see set insert) is available. If necessary, an exception handling is raised. You may determine the<br />

behavior after an empty input with set system(’no object result’,).<br />

Parallelization Information<br />

drag region3 is local and processed completely exclusively without parallelization.<br />

open window, get mposition<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, disp region, set colored, set line width, set draw, set insert,<br />

affine trans image<br />

Alternatives<br />

get mposition, move region, drag region1, drag region2<br />

See Also<br />

set insert, set draw, affine trans image<br />

<strong>HALCON</strong> 6.0


176 CHAPTER 4. GRAPHICS<br />

System<br />

Module<br />

draw circle ( long WindowHandle, double *Row, double *Column,<br />

double *Radius )<br />

Interactive drawing of a circle.<br />

draw circle produces the parameter for a circle created interactive by the user in the window.<br />

To create a circle you have to press the mouse button at the location which is used as the center of that circle. While<br />

keeping the mouse button pressed, the Radius’s length can be modified through moving the mouse. After another<br />

mouse click in the created circle center you can move it. A clicking close to the circular arc you can modify the<br />

Radius of the circle. Pressing the right mousebutton terminates the procedure. After terminating the procedure<br />

the circle is not visible in the window any longer.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Row (output control) .......................................................circle.center.y double *<br />

Barycenter’s row index.<br />

º Column (output control) ...................................................circle.center.x double *<br />

Barycenter’s column index.<br />

º Radius (output control) .....................................................circle.radius double *<br />

Circle’s radius.<br />

Example<br />

read_image(&Image,"affe") ;<br />

draw_circle(WindowHandle,&Row,&Column,&Radius) ;<br />

gen_circle(&Circle,Row,Column,Radius) ;<br />

reduce_domain(Image,Circle,&GrayCircle) ;<br />

disp_image(GrayCircle,WindowHandle) ;<br />

Result<br />

draw circle returns H MSG TRUE if the window is valid and the needed drawing mode (see set insert)<br />

is available. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

draw circle is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, disp region, set colored, set line width, set draw, set insert<br />

Alternatives<br />

draw circle mod, draw ellipse, draw region<br />

See Also<br />

gen circle, draw rectangle1, draw rectangle2, draw polygon, set insert<br />

System<br />

Module<br />

draw circle mod ( long WindowHandle, double RowIn, double ColumnIn,<br />

double RadiusIn, double *Row, double *Column, double *Radius )<br />

Interactive drawing of a circle.<br />

draw circle mod produces the parameter for a circle created interactive by the user in the window.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.1. DRAWING 177<br />

To create a circle are expected the coordinates RowIn and ColumnIn of the center of a circle with radius<br />

RadiusIn. After another mouse click in the created circle center you can move it. A clicking close to the<br />

circular arc you can modify the Radius of the circle. Pressing the right mousebutton terminates the procedure.<br />

After terminating the procedure the circle is not visible in the window any longer.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º RowIn (input control) .......................................................circle.center.y double<br />

Row index of the center.<br />

º ColumnIn (input control) ...................................................circle.center.x double<br />

Column index of the center.<br />

º RadiusIn (input control) ....................................................circle.radius1 double<br />

Radius of the circle.<br />

º Row (output control) .......................................................circle.center.y double *<br />

Barycenter’s row index.<br />

º Column (output control) ...................................................circle.center.x double *<br />

Barycenter’s column index.<br />

º Radius (output control) .....................................................circle.radius double *<br />

Circle’s radius.<br />

Example<br />

read_image(&Image,"affe") ;<br />

draw_circle_mod(WindowHandle,20,20,15,&Row,&Column,&Radius) ;<br />

gen_circle(&Circle,Row,Column,Radius) ;<br />

reduce_domain(Image,Circle,&GrayCircle) ;<br />

disp_image(GrayCircle,WindowHandle) ;<br />

Result<br />

draw circle mod returns H MSG TRUE if the window is valid and the needed drawing mode (see<br />

set insert) is available. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

draw circle mod is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, disp region, set colored, set line width, set draw, set insert<br />

Alternatives<br />

draw circle, draw ellipse, draw region<br />

See Also<br />

gen circle, draw rectangle1, draw rectangle2, draw polygon, set insert<br />

System<br />

Module<br />

draw ellipse ( long WindowHandle, double *Row, double *Column,<br />

double *Phi, double *Radius1, double *Radius2 )<br />

Interactive drawing of an ellipse.<br />

draw ellipse returns the parameter for any orientated ellipse, which has been created interactively by the user<br />

in the window.<br />

The created ellipse is described by its center, its two half axes and the angle between the first half axis and the<br />

horizontal coordinate axis.<br />

To create an ellipse you have to determine the center of the ellipse with the left mouse button. Keeping the button<br />

pressed determines the length (Radius1) and the orientation (Phi) of the first half axis. In doing so a temporary<br />

<strong>HALCON</strong> 6.0


178 CHAPTER 4. GRAPHICS<br />

default length for the second half axis is assumed, which may be modified afterwards on demand. After another<br />

mouse click in the center of the created ellipse you can move it. A mouse click close to a vertex “grips” it to<br />

modify the length of the appropriate half axis. You may modify the orientation only, if a vertex of the first half axis<br />

is gripped.<br />

Pressing the right mouse button terminates the procedure. After terminating the procedure the ellipse is not visible<br />

in the window any longer.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Row (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.y double *<br />

Row index of the center.<br />

º Column (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.x double *<br />

Column index of the center.<br />

º Phi (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.angle.rad double *<br />

Orientation of the first half axis in radians.<br />

º Radius1 (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius1 double *<br />

First half axis.<br />

º Radius2 (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius2 double *<br />

Second half axis.<br />

Example<br />

read_image(&Image,"affe") ;<br />

draw_ellipse(WindowHandle,&Row,&Column,&Phi,&Radius1,&Radius2) ;<br />

gen_ellipse(&Ellipse,Row,Column,Phi,Radius1,Radius2) ;<br />

reduce_domain(Image,Ellipse,&GrayEllipse) ;<br />

sobel_amp(GrayEllipse,&Sobel,"sum_abs",3) ;<br />

disp_image(Sobel,WindowHandle) ;<br />

Result<br />

draw ellipse returns H MSG TRUE, if the window is valid and the needed drawing mode (see set insert)<br />

is available. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

draw ellipse is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, disp region, set colored, set line width, set draw, set insert<br />

Alternatives<br />

draw ellipse mod, draw circle, draw region<br />

See Also<br />

gen ellipse, draw rectangle1, draw rectangle2, draw polygon, set insert<br />

System<br />

Module<br />

draw ellipse mod ( long WindowHandle, double RowIn, double ColumnIn,<br />

double PhiIn, double Radius1In, double Radius2In, double *Row,<br />

double *Column, double *Phi, double *Radius1, double *Radius2 )<br />

Interactive drawing of an ellipse.<br />

draw ellipse mod returns the parameter for any orientated ellipse, which has been created interactively by the<br />

user in the window.<br />

The created ellipse is described by its center, its two half axes and the angle between the first half axis and the<br />

horizontal coordinate axis.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.1. DRAWING 179<br />

To create an ellipse are expected the parameters RowIn, ColumnIn,PhiIn,Radius1In,Radius2In. Keeping<br />

the button pressed determines the length (Radius1) and the orientation (Phi) of the first half axis. In doing<br />

so a temporary default length for the second half axis is assumed, which may be modified afterwards on demand.<br />

After another mouse click in the center of the created ellipse you can move it. A mouse click close to a vertex<br />

“grips” it to modify the length of the appropriate half axis. You may modify the orientation only, if a vertex of the<br />

first half axis is gripped.<br />

Pressing the right mouse button terminates the procedure. After terminating the procedure the ellipse is not visible<br />

in the window any longer.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º RowIn (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ellipse.center.y double<br />

Row index of the barycenter.<br />

º ColumnIn (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.x double<br />

Column index of the barycenter.<br />

º PhiIn (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.angle.rad double<br />

Orientation of the bigger half axis in radians.<br />

º Radius1In (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ellipse.radius1 double<br />

Bigger half axis.<br />

º Radius2In (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ellipse.radius1 double<br />

Smallerhalfaxis.<br />

º Row (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.y double *<br />

Row index of the center.<br />

º Column (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.x double *<br />

Column index of the center.<br />

º Phi (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.angle.rad double *<br />

Orientation of the first half axis in radians.<br />

º Radius1 (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius1 double *<br />

First half axis.<br />

º Radius2 (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius2 double *<br />

Second half axis.<br />

Example<br />

read_image(&Image,"affe") ;<br />

draw_ellipse_mod(WindowHandle,RowIn,ColumnIn,PhiIn,Radius1In,Radius2In,&Row,&Column,&Phi<br />

gen_ellipse(&Ellipse,Row,Column,Phi,Radius1,Radius2) ;<br />

reduce_domain(Image,Ellipse,&GrayEllipse) ;<br />

sobel_amp(GrayEllipse,&Sobel,"sum_abs",3) ;<br />

disp_image(Sobel,WindowHandle) ;<br />

Result<br />

draw ellipse mod returns H MSG TRUE, if the window is valid and the needed drawing mode (see<br />

set insert) is available. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

draw ellipse mod is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, disp region, set colored, set line width, set draw, set insert<br />

Alternatives<br />

draw ellipse, draw circle, draw region<br />

See Also<br />

gen ellipse, draw rectangle1, draw rectangle2, draw polygon, set insert<br />

System<br />

Module<br />

<strong>HALCON</strong> 6.0


180 CHAPTER 4. GRAPHICS<br />

draw line ( long WindowHandle, double *Row1, double *Column1,<br />

double *Row2, double *Column2 )<br />

Draw a line.<br />

draw line returns the parameter for a line, which has been created interactively by the user in the window.<br />

To create a line you have to press the left mouse button determining a start point of the line. While keeping the<br />

button pressed you may “drag” the line in any direction. After another mouse click in the middle of the created<br />

line you can move it. If you click on one end point of the created line, you may move this point. Pressing the right<br />

mousebutton terminates the procedure.<br />

After terminating the procedure the line is not visible in the window any longer.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Row1 (output control) ........................................................line.begin.y double *<br />

Row index of the first point of the line.<br />

º Column1 (output control) ....................................................line.begin.x double *<br />

Column index of the first point of the line.<br />

º Row2 (output control) ..........................................................line.end.y double *<br />

Row index of the second point of the line.<br />

º Column2 (output control) ......................................................line.end.x double *<br />

Column index of the second point of the line.<br />

Example<br />

get_system("width",Width) ;<br />

get_system("height",Height) ;<br />

set_part(WindowHandle,0,0,Width-1,Height-1) ;<br />

read_image(&Image,"affe") ;<br />

disp_image(Image,WindowHandle) ;<br />

draw_line(WindowHandle,&Row1,&Column1,&Row2,&Column2) ;<br />

set_part(WindowHandle,Row1,Column1,Row2,Column2) ;<br />

disp_image(Image,WindowHandle) ;<br />

fwrite_string("Clipping = (") ;<br />

fwrite_string(Row1) ;<br />

fwrite_string(",") ;<br />

fwrite_string(Column1) ;<br />

fwrite_string("),(") ;<br />

fwrite_string(Row2) ;<br />

fwrite_string(",") ;<br />

fwrite_string(Column2) ;<br />

fwrite_string(")") ;<br />

fnew_line(:::) ;<br />

Result<br />

draw line returns H MSG TRUE, if the window is valid and the needed drawing mode (see set insert) is<br />

available. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

draw line is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, (T )disp line, set colored, set line width, set draw, set insert<br />

See Also<br />

draw line mod, gen rectangle1, draw circle, draw ellipse, set insert<br />

System<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.1. DRAWING 181<br />

draw line mod ( long WindowHandle, double Row1In, double Column1In,<br />

double Row2In, double Column2In, double *Row1, double *Column1,<br />

double *Row2, double *Column2 )<br />

Draw a line.<br />

draw line mod returns the parameter for a line, which has been created interactively by the user in the window.<br />

To create a line are expected the coordinates of the start point Row1In, Column1In and of the end point<br />

Row2In,Column2In. If you click on one end point of the created line, you may move this point. After another<br />

mouse click in the middle of the created line you can move it.<br />

Pressing the right mousebutton terminates the procedure.<br />

After terminating the procedure the line is not visible in the window any longer.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Row1In (input control) ........................................................line.begin.y double<br />

Row index of the first point of the line.<br />

º Column1In (input control) ....................................................line.begin.x double<br />

Column index of the first point of the line.<br />

º Row2In (input control) ..........................................................line.end.y double<br />

Row index of the second point of the line.<br />

º Column2In (input control) ......................................................line.end.x double<br />

Column index of the second point of the line.<br />

º Row1 (output control) ........................................................line.begin.y double *<br />

Row index of the first point of the line.<br />

º Column1 (output control) ....................................................line.begin.x double *<br />

Column index of the first point of the line.<br />

º Row2 (output control) ..........................................................line.end.y double *<br />

Row index of the second point of the line.<br />

º Column2 (output control) ......................................................line.end.x double *<br />

Column index of the second point of the line.<br />

Example<br />

get_system("width",Width) ;<br />

get_system("height",Height) ;<br />

set_part(WindowHandle,0,0,Width-1,Height-1) ;<br />

read_image(&Image,"affe") ;<br />

disp_image(Image,WindowHandle) ;<br />

draw_line_mod(WindowHandle,10,20,55,124,&Row1,&Column1,&Row2,&Column2) ;<br />

set_part(WindowHandle,Row1,Column1,Row2,Column2) ;<br />

disp_image(Image,WindowHandle) ;<br />

fwrite_string("Clipping = (") ;<br />

fwrite_string(Row1) ;<br />

fwrite_string(",") ;<br />

fwrite_string(Column1) ;<br />

fwrite_string("),(") ;<br />

fwrite_string(Row2) ;<br />

fwrite_string(",") ;<br />

fwrite_string(Column2) ;<br />

fwrite_string(")") ;<br />

fnew_line(:::) ;<br />

Result<br />

draw line mod returns H MSG TRUE, if the window is valid and the needed drawing mode is available. If<br />

necessary, an exception handling is raised.<br />

<strong>HALCON</strong> 6.0


182 CHAPTER 4. GRAPHICS<br />

Parallelization Information<br />

draw line mod is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, (T )disp line, set colored, set line width, set draw, set insert<br />

draw line, draw ellipse, draw region<br />

Alternatives<br />

See Also<br />

gen circle, draw rectangle1, draw rectangle2<br />

System<br />

Module<br />

draw point ( long WindowHandle, double *Row, double *Column )<br />

Draw a point.<br />

draw point returns the parameter for a point, which has been created interactively by the user in the window.<br />

To create a point you have to press the left mouse button. While keeping the button pressed you may “drag” the<br />

point in any direction. Pressing the right mousebutton terminates the procedure.<br />

After terminating the procedure the point is not visible in the window any longer.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Row (output control) ..............................................................point.y double *<br />

Row index of the point.<br />

º Column (output control) ..........................................................point.x double *<br />

Column index of the point.<br />

Example<br />

get_system("width",Width) ;<br />

get_system("height",Height) ;<br />

set_part(WindowHandle,0,0,Width-1,Height-1) ;<br />

read_image(&Image,"affe") ;<br />

disp_image(Image,WindowHandle) ;<br />

draw_point(WindowHandle,&Row1,&Column1) ;<br />

disp_line(WindowHandle,Row1-2,Column1,Row1+2,Column1) ;<br />

disp_line(WindowHandle,Row1,Column1-2,Row1,Column1+2) ;<br />

disp_image(Image,WindowHandle) ;<br />

fwrite_string("Clipping = (") ;<br />

fwrite_string(Row1) ;<br />

fwrite_string(",") ;<br />

fwrite_string(Column1) ;<br />

fwrite_string("),(") ;<br />

fnew_line(:::) ;<br />

Result<br />

draw point returns H MSG TRUE, if the window is valid and the needed drawing mode is available. If necessary,<br />

an exception handling is raised.<br />

Parallelization Information<br />

draw point is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.1. DRAWING 183<br />

Possible Successor Functions<br />

reduce domain, (T )disp line, set colored, set line width, set draw, set insert<br />

See Also<br />

draw point mod, draw circle, draw ellipse, set insert<br />

System<br />

Module<br />

draw point mod ( long WindowHandle, double RowIn, double ColumnIn,<br />

double *Row, double *Column )<br />

Draw a point.<br />

draw point mod returns the parameter for a point, which has been created interactively by the user in the<br />

window.<br />

To create a point are expected the coordinates RowIn and ColumnIn. While keeping the button pressed you may<br />

“drag” the point in any direction. Pressing the right mousebutton terminates the procedure.<br />

After terminating the procedure the point is not visible in the window any longer.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º RowIn (input control) ..............................................................point.y double<br />

Row index of the point.<br />

º ColumnIn (input control) ..........................................................point.x double<br />

Column index of the point.<br />

º Row (output control) ..............................................................point.y double *<br />

Row index of the point.<br />

º Column (output control) ..........................................................point.x double *<br />

Column index of the point.<br />

Example<br />

get_system("width",Width) ;<br />

get_system("height",Height) ;<br />

set_part(WindowHandle,0,0,Width-1,Height-1) ;<br />

read_image(&Image,"affe") ;<br />

disp_image(Image,WindowHandle) ;<br />

draw_point_mod(WindowHandle,&Row1,&Column1) ;<br />

disp_line(WindowHandle,Row1-2,Column1,Row1+2,Column1) ;<br />

disp_line(WindowHandle,Row1,Column1-2,Row1,Column1+2) ;<br />

disp_image(Image,WindowHandle) ;<br />

fwrite_string("Clipping = (") ;<br />

fwrite_string(Row1) ;<br />

fwrite_string(",") ;<br />

fwrite_string(Column1) ;<br />

fwrite_string("),(") ;<br />

fnew_line(:::) ;<br />

Result<br />

draw point mod returns H MSG TRUE, if the window is valid and the needed drawing mode is available. If<br />

necessary, an exception handling is raised.<br />

Parallelization Information<br />

draw point mod is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

<strong>HALCON</strong> 6.0


184 CHAPTER 4. GRAPHICS<br />

Possible Successor Functions<br />

reduce domain, (T )disp line, set colored, set line width, set draw, set insert<br />

See Also<br />

draw point, draw circle, draw ellipse, set insert<br />

System<br />

Module<br />

draw polygon ( Hobject *PolygonRegion, long WindowHandle )<br />

Interactive drawing of a polygon row.<br />

draw polygon produces an image. The region of that image spans exactly the imagepoints entered interactively<br />

by mouse clicks (gray values remain undefined).<br />

Painting in the output window happens while pressing the left mouse button. Releasing the left mouse button and<br />

repressing it at another position effects drawing a line between these two points. Pressing the right mouse button<br />

terminates the input. Painting uses that color which has been set by (T )set color, T set rgb,etc..<br />

To put gray values on the created PolygonRegion for further processing, you may use the procedure<br />

reduce domain.<br />

Attention<br />

The painted contour is not closed automatically, in particular it is not “filled up” either.<br />

Output object’s gray values are not defined.<br />

Parameter<br />

º PolygonRegion (output object) .................................................region Hobject *<br />

Region, which encompasses all painted points.<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

Example<br />

draw_polygon(&Polygon,WindowHandle) ;<br />

convex(Polygon,&Filled) ;<br />

disp_region(Filled,WindowHandle) ;<br />

Result<br />

If the window is valid, draw polygon returns H MSG TRUE. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

draw polygon is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, disp region, set colored, set line width, set draw<br />

Alternatives<br />

draw region, draw circle, draw rectangle1, draw rectangle2, boundary<br />

reduce domain, fill up, (T )set color<br />

System<br />

See Also<br />

Module<br />

draw rectangle1 ( long WindowHandle, double *Row1, double *Column1,<br />

double *Row2, double *Column2 )<br />

Draw a rectangle parallel to the coordinate axis.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.1. DRAWING 185<br />

draw rectangle1 returns the parameter for a rectangle parallel to the coordinate axes, which has been created<br />

interactively by the user in the window.<br />

To create a rectangle you have to press the left mouse button determining a corner of the rectangle. While keeping<br />

the button pressed you may “drag” the rectangle in any direction. After another mouse click in the middle of the<br />

created rectangle you can move it. A click close to one side “grips” it to modify the rectangle’s dimension in<br />

perpendicular direction to this side. If you click on one corner of the created rectangle, you may move this corner.<br />

Pressing the right mousebutton terminates the procedure.<br />

After terminating the procedure the rectangle is not visible in the window any longer.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Row1 (output control) ...................................................rectangle.origin.y double *<br />

Row index of the left upper corner.<br />

º Column1 (output control) ...............................................rectangle.origin.x double *<br />

Column index of the left upper corner.<br />

º Row2 (output control) ..................................................rectangle.corner.y double *<br />

Row index of the right lower corner.<br />

º Column2 (output control) ..............................................rectangle.corner.x double *<br />

Column index of the right lower corner.<br />

Example<br />

get_system("width",Width) ;<br />

get_system("height",Height) ;<br />

set_part(WindowHandle,0,0,Width-1,Height-1) ;<br />

read_image(&Image,"affe") ;<br />

disp_image(Image,WindowHandle) ;<br />

draw_rectangle1(WindowHandle,&Row1,&Column1,&Row2,&Column2) ;<br />

set_part(WindowHandle,Row1,Column1,Row2,Column2) ;<br />

disp_image(Image,WindowHandle) ;<br />

fwrite_string("Clipping = (") ;<br />

fwrite_string(Row1) ;<br />

fwrite_string(",") ;<br />

fwrite_string(Column1) ;<br />

fwrite_string("),(") ;<br />

fwrite_string(Row2) ;<br />

fwrite_string(",") ;<br />

fwrite_string(Column2) ;<br />

fwrite_string(")") ;<br />

fnew_line(:::) ;<br />

Result<br />

draw rectangle1 returns H MSG TRUE, if the window is valid and the needed drawing mode (see<br />

set insert) is available. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

draw rectangle1 is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, disp region, set colored, set line width, set draw, set insert<br />

Alternatives<br />

draw rectangle1 mod, draw rectangle2, draw region<br />

See Also<br />

gen rectangle1, draw circle, draw ellipse, set insert<br />

System<br />

Module<br />

<strong>HALCON</strong> 6.0


186 CHAPTER 4. GRAPHICS<br />

draw rectangle1 mod ( long WindowHandle, double Row1In,<br />

double Column1In, double Row2In, double Column2In, double *Row1,<br />

double *Column1, double *Row2, double *Column2 )<br />

Draw a rectangle parallel to the coordinate axis.<br />

draw rectangle1 mod returns the parameter for a rectangle parallel to the coordinate axes, which has been<br />

created interactively by the user in the window.<br />

To create a rectangle are expected the parameters Row1In, Column1In,Row2In und Column2In. After a<br />

mouse click in the middle of the created rectangle you can move it. A click close to one side “grips” it to modify<br />

the rectangle’s dimension in perpendicular direction to this side. If you click on one corner of the created rectangle,<br />

you may move this corner. Pressing the right mousebutton terminates the procedure.<br />

After terminating the procedure the rectangle is not visible in the window any longer.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Row1In (input control) ...................................................rectangle.origin.y double<br />

Row index of the left upper corner.<br />

º Column1In (input control) ...............................................rectangle.origin.x double<br />

Column index of the left upper corner.<br />

º Row2In (input control) ...................................................rectangle.corner.y double<br />

Row index of the right lower corner.<br />

º Column2In (input control) ..............................................rectangle.corner.x double<br />

Column index of the right lower corner.<br />

º Row1 (output control) ...................................................rectangle.origin.y double *<br />

Row index of the left upper corner.<br />

º Column1 (output control) ...............................................rectangle.origin.x double *<br />

Column index of the left upper corner.<br />

º Row2 (output control) ..................................................rectangle.corner.y double *<br />

Row index of the right lower corner.<br />

º Column2 (output control) ..............................................rectangle.corner.x double *<br />

Column index of the right lower corner.<br />

Example<br />

get_system("width",Width) ;<br />

get_system("height",Height) ;<br />

set_part(WindowHandle,0,0,Width-1,Height-1) ;<br />

read_image(&Image,"affe") ;<br />

disp_image(Image,WindowHandle) ;<br />

draw_rectangle1_mod(WindowHandle,Row1In,Column1In,Row2In,Column2In,&Row1,&Column1,&Row2,<br />

set_part(WindowHandle,Row1,Column1,Row2,Column2) ;<br />

disp_image(Image,WindowHandle) ;<br />

fwrite_string("Clipping = (") ;<br />

fwrite_string(Row1) ;<br />

fwrite_string(",") ;<br />

fwrite_string(Column1) ;<br />

fwrite_string("),(") ;<br />

fwrite_string(Row2) ;<br />

fwrite_string(",") ;<br />

fwrite_string(Column2) ;<br />

fwrite_string(")") ;<br />

fnew_line(:::) ;<br />

Result<br />

draw rectangle1 mod returns H MSG TRUE, if the window is valid and the needed drawing mode (see<br />

set insert) is available. If necessary, an exception handling is raised.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.1. DRAWING 187<br />

Parallelization Information<br />

draw rectangle1 mod is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, disp region, set colored, set line width, set draw, set insert<br />

Alternatives<br />

draw rectangle1, draw rectangle2, draw region<br />

See Also<br />

gen rectangle1, draw circle, draw ellipse, set insert<br />

System<br />

Module<br />

draw rectangle2 ( long WindowHandle, double *Row, double *Column,<br />

double *Phi, double *Length1, double *Length2 )<br />

Interactive drawing of any orientated rectangle.<br />

draw rectangle2 returns the parameter for any orientated rectangle, which has been created interactively by<br />

the user in the window.<br />

The created rectangle is described by its center, its two half axes and the angle between the first half axis and the<br />

horizontal coordinate axis.<br />

To create a rectangle you have to press the left mouse button for the center of the rectangle. While keeping the<br />

button pressed you may dimension the length (Length1) and the orientation (Phi) of the first half axis. In doing<br />

so a temporary default length for the second half axis is assumed, which may be modified afterwards on demand.<br />

After another mouse click in the middle of the created rectangle, you can move it. A click close to one side “grips”<br />

it to modify the rectangle’s dimension in perpendicular direction to this side. You only can modify the orientation,<br />

if you grip a side perpendicular to the first half axis. Pressing the right mouse button terminates the procedure.<br />

After terminating the procedure the rectangle is not visible in the window any longer.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Row (output control) ...................................................rectangle2.center.y double *<br />

Row index of the barycenter.<br />

º Column (output control) ...............................................rectangle2.center.x double *<br />

Column index of the barycenter.<br />

º Phi (output control) ..................................................rectangle2.angle.rad double *<br />

Orientation of the bigger half axis in radians.<br />

º Length1 (output control) ..............................................rectangle2.hwidth double *<br />

Bigger half axis.<br />

º Length2 (output control) ..............................................rectangle2.hheight double *<br />

Smallerhalfaxis.<br />

Result<br />

draw rectangle2 returns H MSG TRUE, if the window is valid and the needed drawing mode (see<br />

set insert) is available. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

draw rectangle2 is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, disp region, set colored, set line width, set draw, set insert<br />

Alternatives<br />

draw rectangle2 mod, draw rectangle1, draw region<br />

<strong>HALCON</strong> 6.0


188 CHAPTER 4. GRAPHICS<br />

See Also<br />

gen rectangle2, draw circle, draw ellipse, set insert<br />

System<br />

Module<br />

draw rectangle2 mod ( long WindowHandle, double RowIn, double ColumnIn,<br />

double PhiIn, double Length1In, double Length2In, double *Row,<br />

double *Column, double *Phi, double *Length1, double *Length2 )<br />

Interactive drawing of any orientated rectangle.<br />

draw rectangle2 mod returns the parameter for any orientated rectangle, which has been created interactively<br />

by the user in the window.<br />

The created rectangle is described by its center, its two half axes and the angle between the first half axis and the<br />

horizontal coordinate axis.<br />

To create a rectangle are expected the parameters RowIn, ColumnIn,PhiIn,Length1In,Length2In. A<br />

click close to one side “grips” it to modify the rectangle’s dimension in perpendicular direction (Length2)tothis<br />

side. You only can modify the orientation (Phi), if you grip a side perpendicular to the first half axis. After another<br />

mouse click in the middle of the created rectangle, you can move it. Pressing the right mouse button terminates<br />

the procedure.<br />

After terminating the procedure the rectangle is not visible in the window any longer.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º RowIn (input control) ...................................................rectangle2.center.y double<br />

Row index of the barycenter.<br />

º ColumnIn (input control) ...............................................rectangle2.center.x double<br />

Column index of the barycenter.<br />

º PhiIn (input control) ..................................................rectangle2.angle.rad double<br />

Orientation of the bigger half axis in radians.<br />

º Length1In (input control) ..............................................rectangle2.hwidth double<br />

Bigger half axis.<br />

º Length2In (input control) ..............................................rectangle2.hheight double<br />

Smallerhalfaxis.<br />

º Row (output control) ...................................................rectangle2.center.y double *<br />

Row index of the barycenter.<br />

º Column (output control) ...............................................rectangle2.center.x double *<br />

Column index of the barycenter.<br />

º Phi (output control) ..................................................rectangle2.angle.rad double *<br />

Orientation of the bigger half axis in radians.<br />

º Length1 (output control) ..............................................rectangle2.hwidth double *<br />

Bigger half axis.<br />

º Length2 (output control) ..............................................rectangle2.hheight double *<br />

Smallerhalfaxis.<br />

Result<br />

draw rectangle2 mod returns H MSG TRUE, if the window is valid and the needed drawing mode (see<br />

set insert) is available. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

draw rectangle2 mod is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, disp region, set colored, set line width, set draw, set insert<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.1. DRAWING 189<br />

Alternatives<br />

draw rectangle2, draw rectangle1, draw rectangle2, draw region<br />

See Also<br />

gen rectangle2, draw circle, draw ellipse, set insert<br />

System<br />

Module<br />

draw region ( Hobject *Region, long WindowHandle )<br />

Interactive drawing of a closed region.<br />

draw region produces an image. The region of that image spans exactly the image region entered interactively<br />

by mouse clicks (gray values remain undefined). Painting happens in the ouput window while keeping the left<br />

mouse button pressed. The left mouse button even operates by clicking in the output window; through this a line<br />

between the previous clicked points is drawn. Clicking the right mouse button terminates input and closes the<br />

outline. Subsequently the image is “filled up”. Also it contains the whole image area enclosed by the mouse.<br />

Painting uses that color which has been set by (T )set color, T set rgb,etc..<br />

The output object’s gray values are not defined.<br />

Attention<br />

Parameter<br />

º Region (output object) ..........................................................region Hobject *<br />

Interactive created region.<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

Example<br />

read_image(&Image,"fabrik") ;<br />

disp_image(Image,WindowHandle) ;<br />

draw_region(&Region,WindowHandle) ;<br />

reduce_domain(Image,Region,&New) ;<br />

regiongrowing(New,&Segmente,5,5,6,50) ;<br />

set_colored(WindowHandle,12) ;<br />

disp_region(Segmente,WindowHandle) ;<br />

Result<br />

If the window is valid, draw region returns H MSG TRUE. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

draw region is local and processed completely exclusively without parallelization.<br />

open window<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

reduce domain, disp region, set colored, set line width, set draw<br />

Alternatives<br />

draw circle, draw ellipse, draw rectangle1, draw rectangle2<br />

See Also<br />

draw polygon, reduce domain, fill up, (T )set color<br />

System<br />

Module<br />

<strong>HALCON</strong> 6.0


190 CHAPTER 4. GRAPHICS<br />

4.2 Gnuplot<br />

gnuplot close ( long GnuplotFileID )<br />

Close all open gnuplot files or terminate an active gnuplot sub-process.<br />

gnuplot close closes all gnuplot files opened by gnuplot open file or terminates the gnuplot subprocess<br />

created with gnuplot open pipe. In the latter case, all temporary files used to display images<br />

and control values are deleted. This means that gnuplot close must be called after such a plot sequence.<br />

GnuplotFileID is the identifier of the corresponding gnuplot output stream.<br />

Parameter<br />

º GnuplotFileID (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . gnuplot id long<br />

Identifier for the gnuplot output stream.<br />

Result<br />

gnuplot close returns H MSG TRUE if GnuplotFileID is a valid gnuplot output stream. Otherwise, an<br />

exception handling is raised.<br />

Parallelization Information<br />

gnuplot close is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

gnuplot open pipe, gnuplot open file, gnuplot plot image<br />

See Also<br />

gnuplot open pipe, gnuplot open file, gnuplot plot image<br />

System<br />

Module<br />

gnuplot open file ( const char *FileName, long *GnuplotFileID )<br />

Open a gnuplot file for visualization of images and control values.<br />

gnuplot open file allows the output of images and control values in a format which can be later<br />

processed by gnuplot. The parameter FileName determines the base-name of the files to be created<br />

by calls to gnuplot plot image. gnuplot open file generates a gnuplot control file with the<br />

name FileName.gp, in which the respective plot commands are written. Each image plotted by<br />

gnuplot plot image (or control values plotted by T gnuplot plot ctrl) creates a data file with the<br />

name FileName.dat.Number, where Number is the number of the plot in the current sequence. The generated<br />

control file can later be edited to create the desired effect. After the last plot gnuplot close has to be<br />

called in order to close all open files. The corresponding identifier for the gnuplot output stream is returned in<br />

GnuplotFileID.<br />

Parameter<br />

º FileName (input control) ...................................................filename const char *<br />

Base name for control and data files.<br />

º GnuplotFileID (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . gnuplot id long *<br />

Identifier for the gnuplot output stream.<br />

Result<br />

gnuplot open file returns the value H MSG TRUE if the control file could be opened. Otherwise, an exception<br />

handling is raised.<br />

Parallelization Information<br />

gnuplot open file is processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

gnuplot plot image, gnuplot close<br />

gnuplot open pipe<br />

Alternatives<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.2. GNUPLOT 191<br />

See Also<br />

gnuplot open pipe, gnuplot close, gnuplot plot image<br />

System<br />

Module<br />

gnuplot open pipe ( long *GnuplotFileID )<br />

Open a pipe to a gnuplot process for visualization of images and control values.<br />

gnuplot open pipe opens a pipe to a gnuplot sub-process with which subsequently images can<br />

be visualized as 3D-plots (gnuplot plot image) or control values can be visualized as 2D-plots<br />

(T gnuplot plot ctrl). The sub-process must be terminated after displaying the last plot by calling<br />

gnuplot close. The corresponding identifier for the gnuplot output stream is returned in GnuplotFileID.<br />

Attention<br />

gnuplot open pipe is only implemented for Unix because gnuplot for Windows (wgnuplot) cannot be<br />

controlled by an external process.<br />

Parameter<br />

º GnuplotFileID (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . gnuplot id long *<br />

Identifier for the gnuplot output stream.<br />

Result<br />

gnuplot open pipe returns the value H MSG TRUE if the sub-process could be created. Otherwise, an exception<br />

handling is raised.<br />

Parallelization Information<br />

gnuplot open pipe is processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

gnuplot plot image, T gnuplot plot ctrl, gnuplot close<br />

gnuplot open file<br />

System<br />

Alternatives<br />

Module<br />

T gnuplot plot ctrl ( Htuple GnuplotFileID, Htuple Values )<br />

Plot control values using gnuplot.<br />

T gnuplot plot ctrl displays a tuple of control values using gnuplot. If there is an active gnuplot subprocess<br />

(started with gnuplot open pipe), the image is displayed in a gnuplot window. Otherwise, the image<br />

is output to a file, which can be later read by gnuplot. In both cases the gnuplot output stream is identified by<br />

GnuplotFileID.<br />

Parameter<br />

º GnuplotFileID (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . gnuplot id Htuple . long<br />

Identifier for the gnuplot output stream.<br />

º Values (input control) ........................................number-array Htuple . double / long<br />

Control values to be plotted (y-values).<br />

Result<br />

T gnuplot plot ctrl returns the value if GnuplotFileID is a valid gnuplot output stream, if the data<br />

file for the current plot could be opened, and if only integer or floating point values were passed. Otherwise, an<br />

exception handling is raised.<br />

Parallelization Information<br />

T gnuplot plot ctrl is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

gnuplot open pipe, gnuplot open file<br />

<strong>HALCON</strong> 6.0


192 CHAPTER 4. GRAPHICS<br />

gnuplot close<br />

Possible Successor Functions<br />

See Also<br />

gnuplot open pipe, gnuplot open file, gnuplot close<br />

System<br />

Module<br />

T gnuplot plot funct 1d ( Htuple GnuplotFileID, Htuple Function )<br />

Plot a function using gnuplot.<br />

T gnuplot plot ctrl displays a function of control values using gnuplot. If there is an active gnuplot subprocess<br />

(started with gnuplot open pipe), the image is displayed in a gnuplot window. Otherwise, the image<br />

is output to a file, which can be later read by gnuplot. In both cases the gnuplot output stream is identified by<br />

GnuplotFileID.<br />

Parameter<br />

º GnuplotFileID (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . gnuplot id Htuple . long<br />

Identifier for the gnuplot output stream.<br />

º Function (input control) ..................................function 1d-array Htuple . double / long<br />

Function to be plotted.<br />

Result<br />

T gnuplot plot ctrl returns H MSG TRUE if GnuplotFileID is a valid gnuplot output stream, and if<br />

the data file for the current plot could be opened. Otherwise, an exception handling is raised.<br />

Parallelization Information<br />

T gnuplot plot funct 1d is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

gnuplot open pipe, gnuplot open file<br />

gnuplot close<br />

T gnuplot plot ctrl<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

gnuplot open pipe, gnuplot open file, gnuplot close<br />

System<br />

Module<br />

gnuplot plot image ( Hobject Image, long GnuplotFileID, long SamplesX,<br />

long SamplesY, double ViewRotX, double ViewRotZ, const char *Hidden3D )<br />

Visualize images using gnuplot.<br />

gnuplot plot image displays an image as a 3D-plot using gnuplot. If there is an active gnuplot sub-process<br />

(started with gnuplot open pipe), the image is displayed in a gnuplot window. Otherwise, the image is<br />

output to a file, which can be later read by gnuplot. In both cases the gnuplot output stream is identified by<br />

GnuplotFileID. The parameters SamplesX and SamplesY determine the number of data points in the x-<br />

and y-direction, respectively, which gnuplot should use to display the image. They are the equivalent of the gnuplot<br />

variables samples and isosamples. The parameters ViewRotX und ViewRotZ determine the rotation of the plot<br />

with respect to the viewer. ViewRotX is the rotation of the coordinate system about the x-axis, while ViewRotZ<br />

is the rotation of the plot about the z-axis. These two parameters correspond directly to the first two parameters<br />

of the ’set view’ command in gnuplot. The parameter Hidden3D determines whether hidden surfaces should be<br />

removed. This is equivalent to the ’set hidden3d’ command in gnuplot. If a single image is passed to the operator,<br />

it is displayed in a separate plot. If multiple images are passed, they are displayed in the same plot.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.3. LUT 193<br />

Parameter<br />

º Image (input object) ..............................................................image Hobject<br />

Image to be plotted.<br />

º GnuplotFileID (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . gnuplot id long<br />

Identifier for the gnuplot output stream.<br />

º SamplesX (input control) ............................................................integer long<br />

Number of samples in the x-direction.<br />

Default Value : 64<br />

Typical Range of Values : 2 SamplesX 10000<br />

Restriction : SamplesX 2<br />

º SamplesY (input control) ............................................................integer long<br />

Number of samples in the y-direction.<br />

Default Value : 64<br />

Typical Range of Values : 2 SamplesY 10000<br />

Restriction : SamplesY 2<br />

º ViewRotX (input control) ...................................................number double / long<br />

Rotation of the plot about the x-axis.<br />

Default Value : 60<br />

Typical Range of Values : 0 ViewRotX 180<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 10<br />

Restriction : ´0 ViewRotXµ ´ViewRotX 180µ<br />

º ViewRotZ (input control) ...................................................number double / long<br />

Rotation of the plot about the z-axis.<br />

Default Value : 30<br />

Typical Range of Values : 0 ViewRotZ 360<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 10<br />

Restriction : ´0 ViewRotZµ ´ViewRotZ 360µ<br />

º Hidden3D (input control) ......................................................string const char *<br />

Plot the image with hidden surfaces removed.<br />

Default Value : ’hidden3d’<br />

Value List : Hidden3D ¾’hidden3d’, ’nohidden3d’<br />

Result<br />

gnuplot plot image returns the value if GnuplotFileID is a valid gnuplot output stream, and if the data<br />

file for the current plot could be opened. Otherwise, an exception handling is raised.<br />

Parallelization Information<br />

gnuplot plot image is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

gnuplot open pipe, gnuplot open file<br />

gnuplot close<br />

Possible Successor Functions<br />

See Also<br />

gnuplot open pipe, gnuplot open file, gnuplot close<br />

System<br />

Module<br />

4.3 LUT<br />

disp lut ( long WindowHandle, long Row, long Column, long Scale )<br />

Graphical view of the look-up-table (lut).<br />

<strong>HALCON</strong> 6.0


194 CHAPTER 4. GRAPHICS<br />

disp lut displays a graphical view of the look-up-table (lut) in the valid window. A look-up-table defines the<br />

transformation of image gray values to colors/gray levels on the screen. On most systems this can be modified.<br />

disp lut creates a graphical view of the table assigned to the output window with the logical window number<br />

WindowHandle and displays it for every basic color (red, green, blue). Row and Column define the position<br />

of the centre of the graphic. Scale allows scaling of the graphic, whereas 1 means displaying all 256 values,<br />

2 means displaying 128 values, 3 means displaying only 64 values, etc. Tables for monochrome-representations<br />

are displayed in the currently set color (see (T )set color, T set rgb, etc.). Tables for displaying ”‘false<br />

colors”’ are viewed with red, green and blue for each color component.<br />

Attention<br />

draw lut can only be used on hardware supporting look-up-tables for the output.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Row (input control) ...................................................................point.y long<br />

Row of centre of the graphic.<br />

Default Value : 128<br />

Typical Range of Values : 0 Row 511<br />

º Column (input control) ...............................................................point.x long<br />

Column of centre of the graphic.<br />

Default Value : 128<br />

Typical Range of Values : 0 Column 511<br />

º Scale (input control) ................................................................integer long<br />

Scaling of the graphic.<br />

Default Value : 1<br />

Value List : Scale ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10<br />

Typical Range of Values : 0 Scale 20<br />

set_lut(WindowHandle,"color") ;<br />

disp_lut(WindowHandle,256,256,1) ;<br />

get_mbutton(WindowHandle,_,_,_) ;<br />

set_lut(WindowHandle,"sqrt") ;<br />

disp_lut(WindowHandle,128,128,2) ;<br />

Example<br />

Result<br />

disp lut returns H MSG TRUE if the hardware supports a look-up-table, the window is valid and the parameters<br />

are correct. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

disp lut is local and processed completely exclusively without parallelization.<br />

(T )set lut<br />

Possible Predecessor Functions<br />

See Also<br />

open window, open textwindow, draw lut, (T )set lut, set fix, T set pixel, write lut,<br />

T get lut, (T )set color<br />

System<br />

Module<br />

draw lut ( long WindowHandle )<br />

Manipulate look-up-table (lut) interactively.<br />

draw lut allows interactive manipulation of the look-up-table of the device currently displaying the output window.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.3. LUT 195<br />

By pressing and holding down the left mouse button one can change (from ”‘left to right”’) the red-, green- and<br />

blue-intensity displayed in a 2 dimensional diagram with the gray values on the x-axis. The left mouse button<br />

also is used for choosing the color channel that should be changed. As an alternative, one can map pure gray<br />

levels (gray ”‘color channel”’) to the gray values on the x-axis. The right mouse button is used for terminating the<br />

change-process. The modified look-up-table can be saved by write lut and reloaded later by (T )set lut.<br />

T get lut succeeding draw lut returns directly the RGB tuple of the look-up-table. These are suitable as<br />

input of (T )set lut.<br />

Attention<br />

draw lut can only be used on hardware supporting look-up-tables for the output and allow dynamic changing of<br />

the tables.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

Example<br />

read_image(&Image,"fabrik") ;<br />

disp_image(Image,WindowHandle) ;<br />

draw_lut(WindowHandle) ;<br />

write_lut(WindowHandle,"my_lut") ;<br />

...<br />

read_image(&Image,"fabrik") ;<br />

set_lut(WindowHandle,"my_lut") ;<br />

Result<br />

draw lut returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

draw lut is local and processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

set lut style, (T )set lut, write lut, disp lut<br />

set fix, T set rgb<br />

Alternatives<br />

See Also<br />

write lut, (T )set lut, T get lut, disp lut<br />

System<br />

Module<br />

get fixed lut ( long WindowHandle, char *Mode )<br />

Get fixing of ”‘look-up-table”’ (lut) for ”‘real color images”’<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Mode (output control) ................................................................string char *<br />

Mode of fixing.<br />

Default Value : ’true’<br />

Value List : Mode ¾’true’, ’false’<br />

Parallelization Information<br />

get fixed lut is local and processed completely exclusively without parallelization.<br />

set fixed lut<br />

System<br />

Possible Successor Functions<br />

Module<br />

<strong>HALCON</strong> 6.0


196 CHAPTER 4. GRAPHICS<br />

T get lut ( Htuple WindowHandle, Htuple *LookUpTable )<br />

Get current look-up-table (lut).<br />

T get lut returns the name or the values of the look-up-table (lut) of the window, currently used by<br />

disp image (or indirectly by disp region, etc.) for output. To set a look-up-table use (T )set lut.<br />

If the current table is a system table without any modification ( by set fix ), the name of the table is returned. If<br />

it is a modified table, a table read from a file or a table for output with pseudo real colors, the RGB-values of the<br />

table are returned.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window identifier.<br />

º LookUpTable (output control) .................................string-array Htuple . char * / long *<br />

Name of look-up-table or tuple of RGB-values.<br />

Result<br />

T get lut returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T get lut is local and processed completely exclusively without parallelization.<br />

draw lut, (T )set lut<br />

set fix, T get pixel<br />

(T )set lut, draw lut<br />

System<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

get lut style ( long WindowHandle, double *Hue, double *Saturation,<br />

double *Intensity )<br />

Get modification parameters of look-up-table (lut).<br />

get lut style returns the values that were set with set lut style. Default is:<br />

Hue: 0.0<br />

Saturation 1.0<br />

Intensity 1.0<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Hue (output control) .................................................................real double *<br />

Modification of color value.<br />

º Saturation (output control) .......................................................real double *<br />

Modification of saturation.<br />

º Intensity (output control) ........................................................real double *<br />

Modification of intensity.<br />

Result<br />

get lut style returns H MSG TRUE if the window is valid and the parameter is correct. Otherwise an exception<br />

handling is raised.<br />

Parallelization Information<br />

get lut style is local and processed completely exclusively without parallelization.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.3. LUT 197<br />

set lut style, (T )set lut<br />

set lut style<br />

System<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

T query lut ( Htuple WindowHandle, Htuple *LookUpTable )<br />

Query all available look-up-tables (lut).<br />

T query lut returns the names of all look-up-tables available on the current used device. These tables can be<br />

set with (T )set lut. An table named ’default’ is always available.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window identifier.<br />

º LookUpTable (output control) .........................................string-array Htuple . char *<br />

Names of look-up-tables.<br />

Result<br />

T query lut returns H MSG TRUE if a window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T query lut is local and processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

set lut style, (T )set lut, write lut, disp lut<br />

(T )set lut<br />

System<br />

See Also<br />

Module<br />

set fixed lut ( long WindowHandle, const char *Mode )<br />

Fix ”‘look-up-table”’ (lut) for ”‘real color images”’.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Mode (input control) ............................................................string const char *<br />

Mode of fixing.<br />

Default Value : ’true’<br />

Value List : Mode ¾’true’, ’false’<br />

Parallelization Information<br />

set fixed lut is local and processed completely exclusively without parallelization.<br />

get fixed lut<br />

System<br />

Possible Predecessor Functions<br />

Module<br />

<strong>HALCON</strong> 6.0


198 CHAPTER 4. GRAPHICS<br />

set lut ( long WindowHandle, const char *LookUpTable )<br />

T set lut ( Htuple WindowHandle, Htuple LookUpTable )<br />

Set ”‘look-up-table”’ (lut).<br />

(T )set lut sets look-up-table of the device (monitor) displaying the output window. A look-up-table defines<br />

the transformation of a ”‘gray value”’ within an image into a gray value or color on the screen. It describes the<br />

screen gray value/color as a combination of red, green and blue for any image gray value (0..255) (so it is a ’table’<br />

to ’look up’ the screen gray value/color for each image gray value: look-up-table). Transformation into screencolors<br />

is performed in real-time at every time the screen is displayed new (typically this happens about 60 - 70<br />

times per second). So it is possible to change the llok-up-table to get a new look of images or regions. Please<br />

remind that not all machines support changing the look-up-table (e.g. monochrome resp. real color).<br />

Look-up-tables within <strong>HALCON</strong> (and on a machine that supports 256 colors) are diposed into three areas:<br />

S: system area resp. user area,<br />

G: graphic colors,<br />

B: image data.<br />

Colors in S descend from applications that were active before starting <strong>HALCON</strong> and should not get lost. Graphic<br />

colors in G are used for operators such as disp region, (T )disp circle etc. and are set unique within<br />

all look-up-tables. An output in a graphic color has always got the same (color-)look, even if different look-uptables<br />

are used. (T )set color and T set rgb set graphic colors. Gray values resp. colors in B are used<br />

by disp image to display an image. They can change according to the current look-up-table. There exist two<br />

exceptions to this concept:<br />

¯ (T )set gray allows setting of colors of the area B for operators such as disp region,<br />

¯ set fix that allows modification of graphic colors.<br />

For common monitors only one look-up-table can be loaded per screen. Whereas (T )set lut can be activated<br />

separately for each window. There is the following solution for this problem: It will always be activated the<br />

look-up-table that is assigned to the ”‘active window”’ (a window is set into the state ”‘active”’ by the window<br />

manager).<br />

look-up-table can also be used with truecolor displays. In this case the look-up-table will be simulated in software.<br />

This means, that the look-up-table will be used each time an image is displayed.<br />

WindowsNT specific: if the graphiccard is used in mode different from truecolor, you must display the image after<br />

setting the look-up-taple.<br />

T query lut lists the names of all look-up-tables. They differ from each other in the area used for gray values.<br />

Within this area the following behaiviour is defined:<br />

gray value tables (1-7 image levels)<br />

’default’: Only the two basic colors (generally black and white) are used.<br />

color tables (Real color, static gray value steps)<br />

’default’: Table proposed by the hardware.<br />

gray value tables (256 colors)<br />

’default’: As ’linear’.<br />

’linear’: Linear increasing of gray values from 0 (black) to 255 (white).<br />

’inverse’: Inverse function of ’linear’.<br />

’sqr’: Gray values increase according to square function.<br />

’inv sqr’: Inverse function of ’sqr’.<br />

’cube’: Gray values increase according to cubic function.<br />

’inv cube’: Inverse function of ’cube’.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.3. LUT 199<br />

’sqrt’: Gray values increase according to square-root function.<br />

’inv sqrt’: Inverse Function of ’sqrt’.<br />

’cubic root’: Gray values increase according to cubic-root function.<br />

’inv cubic root’: Inverse Function of ’cubic root’.<br />

color tables (256 colors)<br />

’color1’: Linear transition from red via green to blue.<br />

’color2’: Smooth transition from yellow via red, blue to green.<br />

’color3’: Smooth transition from yellow via red, blue, green, red to blue.<br />

’color4’: Smooth transition from yellow via red to blue.<br />

’three’: Displaying the three colors red, green and blue.<br />

’six’: Displaying the six basic colors yellow, red, magenta, blue, cyan and green.<br />

’twelve’: Displaying 12 colors.<br />

’twenty four’: Displaying 24 colors.<br />

’rainbow’: Displaying the spectral colors from red via green to blue.<br />

’temperature’: Temperature table from black via red, yellow to white.<br />

’change1’: Color changement after every pixel within the table alternating the six basic colors.<br />

’change2’: Fivefold color changement from green via red to blue.<br />

’change3’: Threefold color changement from green via red to blue.<br />

A look-up-table can be read from a file. Every line of such a file must contain three numbers in the range of<br />

0 to 255, with the first number describing the amount of red, the second the amount of green and the third the<br />

amount of blue of the represented display color. The number of lines can vary. The first line contains information<br />

for the first gray value and the last line for the last value. If there are less lines than gray values, the<br />

available information values are distributed over the whole interval calculating the missing values by interpolation.<br />

If there are more lines than gray values, a number of (uniformly distributed) lines is ignored. The file-name must<br />

conform to ”‘LookUpTable.lut”’. Within the parameter the name is specified without file extension. HAL-<br />

CON will search for the file in the current directory and after that in a specified directory ( see set system<br />

(’lut dir’,) ). It is also possible to call (T )set lut with a tuple of RGB-Values. These will<br />

be set directly. The number of parameter values must conform to the number of pixels currently used within the<br />

look-up-table.<br />

Attention<br />

(T )set lut can only be used with monitors supporting 256 gray levels/colors.<br />

Parameter<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window identifier.<br />

º LookUpTable (input control) ............................string(-array) (Htuple .) const char * / long<br />

Name of look-up-table, values of look-up-table (RGB) or file name.<br />

Default Value : ’default’<br />

Value Suggestions : LookUpTable ¾’default’, ’linear’, ’inverse’, ’sqr’, ’inv sqr’, ’cube’, ’inv cube’,<br />

’sqrt’, ’inv sqrt’, ’cubic root’, ’inv cubic root’, ’color1’, ’color2’, ’color3’, ’color4’, ’three’, ’six’, ’twelfe’,<br />

’twenty four’, ’rainbow’, ’temperature’, ’cyclic gray’, ’cyclic temperature’, ’hsi’, ’change1’, ’change2’,<br />

’change3’<br />

Example<br />

Htuple WindowHandleTuple, LUTs ;<br />

read_image(&Image,"affe") ;<br />

create_tuple(&WindowHandleTuple,1) ;<br />

set_i(WindowHandleTuple,WindowHandle,0) ;<br />

T_query_lut(WindowHandleTuple,&LUTs) \:<br />

for(i=1; i


200 CHAPTER 4. GRAPHICS<br />

fwrite_string("current table: ") ;<br />

fwrite_string(get_s(LUTs,i)) ;<br />

fnew_line() ;<br />

get_mbutton(WindowHandle,_,_,_) ;<br />

} ;<br />

Result<br />

(T )set lut returns H MSG TRUE if the hardware supports a look-up-table and the parameter is correct. Otherwise<br />

an exception handling is raised.<br />

Parallelization Information<br />

(T )set lut is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

T query lut, draw lut, T get lut<br />

write lut<br />

draw lut, set fix, T set pixel<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

T get lut, T query lut, draw lut, set fix, (T )set color, T set rgb, T set hsi, write lut<br />

System<br />

Module<br />

set lut style ( long WindowHandle, double Hue, double Saturation,<br />

double Intensity )<br />

Changing the look-up-table (lut).<br />

set lut style changes the look-up-table (lut) of the device displaying the valid output window. It has got three<br />

parameters:<br />

Hue: Rotation of color space, Hue = 1.9 conforms to a one-time rotation of the color space. No changement: Hue<br />

= 0.0 Complement colors: Hue = 0.5<br />

Saturation: Changement of saturation, No changement: Saturation = 1.0 Gray value image: Saturation = 0.0<br />

Intensity: Changement of intensity, No changement: Intensity = 1.0 Black image: Intensity = 0.0<br />

Changement affects only the part of an look-up-table that is used for diplaying images. The parameter of modification<br />

remain until the next call of set lut style. Calling (T )set lut has got no effect on these parameters.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Hue (input control) ...................................................................real double<br />

Modification of color value.<br />

Default Value : 0.0<br />

Typical Range of Values : 0.0 Hue 1.0<br />

Restriction : ´0.0 Hueµ ´Hue 1.0µ<br />

º Saturation (input control) ..........................................................real double<br />

Modification of saturation.<br />

Default Value : 1.5<br />

Typical Range of Values : 0.0 Saturation<br />

Restriction : 0.0 Saturation<br />

º Intensity (input control) ...........................................................real double<br />

Modification of intensity.<br />

Default Value : 1.5<br />

Typical Range of Values : 0.0 Intensity<br />

Restriction : 0.0 Intensity<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.3. LUT 201<br />

Example<br />

read_image(&Image,"affe") ;<br />

set_lut(WindowHandle,"color") ;<br />

do{<br />

get_mbutton(WindowHandle,&Row,&Column,&Button) ;<br />

Saturation= Row/300.0 ;<br />

Hue = Column/512.0 ;<br />

set_lut_style(WindowHandle,Hue,Saturation,1.0) ;<br />

}<br />

while(Button > 1) ;<br />

Result<br />

set lut style returns H MSG TRUE if the window is valid and the parameter is correct. Otherwise an exception<br />

handling is raised.<br />

Parallelization Information<br />

set lut style is local and processed completely exclusively without parallelization.<br />

get lut style<br />

(T )set lut<br />

(T )set lut, scale image<br />

get lut style<br />

System<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

write lut ( long WindowHandle, const char *FileName )<br />

Write look-up-table (lut) as file.<br />

write lut saves the look-up-table (resp. the part of it that is relevant for displaying image gray values) of the<br />

valid output window into a file named ’FileName.lut’. It can be read again later with (T )set lut.<br />

Attention<br />

write lut is only suitable for systems using 256 colors.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º FileName (input control) ...................................................filename const char *<br />

File name (of file containing the look-up-table).<br />

Default Value : ’/tmp/lut’<br />

read_image(&Image,"affe") ;<br />

disp_image(Image,WindowHandle) ;<br />

draw_lut(WindowHandle) ;<br />

write_lut(WindowHandle,"test_lut") ;<br />

Example<br />

Result<br />

disp lut returns H MSG TRUE if the window with the demanded properties (256 colors) is valid and the<br />

parameter (file-name) is correct. It returns H MSG FAIL if the specified file can’t be opened. Otherwise an<br />

exception handling is raised.<br />

<strong>HALCON</strong> 6.0


202 CHAPTER 4. GRAPHICS<br />

Parallelization Information<br />

write lut is local and processed completely exclusively without parallelization.<br />

draw lut, (T )set lut<br />

Possible Predecessor Functions<br />

See Also<br />

(T )set lut, draw lut, T set pixel, T get pixel<br />

System<br />

Module<br />

4.4 Mouse<br />

get mbutton ( long WindowHandle, long *Row, long *Column, long *Button )<br />

Wait until a mouse button is pressed.<br />

get mbutton returns the coordinates of the mouse pointer in the output window and the mouse button pressed<br />

(Button):<br />

1: Left button,<br />

2: Middle button,<br />

4: Right button.<br />

The operator waits until a button is pressed in the output window. If more than one button is pressed, the sum of<br />

the individual buttons’ values is returned. The origin of the coordinate system is located in the left upper corner<br />

of the window. The row coordinates increase towards the bottom, while the column coordinates increase towards<br />

the right. For graphics windows, the coordinates of the lower right corner are (image height-1,image width-1)<br />

(see open window, reset obj db), while for text windows they are (window height-1,window width-1) (see<br />

open textwindow).<br />

Attention<br />

get mbutton only returns if a mouse button is pressed in the window.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Row (output control) ................................................................point.y long *<br />

Row coordinate of the mouse position in the window.<br />

º Column (output control) ............................................................point.x long *<br />

Column coordinate of the mouse position in the window.<br />

º Button (output control) ............................................................integer long *<br />

Mouse button(s) pressed.<br />

get mbutton returns the value H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

get mbutton is local and processed completely exclusively without parallelization.<br />

open window, open textwindow<br />

get mposition<br />

open window, open textwindow<br />

System<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.4. MOUSE 203<br />

get mposition ( long WindowHandle, long *Row, long *Column,<br />

long *Button )<br />

Query the mouse position.<br />

get mposition returns the coordinates of the mouse pointer in the output window and the mouse button pressed.<br />

These values are returned regardless of the state of the mouse buttons (pressed or not pressed). If more than one<br />

button is pressed, the sum of the individual buttons’ values is returned. The possible values for Button are:<br />

0: No button,<br />

1: Left button,<br />

2: Middle button,<br />

4: Right button.<br />

The origin of the coordinate system is located in the left upper corner of the window. The row coordinates increase<br />

towards the bottom, while the column coordinates increase towards the right. For graphics windows, the coordinates<br />

of the lower right corner are (image height-1,image width-1) (see open window, reset obj db), while<br />

for text windows they are (window height-1,window width-1) (see open textwindow).<br />

Attention<br />

get mposition fails (returns FAIL) if the mouse pointer is not located within the window. In this case, no<br />

values are returned.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Row (output control) ................................................................point.y long *<br />

Row coordinate of the mouse position in the window.<br />

º Column (output control) ............................................................point.x long *<br />

Column coordinate of the mouse position in the window.<br />

º Button (output control) ............................................................integer long *<br />

Mouse button(s) pressed or 0.<br />

Result<br />

get mposition returns the value H MSG TRUE. If the mouse pointer is not located within the window,<br />

H MSG FAIL is returned.<br />

Parallelization Information<br />

get mposition is local and processed completely exclusively without parallelization.<br />

open window, open textwindow<br />

get mbutton<br />

open window, open textwindow<br />

System<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

get mshape ( long WindowHandle, char *Cursor )<br />

Query the current mouse pointer shape.<br />

get mshape returns the name of the pointer shape set for the window. The mouse pointer shape can be used in<br />

the operator set mshape.<br />

<strong>HALCON</strong> 6.0


204 CHAPTER 4. GRAPHICS<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Cursor (output control) .............................................................string char *<br />

Mouse pointer name.<br />

Result<br />

get mshape returns the value H MSG TRUE.<br />

Parallelization Information<br />

get mshape is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, open textwindow, T query mshape<br />

set mshape<br />

set mshape, T query mshape<br />

System<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

T query mshape ( Htuple WindowHandle, Htuple *ShapeNames )<br />

Query all available mouse pointer shapes.<br />

T query mshape returns the names of all available mouse pointer shapes for the window. These can be used in<br />

the operator set mshape. If no mouse pointers are available, the empty tuple is returned.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window identifier.<br />

º ShapeNames (output control) ..........................................string-array Htuple . char *<br />

Available mouse pointer names.<br />

Result<br />

T query mshape returns the value H MSG TRUE.<br />

Parallelization Information<br />

T query mshape is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, open textwindow, get mshape<br />

set mshape<br />

set mshape, get mshape<br />

System<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

set mshape ( long WindowHandle, const char *Cursor )<br />

Set the current mouse pointer shape.<br />

set mshape sets the shape of the mouse pointer for the window. A list of the names of all available mouse<br />

pointer shapes can be obtained by calling T query mshape. The mouse pointer shape given by Cursor is used<br />

if the mouse pointer enters the window, irrespective of which window is the output window at present.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.5. OUTPUT 205<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Cursor (input control) .........................................................string const char *<br />

Mouse pointer name.<br />

Default Value : ’arrow’<br />

Result<br />

set mshape returns the value H MSG TRUE if the mouse pointer shape Cursor is defined for this window.<br />

Otherwise, an exception handling is raised.<br />

Parallelization Information<br />

set mshape is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, open textwindow, T query mshape, get mshape<br />

get mshape, T query mshape<br />

System<br />

See Also<br />

Module<br />

4.5 Output<br />

disp arc ( long WindowHandle, double CenterRow, double CenterCol,<br />

double Angle, long BeginRow, long BeginCol )<br />

T disp arc ( Htuple WindowHandle, Htuple CenterRow, Htuple CenterCol,<br />

Htuple Angle, Htuple BeginRow, Htuple BeginCol )<br />

Displays circular arcs in a window.<br />

(T )disp arc displays one or several circular arcs in the output window. An arc is described by its center point<br />

(CenterRow,CenterCol), the angle between start and end of the arc (Angle in radians) and the first point of<br />

the arc (BeginRow,BeginCol). The arc is displayed in clockwise direction. The parameters for output can be<br />

determined - as with the output of regions - with the procedures (T )set color, (T )set gray, set draw,<br />

etc. It is possible to draw several arcs with one call by using tupel parameters. For the use of colors with several<br />

arcs, see (T )set color.<br />

Attention<br />

The center point has to be within the window. The radius of the arc has be at least 2 pixel.<br />

Parameter<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window identifier.<br />

º CenterRow (input control) ....................................arc.center.y (Htuple .) double / long<br />

Row coordinate of center point.<br />

Default Value : 64<br />

Value Suggestions : CenterRow ¾0, 64, 128, 256<br />

Typical Range of Values : 0 CenterRow 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º CenterCol (input control) ....................................arc.center.x (Htuple .) double / long<br />

Column coordinate of center point.<br />

Default Value : 64<br />

Value Suggestions : CenterCol ¾0, 64, 128, 256<br />

Typical Range of Values : 0 CenterCol 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

<strong>HALCON</strong> 6.0


206 CHAPTER 4. GRAPHICS<br />

º Angle (input control) .........................................arc.angle.rad (Htuple .) double / long<br />

Angle between start and end of the arc (in radians).<br />

Default Value : 3.1415926<br />

Value Suggestions : Angle ¾0.0, 0.785398, 1.570796, 3.1415926, 6.283185<br />

Typical Range of Values : 0.0 Angle 6.283185 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Angle 0.0<br />

º BeginRow (input control) ...............................arc.begin.y(-array) (Htuple .) long / double<br />

Row coordinate of the start of the arc.<br />

Default Value : 32<br />

Value Suggestions : BeginRow ¾0, 64, 128, 256<br />

Typical Range of Values : 0 BeginRow 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º BeginCol (input control) ...............................arc.begin.x(-array) (Htuple .) long / double<br />

Column coordinate of the start of the arc.<br />

Default Value : 32<br />

Value Suggestions : BeginCol ¾0, 64, 128, 256<br />

Typical Range of Values : 0 BeginCol 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Example<br />

double Row, Column, WindowHandle;<br />

open_window(0,0,-1,-1,"root","visible","",&WindowHandle) ;<br />

set_draw(WindowHandle,"fill") ;<br />

set_color(WindowHandle,"white") ;<br />

set_insert(WindowHandle,"not") ;<br />

Row = 100 ;<br />

Column = 100 ;<br />

disp_arc(WindowHandle,Row,Column,(double)3.14,(int)Row+10,(int)Column+10) ;<br />

close_window(WindowHandle).<br />

(T )disp arc returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )disp arc is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, set draw, (T )set color, set colored, set line width, T set rgb, T set hsi<br />

Alternatives<br />

(T )disp circle, (T )disp ellipse, disp region, gen circle, gen ellipse<br />

See Also<br />

open window, open textwindow, (T )set color, set draw, T set rgb, T set hsi<br />

System<br />

Module<br />

disp arrow ( long WindowHandle, double Row1, double Column1,<br />

double Row2, double Column2, double Size )<br />

T disp arrow ( Htuple WindowHandle, Htuple Row1, Htuple Column1,<br />

Htuple Row2, Htuple Column2, Htuple Size )<br />

Displays arrows in a window.<br />

(T )disp arrow displays one or several arrows in the output window. An arrow is described by the coordinates<br />

of the start (Row1,Column1) and the end (Row2,Column2). An arrowhead is displayed at the end of the arrow.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.5. OUTPUT 207<br />

The size of the arrowhead is specified by the parameter Size. If the arrow consists of just one point (start = end)<br />

nothing is displayed. The procedures used to control the display of regions (e.g. set draw, (T )set color,<br />

set line width) can also be used with arrows. Several arrows can be displayed with one call by using tuple<br />

parameters. For the use of colors with several arcs, see (T )set color.<br />

Attention<br />

The start and the end of the arrows must fall within the window.<br />

Parameter<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window identifier.<br />

º Row1 (input control) ....................................line.begin.y(-array) (Htuple .) double / long<br />

Row index of the start.<br />

Default Value : 10.0<br />

Value Suggestions : Row1 ¾0.0, 64.0, 128.0, 256.0<br />

Typical Range of Values : 0.0 Row1 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 1.0<br />

º Column1 (input control) ................................line.begin.x(-array) (Htuple .) double / long<br />

Column index of the start.<br />

Default Value : 10.0<br />

Value Suggestions : Column1 ¾0.0, 64.0, 128.0, 256.0<br />

Typical Range of Values : 0.0 Column1 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 1.0<br />

º Row2 (input control) ......................................line.end.y(-array) (Htuple .) double / long<br />

Row index of the end.<br />

Default Value : 118.0<br />

Value Suggestions : Row2 ¾0.0, 64.0, 128.0, 256.0<br />

Typical Range of Values : 0.0 Row2 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 1.0<br />

º Column2 (input control) ..................................line.end.x(-array) (Htuple .) double / long<br />

Column index of the end.<br />

Default Value : 118.0<br />

Value Suggestions : Column2 ¾0.0, 64.0, 128.0, 256.0<br />

Typical Range of Values : 0.0 Column2 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 1.0<br />

º Size (input control) ...............................................number (Htuple .) double / long<br />

Size of the arrowhead.<br />

Default Value : 1.0<br />

Value Suggestions : Size ¾1.0, 2.0, 3.0, 5.0<br />

Typical Range of Values : 0.0 Size 20.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 1.0<br />

Restriction : Size 0.0<br />

Example<br />

set_colored(WindowHandle,3) ;<br />

disp_arrow(WindowHandle,10,10,118,118,1.0);<br />

(T )disp arrow returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )disp arrow is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, set draw, (T )set color, set colored, set line width, T set rgb, T set hsi<br />

<strong>HALCON</strong> 6.0


208 CHAPTER 4. GRAPHICS<br />

Alternatives<br />

(T )disp line, gen region polygon, disp region<br />

See Also<br />

open window, open textwindow, (T )set color, set draw, set line width<br />

System<br />

Module<br />

disp channel ( Hobject MultichannelImage, long WindowHandle,<br />

long Channel )<br />

T disp channel ( Hobject MultichannelImage, Htuple WindowHandle,<br />

Htuple Channel )<br />

Displays images with several channels.<br />

(T )disp channel displays an image in the output window. It is possible to display several images with one<br />

call. In this case the images are displayed one after another. If the definition domains of the images overlap only<br />

the last image is visible. The parameter Channel defines the number of the channel that is displayed. For RGBimages<br />

the three color channels have to be used within a tuple parameter. For more information see disp image.<br />

Parameter<br />

º MultichannelImage (input object) .......................................image(-array) Hobject<br />

Multichannel images to be displayed.<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window identifier.<br />

º Channel (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Number of channel or the numbers of the RGB-channels<br />

Default Value : 1<br />

Value List : Channel ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10<br />

Example<br />

/* Tranformation from rgb to gray */<br />

read_image(Image,"patras") ;<br />

disp_color(Image,WindowHandle) ;<br />

rgb1_to_gray(Image,&GrayImage) ;<br />

disp_image(GrayImage,WindowHandle);<br />

Result<br />

If the used images contain valid values and a correct output mode is set, (T )disp channel returns<br />

H MSG TRUE. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

(T )disp channel is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, T set rgb, (T )set lut, T set hsi<br />

disp image, disp color<br />

Alternatives<br />

See Also<br />

open window, open textwindow, reset obj db, (T )set lut, draw lut, (T )dump window<br />

System<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.5. OUTPUT 209<br />

disp circle ( long WindowHandle, double Row, double Column,<br />

double Radius )<br />

T disp circle ( Htuple WindowHandle, Htuple Row, Htuple Column,<br />

Htuple Radius )<br />

Displays circles in a window.<br />

(T )disp circle displays one or several circles in the output window. A circle is described by the center<br />

(Row, Column) and the radius Radius. If the used coordinates are not within the window the circle is clipped<br />

accordingly.<br />

The procedures used to control the display of regions (e.g. set draw, (T )set gray, set draw) can also be<br />

used with circles. Several circles can be displayed with one call by using tuple parameters. For the use of colors<br />

with several circles, see (T )set color.<br />

Attention<br />

The center of the circle must be within the window.<br />

Parameter<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window identifier.<br />

º Row (input control) ...................................circle.center.y(-array) (Htuple .) double / long<br />

Row index of the center.<br />

Default Value : 64<br />

Value Suggestions : Row ¾0, 64, 128, 256<br />

Typical Range of Values : 0 Row 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Column (input control) ...............................circle.center.x(-array) (Htuple .) double / long<br />

Column index of the center.<br />

Default Value : 64<br />

Value Suggestions : Column ¾0, 64, 128, 256<br />

Typical Range of Values : 0 Column 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Radius (input control) .................................circle.radius(-array) (Htuple .) double / long<br />

Radius of the circle.<br />

Default Value : 64<br />

Value Suggestions : Radius ¾0, 64, 128, 256<br />

Typical Range of Values : 0 Radius 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : Radius 0.0<br />

Example<br />

open_window(0,0,-1,-1,"root","visible","",&WindowHandle) ;<br />

set_draw(WindowHandle,"fill") ;<br />

set_color(WindowHandle,"white") ;<br />

set_insert(WindowHandle,"not") ;<br />

get_mbutton(WindowHandle,&Row,&Column,&Button) ;<br />

disp_circle(WindowHandle,Row,Column,(Row + Column) mod 50) ;<br />

(T )disp circle returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )disp circle is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, set draw, (T )set color, set colored, set line width, T set rgb, T set hsi<br />

<strong>HALCON</strong> 6.0


210 CHAPTER 4. GRAPHICS<br />

Alternatives<br />

(T )disp ellipse, disp region, gen circle, gen ellipse<br />

See Also<br />

open window, open textwindow, (T )set color, set draw, T set rgb, T set hsi<br />

System<br />

Module<br />

disp color ( Hobject ColorImage, long WindowHandle )<br />

Displays a color (RGB) image<br />

disp color displays the three channels of a color image in the output window. The channels are ordered in the<br />

sequence (red,green,blue). disp color can be simulated by (T )disp channel.<br />

Attention<br />

Due to the restricted number of available colors the color appearance is usually different from the original.<br />

Parameter<br />

º ColorImage (input object) ........................................................image Hobject<br />

Color image to display.<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

Example<br />

/* disp_color(ColorImage) is identical to: */<br />

Herror my_disp_color(Hobject ColorImage, Htuple *WindowHandle) {<br />

Htuple Tupel;<br />

create_tuple(&Tupel,3);<br />

set_i(Tupel,1,0);<br />

set_i(Tupel,2,1);<br />

set_i(Tupel,3,2);<br />

T_disp_channel(ColorImage,*WindowHandle,Tupel);<br />

destroy_tuple(Tupel);<br />

}<br />

Result<br />

If the used image contains valid values and a correct output mode is set, disp color returns H MSG TRUE.<br />

Otherwise an exception handling is raised.<br />

Parallelization Information<br />

disp color is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, T set rgb, (T )set lut, T set hsi<br />

(T )disp channel, disp obj<br />

Alternatives<br />

See Also<br />

disp image, open window, open textwindow, reset obj db, (T )set lut, draw lut,<br />

(T )dump window<br />

Module<br />

System<br />

T disp distribution ( Htuple WindowHandle, Htuple Distribution,<br />

Htuple Row, Htuple Column, Htuple Scale )<br />

Displays a noise distribution.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.5. OUTPUT 211<br />

T disp distribution displays a distribution in the window. The parameters are the same as in<br />

T set paint(WindowHandle,’histogram’) or gen region histo. Noise distributions can be generated<br />

with operations like gauss distribution or noise distribution mean.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window identifier.<br />

º Distribution (input control) ..........................................real-array Htuple . double<br />

Gray value distribution (513 values).<br />

º Row (input control) ...........................................................point.y Htuple . long<br />

Row index of center.<br />

Default Value : 256<br />

Value Suggestions : Row ¾0, 64, 128, 256<br />

Typical Range of Values : 0 Row 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Column (input control) .......................................................point.x Htuple . long<br />

Column index of center.<br />

Default Value : 256<br />

Value Suggestions : Column ¾0, 64, 128, 256<br />

Typical Range of Values : 0 Column 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Scale (input control) ........................................................integer Htuple . long<br />

Size of display.<br />

Default Value : 1<br />

Value Suggestions : Scale ¾1, 2, 3, 4, 5, 6<br />

Example<br />

open_window(0,0,-1,-1,"root","visible","",&WindowHandle) ;<br />

set_draw(WindowHandle,"fill") ;<br />

set_color(WindowHandle,"white") ;<br />

set_insert(WindowHandle,"not") ;<br />

read_image(Image,"affe") ;<br />

draw_region(&Region,WindowHandle) ;<br />

noise_distribution_mean(Region,Image,21,&Distribution) ;<br />

disp_distribution (WindowHandle,Distribution,100,100,3) ;<br />

Parallelization Information<br />

T disp distribution is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, set draw, (T )set color, set colored, set line width, T set rgb,<br />

T set hsi, noise distribution mean, gauss distribution<br />

See Also<br />

gen region histo, T set paint, gauss distribution, noise distribution mean<br />

System<br />

Module<br />

disp ellipse ( long WindowHandle, long CenterRow, long CenterCol,<br />

double Phi, double Radius1, double Radius2 )<br />

T disp ellipse ( Htuple WindowHandle, Htuple CenterRow,<br />

Htuple CenterCol, Htuple Phi, Htuple Radius1, Htuple Radius2 )<br />

Displays ellipses.<br />

<strong>HALCON</strong> 6.0


212 CHAPTER 4. GRAPHICS<br />

(T )disp ellipse displays one or several ellipses in the output window. An ellipse is described by the center<br />

(CenterRow, CenterCol), the orientation Phi (in radians) and the radii of the minor and the major axis<br />

(Radius1 and Radius2).<br />

The procedures used to control the display of regions (e.g. set draw, (T )set gray, set draw) can also be<br />

used with ellipses. Several ellipses can be displayed with one call by using tuple parameters. For the use of colors<br />

with several ellipses, see (T )set color.<br />

Attention<br />

The center of the ellipse must be within the window.<br />

Parameter<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window identifier.<br />

º CenterRow (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.y(-array) (Htuple .) long<br />

Row index of center.<br />

Default Value : 64<br />

Value Suggestions : CenterRow ¾0, 64, 128, 256<br />

Typical Range of Values : 0 CenterRow 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º CenterCol (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.x(-array) (Htuple .) long<br />

Column index of center.<br />

Default Value : 64<br />

Value Suggestions : CenterCol ¾0, 64, 128, 256<br />

Typical Range of Values : 0 CenterCol 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Phi (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.angle.rad(-array) (Htuple .) double / long<br />

Orientation of the ellipse in radians<br />

Default Value : 0.0<br />

Value Suggestions : Phi ¾0.0, 0.785398, 1.570796, 3.1415926, 6.283185<br />

Typical Range of Values : 0.0 Phi 6.283185 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

º Radius1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius1(-array) (Htuple .) double / long<br />

Radius of major axis.<br />

Default Value : 24.0<br />

Value Suggestions : Radius1 ¾0.0, 64.0, 128.0, 256.0<br />

Typical Range of Values : 0.0 Radius1 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Radius2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius2(-array) (Htuple .) double / long<br />

Radius of minor axis.<br />

Default Value : 14.0<br />

Value Suggestions : Radius2 ¾0.0, 64.0, 128.0, 256.0<br />

Typical Range of Values : 0.0 Radius2 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Example<br />

set_color(WindowHandle,"red") ;<br />

draw_region(&MyRegion,WindowHandle) ;<br />

elliptic_axis(MyRegion,&Ra,&Rb,&Phi) ;<br />

area_center(MyRegion,_,&Row,&Column) ;<br />

disp_ellipse(WindowHandle,Row,Column,Phi,Ra,Rb);<br />

Result<br />

(T )disp ellipse returns H MSG TRUE, if the parameters are correct. Otherwise an exception handling is<br />

raised.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.5. OUTPUT 213<br />

Parallelization Information<br />

(T )disp ellipse is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, set draw, (T )set color, set colored, set line width, T set rgb,<br />

T set hsi, elliptic axis, area center<br />

Alternatives<br />

(T )disp circle, disp region, gen ellipse, gen circle<br />

See Also<br />

open window, open textwindow, (T )set color, T set rgb, T set hsi, set draw,<br />

set line width<br />

Module<br />

System<br />

disp image ( Hobject Image, long WindowHandle )<br />

Displays gray value images.<br />

disp image displays the gray values of an image in the output window. The gray value pixels of the definition<br />

domain (set comprise(WindowHandle,’object’)) or of the whole image (set comprise<br />

(WindowHandle,’image’)) are used. Restriction to the definition domain is the default.<br />

For the display of gray value images the number of gray values is usually reduced. This is due to the fact that colors<br />

have to be reserved for the display of graphics (e.g. (T )set color) and the window manager. Also depending<br />

on the number of bitplanes on the used output device often less than 256 colors (eight bitplanes) are available. The<br />

number of ”’colors”’ actually reserved for the display of gray values can be queried by get system. Before<br />

opening the first window this value can be modified by set system. For instance for 8 bitplanes 200 real gray<br />

values are the default.<br />

The reduction of the number of gray values does not pose problems as long as only gray value information is<br />

displayed, humans cannot distinguish 256 different shades of gray. If certain gray values are used for the representation<br />

of region information (which is not the style commonly used in <strong>HALCON</strong> ), confusions might be<br />

the result, since different numerical values are displayed on the screen with the same gray value. The procedure<br />

label to region should be used on these images in order to transform the label data into <strong>HALCON</strong> objects.<br />

If images of type ’int2’, ’int4’, ’real’ or ’complex’ are displayed, the smallest and largest gray value is computed.<br />

Afterwards the pixel data is rescaled according to the number of available gray values (depending on the output<br />

device. e.g. 200). It is possible that some pixels have a very different value than the other pixels. This might lead<br />

to the display of an (almost) completely white or black image. In order to decide if the current image is a binary<br />

image min max gray can be used. If neccessary the image can be transformed or converted by scale image<br />

and convert image type before it is displayed.<br />

Attention<br />

If a wrong output mode was set by T set paint, the error will be reported when disp image is used.<br />

Parameter<br />

º Image (input object) ..............................................................image Hobject<br />

Gray value image to display.<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

/* Output of a gray image: */<br />

read_image(&Image,"affe");<br />

disp_image(Image,WindowHandle);<br />

Example<br />

Result<br />

If the used image contains valid values and a correct output mode is set, disp image returns H MSG TRUE.<br />

Otherwise an exception handling is raised.<br />

<strong>HALCON</strong> 6.0


214 CHAPTER 4. GRAPHICS<br />

Parallelization Information<br />

disp image is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, T set rgb, (T )set lut, T set hsi, scale image, convert image type,<br />

min max gray<br />

Alternatives<br />

disp obj, disp color<br />

See Also<br />

open window, open textwindow, reset obj db, set comprise, T set paint, (T )set lut,<br />

draw lut, paint gray, scale image, convert image type, (T )dump window<br />

System<br />

Module<br />

disp line ( long WindowHandle, double Row1, double Column1, double Row2,<br />

double Column2 )<br />

T disp line ( Htuple WindowHandle, Htuple Row1, Htuple Column1,<br />

Htuple Row2, Htuple Column2 )<br />

Draws lines in a window.<br />

(T )disp line displays one or several lines in the output window. A line is described by the coordinates of<br />

the start (Row1,Column1) and the coordinates of the end (Row2,Column2). The procedures used to control the<br />

display of regions (e.g. (T )set color, (T )set gray, set draw, set line width) can also be used<br />

with lines. Several lines can be displayed with one call by using tuple parameters. For the use of colors with<br />

several lines, see (T )set color.<br />

Attention<br />

The starting points and the ending points of the lines must be in the window.<br />

Parameter<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window identifier.<br />

º Row1 (input control) ..........................................line.begin.y(-array) (Htuple .) double<br />

Row index of the start.<br />

Default Value : 32<br />

Value Suggestions : Row1 ¾0, 64, 128, 256, 511<br />

Typical Range of Values : 0 Row1 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Column1 (input control) ......................................line.begin.x(-array) (Htuple .) double<br />

Column index of the start.<br />

Default Value : 32<br />

Value Suggestions : Column1 ¾0, 64, 128, 256, 511<br />

Typical Range of Values : 0 Column1 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Row2 (input control) ............................................line.end.y(-array) (Htuple .) double<br />

Row index of end.<br />

Default Value : 64<br />

Value Suggestions : Row2 ¾0, 64, 128, 256, 511<br />

Typical Range of Values : 0 Row2 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.5. OUTPUT 215<br />

º Column2 (input control) ........................................line.end.x(-array) (Htuple .) double<br />

Column index of end.<br />

Default Value : 64<br />

Value Suggestions : Column2 ¾0, 64, 128, 256, 511<br />

Typical Range of Values : 0 Column2 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Example<br />

/* Prozedur zur Ausgabe der Kontur eines Rechtecks: /*<br />

disp_rectangle1_margin(long WindowHandle,<br />

long Row1, long Column1,<br />

long Row2, long Column2)<br />

{<br />

disp_line(WindowHandle,Row1,Column1,Row1,Column2) ;<br />

disp_line(WindowHandle,Row1,Column2,Row2,Column2) ;<br />

disp_line(WindowHandle,Row2,Column2,Row2,Column1) ;<br />

disp_line(WindowHandle,Row2,Column1,Row1,Column1) ;<br />

}<br />

(T )disp line returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )disp line is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, T set rgb, (T )set lut, T set hsi, set draw, (T )set color, set colored,<br />

set line width<br />

Alternatives<br />

(T )disp arrow, (T )disp rectangle1, (T )disp rectangle2, disp region,<br />

gen region polygon, gen region points<br />

See Also<br />

open window, open textwindow, (T )set color, T set rgb, T set hsi, set insert,<br />

set line width<br />

Module<br />

System<br />

disp obj ( Hobject Object, long WindowHandle )<br />

Displays image objects (image, region, XLD).<br />

disp obj displays objects depending of their kind. disp obj is equivalent to disp image for one channel<br />

images, equivalent to disp color for three channel images, equivalent to disp region for regions and<br />

equivalent to disp xld for XLDs.<br />

Parameter<br />

º Object (input object) ......................................................object(-array) Hobject<br />

Image object to be displayed.<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

/* Output of a gray image: */<br />

read_image(&Image,"affe");<br />

Example<br />

<strong>HALCON</strong> 6.0


216 CHAPTER 4. GRAPHICS<br />

disp_obj(Image,WindowHandle);<br />

threshold(Image,&Region,0.0,128.0);<br />

disp_obj(Region,WindowHandle);<br />

Result<br />

If the used object is valid and a correct output mode is set, disp obj returns H MSG TRUE. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

disp obj is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, T set rgb, (T )set lut, T set hsi, scale image, convert image type,<br />

min max gray<br />

Alternatives<br />

disp color, disp image, disp xld, disp region<br />

See Also<br />

open window, open textwindow, reset obj db, set comprise, T set paint, (T )set lut,<br />

draw lut, paint gray, scale image, convert image type, (T )dump window<br />

System<br />

Module<br />

T disp polygon ( Htuple WindowHandle, Htuple Row, Htuple Column )<br />

Displays a polyline.<br />

T disp polygon displays a polyline with the row coordinates Row and the column coordinates Column in the<br />

output window. The parameters Row and Column have to be provided as tuples. Straight lines are drawn between<br />

the given points. The start and the end of the polyline are not connected.<br />

The procedures used to control the display of regions (e.g. (T )set color, (T )set gray, set draw,<br />

set line width) can also be used with polylines.<br />

The given coordinates must lie within the window.<br />

Attention<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window identifier.<br />

º Row (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . polygon.y-array Htuple . long / double<br />

Row index<br />

Default Value : ’[16,80,80]’<br />

Value Suggestions : Row ¾0, 64, 128, 256, 511<br />

Typical Range of Values : 0 Row 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Column (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . polygon.x-array Htuple . long / double<br />

Column index<br />

Default Value : ’[48,16,80]’<br />

Value Suggestions : Column ¾0, 64, 128, 256, 511<br />

Typical Range of Values : 0 Column 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

/* display a rectangle */<br />

Example<br />

disp_rectangle1_margin1(long WindowHandle,<br />

long Row1, long Column1,<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.5. OUTPUT 217<br />

{<br />

long Row2, long Column2)<br />

Htuple Row, Col;<br />

create_tuple(&Row,4) ;<br />

create_tuple(&Col,4) ;<br />

set_i(Row,Row1,0) ;<br />

set_i(Col,Column1,0) ;<br />

set_i(Row,Row1,1) ;<br />

set_i(Col,Column2,1) ;<br />

set_i(Row,Row2,2) ;<br />

set_i(Col,Column2,2) ;<br />

set_i(Row,Row2,3) ;<br />

set_i(Col,Column1,3) ;<br />

set_i(Row,Row1,4) ;<br />

set_i(Col,Column1,4) ;<br />

T_disp_polygon(WindowHandle,Row,Col) ;<br />

}<br />

T disp polygon returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

T disp polygon is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, T set rgb, (T )set lut, T set hsi, set draw, (T )set color, set colored,<br />

set line width<br />

Alternatives<br />

(T )disp line, gen region polygon, disp region<br />

See Also<br />

open window, open textwindow, (T )set color, T set rgb, T set hsi, set insert,<br />

set line width<br />

Module<br />

System<br />

disp rectangle1 ( long WindowHandle, double Row1, double Column1,<br />

double Row2, double Column2 )<br />

T disp rectangle1 ( Htuple WindowHandle, Htuple Row1, Htuple Column1,<br />

Htuple Row2, Htuple Column2 )<br />

Display of rectangles aligned to the coordinate axes.<br />

(T )disp rectangle1 displays one or several rectangles in the output window. A rectangle is described by<br />

the upper left corner (Row1,Column1) and the lower right corner (Row2,Column2). If the given coordinates are<br />

not within the boundary of the window the rectangle is clipped accordingly. The procedures used to control the<br />

display of regions (e.g. (T )set color, (T )set gray, set draw, set line width) can also be used<br />

with rectangles. Several rectangles can be displayed with one call by using tuple parameters.<br />

<strong>HALCON</strong> 6.0


218 CHAPTER 4. GRAPHICS<br />

Parameter<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window identifier.<br />

º Row1 (input control) ...............................rectangle.origin.y(-array) (Htuple .) double / long<br />

Row index of the upper left corner.<br />

Default Value : 16<br />

Value Suggestions : Row1 ¾0, 64, 128, 256, 511<br />

Typical Range of Values : 0 Row1 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Column1 (input control) ...........................rectangle.origin.x(-array) (Htuple .) double / long<br />

Column index of the upper left corner.<br />

Default Value : 16<br />

Value Suggestions : Column1 ¾0, 64, 128, 256, 511<br />

Typical Range of Values : 0 Column1 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Row2 (input control) ..............................rectangle.corner.y(-array) (Htuple .) double / long<br />

Row index of the lower right corner.<br />

Default Value : 48<br />

Value Suggestions : Row2 ¾0, 64, 128, 256, 511<br />

Typical Range of Values : 0 Row2 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Row2 Row1<br />

º Column2 (input control) ..........................rectangle.corner.x(-array) (Htuple .) double / long<br />

Column index of the lower right corner.<br />

Default Value : 80<br />

Value Suggestions : Column2 ¾0, 64, 128, 256, 511<br />

Typical Range of Values : 0 Column2 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Column2 Column1<br />

Example<br />

set_color(WindowHandle,"green") ;<br />

draw_region(&MyRegion,WindowHandle) ;<br />

smallest_rectangle1(MyRegion,&R1,&C1,&R2,&C2) ;<br />

disp_rectangle1(WindowHandle,R1,C1,R2,C2) ;<br />

(T )disp rectangle1 returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )disp rectangle1 is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, T set rgb, (T )set lut, T set hsi, set draw, (T )set color, set colored,<br />

set line width<br />

Alternatives<br />

(T )disp rectangle2, gen rectangle1, disp region, (T )disp line, set shape<br />

See Also<br />

open window, open textwindow, (T )set color, set draw, set line width<br />

System<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.5. OUTPUT 219<br />

disp rectangle2 ( long WindowHandle, double CenterRow,<br />

double CenterCol, double Phi, double Length1, double Length2 )<br />

T disp rectangle2 ( Htuple WindowHandle, Htuple CenterRow,<br />

Htuple CenterCol, Htuple Phi, Htuple Length1, Htuple Length2 )<br />

Displays arbitrarily oriented rectangles.<br />

(T )disp rectangle2 draws one or several arbitrarily oriented rectangles in the output window. A rectangle<br />

is described by the center (CenterRow,CenterCol), the orientation Phi (in radians) and half the lengths of<br />

the edges Length1 and Length2. The procedures used to control the display of regions (e.g. set draw,<br />

(T )set gray, set draw) can also be used with rectangles. Several rectangles can be displayed with one call<br />

by using tuple parameters. For the use of colors with several rectangles, see (T )set color.<br />

Attention<br />

The center must lie within the window boundaries.<br />

Parameter<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window identifier.<br />

º CenterRow (input control) .......................rectangle2.center.y(-array) (Htuple .) double / long<br />

Row index of the center.<br />

Default Value : 48<br />

Value Suggestions : CenterRow ¾0, 64, 128, 256, 511<br />

Typical Range of Values : 0 CenterRow 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º CenterCol (input control) .......................rectangle2.center.x(-array) (Htuple .) double / long<br />

Column index of the center.<br />

Default Value : 64<br />

Value Suggestions : CenterCol ¾0, 64, 128, 256, 511<br />

Typical Range of Values : 0 CenterCol 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Phi (input control) ..............................rectangle2.angle.rad(-array) (Htuple .) double / long<br />

Orientation of rectangle in radians.<br />

Default Value : 0.0<br />

Value Suggestions : Phi ¾0.0, 0.785398, 1.570796, 3.1415926, 6.283185<br />

Typical Range of Values : 0.0 Phi 6.283185 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

º Length1 (input control) ..........................rectangle2.hwidth(-array) (Htuple .) double / long<br />

Half of the length of the longer side.<br />

Default Value : 48<br />

Value Suggestions : Length1 ¾0, 64, 128, 256, 511<br />

Typical Range of Values : 0 Length1 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Length2 (input control) ..........................rectangle2.hheight(-array) (Htuple .) double / long<br />

Half of the length of the shorter side.<br />

Default Value : 32<br />

Value Suggestions : Length2 ¾0, 64, 128, 256, 511<br />

Typical Range of Values : 0 Length2 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Length2 Length1<br />

set_color(WindowHandle,"green") ;<br />

Example<br />

<strong>HALCON</strong> 6.0


220 CHAPTER 4. GRAPHICS<br />

draw_region(&MyRegion,WindowHandle) ;<br />

elliptic_axis(MyRegion,&Ra,&Rb,&Phi) ;<br />

area_center(MyRegion,_,&Row,&Column) ;<br />

disp_gen_rectangle2(WindowHandle,Row,Column,Phi,Ra,Rb) ;<br />

Result<br />

(T )disp rectangle2 returns H MSG TRUE, if the parameters are correct. Otherwise an exception handling<br />

is raised.<br />

Parallelization Information<br />

(T )disp rectangle2 is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, T set rgb, (T )set lut, T set hsi, set draw, (T )set color, set colored,<br />

set line width<br />

Alternatives<br />

disp region, gen rectangle2, (T )disp rectangle1, set shape<br />

See Also<br />

open window, open textwindow, disp region, (T )set color, set draw, set line width<br />

System<br />

Module<br />

disp region ( Hobject DispRegions, long WindowHandle )<br />

Displays regions in a window.<br />

disp region displays the regions in DispRegions in the output window. The parameters for output can be<br />

set with the procedures (T )set color, (T )set gray, set draw, set line width,etc.<br />

The color(s) for the display of the regions are determined with (T )set color, T set rgb, (T )set gray<br />

or set colored. If more than one region is displayed and more than one color is set, the colors are assigned in<br />

a cyclic way to the regions.<br />

The form of the region for output can be modified by T set paint (e.g. encompassing circle, convex<br />

hull). The command set draw determines if the region is filled or only the boundary is drawn. If only the<br />

boundary is drawn, the thickness of the boundary will be determined by set line width and the style by<br />

T set line style.<br />

Parameter<br />

º DispRegions (input object) ...............................................region(-array) Hobject<br />

Regions to display.<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

Example<br />

/* Output with 12 colors: */<br />

set_colored(WindowHandle,12) ;<br />

disp_region(SomeSegments,WindowHandle) ;<br />

/* Symbolic representation: */<br />

set_draw(WindowHandle,"margin") ;<br />

set_color(WindowHandle,"red") ;<br />

set_shape(WindowHandle,"ellipse") ;<br />

disp_region(SomeSegments,WindowHandle) ;<br />

/* Representation of a margin with pattern: */<br />

set_draw(WindowHandle,"margin") ;<br />

create_tuple(&Color,2) ;<br />

set_s(Color,"blue",0) ;<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 221<br />

set_s(Color,"red",0) ;<br />

create_tuple(&Handle,1) ;<br />

set_i(Handle,WindowHandle,0) ;<br />

T_set_color(Handle,Color) ;<br />

create_tuple(&Par,2) ;<br />

set_i(Par,12,0) ;<br />

set_i(Par,3,1) ;<br />

T_set_line_style(WindowHandle,Par) ;<br />

disp_region(Segments,WindowHandle) ;<br />

disp region returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

disp region is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, T set rgb, (T )set lut, T set hsi, set shape, T set line style, set insert,<br />

set fix, set draw, (T )set color, set colored, set line width<br />

Alternatives<br />

disp obj, (T )disp arrow, (T )disp line, (T )disp circle, (T )disp rectangle1,<br />

(T )disp rectangle2, (T )disp ellipse<br />

See Also<br />

open window, open textwindow, (T )set color, set colored, set draw, set shape,<br />

T set paint, (T )set gray, T set rgb, T set hsi, T set pixel, set line width,<br />

T set line style, set insert, set fix, paint region, (T )dump window<br />

System<br />

Module<br />

disp xld ( Hobject XLDObject, long WindowHandle )<br />

DisplayanXLDobject.<br />

disp xld serves to display an XLD object of arbitrary type.<br />

Parameter<br />

º XLDObject (input object) ......................................................xld-array Hobject<br />

XLD object to display.<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

Parallelization Information<br />

disp xld is local and processed completely exclusively without parallelization.<br />

See Also<br />

disp image, disp region, (T )disp channel, disp color, (T )disp line, (T )disp arc<br />

Sub-pixel operators<br />

Module<br />

4.6 Parameters<br />

get comprise ( long WindowHandle, char *Mode )<br />

Get the output treatment of an image matrix.<br />

<strong>HALCON</strong> 6.0


222 CHAPTER 4. GRAPHICS<br />

get comprise returns the output mode of grayvalues in the window WindowHandle that is used by<br />

disp image and disp color. The output mode defines whether only the grayvalues of objects are displayed<br />

or the whole image is displayed. The query is used for temporary mode settings, i.e., the current mode is queried,<br />

then overwritten with (set comprise) and finally reset.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Mode (output control) ................................................................string char *<br />

Display mode for images.<br />

Result<br />

get comprise returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

get comprise is processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

set comprise, disp image, disp image<br />

set comprise, disp image, disp color<br />

System<br />

See Also<br />

Module<br />

get draw ( long WindowHandle, char *Mode )<br />

Get the current region fill mode.<br />

get draw returns the region fill mode of the output window. It is used by operators as disp region,<br />

(T )disp circle, (T )disp arrow, (T )disp rectangle1, (T )disp rectangle2 etc. The region<br />

fill mode is set with set draw.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Mode (output control) ................................................................string char *<br />

Current region fill mode.<br />

Result<br />

get draw returns H MSG TRUE, if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

get draw is processed completely exclusively without parallelization.<br />

set draw, disp region<br />

set draw, disp region, T set paint<br />

System<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

get fix ( long WindowHandle, char *Mode )<br />

Get mode of fixing of current look-up-table (lut).<br />

Use get fix to get mode of fixing of current look-up-table (look-up-table of valid window) set before by<br />

set fix.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 223<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Mode (output control) ................................................................string char *<br />

Current Mode of fixing.<br />

Result<br />

get fix returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

get fix is processed completely exclusively without parallelization.<br />

set fix, T set pixel, T set rgb<br />

set fix<br />

System<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

T get hsi ( Htuple WindowHandle, Htuple *Hue, Htuple *Saturation,<br />

Htuple *Intensity )<br />

Get the HSI coding of the current color.<br />

T get hsi returns the output color or grayvalues, respectively, for the window, described in Hue, Saturation<br />

and Intensity. T get hsi corresponds to the procedure T get pixel but returns the entries of the color<br />

lookup table instead of its indices. The values returned by T get hsi can be set with T set hsi.<br />

Attention<br />

The values returned by T get hsi may be inaccurate due to rounding errors. They do not necessarily match the<br />

values set with T set hsi exactly (colors are stored in RGB internally).<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º Hue (output control) ...................................................integer-array Htuple . long *<br />

Hue (color value) of the current color.<br />

º Saturation (output control) .........................................integer-array Htuple . long *<br />

Saturation of the current color.<br />

º Intensity (output control) ..........................................integer-array Htuple . long *<br />

Intensity of the current color.<br />

Result<br />

T get hsi returns H MSG TRUE, if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T get hsi is processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

T set hsi, T set rgb, disp image<br />

See Also<br />

T set hsi, (T )set color, T set rgb, trans to rgb, trans from rgb<br />

System<br />

Module<br />

get icon ( Hobject *Icon, long WindowHandle )<br />

Query the icon for region output<br />

<strong>HALCON</strong> 6.0


224 CHAPTER 4. GRAPHICS<br />

get icon queries the icon that was set with set icon.<br />

Parameter<br />

º Icon (output object) .............................................................region Hobject *<br />

Icon for the regions center of gravity.<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

Example<br />

/* draw a region and an icon. */<br />

/* set it and get it again. */<br />

draw_region(&Region,WindowHandle) ;<br />

draw_region(&Icon,WindowHandle) ;<br />

set_icon(Icon) ;<br />

set_shape(WindowHandle,"icon") ;<br />

disp_region(Region,WindowHandle) ;<br />

get_icon(&OldIcon) ;<br />

disp_region(OldIcon,WindowHandle) ;<br />

get icon always returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

get icon is processed completely exclusively without parallelization.<br />

set icon<br />

disp region<br />

System<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Module<br />

get insert ( long WindowHandle, char *Mode )<br />

Get the current display mode.<br />

get insert returns the display mode of the output window. It is used by procedures like disp region,<br />

(T )disp line, (T )disp rectangle1, etc. The mode is set with set insert. Possible values for<br />

Mode can be queried with the procedure T query insert.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Mode (output control) ................................................................string char *<br />

Display mode.<br />

Result<br />

get insert returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

get insert is processed completely exclusively without parallelization.<br />

T query insert<br />

set insert, disp image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

set insert, T query insert, disp region, (T )disp line<br />

System<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 225<br />

get line approx ( long WindowHandle, long *Approximation )<br />

Get the current approximation error for contour display.<br />

get line approx returns a parameter that controls the approximation error for region contour display in the<br />

window. It is used by the procedure disp region. Approximation controls the polygon approximation<br />

for contour display (¼ ¸ no approximation). Approximation is only important for displaying the contour of<br />

objects, especially if a line style was set with T set line style.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Approximation (output control) ...................................................string long *<br />

Current approximation error for contour display.<br />

Result<br />

get line approx returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

get line approx is processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

set line approx, T set line style, disp region<br />

See Also<br />

get region polygon, set line approx, T set line style, disp region<br />

System<br />

Module<br />

T get line style ( Htuple WindowHandle, Htuple *Style )<br />

Get the current graphic mode for contours.<br />

T get line style returns the display mode for contoures when displaying regions. It is used by procedures<br />

like disp region, (T )disp line, T disp polygon, etc. Style is set with the procedure<br />

T set line style. Style is only important for displaying the contour of objects, especially if a line style<br />

was set with T set line style.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º Style (output control) ................................................integer-array Htuple . long *<br />

Template for contour display.<br />

Result<br />

T get line style returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T get line style is local and processed completely exclusively without parallelization.<br />

T set line style, disp region<br />

System<br />

See Also<br />

Module<br />

get line width ( long WindowHandle, long *Width )<br />

Get the current line width for contour display.<br />

<strong>HALCON</strong> 6.0


226 CHAPTER 4. GRAPHICS<br />

get line width returns the line width for region display in the window. It is used by procedures<br />

like disp region, (T )disp line, T disp polygon, etc. Width is set with the procedure<br />

set line width. Width is only important for displaying the contour of objects.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Width (output control) .............................................................integer long *<br />

Current line width for contour display.<br />

Result<br />

get line width returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

get line width is processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

set line width, T set line style, disp region<br />

set line width, disp region<br />

System<br />

See Also<br />

Module<br />

T get paint ( Htuple WindowHandle, Htuple *Mode )<br />

Get the current display mode for grayvalues.<br />

T get paint returns the display mode for grayvalues in the window. Mode is used by the procedure<br />

disp image. T get paint is used for temporary changes of the grayvalue display mode. The current value<br />

is queried, then changed (with procedure T set paint) and finally the old value is written back. The available<br />

modes can be viewed with the procedure T query paint. Mode is the name of the display mode. If a mode<br />

can be customized with parameters, the parameter values are passed in a tuple after the mode name. The order of<br />

values is the same as in T set paint.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º Mode (output control) ...........................................string-array Htuple . char * / long *<br />

Name and parameter values of the current display mode.<br />

Result<br />

T get paint returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T get paint is processed completely exclusively without parallelization.<br />

T query paint<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

T set paint, disp region, disp image<br />

T set paint, T query paint, disp image<br />

System<br />

See Also<br />

Module<br />

get part ( long WindowHandle, long *Row1, long *Column1, long *Row2,<br />

long *Column2 )<br />

Get the image part.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 227<br />

get part returns the upper left and lower right corner of the image part shown in the window. The image part<br />

can be changed with the procedure set part (Default is the whole image).<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Row1 (output control) .....................................................rectangle.origin.y long *<br />

Row index of the image part’s upper left corner.<br />

º Column1 (output control) .................................................rectangle.origin.x long *<br />

Column index of the image part’s upper left corner.<br />

º Row2 (output control) .....................................................rectangle.corner.y long *<br />

Row index of the image part’s lower right corner.<br />

º Column2 (output control) ................................................rectangle.corner.x long *<br />

Column index of the image part’s lower right corner.<br />

Result<br />

get part returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

get part is processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

set part, disp region, disp image<br />

See Also<br />

set part, disp image, disp region, disp color<br />

System<br />

Module<br />

get part style ( long WindowHandle, long *Style )<br />

Get the current interpolation mode for grayvalue display.<br />

get part style returns the interpolation mode used for displaying an image part in the window. An interpolation<br />

takes place if the output window is larger than the image format or the image output format (see set part).<br />

<strong>HALCON</strong> supports three interpolation modes:<br />

0 no interpolation (low quality, very fast).<br />

1 unweighted interpolation (average quality and computation time)<br />

2 weighted interpolation (high quality, slow)<br />

The current mode can be changed with set part style.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Style (output control) .............................................................integer long *<br />

Interpolation mode for image display: 0 (fast, low quality) to 2 (slow, high quality).<br />

Value List : Style ¾0, 1, 2<br />

Result<br />

get part style returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

get part style is processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

set part style, disp region, disp image<br />

See Also<br />

set part style, set part, disp image, disp color<br />

System<br />

Module<br />

<strong>HALCON</strong> 6.0


228 CHAPTER 4. GRAPHICS<br />

T get pixel ( Htuple WindowHandle, Htuple *Pixel )<br />

Get the current color lookup table index.<br />

T get pixel returns the internal coding of the output grayvalue or color, respectively, for the window. If the<br />

output mode is set to color(s) or grayvalue(s) (see (T )set color or (T )set gray), then the color- or grayvalues<br />

are transformed for internal use. The internal code is then used for (physical) screen display. The transformation<br />

depends on the mapping characteristics and the condition of the output device and can be different in<br />

different program runs. Don’t confuse the term ”‘pixel”’ with the term ”‘pixel”’ in image processing (the other<br />

procedure is get grayval). Here a pixel is meant to be the color loookup table index.<br />

With T get pixel it is possible to save the output mode without knowing whether colors or grayvalues are used.<br />

Pixel is set with the procedure T set pixel.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º Pixel (output control) .................................................string-array Htuple . long *<br />

Index of the current color loopup table.<br />

Result<br />

get part style returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T get pixel is processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

T set pixel, disp region, disp image<br />

T set pixel, set fix<br />

System<br />

See Also<br />

Module<br />

T get rgb ( Htuple WindowHandle, Htuple *Red, Htuple *Green,<br />

Htuple *Blue )<br />

Get the current color in RGB-coding.<br />

T get rgb returns the output colors or grayvalues, respectively, for the output window. They are defined by the<br />

three color components red, green and blue.<br />

T get rgb is like T get pixel but returns the entries of the color lookup table rather than the indices. The<br />

values returned by T get rgb can be set with T set rgb.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º Red (output control) ...................................................integer-array Htuple . long *<br />

The current color’s red value.<br />

º Green (output control) ................................................integer-array Htuple . long *<br />

The current color’s green value.<br />

º Blue (output control) .................................................integer-array Htuple . long *<br />

The current color’s blue value.<br />

Result<br />

T get rgb returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T get rgb is processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

T set rgb, disp region, disp image<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 229<br />

T set rgb<br />

System<br />

See Also<br />

Module<br />

get shape ( long WindowHandle, char *DisplayShape )<br />

Get the current region output shape.<br />

get shape returns the shape in which regions are displayed.<br />

T query shape and then changed with set shape.<br />

Parameter<br />

The available shapes can be queried with<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º DisplayShape (output control) .....................................................string char *<br />

Current region output shape.<br />

Result<br />

get shape returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

get shape is processed completely exclusively without parallelization.<br />

T query shape<br />

set shape, disp region<br />

set shape, T query shape, disp region<br />

System<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

T query all colors ( Htuple WindowHandle, Htuple *Colors )<br />

Query all color names.<br />

T query all colors returns the names of all colors that are known to <strong>HALCON</strong> . That doesn’t mean, that<br />

these colors are available for specific screens. On some screens there may only be a subset of colors available (see<br />

T query color). Before opening the first window, set system can be used to define which and how many<br />

colors should be used. The <strong>HALCON</strong> colors are used to display regions (disp region, T disp polygon,<br />

(T )disp circle, etc.). They can be defined with (T )set color.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º Colors (output control) ................................................string-array Htuple . char *<br />

Color names.<br />

Example<br />

Htuple Colors,ColorsAtWindow,WindowHandleTuple ;<br />

create_tuple(&WindowHandleTuple,1) ;<br />

open_window(0,0,1,1,"root","invisible","",&WindowHandle) ;<br />

set_i(WindowHandleTuple, WindowHandle, 0) ;<br />

T_query_all_colors(WindowHandleTuple,&Colors) ;<br />

/* interactive selection from Colors, provide als result ActColors */<br />

<strong>HALCON</strong> 6.0


230 CHAPTER 4. GRAPHICS<br />

set_system("graphic_colors",ActColors) ;<br />

T_query_color(WindowHandleTuple,&ColorsAtWindow) ;<br />

close_window(WindowHandle) ;<br />

for (i=0; i


4.6. PARAMETERS 231<br />

(T )set color, disp region<br />

Possible Successor Functions<br />

See Also<br />

T query all colors, (T )set color, disp region, open window, open textwindow<br />

System<br />

Module<br />

T query colored ( Htuple *PossibleNumberOfColors )<br />

Query the number of colors for color output.<br />

T query colored returns all possible parameter values for set colored. set colored defines how many<br />

colors are used for region or graphics output.<br />

Parameter<br />

º PossibleNumberOfColors (output control) .........................integer-array Htuple . long *<br />

Tuple of the possible numbers of colors.<br />

Example<br />

Htuple Colors ;<br />

regiongrowing(Image,&Seg,5,5,6,100) ;<br />

T_query_colored(&Colors) ;<br />

set_colored(WindowHandle,get_i(Colors,1)) ;<br />

disp_region(Seg,WindowHandle) ;<br />

Result<br />

T query colored always returns H MSG TRUE.<br />

Parallelization Information<br />

T query colored is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

set colored, (T )set color, disp region<br />

T query color<br />

set colored, (T )set color<br />

System<br />

Alternatives<br />

See Also<br />

Module<br />

T query gray ( Htuple WindowHandle, Htuple *Grayval )<br />

Query the displayable grayvalues.<br />

T query gray returns all grayvalues that are used for grayvalue output (disp image) and that can be reproduced<br />

exactly in the window. They can be set with the (T )set gray call. The number of displayable grayvalues<br />

can be set with set system(’num gray *’,...) before opening the first window.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º Grayval (output control) .............................................integer-array Htuple . long *<br />

Tuple of all displayable grayvalues.<br />

Result<br />

T query gray returns H MSG TRUE, if the window is valid. Otherwise an exception handling is raised.<br />

<strong>HALCON</strong> 6.0


232 CHAPTER 4. GRAPHICS<br />

Parallelization Information<br />

T query gray is local and processed completely exclusively without parallelization.<br />

(T )set gray, disp region<br />

(T )set gray, disp image<br />

System<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

T query insert ( Htuple WindowHandle, Htuple *Mode )<br />

Query the possible graphic modes.<br />

T query insert returns the possible modes pixels can be displayed in the output window. New pixels may e.g.<br />

overwrite old ones. In most of the cases there is a functional relationship between old and new values.<br />

Possible display functions:<br />

’copy’: overwrite displayed pixels<br />

’xor’: display old ”‘xor”’ new pixels<br />

’not’: complement displayed pixels<br />

”‘copy”’ is always available.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º Mode (output control) ..................................................string-array Htuple . char *<br />

Display function name.<br />

Result<br />

T query insert returns H MSG TRUE, if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T query insert is local and processed completely exclusively without parallelization.<br />

set insert, disp region<br />

set insert, get insert<br />

System<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

query line width ( long *Min, long *Max )<br />

Query the possible line widths.<br />

query line width returns the minimal (Min) and maximal (Max) values of widths of region border<br />

which can be displayed. Setting of the border width is done with set line width. Border width is<br />

used by operators like disp region, (T )disp line, (T )disp circle, (T )disp rectangle1,<br />

(T )disp rectangle2 etc. if the drawing mode is ”‘margin”’ (set draw(::WindowHandle,’margin’:)).<br />

Parameter<br />

º Min (output control) ................................................................integer long *<br />

Displayable minimum width.<br />

º Max (output control) ................................................................integer long *<br />

Displayable maximum width.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 233<br />

Result<br />

query line width returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

query line width is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

get line width, set line width, T set line style, (T )disp line<br />

See Also<br />

(T )disp circle, (T )disp line, (T )disp rectangle1, (T )disp rectangle2,<br />

disp region, set line width, get line width, T set line style<br />

System<br />

Module<br />

T query paint ( Htuple WindowHandle, Htuple *Mode )<br />

Query the grayvalue display modes.<br />

T query paint returns the names of all grayvalue display modes (e.g. ’gray’, ’3D-plot’, ’contourline’, etc.) for<br />

the output window. These modes are used by T set paint. T query paint only returns the names of the<br />

display values, not the additional parameters that may be necessary for some modes.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º Mode (output control) ..................................................string-array Htuple . char *<br />

Grayvalue display mode names.<br />

Result<br />

T query paint returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T query paint is local and processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

T get paint, T set paint, disp image<br />

T set paint, T get paint, disp image<br />

System<br />

See Also<br />

Module<br />

T query shape ( Htuple *DisplayShape )<br />

Query the region display modes.<br />

T query shape returns the names of all region display modes (e.g. ’original’, ’circle’, ’rectangle1’, ’rectangle2’,<br />

’ellipse’, etc.) for the window. They are used by set shape.<br />

Parameter<br />

º DisplayShape (output control) .......................................string-array Htuple . char *<br />

region display mode names.<br />

Result<br />

T query shape returns H MSG TRUE, if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T query shape is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

get shape, set shape, disp region<br />

<strong>HALCON</strong> 6.0


234 CHAPTER 4. GRAPHICS<br />

set shape, get shape, disp region<br />

System<br />

See Also<br />

Module<br />

set color ( long WindowHandle, const char *Color )<br />

T set color ( Htuple WindowHandle, Htuple Color )<br />

Set output color.<br />

(T )set color defines the colors for region output in the window. The available colors can be queried with the<br />

procedure T query color. The ”‘colors”’ ’black’ and ’white’ are available for all screens. If colors are used<br />

that are not displayable on the screen, <strong>HALCON</strong> can choose a similar, displayable color of the output. For this,<br />

set check(’˜color’:) must be called. Furthermore, the list of available colors can be set with the procedure<br />

set system(’graphic colors’,...). That must be done before opening the first output window. If only<br />

a single color is passed, all output is in this color. If a tuple of colors is passed, the output color of regions is modulo<br />

to the number of colors. In the example below, the first circle is displayed red, the second in green and the third<br />

in red again. <strong>HALCON</strong> always begins output with the first color passed. Note, that the number of output colors<br />

depends on the number of objects that are displayed in one procedure call. If only single objects are displayed,<br />

they always appear in the first color, even if the consist of more than one connected components.<br />

The defined colors are used until (T )set color, T set pixel, T set rgb, T set hsi or<br />

(T )set gray is called again.<br />

Colors are defined seperately for each window. They can only be changed for the valid window.<br />

Color is used in procedures with region output like disp region, (T )disp line,<br />

(T )disp rectangle1, (T )disp arrow etc. It is also used by procedures with grayvalue output in<br />

certain output modes (e.g. ’3D-plot’,’histogram’, ’contourline’, etc. See T set paint).<br />

Parameter<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window id.<br />

º Color (input control) ..........................................string(-array) (Htuple .) const char *<br />

Output color names.<br />

Default Value : ’white’<br />

Example<br />

Htuple Colors, WindowHandleTuple ;<br />

create_tuple(Colors,2) ;<br />

set_s(Colors,"red",0) ;<br />

set_s(Colors,"green",1) ;<br />

create_tuple(&WindowHandleTuple,1) ;<br />

set_i(WindowHandleTuple, WindowHandle,0) ;<br />

T_set_color(WindowHandleTuple,Colors) ;<br />

disp_circle(WindowHandle,(double)100.0,(double)200.0,(double)100.0) ;<br />

disp_circle(WindowHandle,(double)200.0,(double)300.0,(double)100.0) ;<br />

disp_circle(WindowHandle,(double)300.0,(double)100.0,(double)100.0) ;<br />

Result<br />

(T )set color returns H MSG TRUE if the window is valid and the passed colors are displayable on the<br />

screen. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

(T )set color is local and processed completely exclusively without parallelization.<br />

T query color<br />

Possible Predecessor Functions<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 235<br />

disp region<br />

T set rgb, T set hsi<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

T get rgb, disp region, set fix, T set paint<br />

System<br />

Module<br />

set colored ( long WindowHandle, long NumberOfColors )<br />

Set multiple output colors.<br />

set colored is a shortcut for certain (T )set color calls. It allows the user to display a region set in different<br />

colors. NumberOfColors defines the number of colors that are used. Valid values for NumberOfColors<br />

can be queried with T query colored. Furthermore, the list of available colors can be set with the procedure<br />

set system(’graphic colors’,...). That must be done before opening the first output window.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º NumberOfColors (input control) ....................................................integer long<br />

Number of output colors.<br />

Default Value : 12<br />

Example<br />

Htuple TColors,SColors, WindowHandleTuple ;<br />

set_colored(WindowHandle,Num) ;<br />

if(Num == 3)<br />

{<br />

create_tuple(TColors,3) ;<br />

set_s(Colors,"red",0) ;<br />

set_s(Colors,"green",1) ;<br />

set_s(Colors,"blue",2) ;<br />

create_tuple(&WindowHandleTuple,1) ;<br />

set_i(WindowHandleTuple, WindowHandle, 0) ;<br />

T_set_color(WindowHandleTuple,TColors) ;<br />

}<br />

if(Num == 6)<br />

{<br />

create_tuple(SColors,6) ;<br />

set_s(Colors,"red",0) ;<br />

set_s(Colors,"green",1) ;<br />

set_s(Colors,"blue",2) ;<br />

set_s(Colors,"cyan",3) ;<br />

set_s(Colors,"magenta",4) ;<br />

set_s(Colors,"yellow",5) ;<br />

T_set_color(WindowHandleTuple,SColors) ;<br />

}<br />

Result<br />

set colored returns H MSG TRUE if NumberOfColors is correct and the window is valid. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

set colored is local and processed completely exclusively without parallelization.<br />

<strong>HALCON</strong> 6.0


236 CHAPTER 4. GRAPHICS<br />

Possible Predecessor Functions<br />

T query colored, (T )set color<br />

disp region<br />

Possible Successor Functions<br />

See Also<br />

T query colored, (T )set color, disp region<br />

System<br />

Module<br />

set comprise ( long WindowHandle, const char *Mode )<br />

Define the image matrix output clipping.<br />

set comprise defines the image matrix output clipping. If Mode is set to ’object’, only grayvalues belonging<br />

to the output object are displayed. If set to ’image’, the whole image matrix is displayed. Default is ’object’.<br />

Attention<br />

If Mode was set to ’image’, undefined grayvalues may be displayed. Depending on the context they are black or<br />

can have random content. See the examples.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Mode (input control) ............................................................string const char *<br />

Clipping mode for grayvalue output.<br />

Default Value : ’object’<br />

Value List : Mode ¾’image’, ’object’<br />

Example<br />

open_window(0,0,-1,-1,"root","visible","",&WindowHandle) ;<br />

read_image(&Image,"fabrik") ;<br />

threshold(Image,&Seg,100,255) ;<br />

set_system("init_new_image","false") ;<br />

sobel_amp(Image,&Sob,"sum_abs",3) ;<br />

disp_image(Sob,WindowHandle) ;<br />

get_comprise(&Mode) ;<br />

fwrite_string("Current mode for gray values: ") ;<br />

fwrite_string(Mode) ;<br />

fnew_line() ;<br />

set_comprise(WindowHandle,"image") ;<br />

get_mbutton(WindowHandle,_,_,_) ;<br />

disp_image(Sob,WindowHandle) ;<br />

fwrite_string("Current mode for gray values: image") ;<br />

fnew_line() ;<br />

Result<br />

set comprise returns H MSG TRUE if Mode is correct and the window is valid. Otherwise an exception<br />

handling is raised.<br />

Parallelization Information<br />

set comprise is processed completely exclusively without parallelization.<br />

get comprise<br />

disp image<br />

get comprise, disp image, disp color<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 237<br />

System<br />

Module<br />

set draw ( long WindowHandle, const char *Mode )<br />

Define the region fill mode.<br />

set draw defines the region fill mode. If Mode is set to ’fill’, output regions are filled, if set to ’margin’,<br />

only contours are displayed. Setting Mode only affects the valid window. It is used by procedures with region<br />

output like disp region, (T )disp circle, (T )disp rectangle1, (T )disp rectangle2,<br />

(T )disp arrow etc. It is also used by procedures with grayvalue output for some grayvalue output modes (e.g.<br />

’histogram’, see T set paint). If the mode is ’margin’, the contour can be affected with set line width,<br />

set line approx and T set line style.<br />

Attention<br />

If the output mode is ’margin’ and the line width is more than one, objects may not be displayed.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Mode (input control) ............................................................string const char *<br />

Fill mode for region output.<br />

Default Value : ’fill’<br />

Value List : Mode ¾’fill’, ’margin’<br />

Result<br />

set draw returns H MSG TRUE if Mode is correct and the window is valid. Otherwise an exception handling<br />

is raised.<br />

Parallelization Information<br />

set draw is local and processed completely exclusively without parallelization.<br />

get draw<br />

disp region<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

get draw, disp region, T set paint, disp image, set line width, T set line style<br />

System<br />

Module<br />

set fix ( long WindowHandle, const char *Mode )<br />

Set fixing of ”‘look-up-table”’ (lut)<br />

Behaviour for Mode = ’true’: set fix fixes that pixel lastly ascertained by one of the operators (T )set gray,<br />

(T )set color, T set hsi or T set rgb (Remark: Here a pixel is the index within the current look-uptable).<br />

To assign a new color to a fixed pixel set a color or gray value by using (T )set color, T set rgb,<br />

T set hsi or (T )set gray. This makes it possible to define any color ((T )set color), any gray value<br />

((T )set gray) and any color combination (T set rgb, T set hsi) at any position of the look-up-table.<br />

Mode set to ’false’ reset the fixing. To modify or create a look-up-table process T set pixel, set fix<br />

(WindowHandle,’true’), T set rgb and set fix(WindowHandle,’false’) one after another.<br />

Attention<br />

As a side effect set fix can change colors of ”‘non-<strong>HALCON</strong> windows”’.<br />

<strong>HALCON</strong> 6.0


238 CHAPTER 4. GRAPHICS<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Mode (input control) ............................................................string const char *<br />

Mode of fixing.<br />

Default Value : ’true’<br />

Value List : Mode ¾’true’, ’false’<br />

Result<br />

set fix returns H MSG TRUE if the window is valid, the hardware supports a look-up-table and all parameters<br />

are correct. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

set fix is local and processed completely exclusively without parallelization.<br />

get fix<br />

T set pixel, T set rgb<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

get fix, T set pixel, T set rgb, (T )set color, T set hsi, (T )set gray<br />

System<br />

Module<br />

set gray ( long WindowHandle, long GrayValues )<br />

T set gray ( Htuple WindowHandle, Htuple GrayValues )<br />

Define grayvalues for region output.<br />

(T )set gray defines the grayvalues for region output. Grayvalues are defined as the range of the<br />

color lookup table that is used for grayvalue output with disp image in conjunction with T set paint<br />

(WindowHandle,’gray’). These entries can be modified by (T )set lut. So a ’grayvalue’ is the color in<br />

which a pixel with the same value is displayed (not necessarily really gray). In general, when changing the color<br />

lookup table with (T )set lut, the colors of the displayed image will change too.<br />

If a grayvalue is needed as a color for image output (i.e. no color changes with (T )set lut are possible), it can<br />

be set with (T )set color(WindowHandle,’gray’).<br />

If only a single grayvalue is passed, all output will take place in that grayvalue. If a tuple of grayvalues is passed,<br />

all output will take place in grayvalues modulo the number of tuple elements. In the example below, the first circle<br />

is displayed with grayvalue 100, the second with 200 and the third with 100 again. Every output procedure starts<br />

with the first grayvalue. Note, that the number of output grayvalues depends on the number of objects that are<br />

displayed in one procedure call. If only single objects are displayed, they always appear in the first grayvalue, even<br />

if the consist of more than one connected components.<br />

When the procedures (T )set gray, (T )set color, T set rgb, T set hsi are called, the overwrite<br />

the existing values. If not all grayvalues are displayable on the output device, the number range of GrayValues<br />

(0..255) is dithered to the range of displayable grayvalues. In any case 0 is displayed as black and 255 as white. The<br />

displayable grayvalues can be queried with the procedure T query gray. Furthermore, the number of actually<br />

displayed grayvalues can be changed with set system(’num gray *’,...). This must be done before<br />

opening the first window. With set check(’˜color’:) error messages can be suppressed if a grayvalue<br />

can’t be displayed on the screen. In that case, a similar grayvalue is displayed.<br />

Parameter<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window id.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 239<br />

º GrayValues (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Grayvalues for region output.<br />

Default Value : 255<br />

Value Suggestions : GrayValues ¾0, 1, 2, 10, 16, 32, 64, 100, 120, 128, 250, 251, 252, 253, 254, 255<br />

Typical Range of Values : 0 GrayValues 255<br />

Example<br />

Htuple GrayValues ;<br />

create_tuple(&GrayValues,2) ;<br />

set_i(GrayValues,100,0) ;<br />

set_i(GrayValues,200,0) ;<br />

T_set_gray(WindowHandle,GrayValues) ;<br />

disp_circle(WindowHandle,(double)100.0,(double)200.0,(double)100.0) ;<br />

disp_circle(WindowHandle,(double)200.0,(double)300.0,(double)100.0) ;<br />

disp_circle(WindowHandle,(double)300.0,(double)100.0,(double)100.0) ;<br />

Result<br />

(T )set gray returns H MSG TRUE if GrayValues is displayable and the window is valid. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

(T )set gray is local and processed completely exclusively without parallelization.<br />

disp region<br />

T get pixel, (T )set color<br />

System<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

T set hsi ( Htuple WindowHandle, Htuple Hue, Htuple Saturation,<br />

Htuple Intensity )<br />

Define output colors (HSI-coded).<br />

T set hsi sets the region output color(s)/grayvalue(s) for the valid window.<br />

Saturation,andIntensity. Transformation from HSI to RGB is done with:<br />

Colors are passed as Hue,<br />

À ´¾ÀÙµ¾<br />

Á ´ÔÁÒØÒ×Øݵ¾<br />

Å ½ ´×Ò ´ÀµËØÙÖØÓÒµ´¾ Ô µ<br />

Å ¾ ´Ó× ´ÀµËØÙÖØÓÒµ´¾ Ô ¾µ<br />

Ê ´¾Å ½ · Áµ´ Ô µ<br />

´ Å ½ · Å ¾ · Áµ´ Ô <br />

´ Å ½ Å ¾ · Áµ´ Ô µ<br />

Ê Ê £ ¾<br />

ÖÒ £ ¾<br />

ÐÙ £ ¾<br />

If only one combination is passed, all output will take place in that color. If a tuple of colors is passed, the output<br />

color of regions and geometric objects is modulo to the number of colors. <strong>HALCON</strong> always begins output with<br />

the first color passed. Note, that the number of output colors depends on the number of objects that are displayed<br />

in one procedure call. If only single objects are displayed, they always appear in the first color, even if the consist<br />

of more than one connected components.<br />

Selected colors are used until the next call of (T )set color,T set pixel, T set rgb or (T )set gray.<br />

Colors are relevant to windows, i.e. only the colors of the valid window can be set. Region output colors are used<br />

<strong>HALCON</strong> 6.0


240 CHAPTER 4. GRAPHICS<br />

by operatores like disp region, (T )disp line, (T )disp rectangle1, (T )disp rectangle2,<br />

(T )disp arrow, etc. It is also used by procedures with grayvalue output in certain output modes (e.g. ’3Dplot’,’histogram’,<br />

’contourline’, etc. See T set paint).<br />

Attention<br />

The selected intensities may not be available for the selected hues. In that case, the intensities will be lowered<br />

automatically.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º Hue (input control) .....................................................integer-array Htuple . long<br />

Hue for region output.<br />

Default Value : 30<br />

Typical Range of Values : 0 Hue 255<br />

Restriction : ´0 Hueµ ´Hue 255µ<br />

º Saturation (input control) ............................................integer-array Htuple . long<br />

Saturation for region output.<br />

Default Value : 255<br />

Typical Range of Values : 0 Saturation 255<br />

Restriction : ´0 Saturationµ ´Saturation 255µ<br />

º Intensity (input control) .............................................integer-array Htuple . long<br />

Intensity for region output.<br />

Default Value : 84<br />

Typical Range of Values : 0 Intensity 255<br />

Restriction : ´0 Intensityµ ´Intensity 255µ<br />

Result<br />

T set hsi returns H MSG TRUE if the window is valid and the output colors are displayable. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

T set hsi is local and processed completely exclusively without parallelization.<br />

T get hsi<br />

disp region<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

T get hsi, T get pixel, trans from rgb, trans to rgb, disp region<br />

System<br />

Module<br />

set icon ( Hobject Icon, long WindowHandle )<br />

Icon definition for region output.<br />

set icon defines an icon for region output (disp region). It is displayed in the regions center of gravity. The<br />

use of this icon is activated with set shape.<br />

Parameter<br />

º Icon (input object) ................................................................region Hobject<br />

Icon for center of gravity.<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

/* draw a region and an icon */<br />

Example<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 241<br />

draw_region(&Region,WindowHandle) ;<br />

draw_region(&Icon,WindowHandle) ;<br />

set_icon(Icon) ;<br />

set_shape(WindowHandle,"icon") ;<br />

disp_region(Region,WindowHandle) ;<br />

Result<br />

set icon returns H MSG TRUE if exactly one region is passed. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

set icon is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

gen circle, gen ellipse, gen rectangle1, gen rectangle2, draw region<br />

set shape, disp region<br />

System<br />

Possible Successor Functions<br />

Module<br />

set insert ( long WindowHandle, const char *Mode )<br />

Define the pixel output function.<br />

set insert defines the function, with which pixels are displayed in the output window. It is e.g. possible for a<br />

pixel to overwrite the old value. In most of the cases there is a functional relationship between old and new values.<br />

The definiton value is only valid for the valid window. Output procedures that honor Mode are e.g. disp region,<br />

T disp polygon,(T )disp circle.<br />

Possible display functions are:<br />

’copy’: overwrite displayed pixels<br />

’xor’: display old ”xor” new pixels<br />

’not’: complement displayed pixels<br />

There may not be all functions available, depending on the physical display. However, ”‘copy”’ is always available.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Mode (input control) ............................................................string const char *<br />

Name of the display function.<br />

Default Value : ’copy’<br />

Value List : Mode ¾’copy’, ’xor’, ’not’<br />

Result<br />

set insert returns H MSG TRUE if the paramter is correct and the window is valid. Otherwise an exception<br />

handling is raised.<br />

Parallelization Information<br />

set insert is local and processed completely exclusively without parallelization.<br />

T query insert, get insert<br />

disp region<br />

get insert, T query insert<br />

System<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


242 CHAPTER 4. GRAPHICS<br />

set line approx ( long WindowHandle, long Approximation )<br />

Define the approximation error for contour display.<br />

set line approx defines the approximation error for region contour display in the window.<br />

Approximation values greater than zero cause a polygon approximation smoothing (with a maximum<br />

polygon/contour deviation of Approximation pixel). The approximation algorithm is the same as in<br />

get region polygon. set line approx is important for contour output via T set line style.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Approximation (input control) .....................................................integer long<br />

Maximum deviation from the original contour.<br />

Default Value : 0<br />

Typical Range of Values : 0 Approximation<br />

Restriction : Approximation 0<br />

Example<br />

/* Calling */<br />

set_line_approx(WindowHandle,Approximation) ;<br />

set_draw(WindowHandle,"margin") ;<br />

disp_region(Obj,WindowHandle) ;<br />

/* correspond with */<br />

Htuple Approximation,Row,Col, WindowHandleTuple ;<br />

create_tuple(&Approximation,1) ;<br />

set_i(Approximation,0,0) ;<br />

create_tuple(&WindowHandleTuple,1) ;<br />

set_i(WindowHandleTuple,WindowHandle, 0) ;<br />

T_get_region_polygon(Obj,Approximation,&Row,&Col) ;<br />

T_disp_polygon(WindowHandleTuple,Row,Col) ;<br />

Result<br />

set line approx returns H MSG TRUE if the parameter is correct and the window is valid. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

set line approx is processed completely exclusively without parallelization.<br />

get line approx<br />

disp region<br />

get region polygon, T disp polygon<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

get line approx, T set line style, set draw, disp region<br />

System<br />

Module<br />

T set line style ( Htuple WindowHandle, Htuple Style )<br />

Define a contour output pattern.<br />

T set line style defines the output pattern of region contours. The information is used by procedures<br />

like disp region, (T )disp line, T disp polygon etc. The current value can be queried with<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 243<br />

T get line style. Style contains up to five pairs of values. The first value is the length of the visible<br />

contour part, the second is the length of the invisible part. The value pairs are used cyclical for contour output.<br />

Attention<br />

T set line style does an implicit polygon approximation (see set line approx(WindowHandle,3)).<br />

It is only possible to enlarge it with set line approx.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º Style (input control) ...................................................integer-array Htuple . long<br />

Countour pattern.<br />

Default Value : ’[]’<br />

Htuple LineStyle ;<br />

Example<br />

/* stroke line: X-Windows */<br />

create_tuple(&LineStyle,2) ;<br />

set_i(LineStyle,20,0) ;<br />

set_i(LineStyle,7,1) ;<br />

T_set_line_style(WindowHandle,LineStyle) ;<br />

destroy_tuple(LineStyle) ;<br />

/* point-stroke line: X-Windows */<br />

create_tuple(&LineStyle,4) ;<br />

set_i(LineStyle,20,0) ;<br />

set_i(LineStyle,7,1) ;<br />

set_i(LineStyle,3,2) ;<br />

set_i(LineStyle,7,3) ;<br />

T_set_line_style(WindowHandle,LineStyle) ;<br />

destroy_tuple(LineStyle) ;<br />

/* passing line (standard) */<br />

create_tuple(&LineStyle,0) ;<br />

T_set_line_style(WindowHandle,LineStyle) ;<br />

destroy_tuple(LineStyle) ;<br />

Result<br />

T set line style returns H MSG TRUE if the parameter is correct and the window is valid. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

T set line style is local and processed completely exclusively without parallelization.<br />

T get line style<br />

disp region<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

T get line style, set line approx, disp region<br />

System<br />

Module<br />

set line width ( long WindowHandle, long Width )<br />

Define the line width for region contour output.<br />

<strong>HALCON</strong> 6.0


244 CHAPTER 4. GRAPHICS<br />

set line width defines the line width (in pixel) in which a region contour is displayed (e.g. with<br />

disp region, (T )disp line, T disp polygon, etc.) The procedure get line width returns the current<br />

value for the window. Some output devices may not allow to change the contour width. If it is possible for the<br />

current device, it can be queried with query line width.<br />

Attention<br />

The line width is important if the output mode was set to ’margin’ (see set draw). If the line width is greater<br />

than one, regions may not always be displayed correctly.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Width (input control) ................................................................integer long<br />

Line width for region output in contour mode.<br />

Default Value : 1<br />

Restriction : Width 1<br />

Result<br />

set line width returns H MSG TRUE if the parameter is correct and the window is valid. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

set line width is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

query line width, get line width<br />

disp region<br />

Possible Successor Functions<br />

See Also<br />

get line width, query line width, set draw, disp region<br />

System<br />

Module<br />

T set paint ( Htuple WindowHandle, Htuple Mode )<br />

Define the grayvalue output mode.<br />

T set paint defines the output mode for grayvalue display (single- or multichannel) in the window. The mode<br />

is used by disp image.<br />

This page describes the different modes, that can be used for grayvalue output. It should be noted, that the mode<br />

’default’ is the most suitable.<br />

The hardware characteristics determine how grayvalues can be displayed. On a screen with one to seven bit planes,<br />

only binary data can be displayed. On screens with at least eight bit planes, it is possible to display multiple<br />

grayvalues. For binary displays <strong>HALCON</strong> includes algorithms with dithering matrix (fast, but low resolution),<br />

minimal error (good, but slow) and thresholding. Using the thresholding algorithm, the threshold can be passed as<br />

a second parameter (a tuple with the string ’threshold’ and the actual threshold, e.g.: [’theshold’, 100]).<br />

Displays with eight bit planes use approximately 200 grayvalues for output. Of course it is still possible to use a<br />

binary display on those displays.<br />

A different way to display grayvalues is the histogram (mode: ’histogram’). This mode has two additional parameter<br />

values: Row (second value) and column (third value). They denote row and column of the histogram center<br />

for positioning on the screen. The scale factor (fourth value) determines the histogram size: a scale factor of 1<br />

distinguishes 256 grayvalues, 2 distinguishes 128 grevalues, and so on. The four values are passed as a tuple,<br />

e.g. [’histogram’, 256,256,1]. If only the first value is passed (’histogram’), the other values are set to defaults<br />

or the last values, respectively. For histogram computation see gray histo. Histogram output honors the same<br />

parameters as procedures like disp region etc. (e.g. (T )set color, set draw,etc.)<br />

Yet another mode is the display of relative frequencies of the number of connection components (”’component<br />

histogram”’). For informations on computing the component histogram see shape histo all). Positioning<br />

and resolution are exactly as in the mode ’histogram’.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 245<br />

In mode ’mean’, all object regions are displayed in their mean grayvalue.<br />

The modes ’line’ and ’column’ allow the display of lines or columns, respecively. The position (line- and columnindex)<br />

is passed with the second paramter value. The third parameter value is the scale factor in percent (100 means<br />

1 pixel per grayvalue, 50 means one pixel per two grayvalues).<br />

Gray images can also be interpreted as 3d data, depending on the grayvalue. To view these 3d plots, select the<br />

modes ’contourline’, ’3D-plot’ or ’3D-plot hidden’.<br />

Two-channel images can be viewed as ’vectorfield’.<br />

Three-channel images are interpreted as RGB images. They can be displayed in three different modes. Two of<br />

them can be optimized by Floyd-Steinberg dithering.<br />

Paramters for modes that need more than one parameter can be passed the following ways:<br />

¯ Only the name of the mode is passed: the defaults or the last values are used, respectively. Example:<br />

T set paint(WindowHandle,’contourline’)<br />

¯ All values are passed: all output characteristics can be set. Example: T set paint<br />

(WindowHandle,[’contourline’,10,1])<br />

¯ Only the first n values are passed: only the passed values are changed. Example: T set paint<br />

(WindowHandle,[’contourline’,10])<br />

¯ Some of the values are replaced by an asterisk (’*’): The value of the replaced parameters is not changed.<br />

Example: T set paint(WindowHandle,[’contourline’,’*’,1])<br />

If the current mode is ’default’, <strong>HALCON</strong> chooses a suitable algorithm for the output of 2- and 3-channel images..<br />

No T set paint call is necessary in this case.<br />

Apart from T set paint there are other procedures that affect the output of grayvalues. The most important<br />

of them are set part, set part style,(T )set lut and set lut style. Some output modes display<br />

grayvalues using region output (e.g. ’histogram’,’contourline’,’3D-plot’, etc.). In these modes, paramters<br />

set with (T )set color, T set rgb,T set hsi, T set pixel, set shape, set line width and<br />

set insert influence grayvalue output. This can lead to unexpected results when using set shape<br />

(’convex’) and T set paint(WindowHandle,’histogram’). Here the convex hull of the histogram<br />

is displayed.<br />

Modes:<br />

¯ one-channel images:<br />

’default’ optimal display on given hardware<br />

’gray’ grayvalue output<br />

’mean’ mean grayvalue<br />

’dither4 1’ binary image, dithering matrix 4x4<br />

’dither4 2’ binary image, dithering matrix 4x4<br />

’dither4 3’ binary image, dithering matrix 4x4<br />

’dither8 1’ binary image, dithering matrix 8x8<br />

’floyd steinberg’ binary image, optimal grayvalue simulation<br />

[’threshold’,Threshold ]<br />

’threshold’ binary image, threshold: 128 (default)<br />

[’threshold’,200 ] binary image, any threshold: (here: 200)<br />

[’histogram’,Line,Column,Scale ]<br />

’histogram’ grayvalue output as histogram.<br />

position default: max. size, in the window center<br />

[’histogram’,256,256,2 ] grayvalue output as histogram, any parameter values.<br />

positioning: window center (here (256,256))<br />

size: (here 2, half the max. size)<br />

[’component histogram’,Line,Column,Scale ]<br />

’component histogram’ output as histogram of the connection components.<br />

Positioning: default<br />

[’component histogram’,256,256,1 ] output as histogram of the connection components.<br />

Positioning: (here (256, 256))<br />

Scaling: (here 1, max. size)<br />

<strong>HALCON</strong> 6.0


246 CHAPTER 4. GRAPHICS<br />

[’line’,Line,Scale ]<br />

’line’ output of the grayvalue profile along the given line.<br />

line: image center (default)<br />

Scaling: 50<br />

[’line’,100,20 ] output of the grayvalue profile of line 100 with a scaling of 0.2 (20<br />

[’column’,Column,Scale ]<br />

’column’ output of the grayvalue profile along the given column.<br />

column: image center (default)<br />

Scaling: 50<br />

[’column’,100,20 ] output of the grayvalue profile of column 100 with a scaling of 0.2 (20<br />

[’contourline’,Step,Colored ]<br />

’contourline’ grayvalue output as contour lines: the grayvalue difference per line is defined with the<br />

parameter ’Step’ (default: 30, i.e. max. 8 lines for 256 grayvalues). The line can be displayed in<br />

a given color (see set color) or in the grayvalue they represent. This behaviour is defined with the<br />

parameter ’Colored’ (0 = color, 1 = grayvalues). Default is color.<br />

[’contourline’,15,1 ] grayvalue output as contour lines with a step of 15 and gray output.<br />

[’3D-plot’, Step, Colored, EyeHeight, EyeDistance, ScaleGray, LinePos, ColumnPos]<br />

’3D-plot’ grayvalues are interpreted as 3d data: the greater the value, the ’higher’ the assumed mountain.<br />

Lines with step 2 (second paramter value) are drawn along the x- and y-axes. The third parameter<br />

(Colored) determines, if the output should be in color (default) or grayvalues. To define the<br />

projection of the 3d data, use the parameters EyeHeight and EyeDistance. The projection parameters<br />

take values from 0 to 255. ScaleGray defines a factor, by which the grayvalues are multiplied for<br />

’height’ interpretation (given in percent. 100EyeHeight and EyeDistance the image can be shifted<br />

out of place. Use RowPos and ColumnPos to move the whole output. Values from -127 to 127 are<br />

possible.<br />

[’3D-plot’, 5, 1, 110, 160, 150, 70, -10 ] line step: 5 pixel<br />

Colored: yes (1)<br />

EyeHeight: 110<br />

EyeDistance: 160<br />

ScaleGray: 1.5 (150)<br />

RowPos: 70 pixel down<br />

ColumnPos: 10 pixel right<br />

[’3D-plot hidden’, Step, Colored, EyeHeight, EyeDistance, ScaleGray, LinePos, ColumnPos]<br />

’3D-plot hidden’ like ’3D-plot’, but computes hidden lines.<br />

¯ Two-channel images:<br />

’default’ output as vector field.<br />

[’vectorfield’, Step, MinLengh, ScaleLength ]<br />

’vectorfield’ output of the two channels as displacement vector field. Procedures like optical flow*<br />

produce images of pixel displacements (first channel: x-displacement, second channel: y-<br />

displacement).<br />

In this mode, an arrow is drawn for each vector. The parameter Step has to be set in correspondence<br />

to optical flow*. Short vectors can be suppressed by the third parameter value (MinLength). The<br />

fourth parameter value scales the vector length. Vectors, that exceed the window boundaries are nor<br />

drawn.<br />

[’vectorfield’,16,2,3 ] Output of every 16. vector, that is longer than 2 pixel. Each vector is multiplied<br />

by 3 for output.<br />

¯ Three-channel images:<br />

’default’ output as RGB image with ’median cut’.<br />

’television’ color addition algorithm for RGB images: (three components necessary for disp image).<br />

Images are displayed via a fixed color lookup table. Fast, but non-optimal color resolution. Only recommended<br />

on bright screens.<br />

’grid scan’ grid-scan algorithm for RGB images (three components necessary for disp image). An optimized<br />

color lookup table is generated for each image. Slower than ’television’. Disadvantages: Hard<br />

color boundaries (no dithering). Different color lookup table for every image.<br />

’grid scan floyd steinberg’ grid-scan with Floyd-Steinberg dithering for smooth color boundaries.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 247<br />

’median cut’ median-cut algorithm for RGB images (three components necessary for disp image). Similar<br />

to grid-scan. Disadvantages: Hard color boundaries (no dithering). Different color lookup table for<br />

every image.<br />

’median cut floyd steinberg’ median-cut algorithm with Floyd-Steinberg dithering for smooth color<br />

boundaries.<br />

Attention<br />

¯ Display of color images (’television’, ’grid scan’, etc.) changes the color lookup tables.<br />

¯ If a wrong color mode is set, the error message may appear not until the disp image call.<br />

¯ Grayvalue output may be influenced by region output parameters. This can yield unexpected results.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º Mode (input control) ........................................string-array Htuple . const char * / long<br />

Grevalue output name. Additional parameters possible.<br />

Default Value : ’default’<br />

Example<br />

Htuple Modi,HilfsTuple1,HilfsTuple2,HilfsTuple3, WindowHandleTuple ;<br />

create_tuple(&HilfsTuple1,1) ;<br />

create_tuple(&HilfsTuple2,2) ;<br />

create_tuple(&HilfsTuple3,3) ;<br />

create_tuple(&WindowHandleTuple,1) ;<br />

read_image(&Image,"fabrik") ;<br />

open_window(0,0,-1,-1,"root","visible","",&WindowHandle) ;<br />

T_query_paint(WindowHandleTuple,Modi) ;<br />

T_fwrite_string(Modi) ;<br />

fnew_line() ;<br />

disp_image(Image,WindowHandle) ;<br />

get_mbutton(WindowHandle,_,_,_) ;<br />

set_s(HilfsTuple1,"red",0) ;<br />

set_i(WindowHandleTuple,WindowHandle,0);<br />

T_set_color(WindowHandleTuple,HilfsTuple1) ;<br />

set_draw(WindowHandle,"margin") ;<br />

set_s(HilfsTuple1,"histogram",0) ;<br />

T_set_paint(WindowHandleTuple,HilfsTuple1) ;<br />

disp_image(Image,WindowHandle) ;<br />

set_s(HilfsTuple1,"blue",0) ;<br />

T_set_color(WindowHandleTuple,HilfsTuple1) ;<br />

set_s(HilfsTuple3,"histogram",0) ;<br />

set_s(HilfsTuple3,100,1) ;<br />

set_s(HilfsTuple3,100,2) ;<br />

T_set_paint(WindowHandleTuple,HilfsTuple3) ;<br />

disp_image(Image,WindowHandle) ;<br />

set_s(HilfsTuple1,"yellow",0) ;<br />

T_set_color(WindowHandleTuple,HilfsTuple1) ;<br />

set_s(HilfsTuple2,"line",0) ;<br />

set_s(HilfsTuple2,100,1) ;<br />

T_set_paint(WindowHandleTuple,HilfsTuple3) ;<br />

disp_image(Image,WindowHandle) ;<br />

get_mbutton(WindowHandle,_,_,_) ;<br />

<strong>HALCON</strong> 6.0


248 CHAPTER 4. GRAPHICS<br />

clear_window(WindowHandle) ;<br />

set_s(HilfsTuple3,"contourline",0) ;<br />

set_s(HilfsTuple3,10,1) ;<br />

set_s(HilfsTuple3,1,2) ;<br />

T_set_paint(WindowHandleTuple,HilfsTuple3) ;<br />

disp_image(Image,WindowHandle) ;<br />

set_lut(WindowHandle,"color") ;<br />

get_mbutton(WindowHandle,_,_,_) ;<br />

clear_window(WindowHandle) ;<br />

set_part(WindowHandle,100,100,300,300) ;<br />

set_s(HilfsTuple1,"3D-plot",0) ;<br />

T_set_paint(WindowHandleTuple,HilfsTuple1) ;<br />

disp_image(Image,WindowHandle) ;<br />

Result<br />

T set paint returns H MSG TRUE if the parameter is correct and the window is valid. Otherwise an exception<br />

handling is raised.<br />

Parallelization Information<br />

T set paint is local and processed completely exclusively without parallelization.<br />

T query paint, T get paint<br />

disp image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

T get paint, T query paint, disp image, set shape, T set rgb, (T )set color,<br />

(T )set gray<br />

Module<br />

System<br />

set part ( long WindowHandle, long Row1, long Column1, long Row2,<br />

long Column2 )<br />

Modify the displayed image part.<br />

set part modifies the image part that is displayed in the window. (Row1,Column1) denotes the upper left<br />

corner and (Row2,Column2) the lower right corner of the image part to display. The changed values are used by<br />

grayvalue output operators (disp image, disp color) as well as region output operators (disp region)).<br />

If only part of an image is displayed, it will be zoomed to full window size. The zooming interpolation method<br />

can be set with set part style. get part returns the values of the image part to display.<br />

Beside setting the image part directly, the following special modes are supported:<br />

Row1 = Column1 = Row2 = Column2 =-1: The window size is choosen as the image part, i.e. no zooming of<br />

the image will be performed.<br />

Row1, Column1 -1 and Row2 = Column2 =-1: The size of the last displayed image (in this window) is<br />

choosen as the image part, i.e. the image can completely be displayed in the image. For this the image<br />

will be zoomed if necessary.<br />

Attention<br />

After a call of set part, some operators like draw region, draw ellipse, etc. can no longer be used.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Row1 (input control) ........................................................rectangle.origin.y long<br />

Row of the upper left corner of the chosen image part.<br />

Default Value : 0<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 249<br />

º Column1 (input control) ....................................................rectangle.origin.x long<br />

Column of the upper left corner of the chosen image part.<br />

Default Value : 0<br />

º Row2 (input control) .......................................................rectangle.corner.y long<br />

Row of the lower right corner of the chosen image part.<br />

Default Value : -1<br />

Restriction : ´Row2 Row1µ ´Row2 -1µ<br />

º Column2 (input control) ...................................................rectangle.corner.x long<br />

Column of the lower right corner of the chosen image part.<br />

Default Value : -1<br />

Restriction : ´Column2 Column1µ ´Column2 -1µ<br />

Example<br />

get_system("width",Width) ;<br />

get_system("height",Height) ;<br />

set_part(WindowHandle,0,0,Height-1,Width-1) ;<br />

disp_image(Image,WindowHandle) ;<br />

draw_rectangle1(WindowHandle,&Row1,&Column1,&Row2,&Column2) ;<br />

set_part(WindowHandle,Row1,Column1,Row2,Column2) ;<br />

disp_image(Image,WindowHandle) ;<br />

Result<br />

set part returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

set part is processed completely exclusively without parallelization.<br />

get part<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

set part style, disp image, disp region<br />

affine trans image<br />

Alternatives<br />

See Also<br />

get part, set part style, disp region, disp image, disp color<br />

System<br />

Module<br />

set part style ( long WindowHandle, long Style )<br />

Define an interpolation method for grayvalue output.<br />

set part style defines the interpolation method to zoom an image part which is displayed in the window.<br />

Interpolation takes place, if the output window has different size than the image to display (e.g. after a call to<br />

set part or a window resize). Three modes are supported:<br />

0 no interpolation (low quality, very fast).<br />

1 unweighted interpolation (medium quality and run time)<br />

2 weighted interpolation (high quality, slow)<br />

The current value can be queried with get part style.<br />

<strong>HALCON</strong> 6.0


250 CHAPTER 4. GRAPHICS<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Style (input control) ................................................................integer long<br />

Interpolation method for image output: 0 (fast, low quality) to 2 (slow, high quality).<br />

Default Value : 0<br />

Value List : Style ¾0, 1, 2<br />

Result<br />

set part style returns H MSG TRUE if the parameter is correct and the window is valid. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

set part style is processed completely exclusively without parallelization.<br />

get part style<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

set part, disp image, disp region<br />

affine trans image<br />

Alternatives<br />

See Also<br />

get part style, set part, disp image, disp color<br />

System<br />

Module<br />

T set pixel ( Htuple WindowHandle, Htuple Pixel )<br />

Define a color lookup table index.<br />

T set pixel sets pixel values: colors ((T )set color, T set rgb, etc.) and grayvalues ((T )set gray)<br />

are coded together into a number, called pixel. This ’pixel’ is an index in the color lookup table. It ranges from 0<br />

to 1 in b/w images and 0 to 255 color images with 8 bit planes. It is different from the ’pixel’ (”picture element”)<br />

in image processing. Therefore <strong>HALCON</strong> distinguishes between pixel and image element (or grayvalue).<br />

The current value can be queried with T get pixel.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º Pixel (input control) ...................................................integer-array Htuple . long<br />

Color lookup table index.<br />

Default Value : 128<br />

Typical Range of Values : 0 Pixel 255<br />

Result<br />

T set pixel returns H MSG TRUE if the parameter is correct and the window is valid. Otherwise an exception<br />

handling is raised.<br />

Parallelization Information<br />

T set pixel is local and processed completely exclusively without parallelization.<br />

T get pixel<br />

disp image, disp region<br />

T set rgb, (T )set color, T set hsi<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

T get pixel, (T )set lut, disp region, disp image, disp color<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.6. PARAMETERS 251<br />

System<br />

Module<br />

T set rgb ( Htuple WindowHandle, Htuple Red, Htuple Green, Htuple Blue )<br />

Set the color definition via RGB values.<br />

T set rgb sets the output color(s) or the grayvalues, respectively, for region output for the window. The colors<br />

are defined with the red, green and blue components. If only one combination is passed, all output takes place in<br />

that color. If a tuple is passed, region output and output of geometric objects takes place modulo the passed colors.<br />

For every call of an output procedure, output is started with the first color. If only one object is displayed per<br />

call, it will always be displayed in the first color. This is even true for objects with multiple connection components.<br />

If multiple objects are displayed per procedure call, multiple colors are used. The defined colors are used<br />

until (T )set color, T set pixel, T set rgb or (T )set gray is called again. The values are used<br />

by procedures like disp region, (T )disp line, (T )disp rectangle1, (T )disp rectangle2,<br />

(T )disp arrow,etc.<br />

Attention<br />

If a passed is not available, an exception handling is raised. If set check(’˜color’:) was called before,<br />

<strong>HALCON</strong> uses a similar color and suppresses the error.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º Red (input control) .....................................................integer-array Htuple . long<br />

Red component of the color.<br />

Default Value : 255<br />

Typical Range of Values : 0 Red 255<br />

Restriction : ´0 Redµ ´Red 255µ<br />

º Green (input control) ...................................................integer-array Htuple . long<br />

Green component of the color.<br />

Default Value : 0<br />

Typical Range of Values : 0 Green 255<br />

Restriction : ´0 Greenµ ´Green 255µ<br />

º Blue (input control) ....................................................integer-array Htuple . long<br />

Blue component of the color.<br />

Default Value : 0<br />

Typical Range of Values : 0 Blue 255<br />

Restriction : ´0 Blueµ ´Blue 255µ<br />

Result<br />

T set rgb returns H MSG TRUE if the window is valid and all passed colors are available and displayable.<br />

Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T set rgb is local and processed completely exclusively without parallelization.<br />

disp image, disp region<br />

Possible Successor Functions<br />

Alternatives<br />

T set hsi, (T )set color, (T )set gray<br />

set fix, disp region<br />

System<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


252 CHAPTER 4. GRAPHICS<br />

set shape ( long WindowHandle, const char *Shape )<br />

Define the region output shape.<br />

set shape defines the shape for region output. It is only valid for the window with the logical window number<br />

WindowHandle. The output shape is used by disp region. The available shapes can be queried with<br />

T query shape.<br />

Available modes:<br />

’original’: The shape is displayed unchanged. Nevertheless modifications via parameters like set line width or<br />

set line approx can take place. This is also true for all other modes.<br />

’outer circle’: Each region is displayed by the smallest surrounding circle. (See smallest circle.)<br />

’inner circle’: Each region is displayed by the largest included circle. (See inner circle.)<br />

’ellipse’: Each region is displayed by an ellipse with the same moments and orientation (See elliptic axis.)<br />

’rectangle1’: Each region is displayed by the smallest surrounding rectangle parallel to the coordinate axes. (See<br />

smallest rectangle1.)<br />

’rectangle2’: Each region is displayed by the smallest surrounding rectangle. (See smallest rectangle2.)<br />

’convex’: Each region is displayed by its convex hull (See convexity.)<br />

’icon’ Each region is displayed by the icon set with set icon in the center of gravity.<br />

Attention<br />

Caution is advised for grayvalue output procedures with output parameter settings that use region<br />

output, e.g. disp image with T set paint(WindowHandle,’histogram’) and set shape<br />

(WindowHandle,’convex’). In that case the convex hull of the grayvalue histogram is displayed.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window id.<br />

º Shape (input control) ..........................................................string const char *<br />

Region output mode.<br />

Default Value : ’original’<br />

Value List : Shape ¾’original’, ’convex’, ’outer circle’, ’inner circle’, ’rectangle1’, ’rectangle2’, ’ellipse’,<br />

’icon’<br />

Example<br />

read_image(&Image,"fabrik");<br />

regiongrowing(Image,&Seg,5,5,6.0,100);<br />

set_colored(WindowHandle,12);<br />

set_shape(WindowHandle,"rectangle2");<br />

disp_region(Seg,WindowHandle);<br />

Result<br />

set shape returns H MSG TRUE if the parameter is correct and the window is valid. Otherwise an exception<br />

handling is raised.<br />

Parallelization Information<br />

set shape is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

set icon, T query shape, get shape<br />

disp region<br />

get shape, T query shape, disp region<br />

System<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.7. TEXT 253<br />

4.7 Text<br />

get font ( long WindowHandle, char *Font )<br />

Get the current font.<br />

get font queries the name of the font used in the output window. The font is used by the operators<br />

T write string, read string etc. The font is set by the operator set font. Text windows as well as<br />

windows for image display use fonts. Both types of windows have a default font that can be modified with<br />

set system(’default font’,Fontname) prior to opening the window. A list of all available fonts can<br />

be obtained using T query font.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Font (output control) ................................................................string char *<br />

Name of the current font.<br />

Example<br />

get_font(WindowHandle,&CurrentFont) ;<br />

set_font(WindowHandle,MyFont) ;<br />

create_tuple(&String,1) ;<br />

sprintf(buf,"The name of my Font is: %s ",Myfont) ;<br />

set_s(String,buf,0) ;<br />

T_write_string(TupleWindowHandle,String) ;<br />

new_line(WindowHandle) ;<br />

set_font(WindowHandle,CurrentFont) ;<br />

get font returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

get font is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, open textwindow, T query font<br />

set font<br />

Possible Successor Functions<br />

See Also<br />

set font, T query font, open window, open textwindow, set system<br />

System<br />

Module<br />

get string extents ( long WindowHandle, const char *Values,<br />

long *Ascent, long *Descent, long *Width, long *Height )<br />

T get string extents ( Htuple WindowHandle, Htuple Values,<br />

Htuple *Ascent, Htuple *Descent, Htuple *Width, Htuple *Height )<br />

Get the spatial size of a string.<br />

(T )get string extents queries width and height of the output size of a string using the font of the window.<br />

In addition the extension above and below the current baseline for writing is returned (Ascent bzw. Descent).<br />

The sizes are measured in the coordinate system of the window (for text windows in pixels). Using<br />

(T )get string extents it is possible to determine text output and input independently from the used<br />

font. The conversion from integer numbers and floating point numbers to text strings is the same as in<br />

T write string.<br />

<strong>HALCON</strong> 6.0


254 CHAPTER 4. GRAPHICS<br />

Parameter<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window identifier.<br />

º Values (input control) ...........................string(-array) (Htuple .) const char * / double / long<br />

Values to consider.<br />

Default Value : ’test string’<br />

º Ascent (output control) ..................................................integer (Htuple .) long *<br />

Maximum height above baseline for writing.<br />

º Descent (output control) .................................................integer (Htuple .) long *<br />

Maximum extension below baseline for writing.<br />

º Width (output control) ....................................................integer (Htuple .) long *<br />

Text width.<br />

º Height (output control) ..................................................integer (Htuple .) long *<br />

Text height.<br />

Result<br />

(T )get string extents returns H MSG TRUE if the window is valid. Otherwise an exception handling is<br />

raised.<br />

Parallelization Information<br />

(T )get string extents is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, open textwindow, set font<br />

Possible Successor Functions<br />

set tposition, T write string, read string, read char<br />

set tposition, set font<br />

System<br />

See Also<br />

Module<br />

get tposition ( long WindowHandle, long *Row, long *Column )<br />

Get cursor position.<br />

get tposition queries the current position of the text cursor in the output window. The position is measured<br />

in the coordinate system of the window (in pixels for text windows). The next output of text in this window starts<br />

at the cursor position. The left end of the baseline for writing the next string (not considering descenders) is placed<br />

on this position. The position is changed by the output or input of text (T write string, read string) or<br />

by an explicit change of position by (set tposition, new line).<br />

Attention<br />

If the output text does not fit completely into the window, an exception handling is raised. This can be avoided by<br />

set check(’˜text’).<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Row (output control) ................................................................point.y long *<br />

Row index of text cursor position.<br />

º Column (output control) ............................................................point.x long *<br />

Column index of text cursor position.<br />

Result<br />

get tposition returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

get tposition is local and processed completely exclusively without parallelization.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.7. TEXT 255<br />

Possible Predecessor Functions<br />

open window, open textwindow, set font<br />

Possible Successor Functions<br />

set tposition, T write string, read string, read char<br />

See Also<br />

new line, read string, set tposition, T write string, set check<br />

System<br />

Module<br />

get tshape ( long WindowHandle, char *TextCursor )<br />

Get the shape of the text cursor.<br />

get tshape queries the shape of the text cursor for the output window. A new cursor shape is set by the operator<br />

set tshape.<br />

A text cursor marks the current position for text output (which can also be invisible). It is different from the mouse<br />

cursor (although both will be called ”’cursor”’ if the context makes misconceptions impossible). The available<br />

shapes for the text cursor can be queried with T query tshape.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º TextCursor (output control) ........................................................string char *<br />

Name of the current text cursor.<br />

Result<br />

get tshape returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

get tshape is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, open textwindow, set font<br />

Possible Successor Functions<br />

set tshape, set tposition, T write string, read string, read char<br />

See Also<br />

set tshape, T query tshape, T write string, read string<br />

System<br />

Module<br />

new line ( long WindowHandle )<br />

Set the position of the text cursor to the beginning of the next line.<br />

new line sets the position of the text cursor to the beginning of the next line. The new position depends on the<br />

current font. The left end of the baseline for writing the following text string (not considering descenders) is placed<br />

on this position.<br />

If the next line does not fit into the window the content of the window is scrolled by the height of one line in the<br />

upper direction. In order to reach the correct new cursor position the font used in the next line must be set before<br />

new line is called. The position is changed by the output or input of text (T write string, read string)<br />

or by an explicit change of position by (set tposition).<br />

<strong>HALCON</strong> 6.0


256 CHAPTER 4. GRAPHICS<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

Result<br />

new line returns H MSG TRUE if the window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

new line is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, open textwindow, set font, T write string<br />

Alternatives<br />

get tposition, (T )get string extents, set tposition, (T )move rectangle<br />

T write string, set font<br />

System<br />

See Also<br />

Module<br />

T query font ( Htuple WindowHandle, Htuple *Font )<br />

Query the available fonts.<br />

T query font queries the fonts available for text output in the output window. They can be set with the operator<br />

set font. Fonts are used by the operators T write string, read char, read string and new line.<br />

Attention<br />

For different machines the available fonts may differ a lot. Therefore T query font will return different fonts<br />

on different machines.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window identifier.<br />

º Font (output control) ..................................................string-array Htuple . char *<br />

Tupel with available font names.<br />

Example<br />

open_window(0,0,-1,-1,"root","visible","",&WindowHandle) ;<br />

set_check("˜text") ;<br />

create_tuple(&Fontlist,1) ;<br />

create_tuple(&String,1) ;<br />

create_tuple(&WindowHandleTuple,1) ;<br />

set_i(WindowHandleTuple,WindowHandle,0) ;<br />

T_query_font(WindowHandleTuple,&Fontlist) ;<br />

set_color(WindowHandle,"white") ;<br />

for(i=0; i


4.7. TEXT 257<br />

open window, open textwindow<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

set font, T write string, read string, read char<br />

See Also<br />

set font, T write string, read string, read char, new line<br />

System<br />

Module<br />

T query tshape ( Htuple WindowHandle, Htuple *TextCursor )<br />

Query all shapes available for text cursors.<br />

T query tshape queries the available shapes of text cursors for the output window. The retrieved shapes can<br />

be used by the operator set tshape.<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window identifier.<br />

º TextCursor (output control) ..........................................string-array Htuple . char *<br />

Names of the available text cursors.<br />

Result<br />

T query tshape returns H MSG TRUE.<br />

Parallelization Information<br />

T query tshape is local and processed completely exclusively without parallelization.<br />

open window, open textwindow<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

set tshape, T write string, read string<br />

See Also<br />

set tshape, get shape, set tposition, T write string, read string<br />

System<br />

Module<br />

read char ( long WindowHandle, char *Char, char *Code )<br />

Read a character from a text window.<br />

read char reads a character from the keyboard in the input window (= output window). If the character is<br />

printable it is returned in Char. If a control key has been pressed, this will be indicated by the value of Code.<br />

Some important keys are recognizable by this value. Possible values are:<br />

’character’: printable character<br />

’left’: cursor left<br />

’right’: cursor right<br />

’up’: cursor up<br />

’down’: cursor down<br />

’insert’: insert<br />

’none’: none of these keys<br />

The window has to be a text window.<br />

Attention<br />

<strong>HALCON</strong> 6.0


258 CHAPTER 4. GRAPHICS<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Char (output control) ................................................................string char *<br />

Input character (if it is not a control character).<br />

º Code (output control) ................................................................string char *<br />

Code for input character.<br />

Result<br />

read char returns H MSG TRUE if the text window is valid. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

read char is local and processed completely exclusively without parallelization.<br />

open textwindow, set font<br />

Possible Predecessor Functions<br />

Alternatives<br />

read string, fread char, fread string<br />

T write string, set font<br />

System<br />

See Also<br />

Module<br />

read string ( long WindowHandle, const char *InString, long Length,<br />

char *OutString )<br />

Read a string in a text window.<br />

read string reads a string with a predetermined maximum size (Length) from the keyboard in the input<br />

window (= output window). The string is read from the current position of the text cursor using the current font.<br />

The maximum size has to be small enough to keep the string within the right window boundary. A default string<br />

which can be edited or simply accepted by the user may be provided. After text input the text cursor is positioned<br />

at the end of the edited string. Commands for editing:<br />

RETURN finish input<br />

BACKSPACE delete the character on the left side of the cursor and move the cursor to this position.<br />

The window has to be a text window.<br />

Attention<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º InString (input control) ......................................................string const char *<br />

Default string (visible before input).<br />

Default Value : ”<br />

º Length (input control) ...............................................................integer long<br />

Maximum number of characters.<br />

Default Value : 32<br />

Restriction : Length 0<br />

º OutString (output control) .........................................................string char *<br />

Read string.<br />

Result<br />

read string returns H MSG TRUE if the text window is valid and a string of maximal length fits within the<br />

right window boundary. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

read string is local and processed completely exclusively without parallelization.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.7. TEXT 259<br />

open textwindow, set font<br />

read char, fread string, fread char<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

set tposition, new line, open textwindow, set font, (T )set color<br />

System<br />

Module<br />

set font ( long WindowHandle, const char *Font )<br />

Set the font used for text output.<br />

set font sets the font for the output window. The font is used by the operators T write string,<br />

read string etc. Text windows as well as windows for image display use fonts. A default font is assigned<br />

when a window is opened. This font can be changed with set font. On UNIX systems all<br />

available fonts can be queried with T query font. The default font can be modified with set system<br />

(’default font’,Fontname). Fonts are not used for file operations.<br />

The syntax for the specification of a font (in Font) differs for UNIX and Windows NT environments: In Windows<br />

NT a string with the following components is used:<br />

-FontName-Height-Width-Italic-Underlined-Strikeoutwhere<br />

“Italic”, “Underlined”, and “Strikeout” can take the values 1 and 0 to activate or deactivate the corresponding<br />

feature. Please refer to the Windows NT documentation for a detailed discussion.<br />

Attention<br />

For different machines the available fonts may differ a lot. Therefore it is suggested to use wildcards, tables of<br />

fonts and/or the operator T query font.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Font (input control) ............................................................string const char *<br />

Name of new font.<br />

Example<br />

// UNIX<br />

set_font(WindowHandle,"-*-courier-*-*-*-*-18-*-*-*-*-*-*-*") ;<br />

// Windows NT<br />

set_font(WindowHandle,"-Arial-18-*-*-*-*-") ;<br />

write_string(WindowHandle,"Text with Font size of 18 pixels") ;<br />

new_line(WindowHandle) ;<br />

Result<br />

set font returns H MSG TRUE if the font name is correct. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

set font is local and processed completely exclusively without parallelization.<br />

open window, open textwindow<br />

T query font<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

get font, T query font, open textwindow, open window<br />

System<br />

Module<br />

<strong>HALCON</strong> 6.0


260 CHAPTER 4. GRAPHICS<br />

set tposition ( long WindowHandle, long Row, long Column )<br />

Set the position of the text cursor.<br />

set tposition sets the position of the text cursor in the output window. The reference position is the upper<br />

left corner of an upper case character.<br />

The position is measured in the coordinate system of the window and has to be valid for the window size and font.<br />

The position of the text cursor can be marked e.g. by an underscore. The next text output in this window starts at<br />

the cursor position. The left end of the baseline for writing the following text string (not considering descenders)<br />

is placed on this position.<br />

The position is changed by the output or input of text (T write string, read string) or by an explicit<br />

change of position by (set tposition, new line). In order to stop the display of the cursor, the operator<br />

set tshape with the parameter ”’invisible”’ can be used.<br />

Attention<br />

If a string starting at the given position does not fit into the window an exception handling will be raised. This<br />

exception handling can be avoided by set check(’˜text’).<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Row (input control) ...................................................................point.y long<br />

Row index of text cursor position.<br />

Default Value : 24<br />

º Column (input control) ...............................................................point.x long<br />

Column index of text cursor position.<br />

Default Value : 12<br />

Result<br />

set tposition returns H MSG TRUE if the window is valid and the values of the parameters are valid. Otherwise<br />

an exception handling is raised.<br />

Parallelization Information<br />

set tposition is local and processed completely exclusively without parallelization.<br />

open window, open textwindow<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

set tshape, T write string, read string<br />

new line<br />

Alternatives<br />

See Also<br />

read string, set tshape, T write string<br />

System<br />

Module<br />

set tshape ( long WindowHandle, const char *TextCursor )<br />

Set the shape of the text cursor.<br />

set tshape sets the shape and the display mode of the text cursor of the output window.<br />

A text cursor marks the current position for text output. It is different from the mouse cursor (although both will<br />

be called ’cursor’, if the context makes misconceptions impossible). The available shapes for the text cursor can<br />

be queried with T query tshape.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.7. TEXT 261<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º TextCursor (input control) ...................................................string const char *<br />

Name of cursor shape.<br />

Default Value : ’invisible’<br />

Result<br />

get tshape returns H MSG TRUE if the window is valid and the given cursor shape is defined for this window.<br />

Otherwise an exception handling is raised.<br />

Parallelization Information<br />

set tshape is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, open textwindow, T query tshape, get tshape<br />

T write string, read string<br />

Possible Successor Functions<br />

See Also<br />

get tshape, T query tshape, T write string, read string<br />

System<br />

Module<br />

T write string ( Htuple WindowHandle, Htuple String )<br />

Printtextinawindow.<br />

T write string prints String in the output window starting at the current cursor position. The output text has<br />

to fit within the right window boundary (the width of the string can be queried by (T )get string extents).<br />

The font currently assigned to the window will used. The text cursor is positioned at the end of the text.<br />

T write string can output all three types of data used in <strong>HALCON</strong> . The conversion to a string is guided by<br />

the following rules:<br />

¯ strings are not converted.<br />

¯ integer numbers are converted without any spaces before or after the number.<br />

¯ floating numbers are printed (if possible) with a floating point and without an exponent.<br />

¯ the resulting strings are concatenated without spaces.<br />

For buffering of texts see set system with the flag ’flush graphic’.<br />

Attention<br />

If clipping at the window boundary is desired, exceptions can be switched off by set check(’˜text’).<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window identifier.<br />

º String (input control) ..............................string-array Htuple . const char * / long / double<br />

Tuple of output values (all types).<br />

Default Value : ’hello’<br />

Result<br />

T write string returns H MSG TRUE if the window is valid and the output text fits within the current line<br />

(see set check). Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T write string is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, open textwindow, set font, (T )get string extents<br />

<strong>HALCON</strong> 6.0


262 CHAPTER 4. GRAPHICS<br />

fwrite string<br />

Alternatives<br />

See Also<br />

set tposition, (T )get string extents, open textwindow, set font, set system,<br />

set check<br />

Module<br />

System<br />

4.8 Window<br />

clear rectangle ( long WindowHandle, long Row1, long Column1,<br />

long Row2, long Column2 )<br />

T clear rectangle ( Htuple WindowHandle, Htuple Row1, Htuple Column1,<br />

Htuple Row2, Htuple Column2 )<br />

Delete a rectangle on the output window.<br />

(T )clear rectangle deletes all entries in the rectangle which is defined through the upper left corner<br />

(Row1,Column1) and the lower right corner (Row2,Column2). Deletion significates that the specified rectangle<br />

is set to the background color (see open window, open textwindow).<br />

If you want to delete more than one rectangle, you may pass several rectangles, i.e. the parameters Row1,<br />

Column1, Row2 and Column2 are tupel.<br />

Parameter<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window identifier.<br />

º Row1 (input control) .......................................rectangle.origin.y(-array) (Htuple .) long<br />

Line index of upper left corner.<br />

Default Value : 10<br />

Typical Range of Values : 0 Row1 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Column1 (input control) ...................................rectangle.origin.x(-array) (Htuple .) long<br />

Column index of upper left corner.<br />

Default Value : 10<br />

Typical Range of Values : 0 Column1 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Row2 (input control) .......................................rectangle.corner.y(-array) (Htuple .) long<br />

Row index of lower right corner.<br />

Default Value : 118<br />

Typical Range of Values : 0 Row2 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : Row2 Row1<br />

º Column2 (input control) ...................................rectangle.corner.x(-array) (Htuple .) long<br />

Column index of lower right corner.<br />

Default Value : 118<br />

Typical Range of Values : 0 Column2 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : Column2 Column1<br />

Example<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.8. WINDOW 263<br />

/* "Interactiv" erase of a rectangle in output window */<br />

draw_rectangle1(WindowHandle,&L1,&C1,&L2,&C2) ;<br />

clear_rectangle(WindowHandle,L1,C1,L2,C2) ;<br />

Result<br />

If an ouputwindow exists and the specified parameters are correct (T )clear rectangle returns<br />

H MSG TRUE. If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )clear rectangle is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, set draw, (T )set color, set colored, set line width, T set rgb,<br />

T set hsi, draw rectangle1<br />

clear window, (T )disp rectangle1<br />

open window, open textwindow<br />

System<br />

Alternatives<br />

See Also<br />

Module<br />

clear window ( long WindowHandle )<br />

Delete an output window.<br />

clear window deletes all entries in the output window. The window (background and edge) is reset to its<br />

original state. Parameters assigned to this window (e.g. with (T )set color, T set paint, etc.) remain<br />

unmodified.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

clear_window(WindowHandle) ;<br />

Example<br />

Result<br />

If the ouput window is valid clear window returns H MSG TRUE. If necessary an exception handling is raised.<br />

Parallelization Information<br />

clear window is local and processed completely exclusively without parallelization.<br />

open window, open textwindow<br />

Possible Predecessor Functions<br />

Alternatives<br />

(T )clear rectangle, (T )disp rectangle1<br />

open window, open textwindow<br />

System<br />

See Also<br />

Module<br />

close window ( long WindowHandle )<br />

Close an output window.<br />

<strong>HALCON</strong> 6.0


264 CHAPTER 4. GRAPHICS<br />

close window closes a window which have been opened by open window or by open textwindow. Afterwards<br />

the output device or the window area, respectively, is ready to accept new calls of open window or<br />

open textwindow.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

Result<br />

If the ouput window is valid close window returns H MSG TRUE. If necessary an exception handling is raised.<br />

Parallelization Information<br />

close window is local and processed completely exclusively without parallelization.<br />

open window, open textwindow<br />

open window, open textwindow<br />

System<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

copy rectangle ( long WindowHandleSource, long WindowHandleDestination,<br />

long Row1, long Column1, long Row2, long Column2, long DestRow,<br />

long DestColumn )<br />

T copy rectangle ( Htuple WindowHandleSource,<br />

Htuple WindowHandleDestination, Htuple Row1, Htuple Column1, Htuple Row2,<br />

Htuple Column2, Htuple DestRow, Htuple DestColumn )<br />

Copy all pixels within rectangles between output windows.<br />

(T )copy rectangle copies all pixels from the specified window with the logical window<br />

number WindowHandleSource in the specified window with the logical window number<br />

WindowHandleDestination. It copies pixels which reside inside a rectangle which is specified by<br />

parameters Row1, Column1, Row2 and Column2. The target position is specified through the upper left corner<br />

of the rectangle (DestRow, DestColumn).<br />

If you want to move more than one rectangle, you may pass them at once (in form of the tupel mode).<br />

You may use (T )copy rectangle to copy edited graphics from an ”‘invisible”’ window in a visible window.<br />

Therefore a window with the option ’buffer’ is opened. The graphics is then displayed in this window and is<br />

copied in a visible window afterwards. The advantage of this strategy is, that (T )copy rectangle is much<br />

more rapid than output procedures as e.g. (T )disp channel. This means a particular advantage while using<br />

demo programs. You could even realise short ”‘clips”’: you have to create for every image of a sequence a window<br />

of a ’buffer’ type and pass the data into it. Output is the image sequence whereat all buffers are copied one after<br />

another in a visible window.<br />

Attention<br />

Both windows have to reside on the same computer.<br />

Parameter<br />

º WindowHandleSource (input control) ....................................window (Htuple .) long<br />

Number of the source window.<br />

º WindowHandleDestination (input control) .............................window (Htuple .) long<br />

Number of the destination window.<br />

º Row1 (input control) .......................................rectangle.origin.y(-array) (Htuple .) long<br />

Row index of upper left corner in the source window.<br />

Default Value : 0<br />

Typical Range of Values : 0 Row1 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.8. WINDOW 265<br />

º Column1 (input control) ...................................rectangle.origin.x(-array) (Htuple .) long<br />

Column index of upper left corner in the source window.<br />

Default Value : 0<br />

Typical Range of Values : 0 Column1 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Row2 (input control) .......................................rectangle.corner.y(-array) (Htuple .) long<br />

Row index of lower right corner in the source window.<br />

Default Value : 128<br />

Typical Range of Values : 0 Row2 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : Row2 Row1<br />

º Column2 (input control) ...................................rectangle.corner.x(-array) (Htuple .) long<br />

Column index of lower right corner in the source window.<br />

Default Value : 128<br />

Typical Range of Values : 0 Column2 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : Column2 Column1<br />

º DestRow (input control) .............................................point.y(-array) (Htuple .) long<br />

Row index of upper left corner in the target window.<br />

Default Value : 0<br />

Typical Range of Values : 0 DestRow 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º DestColumn (input control) .........................................point.x(-array) (Htuple .) long<br />

Column index of upper left corner in the target window.<br />

Default Value : 0<br />

Typical Range of Values : 0 DestColumn 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Example<br />

read_image(Image,"affe") ;<br />

open_window(0,0,-1,-1,"root","buffer","",&WindowHandle) ;<br />

disp_image(Image,WindowHandle) ;<br />

open_window(0,0,-1,-1,"root","visible","",&WindowHandleDestination) ;<br />

do{<br />

get_mbutton(WindowHandleDestination,&Row,&Column,&Button) ;<br />

copy_rectangle(BufferID,WindowHandleDestination,90,120,390,Row,Column) ;<br />

}<br />

while(Button > 1) ;<br />

close_window(WindowHandleDestination) ;<br />

close_window(WindowHandle) ;<br />

clear_obj(Image) ;<br />

Result<br />

If the ouput window is valid and if the specified parameters are correct close window returns H MSG TRUE.<br />

If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )copy rectangle is local and processed completely exclusively without parallelization.<br />

open window, open textwindow<br />

close window<br />

(T )move rectangle, slide image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

<strong>HALCON</strong> 6.0


266 CHAPTER 4. GRAPHICS<br />

open window, open textwindow<br />

System<br />

See Also<br />

Module<br />

dump window ( long WindowHandle, const char *Device,<br />

const char *FileName )<br />

T dump window ( Htuple WindowHandle, Htuple Device, Htuple FileName )<br />

Write the window content to a file.<br />

(T )dump window writes the content of the window to a file. You may continue to process this file by convenient<br />

printers or other programs. The content of a display is prepared for each special device (Device), i.e. it is<br />

formated in a manner, that you may print this file directly or it can be processed furthermore by a graphical<br />

program.<br />

To transform gray values the current color table of the window is used, i.e. the values of set lut style remain<br />

unconsidered.<br />

The gray values of the display have in general a poorer resolution then the original gray values of the output images.<br />

This results in a reduced resolution (default setting are e.g. 200 gray levels with 8 bit planes) for the representation<br />

of gray values (see also (T )disp channel). You may request the amount of actual disposable gray levels by<br />

get system. To modify them before opening the first window you may use set system.<br />

Possible values for Device<br />

’postscript’: PostScript - file. Filetermination: FileName.ps<br />

’postscript’,Width,Height: PostScript - file with specification of the output size. Ï Ø and ÀØ refer to the<br />

size. In this case a tupel with three values as Device is passed. Filetermination: FileName.ps<br />

’tiff’: TIFF - file, 1 byte per pixel incl. current color table or 3 bytes per sample (dependent on VGA card),<br />

uncompressed. Filetermination: FileName.tiff<br />

’bmp’: Windows-BMP format, RGB image, 3 bytes per pixel. The color resolution pendends on the VGA card.<br />

File extension: ’.bmp’<br />

’jpeg’ JPEG format, with lost of information; together with the format string the quality value determining the<br />

compression rate can be provided: e.g., ’jpeg 30’.<br />

Attention<br />

Under X Windows, the <strong>HALCON</strong> window must be completely visible on the root window, because otherwise the<br />

contents of the window cannot be read due to limitations in X Windows. If larger graphical displays are to be<br />

written to a file, the window type ’pixmap’ can be used.<br />

Parameter<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window identifier.<br />

º Device (input control) ...................................string(-array) (Htuple .) const char * / long<br />

Name of the target device or of the graphic format.<br />

Default Value : ’postscript’<br />

Value List : Device ¾’postscript’, ’tiff’, ’bmp’, ’jpeg’, ”jpeg 100”, ”jpeg 80”, ”jpeg 60”, ”jpeg 40”, ”jpeg<br />

20”<br />

º FileName (input control) ..........................................filename (Htuple .) const char *<br />

File name (without extension).<br />

Default Value : ’halcon dump’<br />

Example<br />

/* PostScript - Dump of Image and Regions */<br />

disp_image(Image,WindowHandle) ;<br />

set_colored(WindowHandle,12) ;<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.8. WINDOW 267<br />

disp_region(Regions,WindowHandle) ;<br />

dump_window(WindowHandle,"postscript","/tmp/halcon_dump") ;<br />

system_call("lp -d ps /tmp/halcon_dump.ps") ;<br />

Result<br />

If the appropriate window is valid and the specified parameters are correct (T )dump window returns<br />

H MSG TRUE. If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )dump window is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, set draw, (T )set color, set colored, set line width, open textwindow,<br />

disp region<br />

Possible Successor Functions<br />

system call<br />

See Also<br />

open window, open textwindow, set system<br />

System<br />

Module<br />

get window extents ( long WindowHandle, long *Row, long *Column,<br />

long *Width, long *Height )<br />

Information about a window’s size and position.<br />

get window extents returns the position of the upper left corner, as well as width and height of the output<br />

window.<br />

Attention<br />

Size and position of a window may be modified by the window manager, without explicit instruction in the program.<br />

Therefore the values which are returned by get window extents may change cause of side effects.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Row (output control) ......................................................rectangle.origin.y long *<br />

Row index of upper left corner of the window.<br />

º Column (output control) ..................................................rectangle.origin.x long *<br />

Column index of upper left corner of the window.<br />

º Width (output control) ...................................................rectangle.extent.x long *<br />

Window width.<br />

º Height (output control) ..................................................rectangle.extent.y long *<br />

Window height.<br />

Example<br />

open_window(100,100,200,200,"root","visible","",&WindowHandle) ;<br />

fwrite_string("Move the window with the mouse!") ;<br />

fnew_line() ;<br />

create_tuple(&String,1) ;<br />

do<br />

{<br />

get_mbutton(WindowHandle,_,_,&Button) ;<br />

get_window_extents(WindowHandle,&Row,&Column,&Width,&Height) ;<br />

sprintf(buf,"Row %d Col %d ",Row,Column) ;<br />

set_s(String,buf,0) ;<br />

T_fwrite_string(String) ;<br />

fnew_line() ;<br />

}<br />

while(Button < 4) ;<br />

<strong>HALCON</strong> 6.0


268 CHAPTER 4. GRAPHICS<br />

Result<br />

If the window is valid get window extents returns H MSG TRUE. If necessary an exception handling is<br />

raised.<br />

Parallelization Information<br />

get window extents is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

open window, set draw, (T )set color, set colored, set line width, open textwindow<br />

See Also<br />

set window extents, open window, open textwindow<br />

System<br />

Module<br />

get window pointer3 ( long WindowHandle, long *ImageRed,<br />

long *ImageGreen, long *ImageBlue, long *Width, long *Height )<br />

Access to a window’s pixel data.<br />

get window pointer3 enables (in some window systems) the direct access to the bitmap. Result values are<br />

the three pointers on the color extracts of a 24-bit window (ImageRed, ImageGreen, ImageBlue), as well as<br />

the window size (Width, Height). In the language C the type of the image points is unsigned char.<br />

Attention<br />

get window pointer3 is usable only for window type ’pixmap’.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º ImageRed (output control) .........................................................integer long *<br />

Pointer on red channel of pixel data.<br />

º ImageGreen (output control) ......................................................integer long *<br />

Pointer on green channel of pixel data.<br />

º ImageBlue (output control) ........................................................integer long *<br />

Pointer on blue channel of pixel data.<br />

º Width (output control) ............................................................extent.x long *<br />

Length of an image line.<br />

º Height (output control) ...........................................................extent.y long *<br />

Number of image lines.<br />

Result<br />

If a window of type ’pixmap’ exists and it is valid get window pointer3 returns H MSG TRUE. If necessary<br />

an exception handling is raised.<br />

Parallelization Information<br />

get window pointer3 is local and processed completely exclusively without parallelization.<br />

open window, open textwindow<br />

open window, set window type<br />

System<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

get window type ( long WindowHandle, char *WindowType )<br />

Get the window type.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.8. WINDOW 269<br />

get window type determines the type or the graphical software, respectively, of the output device for the<br />

window. You may query the available types of output devices with procedure T query window type. A<br />

reasonable use for get window type might be in the field of the development of machine independent software.<br />

Possible values are:<br />

’X-Window’ X-Window Version 11.<br />

’pixmap’ Windows are not shown, but managed in memory. By this means Halcon programs can be ported on<br />

computers without a graphical display.<br />

’PostScript’ Objects are output to a PostScript File.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º WindowType (output control) ........................................................string char *<br />

Window type<br />

Example<br />

open_window(100,100,200,200,"root","visible","",&WindowHandle) ;<br />

get_window_type(WindowHandle,&WindowType) ;<br />

fwrite_string("Window type:") ;<br />

sprintf(buf,"%d",WindowType) ;<br />

fwrite_string(buf) ;<br />

fnew_line() ;<br />

Result<br />

If the window is valid get window type returns H MSG TRUE. If necessary an exception handling is raised.<br />

Parallelization Information<br />

get window type is local and processed completely exclusively without parallelization.<br />

open window, open textwindow<br />

Possible Predecessor Functions<br />

See Also<br />

T query window type, set window type, get window pointer3, open window,<br />

open textwindow<br />

Module<br />

System<br />

move rectangle ( long WindowHandle, long Row1, long Column1, long Row2,<br />

long Column2, long DestRow, long DestColumn )<br />

T move rectangle ( Htuple WindowHandle, Htuple Row1, Htuple Column1,<br />

Htuple Row2, Htuple Column2, Htuple DestRow, Htuple DestColumn )<br />

Copy inside an output window.<br />

(T )move rectangle copies all entries in the rectangle (Row1,Column1), (Row2,Column2) of the output<br />

window to a new position inside the same window. This position is determined by the upper left corner (DestRow,<br />

DestColumn). Regions of the window, which are ”‘uncovered”’ through moving the rectangle, are set to the color<br />

of the background.<br />

If you want to move several rectangles at once, you may pass parameters in form of tupels.<br />

Parameter<br />

º WindowHandle (input control) ............................................window (Htuple .) long<br />

Window identifier.<br />

<strong>HALCON</strong> 6.0


270 CHAPTER 4. GRAPHICS<br />

º Row1 (input control) .......................................rectangle.origin.y(-array) (Htuple .) long<br />

Row index of upper left corner of the source rectangle.<br />

Default Value : 0<br />

Typical Range of Values : 0 Row1 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Column1 (input control) ...................................rectangle.origin.x(-array) (Htuple .) long<br />

Column index of upper left corner of the source rectangle.<br />

Default Value : 0<br />

Typical Range of Values : 0 Column1 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Row2 (input control) .......................................rectangle.corner.y(-array) (Htuple .) long<br />

Row index of lower right corner of the source rectangle.<br />

Default Value : 64<br />

Typical Range of Values : 0 Row2 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Column2 (input control) ...................................rectangle.corner.x(-array) (Htuple .) long<br />

Column index of lower right corner of the source rectangle.<br />

Default Value : 64<br />

Typical Range of Values : 0 Column2 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º DestRow (input control) .............................................point.y(-array) (Htuple .) long<br />

Row index of upper left corner of the target position.<br />

Default Value : 64<br />

Typical Range of Values : 0 DestRow 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º DestColumn (input control) .........................................point.x(-array) (Htuple .) long<br />

Column index of upper left corner of the target position.<br />

Default Value : 64<br />

Typical Range of Values : 0 DestColumn 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Example<br />

/* "Interactiv" copy of a rectangle in the same window */<br />

draw_rectangle1(WindowHandle,&L1,&C1,&L2,&C2) ;<br />

get_mbutton(WindowHandle,LN,CN,_) ;<br />

move_rectangle(WindowHandle,L1,C1,L2,C2,LN,CN) ;<br />

Result<br />

If the window is valid and the specified parameters are correct (T )move rectangle returns H MSG TRUE.<br />

If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )move rectangle is local and processed completely exclusively without parallelization.<br />

open window, open textwindow<br />

(T )copy rectangle<br />

open window, open textwindow<br />

System<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.8. WINDOW 271<br />

new extern window ( long WINHWnd, long WINHDC, long Row, long Column,<br />

long Width, long Height, long *WindowHandle )<br />

Create a virtual graphics window under Windows NT.<br />

new extern window opens a new virtual window. Virtual means that a new window will not be created, but the<br />

window whose Windows NT handle is given in the parameter WINHWnd is used to perform output of gray value<br />

data, regions, graphics as well as to perform textual output. Visualization parameters for the output of data can be<br />

done either using Halcon commands or by the appropriate Windows NT commands.<br />

Example: setting of the drawing color:<br />

Halcon:<br />

set\_color(WindowHandle,"green");<br />

disp\_region(WindowHandle,region);<br />

Windows NT:<br />

HPEN* penold;<br />

HPEN penGreen = CreatePen(PS\_SOLID,1,RGB(0,255,0));<br />

pen = (HPEN*)SelectObject(WINHDC,penGreen);<br />

disp\_region(WindowHandle,region);<br />

Interactive operators, for example draw region, draw circle or get mbutton cannot be used in this window.<br />

The following operators can be used:<br />

¯ Output of gray values: T set paint, set comprise, ((T )set lut and set lut style after output)<br />

¯ Regions: (T )set color, T set rgb, T set hsi, (T )set gray, T set pixel, set shape,<br />

set line width, set insert, T set line style, set draw<br />

¯ Image part: set part<br />

¯ Text: set font<br />

You may query current set values by calling procedures like get shape. As some parameters are specified<br />

through the hardware (Resolution/Colors), you may query current available resources by calling operators like<br />

T query color.<br />

The parameter WINHWnd is used to pass the window handle of the Windows NT window, in which output should<br />

be done. The parameter WINHDC is used to pass the device context of the window WINHWnd. This device context<br />

is used in the output routines of Halcon.<br />

The origin of the coordinate system of the window resides in the upper left corner (coordinates: (0,0)). The row<br />

index grows downward (maximum: Height-1), the column index grows to the right (maximal: Width-1).<br />

You may use the value -1 for parameters Width and Height. This means, that the corresponding value is chosen<br />

automatically. In particular, this is important if the aspect ratio of the pixels is not 1.0 (see set system). If one<br />

of the two parameters is set to -1, it will be chosen through the size which results out of the aspect ratio of the<br />

pixels. If both parameters are set to -1, they will be set to the current image format.<br />

The position and size of a window may change during runtime of a program. This may be achieved by calling<br />

set window extents, but also through external influences (window manager). For the latter case the procedure<br />

set window extents is provided.<br />

Opening a window causes the assignment of a default font. It is used in connection with procedures<br />

like T write string and you may change it by performing set font after calling open window.<br />

On the other hand, you have the possibility to specify a default font by calling set system<br />

(’default font’,) before opening a window (and all following windows; see also<br />

T query font).<br />

You may set the color of graphics and font, which is used for output procedures like disp region<br />

or (T )disp circle, by calling T set rgb, T set hsi, (T )set gray or T set pixel. Calling<br />

set insert specifies how graphics is combined with the content of the image repeat memory. Thereto you<br />

may achieve by calling e.g. set insert(::’not’:) to eliminate the font after writing text twice at the same<br />

position.<br />

<strong>HALCON</strong> 6.0


272 CHAPTER 4. GRAPHICS<br />

The content of the window is not saved, if other windows overlap the window. This must be done in the program<br />

code that handles the Windows NT window in the calling program.<br />

For graphical output (disp image,disp region, etc.) you may adjust the window by calling procedure<br />

set part in order to represent a logical clipping of the image format. In particular this implies that only this part<br />

(appropriately scaled) of images and regions is displayed.<br />

Steps to use new extern window:<br />

Creation: ¯ Create a Windows-window.<br />

¯ Call new extern window whit the WINHWnd of the above created window.<br />

Use: ¯ Before drawing in the window you have to call the method set window dc. This ensures that the halcon<br />

drawing routines use the right DC.<br />

Destroy: ¯ Call close window.<br />

Attention<br />

Note that parameters as Row, Column, Width and Height are constrained through the output device, i.e., the<br />

size of the Windows NT desktop.<br />

Parameter<br />

º WINHWnd (input control) .............................................................integer long<br />

Windows windowhandle of a previously created window.<br />

Restriction : WINHWnd 0<br />

º WINHDC (input control) ...............................................................integer long<br />

Device context of WINHWnd.<br />

Restriction : WINHDC 0<br />

º Row (input control) .........................................................rectangle.origin.y long<br />

Row coordinate of upper left corner.<br />

Default Value : 0<br />

Restriction : Row 0<br />

º Column (input control) .....................................................rectangle.origin.x long<br />

Column coordinate of upper left corner.<br />

Default Value : 0<br />

Restriction : Column 0<br />

º Width (input control) ......................................................rectangle.extent.x long<br />

Width of the window.<br />

Default Value : 512<br />

Restriction : ´Width 0µ ´Width -1µ<br />

º Height (input control) .....................................................rectangle.extent.y long<br />

Height of the window.<br />

Default Value : 512<br />

Restriction : ´Height 0µ ´Height -1µ<br />

º WindowHandle (output control) ...................................................window long *<br />

Window identifier.<br />

HTuple m_tHalconWindow ;<br />

Hobject m_objImage ;<br />

Example<br />

WM_CREATE:<br />

/* here you should create your extern halcon window*/<br />

HTuple tWnd, tDC ;<br />

::set_check("˜father") ;<br />

tWnd = (INT)((INT*)&m_hWnd) ;<br />

tDC = (INT)(INT*)GetWindowDC() ;<br />

::new_extern_window(tWnd, tDC, 0, 0, sizeTotal.cx, sizeTotal.cy, &m_tHalconWindow) ;<br />

::set_check("father") ;<br />

WM_PAINT:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.8. WINDOW 273<br />

/* here you can draw halcon objects */<br />

if (m_thWindow != -1) {<br />

/* dont forget to set the dc !! */<br />

HTuple tDC((INT)(INT*)&pDC->m_hDC) ;<br />

::set_window_dc(m_tHalconWindow,tDC) ;<br />

::disp_obj(pDoc->m_objImage, m_tHalconWindow) ;<br />

}<br />

WM_CLOSE:<br />

/* close the halcon window */<br />

if (m_tHalconWindow != -1) {<br />

::close_window(m_tHalconWindow) ;<br />

}<br />

Result<br />

If the values of the specified parameters are correct new extern window returns H MSG TRUE. If necessary,<br />

an exception is raised.<br />

Parallelization Information<br />

new extern window is local and processed completely exclusively without parallelization.<br />

reset obj db<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

(T )set color, T query window type, get window type, set window type, get mposition,<br />

set tposition, set tshape, set window extents, get window extents, T query color,<br />

set check, set system<br />

open window, open textwindow<br />

Alternatives<br />

See Also<br />

open window, disp region, disp image, disp color, (T )set lut, T query color,<br />

(T )set color, T set rgb, T set hsi, T set pixel, (T )set gray, set part,<br />

set part style, T query window type, get window type, set window type, get mposition,<br />

set tposition, set window extents, get window extents, set window attr, set check,<br />

set system<br />

Module<br />

System<br />

open textwindow ( long Row, long Column, long Width, long Height,<br />

long BorderWidth, const char *BorderColor, const char *BackgroundColor,<br />

long FatherWindow, const char *Mode, const char *Machine,<br />

long *WindowHandle )<br />

Open a textual window.<br />

open textwindow opens a new textual window, which can be used to perform textual input and output, as<br />

well as to perform output of images. All output (T write string, read string, disp region, etc.) is<br />

redirected to this window, if the same logical window number WindowHandle is used.<br />

Besides the mouse cursor textual windows possess also a textual cursor which indicates the current writing position<br />

(more exactly: the lower left corner of the output string without consideration of descenders). Its position is<br />

indicated through an underscore or another type (the indication of this position may also be disabled (= default<br />

setting); cf. set tshape). You may set or query the position by calling the procedures set tposition or<br />

get tposition.<br />

After you opened a textual window the position of the cursor is set to (H,0). Whereby H significates the height of<br />

the default font less the descenders. But the cursor is not shown. Hence the output starts for writing in the upper<br />

left corner of the window.<br />

You may query the colors of the background and the image edges by calling T query color. Inthesameway<br />

you may use T query color in a window of type ’invisible’. During output (T write string) you may set<br />

<strong>HALCON</strong> 6.0


274 CHAPTER 4. GRAPHICS<br />

the clipping of text out of the window edges by calling set check(::’ text’:). This disables the creation of error<br />

messages, if text passes over the edge of the window.<br />

The origin of the coordinate system of the window resides in the upper left corner (coordinates: (0,0)). The row<br />

index grows downward (maximal: Height-1), the column index grows to the right (maximal: Width-1).<br />

The parameter Machine indicates the name of the computer, which has to open the window. In case of a X-<br />

window, TCP-IP only sets the name, DEC-Net sets in addition a colon behind the name. The ”‘server”’ or the<br />

”‘screen”’, respectively, are not specified. If the empty string is passed the environment variable DISPLAY is<br />

used. It indicates the target computer. At this the name is indicated in common syntax<br />

:0.0<br />

.<br />

Position and size of a window may change during runtime of a program. This may be achieved by calling<br />

set window extents, but also through external interferences (window manager). In the latter case the procedure<br />

set window extents is provided.<br />

Opening a window causes the assignment of a called default font. It is used in connection with<br />

procedures like T write string and you may overwrite it by performing set font after calling<br />

open textwindow. On the other hand you have the possibility to specify a default font by calling<br />

set system(’default font’,) before opening a window (and all following windows; see<br />

also T query font).<br />

You may set the color of the font (T write string, read string) by calling (T )set color,<br />

T set rgb, T set hsi, (T )set gray or T set pixel. Calling set insert specifies how the text or<br />

the graphics, respectively, is combined with the content of the image repeat memory. So you may achieve by<br />

calling e.g. set insert(::’not’:) to eliminate the font after writing text twice at the same position.<br />

Normally every output (e.g. T write string, disp region, (T )disp circle, etc.) in a window is<br />

terminated by a ”‘flush”’. This causes the data to be fully visible on the display after termination of the output<br />

procedure. But this is not necessary in all cases, in particular if there are permanently output tasks or there is a<br />

mouse procedure active. Therefore it is more favorable (i.e. more rapid) to store the data until sufficient data is<br />

available. You may stop this behavior by calling set system(’flush graphic’,’false’).<br />

The content of windows is saved (in case it is supported by special driver software); i.e. it is preserved, also<br />

if the window is hidden by other windows. But this is not necessary in all cases: If you use a textual window<br />

e.g. as a parent window for other windows, you may suppress the security mechanism for it and save the<br />

necessary memory at the same moment. You achieve this before opening the window by calling set system<br />

(’backing store’,’false’).<br />

Difference: graphical window - textual window<br />

¯ In contrast to graphical windows (open window) you may specify more parameters (color, edge) for a<br />

textual window while opening it.<br />

¯ You may use textual windows only for input of user data (read string).<br />

¯ Using textual windows, the output of images, regions and graphics is ”‘clipped”’ at the edges. Whereas<br />

during the use of graphical windows the edges are ”‘zoomed”’.<br />

¯ The coordinate system (e.g. with get mbutton or get mposition) consists of display coordinates<br />

independently of image size. The maximum coordinates are equal to the size of the window minus 1. In<br />

contrast to this, graphical windows (open window) use always a coordinate system, which corresponds to<br />

the image format.<br />

The parameter Mode specifies the mode of the window. It can have following values:<br />

’visible’: Normal mode for textual windows: The window is created according to the parameters and all inputs<br />

and outputs are possible.<br />

’invisible’: Invisible windows are not displayed in the display. Parameters like Row, Column, BorderWidth,<br />

BorderColor, BackgroundColor and FatherWindow do not have any meaning. Output to these<br />

windows has no effect. Input (read string, mouse, etc.) is not possible. You may use these windows to<br />

query representation parameter for an output device without opening a (visible) window. General queries are<br />

e.g. T query color and (T )get string extents.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.8. WINDOW 275<br />

’transparent’: These windows are transparent: the window itself is not visible (edge and background), but<br />

all the other operations are possible and all output is displayed. Parameters like BorderColor and<br />

BackgroundColor do not have any meaning. A common use for this mode is the creation of mouse<br />

sensitive regions.<br />

’buffer’: These are also not visible windows. The output of images, regions and graphics is not visible on<br />

the display, but is stored in memory. Parameters like Row, Column, BorderWidth, BorderColor,<br />

BackgroundColor and FatherWindow do not have any meaning. You may use buffer windows, if you<br />

prepare output (in the background) and copy it finally with (T )copy rectangle in a visible window.<br />

Another usage might be the rapid processing of image regions during interactive manipulations. Textual input<br />

and mouse interaction are not possible in this mode.<br />

Attention<br />

You have to keep in mind that parameters like Row, Column, Width and Height are restricted by the output<br />

device. Is a father window (FatherWindow ’root’) specified, then the coordinates are relative to this window.<br />

Parameter<br />

º Row (input control) .........................................................rectangle.origin.y long<br />

Row index of upper left corner.<br />

Default Value : 0<br />

Typical Range of Values : 0 Row (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : Row 0<br />

º Column (input control) .....................................................rectangle.origin.x long<br />

Column index of upper left corner.<br />

Default Value : 0<br />

Typical Range of Values : 0 Column (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : Column 0<br />

º Width (input control) ......................................................rectangle.extent.x long<br />

Window’s width.<br />

Default Value : 256<br />

Typical Range of Values : 0 Width (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : Width 0<br />

º Height (input control) .....................................................rectangle.extent.y long<br />

Window’s height.<br />

Default Value : 256<br />

Typical Range of Values : 0 Height (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : Height 0<br />

º BorderWidth (input control) ........................................................integer long<br />

Window border’s width.<br />

Default Value : 2<br />

Typical Range of Values : 0 BorderWidth (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : BorderWidth 0<br />

º BorderColor (input control) ..................................................string const char *<br />

Window border’s color.<br />

Default Value : ’white’<br />

º BackgroundColor (input control) .............................................string const char *<br />

Background color.<br />

Default Value : ’black’<br />

<strong>HALCON</strong> 6.0


276 CHAPTER 4. GRAPHICS<br />

º FatherWindow (input control) .........................................integer long / const char *<br />

Logical number of the father window. For the display as father you may specify ’root’ or 0.<br />

Default Value : 0<br />

Restriction : FatherWindow 0<br />

º Mode (input control) ............................................................string const char *<br />

Window mode.<br />

Default Value : ’visible’<br />

Value List : Mode ¾’visible’, ’invisible’, ’transparent’, ’buffer’<br />

º Machine (input control) .......................................................string const char *<br />

Computer name, where the window has to be opened or empty string.<br />

Default Value : ”<br />

º WindowHandle (output control) ...................................................window long *<br />

Window identifier.<br />

Example<br />

open_textwindow(0,0,900,600,1,"black","slate blue","root","visible",<br />

"",&WindowHandle1) ;<br />

open_textwindow(10,10,300,580,3,"red","blue",Father,"visible",<br />

"",&WindowHandle2) ;<br />

open_window(10,320,570,580,Father,"visible","",&WindowHandle) ;<br />

set_color(WindowHandle,"red") ;<br />

read_image(&Image,"affe") ;<br />

disp_image(Image,WindowHandle) ;<br />

create_tuple(&String,1) ;<br />

do {<br />

get_mposition(WindowHandle,&Row,&Column,&Button) ;<br />

get_grayval(Image,Row,Column,1,&Gray) ;<br />

sprintf(buf,"Position( %d,%d ) ",Row,Column) ;<br />

set_s(String,buf,0) ;<br />

T_fwrite_string(String) ;<br />

new_line(WindowHandle) ;<br />

}<br />

while(Button < 4) ;<br />

close_window(WindowHandle) ;<br />

clear_obj(Image) ;<br />

Result<br />

If the values of the specified parameters are correct open textwindow returns H MSG TRUE. If necessary an<br />

exception handling is raised.<br />

Parallelization Information<br />

open textwindow is local and processed completely exclusively without parallelization.<br />

reset obj db<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

(T )set color, T query window type, get window type, set window type, get mposition,<br />

set tposition, set tshape, set window extents, get window extents, T query color,<br />

set check, set system<br />

open window<br />

Alternatives<br />

See Also<br />

T write string, read string, new line, (T )get string extents, get tposition,<br />

(T )set color, T query window type, get window type, set window type, get mposition,<br />

set tposition, set tshape, set window extents, get window extents, T query color,<br />

set check, set system<br />

System<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.8. WINDOW 277<br />

open window ( long Row, long Column, long Width, long Height,<br />

long FatherWindow, const char *Mode, const char *Machine,<br />

long *WindowHandle )<br />

Open a graphics window.<br />

open window opens a new window, which can be used to perform output of gray value data, regions, graphics as<br />

well as to perform textual output. All output (disp region, disp image, etc.) is redirected to this window, if<br />

the same logical window number WindowHandle is used.<br />

The background of the created window is set to black in advance and it has a white border, which is 2 pixels wide<br />

(see also set window attr(’border width’,).<br />

Certain parameters used for the editing of output data are assigned to a window. These parameters are considered<br />

during the output itself (e.g. with disp image or disp region). They are not specified by an output procedure,<br />

but by ”‘configuration procedures”’. If you want to set e.g. the color red for the output of regions, you have to call<br />

(T )set color(WindowHandle,’red’) before calling disp region. These parameters are always set<br />

for the window with the logical window number WindowHandle and remain assigned to a window as long as<br />

they will be overwritten. You may use the following configuration procedures:<br />

¯ Output of gray values: T set paint, set comprise, ((T )set lut and set lut style after output)<br />

¯ Regions: (T )set color, T set rgb, T set hsi, (T )set gray, T set pixel, set shape,<br />

set line width, set insert, T set line style, set draw<br />

¯ Image clipping: set part<br />

¯ Text: set font<br />

You may query current set values by calling procedures like get shape. As some parameters are<br />

specified through the hardware (Resolution/Colors), you may query current available ressources by calling<br />

T query color.<br />

The origin of the coordinate system of the window resides in the upper left corner (coordinates: (0,0)). The row<br />

index grows downward (maximal: Height-1), the column index grows to the right (maximal: Width-1). You<br />

have to keep in mind, that the range of the coordinate system is independent of the window size. It is specified<br />

only through the image format (see reset obj db).<br />

The parameter Machine indicates the name of the computer, which has to open the window. In case of a X-<br />

window, TCP-IP only sets the name, DEC-Net sets in addition a colon behind the name. The ”‘server”’ resp. the<br />

”‘screen”’ are not specified. If the empty string is passed the environment variable DISPLAY is used. It indicates<br />

the target computer. At this the name is indicated in common syntax<br />

:0.0<br />

.<br />

You may use the value ”‘-1”’ for parameters Width and Height. This means, that the according value has to be<br />

specified automatically. In particular this is of importance, if the proportion of pixels is not 1.0 (see set system):<br />

Is one of the two parameters set to ”‘-1”’, it will be specified through the size which results out of the proportion<br />

of pixels. Are both parameters set to ”‘-1”’, they will be set to the maximum image format, which is currently<br />

used (further information about the currently used maximum image format can be found in the description of<br />

get system using ”‘width”’ or ”‘height”’).<br />

Position and size of a window may change during runtime of a program. This may be achieved by calling<br />

set window extents, but also through external interferences (window manager). In the latter case the procedure<br />

set window extents is provided.<br />

Opening a window causes the assignment of a called default font. It is used in connection with<br />

procedures like T write string and you may overwrite it by performing set font after calling<br />

open window. On the other hand you have the possibility to specify a default font by calling set system<br />

(’default font’,) before opening a window (and all following windows; see also<br />

T query font).<br />

You may set the color of graphics and font, which is used for output procedures like disp region<br />

or (T )disp circle, by calling T set rgb, T set hsi, (T )set gray or T set pixel. Calling<br />

set insert specifies how graphics is combined with the content of the image repeat memory. Thereto you<br />

<strong>HALCON</strong> 6.0


278 CHAPTER 4. GRAPHICS<br />

may achieve by calling e.g. set insert(::’not’:) to eliminate the font after writing text twice at the same<br />

position.<br />

Normally every output (e.g. disp image, disp region, (T )disp circle, etc.) in a window is terminated<br />

by a called ”‘flush”’. This causes the data to be fully visible on the display after termination of the output procedure.<br />

But this is not necessary in all cases, in particular if there are permanently output tasks or if there is a mouse<br />

procedure active. Therefore it is more favorable (i.e. more rapid) to store the data until sufficient data is available.<br />

You may stop this behavior by calling set system(’flush graphic’,’false’).<br />

The content of windows is saved (in case it is supported by special driver software); i.e. it is preserved, also if the<br />

window is hidden by other windows. But this is not necessary in all cases: If the content of a window is built up<br />

permanently new ((T )copy rectangle), you may suppress the security mechanism for that and hence you<br />

can save the necessary memory. This is done by calling set system(’backing store’,’false’) before<br />

opening a window. In doing so you save not only memory but also time to compute. This is significant for the<br />

output of video clips (see (T )copy rectangle).<br />

For graphical output (disp image,disp region, etc.) you may adjust the window by calling procedure<br />

set part in order to represent a logical clipping of the image format. In particular this implicates that you<br />

obtain this clipping (with appropriate enlargement) of images and regions only.<br />

Difference: graphical window - textual window<br />

¯ Using graphical windows the layout is not as variable as concerned to textual windows.<br />

¯ You may use textual windows for the input of user data only (read string).<br />

¯ During the output of images, regions and graphics a ”‘zooming”’ is performed using graphical windows:<br />

Independent on size and side ratio of the window images are transformed in that way, that they are displayed<br />

in the window by filling it completely. On the opposite side using textual windows the output does not care<br />

about the size of the window (only if clipping is necessary).<br />

¯ Using graphical windows the coordinate system of the window corresponds to the coordinate system of<br />

the image format. Using textual windows, its coordinate system is always equal to the display coordinates<br />

independent on image size.<br />

The parameter Mode determines the mode of the window. It may have following values:<br />

’visible’: Normal mode for graphical windows: The window is created according to the parameters and all input<br />

and output are possible.<br />

’invisible’: Invisible windows are not displayed in the display. Parameters like Row, Column and<br />

FatherWindow do not have any meaning. Output to these windows has no effect. Input (read string,<br />

mouse, etc.) is not possible. You may use these windows to query representation parameter for an<br />

output device without opening a (visible) window. Common queries are e.g. T query color and<br />

(T )get string extents.<br />

’transparent’: These windows are transparent: the window itself is not visible (edge and background), but all<br />

the other operations are possible and all output is displayed. A common use for this mode is the creation of<br />

mouse sensitive regions.<br />

’buffer’: These are also not visible windows. The output of images, regions and graphics is not visible on the<br />

display, but is stored in memory. Parameters like Row, Column and FatherWindow do not have any<br />

meaning. You may use buffer windows, if you prepare output (in the background) and copy it finally with<br />

(T )copy rectangle in a visible window. Another usage might be the rapid processing of image regions<br />

during interactive manipulations. Textual input and mouse interaction are not possible in this mode.<br />

Attention<br />

You may keep in mind that parameters as Row, Column, Width and Height are constrained by the output<br />

device. If you specify a father window (FatherWindow ’root’) the coordinates are relative to this window.<br />

Parameter<br />

º Row (input control) .........................................................rectangle.origin.y long<br />

Row index of upper left corner.<br />

Default Value : 0<br />

Typical Range of Values : 0 Row (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : Row 0<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.8. WINDOW 279<br />

º Column (input control) .....................................................rectangle.origin.x long<br />

Column index of upper left corner.<br />

Default Value : 0<br />

Typical Range of Values : 0 Column (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : Column 0<br />

º Width (input control) ......................................................rectangle.extent.x long<br />

Width of the window.<br />

Default Value : 256<br />

Typical Range of Values : 0 Width (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : ´Width 0µ ´Width -1µ<br />

º Height (input control) .....................................................rectangle.extent.y long<br />

Height of the window.<br />

Default Value : 256<br />

Typical Range of Values : 0 Height (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : ´Height 0µ ´Height -1µ<br />

º FatherWindow (input control) .........................................integer long / const char *<br />

Logical number of the father window. To specify the display as father you may enter ’root’ or 0.<br />

Default Value : 0<br />

Restriction : FatherWindow 0<br />

º Mode (input control) ............................................................string const char *<br />

Window mode.<br />

Default Value : ’visible’<br />

Value List : Mode ¾’visible’, ’invisible’, ’transparent’, ’buffer’<br />

º Machine (input control) .......................................................string const char *<br />

Name of the computer on which you want to open the window. Otherwise the empty string.<br />

Default Value : ”<br />

º WindowHandle (output control) ...................................................window long *<br />

Window identifier.<br />

Example<br />

set_system("pixel_ratio",1.53) ;<br />

open_window(0,0,400,-1,"root","visible","",&WindowHandle) ;<br />

read_image(&Image,"fabrik") ;<br />

disp_image(Image,WindowHandle) ;<br />

write_string(WindowHandle,"File: fabrik.ima") ;<br />

new_line(WindowHandle) ;<br />

get_mbutton(WindowHandle,_,_,_) ;<br />

set_lut(WindowHandle,"temperature") ;<br />

set_color(WindowHandle,"blue") ;<br />

write_string(WindowHandle,"temperature") ;<br />

new_line(WindowHandle) ;<br />

write_string(WindowHandle,"Draw Rectangle") ;<br />

new_line(WindowHandle) ;<br />

draw_rectangle1(WindowHandle,&Row1,&Column1,&Row2,&Column2) ;<br />

set_part(Row1,Column1,Row2,Column2) ;<br />

disp_image(Image,WindowHandle) ;<br />

new_line(WindowHandle) ;<br />

Result<br />

If the values of the specified parameters are correct open window returns H MSG TRUE. If necessary an exception<br />

handling is raised.<br />

<strong>HALCON</strong> 6.0


280 CHAPTER 4. GRAPHICS<br />

Parallelization Information<br />

open window is local and processed completely exclusively without parallelization.<br />

reset obj db<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

(T )set color, T query window type, get window type, set window type, get mposition,<br />

set tposition, set tshape, set window extents, get window extents, T query color,<br />

set check, set system<br />

open textwindow<br />

Alternatives<br />

See Also<br />

disp region, disp image, disp color, (T )set lut, T query color, (T )set color,<br />

T set rgb, T set hsi, T set pixel, (T )set gray, set part, set part style,<br />

T query window type, get window type, set window type, get mposition, set tposition,<br />

set window extents, get window extents, set window attr, set check, set system<br />

System<br />

Module<br />

T query window type ( Htuple *WindowTypes )<br />

Query all available window types.<br />

T query window type returns a tupel which contains all devices or software systems, respectively, which<br />

are used to display image objects. You may use T query window type usefully while developing machine<br />

independent programs. Possible values are:<br />

’X-Window’ X-Window Version 11.<br />

’pixmap’ Windows are not displayed, but managed in memory. In this manner it is possible to port Halcon<br />

programs to computers without graphical display.<br />

’PostScript’ Objects are output to a PostScript File.<br />

Parameter<br />

º WindowTypes (output control) .........................................string-array Htuple . char *<br />

Names of available window types.<br />

Result<br />

T query window type always returns H MSG TRUE.<br />

Parallelization Information<br />

T query window type is local and processed completely exclusively without parallelization.<br />

reset obj db<br />

System<br />

Possible Predecessor Functions<br />

Module<br />

set window attr ( const char *AttributeName,<br />

const char *AttributeValue )<br />

Set window’s characteristics.<br />

You may use set window attr to set specific characteristics of graphical windows. With it you may modify<br />

following default parameters of a window:<br />

’border width’ Width of the window border in pixels.<br />

’border color’ Color of the window border.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.8. WINDOW 281<br />

’background color’ Background color of the window.<br />

’window title’ Name of the window in the titlebar.<br />

Attention<br />

You have to call set window attr before calling open window.<br />

Parameter<br />

º AttributeName (input control) ...............................................string const char *<br />

Name of the attribut, which has to be modified.<br />

Value List : AttributeName ¾’border width’, ’border color’, ’background color’, ’window title’<br />

º AttributeValue (input control) ........................................string const char * / long<br />

Value of the attribut, which has to be set.<br />

Value List : AttributeValue ¾0, 1, 2, ’white’, ’black’, ’MyName’, ’default’<br />

Result<br />

If the parameters are correct set window attr returns H MSG TRUE. If necessary an exception handling is<br />

raised.<br />

Parallelization Information<br />

set window attr is reentrant, local, and processed without parallelization.<br />

Possible Predecessor Functions<br />

open window, set draw, (T )set color, set colored, set line width, open textwindow<br />

open window<br />

System<br />

See Also<br />

Module<br />

set window dc ( long WindowHandle, long WINHDC )<br />

Set the device context of a virtual graphics window (Windows NT).<br />

set window dc sets the device context of a window previously opened with new extern window. All output<br />

(disp region, disp image, etc.) is done in the window with this device context.<br />

The parameter WINHDC contains the device context of the window in which Halcon should output its data. This<br />

device context is used in all output routines of Halcon.<br />

Attention<br />

The window WindowHandle has to created with new extern window beforehand.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º WINHDC (input control) ...............................................................integer long<br />

devicecontext of WINHWnd.<br />

Restriction : WINHDC 0<br />

Example<br />

set_system("pixel_ratio",1.53) ;<br />

hWnd = createWINDOW(...) ;<br />

new_extern_window(hwnd, hdc, 0,0,400,-1,WindowHandle) ;<br />

set_device_context(WindowHandle, hdc) ;<br />

read_image(&Image,"fabrik") ;<br />

disp_image(Image,WindowHandle) ;<br />

write_string(WindowHandle,"File: fabrik.ima") ;<br />

new_line(WindowHandle) ;<br />

get_mbutton(WindowHandle,_,_,_) ;<br />

set_lut(WindowHandle,"temperature") ;<br />

<strong>HALCON</strong> 6.0


282 CHAPTER 4. GRAPHICS<br />

set_color(WindowHandle,"blue") ;<br />

write_string(WindowHandle,"temperature") ;<br />

new_line(WindowHandle) ;<br />

write_string(WindowHandle,"Draw Rectangle") ;<br />

new_line(WindowHandle) ;<br />

draw_rectangle1(WindowHandle,&Row1,&Column1,&Row2,&Column2) ;<br />

set_part(Row1,Column1,Row2,Column2) ;<br />

disp_image(Image,WindowHandle) ;<br />

new_line(WindowHandle) ;<br />

Result<br />

If the values of the specified parameters are correct, set window dc returns H MSG TRUE. If necessary, an<br />

exception is raised.<br />

Parallelization Information<br />

set window dc is local and processed completely exclusively without parallelization.<br />

new extern window<br />

disp image, disp region<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

new extern window, disp region, disp image, disp color, (T )set lut, T query color,<br />

(T )set color, T set rgb, T set hsi, T set pixel, (T )set gray, set part,<br />

set part style, T query window type, get window type, set window type, get mposition,<br />

set tposition, set window extents, get window extents, set window attr, set check,<br />

set system<br />

Module<br />

System<br />

set window extents ( long WindowHandle, long Row, long Column,<br />

long Width, long Height )<br />

Modify position and size of a window.<br />

set window extents positions the upper left corner of the output window at (Row,Column) and changes the<br />

size of the window to Width and Height at the same time.<br />

Attention<br />

If you modify the size of a window an adaptation of the displayed date to the new format is not processed automatically.<br />

This has to be done by the program in performing another output of these data.<br />

Parameter<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

º Row (input control) .........................................................rectangle.origin.y long<br />

Row index of upper left corner in target position.<br />

Default Value : 0<br />

Typical Range of Values : 0 Row (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Column (input control) .....................................................rectangle.origin.x long<br />

Column index of upper left corner in target position.<br />

Default Value : 0<br />

Typical Range of Values : 0 Column (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


4.8. WINDOW 283<br />

º Width (input control) ......................................................rectangle.extent.x long<br />

Width of the window.<br />

Default Value : 512<br />

Typical Range of Values : 0 Width (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Height (input control) .....................................................rectangle.extent.y long<br />

Height of the window.<br />

Default Value : 512<br />

Typical Range of Values : 0 Height (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Result<br />

If the window is valid and the parameters are correct set window extents returns H MSG TRUE. If necessary<br />

an exception handling is raised.<br />

Parallelization Information<br />

set window extents is local and processed completely exclusively without parallelization.<br />

open window, open textwindow<br />

Possible Predecessor Functions<br />

See Also<br />

get window extents, open window, open textwindow<br />

System<br />

Module<br />

set window type ( const char *WindowType )<br />

Specify a window type.<br />

set window type determines on which type of output device the output is going to be displayed. This specification<br />

is going to be used by procedure open window while opening the windows. You may open different<br />

windows on different types of output devices. Therefore you have to specify the wanted type before opening. You<br />

may request the available types of output devices by calling procedure T query window type. Possible values<br />

are:<br />

’X-Window’ X-Window Version 11.<br />

’WIN32-Window’ Microsoft Windows.<br />

’pixmap’ Windows are not displayed, but managed in memory only. In this manner you may port Halcon programs<br />

to computers without graphical display.<br />

’PostScript’ Objects are output to a PostScript File.<br />

A useful usage of set window type could be the development of machine independent programs.<br />

Parameter<br />

º WindowType (input control) ...................................................string const char *<br />

Name of the window type which has to be set.<br />

Default Value : ’X-Window’<br />

Value List : WindowType ¾’X-Window’, ’WIN32-Window’, ’pixmap’, ’PostScript’<br />

Result<br />

If the type of the output device is available, then set window type returns H MSG TRUE. If necessary an<br />

exception handling is raised.<br />

Parallelization Information<br />

set window type is local and processed completely exclusively without parallelization.<br />

open window, open textwindow<br />

Possible Predecessor Functions<br />

<strong>HALCON</strong> 6.0


284 CHAPTER 4. GRAPHICS<br />

See Also<br />

open window, open textwindow, T query window type, get window type<br />

System<br />

Module<br />

slide image ( long WindowHandleSource1, long WindowHandleSource2,<br />

long WindowHandle )<br />

Interactive output from two window buffers.<br />

slide image divides the window horizontal in two logical areas dependent of the mouse position. The content<br />

of the first indicated window is copied in the upper area, the content of the second window is copied in the lower<br />

area. If you press the left mouse button you may scroll the delimitation between the two areas (you may move<br />

the mouse outside the window, too. In doing so the position of the mouse relative to the window determines the<br />

borderline).<br />

Pressing the right mouse button in the window terminates the procedure slide image.<br />

A useful application of procedure slide image might be the visualisation of the effect of a filtering operation<br />

for an image. The output is directed to the current set window (WindowHandle).<br />

Attention<br />

The three windows must have the same size and have to reside on the same computer.<br />

Parameter<br />

º WindowHandleSource1 (input control) ............................................window long<br />

Logical window number of the ”‘upper window”’.<br />

º WindowHandleSource2 (input control) ............................................window long<br />

Logical window number of the ”‘lower window”’.<br />

º WindowHandle (input control) ......................................................window long<br />

Window identifier.<br />

Example<br />

read_image(&Image,"fabrik") ;<br />

sobel_amp(Image,&Amp,"sum_abs",3) ;<br />

open_window(0,0,-1,-1,"root","buffer","",&WindowHandle) ;<br />

disp_image(Amp,WindowHandle) ;<br />

sobel_dir(Image,&Dir,"sum_abs",3) ;<br />

open_window(0,0,-1,-1,"root","buffer","",&WindowHandle) ;<br />

disp_image(Dir,WindowHandle) ;<br />

open_window(0,0,-1,-1,"root","visible","",&WindowHandle) ;<br />

slide_image(Puffer1,Puffer2,WindowHandle) ;<br />

Result<br />

If the both windows exist and one of these windows is valid slide image returns H MSG TRUE. If necessary<br />

an exception handling is raised.<br />

Parallelization Information<br />

slide image is local and processed completely exclusively without parallelization.<br />

open window, open textwindow<br />

(T )copy rectangle, get mposition<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

open window, open textwindow, (T )move rectangle<br />

System<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Chapter 5<br />

Image<br />

5.1 Channel<br />

access channel ( Hobject MultiChannelImage, Hobject *Image,<br />

long Channel )<br />

Access a channel of a multichannel image.<br />

The operator access channel accesses a channel of the (multichannel) input image. The result is a one-channel<br />

image. The definition domain of the input is adopted. The channels are numbered from 1 to n. The number of<br />

channels can be determined via the operator (T )count channels.<br />

Parameter<br />

º MultiChannelImage (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .multichannel-image Hobject<br />

Multichannel image.<br />

º Image (output object) ..............................................singlechannel-image Hobject *<br />

One channel of MultiChannelImage.<br />

º Channel (input control) .............................................................channel long<br />

Index of channel to be accessed.<br />

Default Value : 1<br />

Value Suggestions : Channel ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12<br />

Typical Range of Values : 1 Channel<br />

Example<br />

read_image(&Color,"patras"); /* Farbbild einlesen */<br />

access_channel(Color,&Red,1); /* Rotkanal extrahieren */<br />

disp_image(Red,WindowHandle);<br />

Parallelization Information<br />

access channel is reentrant and processed without parallelization.<br />

(T )count channels<br />

disp image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

decompose2, decompose3, decompose4, decompose5<br />

(T )count channels<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

285


286 CHAPTER 5. IMAGE<br />

append channel ( Hobject MultiChannelImage, Hobject Image,<br />

Hobject *ImageExtended )<br />

Append additional matrices (channels) to the image.<br />

The operator append channel appends the matrices of the image Image to the matrices of<br />

MultiChannelImage. The result is an image containing as many matrices (channels) as<br />

MultiChannelImage and Image combined. The definition domain of the ouptput image is calculated<br />

as the average of the definition domains of both input images.<br />

Parameter<br />

º MultiChannelImage (input object) ..............................................image Hobject<br />

Multichannel image.<br />

º Image (input object) ..............................................................image Hobject<br />

Image to be appended.<br />

º ImageExtended (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . multichannel-image Hobject *<br />

Image appended by Image.<br />

Parallelization Information<br />

append channel is reentrant and processed without parallelization.<br />

disp image<br />

Possible Successor Functions<br />

Alternatives<br />

compose2, compose3, compose4, compose5<br />

Image / region / XLD management<br />

Module<br />

channels to image ( Hobject Images, Hobject *MultiChannelImage )<br />

Convert one-channel images into a multichannel image<br />

The operator channels to image converts several one-channel images into a multichannel image. The new<br />

definition domain is the average of the definition domains of the input images.<br />

Parameter<br />

º Images (input object) ..........................................singlechannel-image-array Hobject<br />

One-channel images to be combined into a one-channel image.<br />

º MultiChannelImage (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .multichannel-image Hobject *<br />

Multichannel image.<br />

Parallelization Information<br />

channels to image is reentrant, local, and processed without parallelization.<br />

Possible Successor Functions<br />

(T )count channels, disp image<br />

Image / region / XLD management<br />

Module<br />

compose2 ( Hobject Image1, Hobject Image2, Hobject *MultiChannelImage )<br />

Convert two images into a two-channel image.<br />

The operator compose2 converts 2 one-channel images into a 2-channel image. The definition domain is calculated<br />

as the intersection of the definition domains of the input images.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.1. CHANNEL 287<br />

Parameter<br />

º Image1 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 1.<br />

º Image2 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 2.<br />

º MultiChannelImage (output object) . . . . . . . . . . . . . . . . . . . . . . . . multichannel-image(-array) Hobject *<br />

Multichannel image.<br />

Parallelization Information<br />

compose2 is reentrant and automatically parallelized (on tuple level).<br />

disp image<br />

append channel<br />

decompose2<br />

Image / region / XLD management<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

compose3 ( Hobject Image1, Hobject Image2, Hobject Image3,<br />

Hobject *MultiChannelImage )<br />

Convert 3 images into a three-channel image.<br />

The operator compose3 converts 3 one-channel images into a 3-channel image. The definition domain is calculated<br />

as the intersection of the definition domains of the input images.<br />

Parameter<br />

º Image1 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 1.<br />

º Image2 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 2.<br />

º Image3 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 3.<br />

º MultiChannelImage (output object) . . . . . . . . . . . . . . . . . . . . . . . . multichannel-image(-array) Hobject *<br />

Multichannel image.<br />

Parallelization Information<br />

compose3 is reentrant and automatically parallelized (on tuple level).<br />

disp image<br />

append channel<br />

decompose3<br />

Image / region / XLD management<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

compose4 ( Hobject Image1, Hobject Image2, Hobject Image3,<br />

Hobject Image4, Hobject *MultiChannelImage )<br />

Convert 4 images into a four-channel image.<br />

The operator compose4 converts 4 one-channel images into a 4-channel image. The definition domain is calculated<br />

as the intersection of the definition domains of the input images.<br />

<strong>HALCON</strong> 6.0


288 CHAPTER 5. IMAGE<br />

Parameter<br />

º Image1 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 1.<br />

º Image2 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 2.<br />

º Image3 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 3.<br />

º Image4 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 4.<br />

º MultiChannelImage (output object) . . . . . . . . . . . . . . . . . . . . . . . . multichannel-image(-array) Hobject *<br />

Multichannel image.<br />

Parallelization Information<br />

compose4 is reentrant and automatically parallelized (on tuple level).<br />

disp image<br />

append channel<br />

decompose4<br />

Image / region / XLD management<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

compose5 ( Hobject Image1, Hobject Image2, Hobject Image3,<br />

Hobject Image4, Hobject Image5, Hobject *MultiChannelImage )<br />

Convert 5 images into a five-channel image.<br />

The operator compose5 converts 5 one-channel images into a 5-channel image. The definition domain is calculated<br />

as the intersection of the definition domains of the input images.<br />

Parameter<br />

º Image1 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 1.<br />

º Image2 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 2.<br />

º Image3 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 3.<br />

º Image4 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 4.<br />

º Image5 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 5.<br />

º MultiChannelImage (output object) . . . . . . . . . . . . . . . . . . . . . . . . multichannel-image(-array) Hobject *<br />

Multichannel image.<br />

Parallelization Information<br />

compose5 is reentrant and automatically parallelized (on tuple level).<br />

disp image<br />

append channel<br />

decompose5<br />

Image / region / XLD management<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.1. CHANNEL 289<br />

compose6 ( Hobject Image1, Hobject Image2, Hobject Image3,<br />

Hobject Image4, Hobject Image5, Hobject Image6,<br />

Hobject *MultiChannelImage )<br />

Convert 6 images into a six-channel image.<br />

The operator compose6 converts 6 one-channel images into a 6-channel image. The definition domain is calculated<br />

as the intersection of the definition domains of the input images.<br />

Parameter<br />

º Image1 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 1.<br />

º Image2 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 2.<br />

º Image3 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 3.<br />

º Image4 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 4.<br />

º Image5 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 5.<br />

º Image6 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 6.<br />

º MultiChannelImage (output object) . . . . . . . . . . . . . . . . . . . . . . . . multichannel-image(-array) Hobject *<br />

Multichannel image.<br />

Parallelization Information<br />

compose6 is reentrant and automatically parallelized (on tuple level).<br />

disp image<br />

append channel<br />

decompose6<br />

Image / region / XLD management<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

compose7 ( Hobject Image1, Hobject Image2, Hobject Image3,<br />

Hobject Image4, Hobject Image5, Hobject Image6, Hobject Image7,<br />

Hobject *MultiChannelImage )<br />

Convert 7 images into a seven-channel image.<br />

The operator compose7 converts 7 one-channel images into a 7-channel image. The definition domain is calculated<br />

as the intersection of the definition domains of the input images.<br />

Parameter<br />

º Image1 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 1.<br />

º Image2 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 2.<br />

º Image3 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 3.<br />

º Image4 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 4.<br />

º Image5 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 5.<br />

<strong>HALCON</strong> 6.0


290 CHAPTER 5. IMAGE<br />

º Image6 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 6.<br />

º Image7 (input object) .........................................singlechannel-image(-array) Hobject<br />

Input image 7.<br />

º MultiChannelImage (output object) . . . . . . . . . . . . . . . . . . . . . . . . multichannel-image(-array) Hobject *<br />

Multichannel image.<br />

Parallelization Information<br />

compose7 is reentrant and automatically parallelized (on tuple level).<br />

disp image<br />

append channel<br />

decompose7<br />

Image / region / XLD management<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

count channels ( Hobject MultiChannelImage, long *Channels )<br />

T count channels ( Hobject MultiChannelImage, Htuple *Channels )<br />

Count channels of image.<br />

The operator (T )count channels counts the number of channels of all input images.<br />

Parameter<br />

º MultiChannelImage (input object) . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject<br />

One- or multichannel image.<br />

º Channels (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long *<br />

Number of channels.<br />

Example<br />

read_image(&Color,"patras");<br />

count_channels(Color,&num_channels);<br />

for (i=1; i


5.1. CHANNEL 291<br />

The operator decompose2 converts a 2-channel image into two one-channel images with the same definition<br />

domain.<br />

Parameter<br />

º MultiChannelImage (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . .multichannel-image(-array) Hobject<br />

Multichannel image.<br />

º Image1 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 1.<br />

º Image2 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 2.<br />

Parallelization Information<br />

decompose2 is reentrant and automatically parallelized (on tuple level).<br />

(T )count channels<br />

disp image<br />

access channel, image to channels<br />

compose2<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

decompose3 ( Hobject MultiChannelImage, Hobject *Image1,<br />

Hobject *Image2, Hobject *Image3 )<br />

Convert a three-channel image into three images.<br />

The operator decompose3 converts a 3-channel image into three one-channel images with the same definition<br />

domain.<br />

Parameter<br />

º MultiChannelImage (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . .multichannel-image(-array) Hobject<br />

Multichannel image.<br />

º Image1 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 1.<br />

º Image2 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 2.<br />

º Image3 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 3.<br />

Parallelization Information<br />

decompose3 is reentrant and automatically parallelized (on tuple level).<br />

(T )count channels<br />

disp image<br />

access channel, image to channels<br />

compose3<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


292 CHAPTER 5. IMAGE<br />

decompose4 ( Hobject MultiChannelImage, Hobject *Image1,<br />

Hobject *Image2, Hobject *Image3, Hobject *Image4 )<br />

Convert a four-channel image into four images.<br />

The operator decompose4 converts a 4-channel image into four one-channel images with the same definition<br />

domain.<br />

Parameter<br />

º MultiChannelImage (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . .multichannel-image(-array) Hobject<br />

Multichannel image.<br />

º Image1 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 1.<br />

º Image2 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 2.<br />

º Image3 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 3.<br />

º Image4 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 4.<br />

Parallelization Information<br />

decompose4 is reentrant and automatically parallelized (on tuple level).<br />

(T )count channels<br />

disp image<br />

access channel, image to channels<br />

compose4<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

decompose5 ( Hobject MultiChannelImage, Hobject *Image1,<br />

Hobject *Image2, Hobject *Image3, Hobject *Image4, Hobject *Image5 )<br />

Convert a five-channel image into five images.<br />

The operator decompose5 converts a 5-channel image into five one-channel images with the same definition<br />

domain.<br />

Parameter<br />

º MultiChannelImage (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . .multichannel-image(-array) Hobject<br />

Multichannel image.<br />

º Image1 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 1.<br />

º Image2 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 2.<br />

º Image3 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 3.<br />

º Image4 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 4.<br />

º Image5 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 5.<br />

Parallelization Information<br />

decompose5 is reentrant and automatically parallelized (on tuple level).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.1. CHANNEL 293<br />

Possible Predecessor Functions<br />

(T )count channels<br />

Possible Successor Functions<br />

disp image<br />

Alternatives<br />

access channel, image to channels<br />

See Also<br />

compose5<br />

Module<br />

Image / region / XLD management<br />

decompose6 ( Hobject MultiChannelImage, Hobject *Image1,<br />

Hobject *Image2, Hobject *Image3, Hobject *Image4, Hobject *Image5,<br />

Hobject *Image6 )<br />

Convert a six-channel image into six images.<br />

The operator decompose6 converts a 6-channel image into six one-channel images with the same definition<br />

domain.<br />

Parameter<br />

º MultiChannelImage (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . .multichannel-image(-array) Hobject<br />

Multichannel image.<br />

º Image1 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 1.<br />

º Image2 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 2.<br />

º Image3 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 3.<br />

º Image4 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 4.<br />

º Image5 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 5.<br />

º Image6 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 6.<br />

Parallelization Information<br />

decompose6 is reentrant and automatically parallelized (on tuple level).<br />

(T )count channels<br />

disp image<br />

access channel, image to channels<br />

compose6<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

decompose7 ( Hobject MultiChannelImage, Hobject *Image1,<br />

Hobject *Image2, Hobject *Image3, Hobject *Image4, Hobject *Image5,<br />

Hobject *Image6, Hobject *Image7 )<br />

Convert a seven-channel image into seven images.<br />

<strong>HALCON</strong> 6.0


294 CHAPTER 5. IMAGE<br />

The operator decompose7 converts a 7-channel image into seven one-channel images with the same definition<br />

domain.<br />

Parameter<br />

º MultiChannelImage (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . .multichannel-image(-array) Hobject<br />

Multichannel image.<br />

º Image1 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 1.<br />

º Image2 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 2.<br />

º Image3 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 3.<br />

º Image4 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 4.<br />

º Image5 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 5.<br />

º Image6 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 6.<br />

º Image7 (output object) ......................................singlechannel-image(-array) Hobject *<br />

Output image 7.<br />

Parallelization Information<br />

decompose7 is reentrant and automatically parallelized (on tuple level).<br />

(T )count channels<br />

disp image<br />

access channel, image to channels<br />

compose7<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

image to channels ( Hobject MultiChannelImage, Hobject *Images )<br />

Convert a multichannel image into One-channel images<br />

The operator image to channels generates a one-channel image for each channel of the multichannel image<br />

in MultiChannelImage. The definition domains are adopted from the input image. As many images are<br />

created as MultiChannelImage has channels.<br />

Parameter<br />

º MultiChannelImage (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .multichannel-image Hobject<br />

Multichannel image to be decomposed.<br />

º Images (output object) ........................................singlechannel-image-array Hobject *<br />

Generated one-channel images.<br />

Parallelization Information<br />

image to channels is reentrant and processed without parallelization.<br />

(T )count channels<br />

disp image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

access channel, decompose2, decompose3, decompose4, decompose5<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.2. CREATION 295<br />

Image / region / XLD management<br />

Module<br />

5.2 Creation<br />

copy image ( Hobject Image, Hobject *DupImage )<br />

Copy an image and allocate new memory for it.<br />

copy image copies the first channel of the input image into a new (single-channel) image with the same domain<br />

as the imput image. In contrast to <strong>HALCON</strong> operators such as copy obj, the image is copied into a newly<br />

allocated memory segment. This can be used to modify the gray values of the new image, for example (see<br />

get image pointer1).<br />

Parameter<br />

º Image (input object) ..............................................................image Hobject<br />

Image to be copied.<br />

º DupImage (output object) ........................................................image Hobject *<br />

Copied image.<br />

Parallelization Information<br />

copy image is reentrant and processed without parallelization.<br />

read image, gen image const<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

(T )set grayval, get image pointer1<br />

Alternatives<br />

(T )set grayval, paint gray, gen image const, gen image proto<br />

get image pointer1<br />

Basic operators<br />

See Also<br />

Module<br />

gen image1 ( Hobject *Image, const char *Type, long Width, long Height,<br />

long PixelPointer )<br />

Create an image from a pointer to the pixels.<br />

The operator gen image1 creates an image of the size Width ¢ Height. The pixels in PixelPointer are<br />

stored line-sequentially. The type of the given pixels (PixelPointer) must correspond to Type. The storage<br />

for the new image is newly created by <strong>HALCON</strong> . Thus, the storage on the PixelPointer can be released after<br />

the call. Since the type of the parameter PixelPointer is generic (long) a cast has to be used for the call.<br />

Parameter<br />

º Image (output object) ............................................................image Hobject *<br />

Created image with new image matrix.<br />

º Type (input control) ............................................................string const char *<br />

Pixel type.<br />

Default Value : ’byte’<br />

Value List : Type ¾’int1’, ’int2’, ’int4’, ’byte’, ’real’, ’direction’, ’cyclic’<br />

<strong>HALCON</strong> 6.0


296 CHAPTER 5. IMAGE<br />

º Width (input control) ...............................................................extent.x long<br />

Width of image.<br />

Default Value : 512<br />

Value Suggestions : Width ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Width 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Width 1<br />

º Height (input control) ..............................................................extent.y long<br />

Height of image.<br />

Default Value : 512<br />

Value Suggestions : Height ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Height 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Height 1<br />

º PixelPointer (input control) ......................................................integer long<br />

Pointer to first gray value.<br />

Example<br />

void NewImage(Hobject *new)<br />

{<br />

unsigned char image[768*525];<br />

int<br />

r,c;<br />

for (r=0; r


5.2. CREATION 297<br />

void ClearProc(void* ptr);<br />

It is called when deleting Image. If the memory shall not be released (in the case of frame grabbers or<br />

static memory) a procedure “without trunk” or the NULL-Pointer can be passed. Analogous to the parameter<br />

PixelPointer the pointer has to be passed to the procedure by casting it to long.<br />

Parameter<br />

º Image (output object) ............................................................image Hobject *<br />

Created <strong>HALCON</strong> image.<br />

º Type (input control) ............................................................string const char *<br />

Pixel type.<br />

Default Value : ’byte’<br />

Value List : Type ¾’int1’, ’int2’, ’int4’, ’byte’, ’real’, ’direction’, ’cyclic’<br />

º Width (input control) ...............................................................extent.x long<br />

Width of image.<br />

Default Value : 512<br />

Value Suggestions : Width ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Width 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Width 1<br />

º Height (input control) ..............................................................extent.y long<br />

Height of image.<br />

Default Value : 512<br />

Value Suggestions : Height ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Height 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Height 1<br />

º PixelPointer (input control) ......................................................integer long<br />

Pointer to the first gray value.<br />

º ClearProc (input control) ...........................................................integer long<br />

Pointer to the procedure re-releasing the memory of the image when deleting the object.<br />

Default Value : 0<br />

Example<br />

void NewImage(Hobject *new)<br />

{<br />

unsigned char *image;<br />

int<br />

r,c;<br />

image = malloc(640*480);<br />

for (r=0; r


298 CHAPTER 5. IMAGE<br />

gen image1 rect ( Hobject *Image, long PixelPointer, long Width,<br />

long Height, long VerticalPitch, long HorizontalBitPitch,<br />

long BitsPerPixel, const char *DoCopy, long ClearProc )<br />

Create an image with a rectangular domain from a pointer on the pixels (with storage management).<br />

The operator gen image1 rect creates an image of size (Width + VerticalPitch)*Height. The pixels<br />

pointed to by PixelPointer are stored line by line. Since the type of the parameter PixelPointer is generic<br />

(long) a cast must be used for the call. VerticalPitch determines the distance (in pixels) between the last pixel<br />

in row n and the first pixel in row n+1 inside of memory. All rows of the ’input image’ have the same vertical<br />

pitch. The width of the output image equals Width + VerticalPitch. The height of input and output image<br />

are equal. The domain of the output image Image is a rectangle of the size Width * Height. The parameters<br />

HorizontalBitPitch and BitsPerPixel are not supported at the time and have to be passed as default<br />

values.<br />

If DoCopy is set ’true’, the image data pointed to by PixelPointer is copied and memory for the new image is<br />

newly allocated by <strong>HALCON</strong> . Else the image data is not duplicated and the memory space that PixelPointer<br />

points to must be released when deleting the object Image. This is done by the procedure ClearProc provided<br />

by the caller. This procedure must have the following signature:<br />

void ClearProc(void* ptr);<br />

It is called when deleting Image. If the memory shall not be released (in the case of frame grabbers or<br />

static memory) a procedure ”without trunk” or the NULL-pointer can be passed. Analogously to the parameter<br />

PixelPointer the pointer has to be passed to the procedure by casting it to long. If DoCopy<br />

is ’true’ then ClearProc is irrelevant. The operator gen image1 rect is approximately symmetrical to<br />

get image pointer1 rect.<br />

Parameter<br />

º Image (output object) ............................................................image Hobject *<br />

Created <strong>HALCON</strong> image.<br />

º PixelPointer (input control) ......................................................integer long<br />

Pointer to the first pixel.<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the image.<br />

Default Value : 512<br />

Value Suggestions : Width ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Width 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Width 1<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the image.<br />

Default Value : 512<br />

Value Suggestions : Height ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Height 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Height 1<br />

º VerticalPitch (input control) .....................................................integer long<br />

Distance between last pixel in row n and first pixel in row n+1 of the ’input image’.<br />

Restriction : VerticalPitch 0<br />

º HorizontalBitPitch (input control) ..............................................integer long<br />

Distance between two neighbouring pixels in bits .<br />

Default Value : 8<br />

Restriction : HorizontalBitPitch 8<br />

º BitsPerPixel (input control) ......................................................integer long<br />

Number of used bits per pixel.<br />

Default Value : 8<br />

Restriction : BitsPerPixel 8<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.2. CREATION 299<br />

º DoCopy (input control) .........................................................string const char *<br />

Copy image data.<br />

Default Value : ’false’<br />

Value Suggestions : DoCopy ¾’true’, ’false’<br />

º ClearProc (input control) ...........................................................integer long<br />

Pointer to the procedure releasing the memory of the image when deleting the object.<br />

Default Value : 0<br />

void NewImage(Hobject *new)<br />

{<br />

unsigned char *image;<br />

int r,c;<br />

Example<br />

}<br />

image = malloc(640*480);<br />

for (r=0; r


300 CHAPTER 5. IMAGE<br />

º Width (input control) ...............................................................extent.x long<br />

Width of image.<br />

Default Value : 512<br />

Value Suggestions : Width ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Width 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Height (input control) ..............................................................extent.y long<br />

Height of image.<br />

Default Value : 512<br />

Value Suggestions : Height ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Height 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º PixelPointerRed (input control) ..................................................integer long<br />

Pointer to first red value (channel 1).<br />

º PixelPointerGreen (input control) ................................................integer long<br />

Pointer to first green value (channel 2).<br />

º PixelPointerBlue (input control) .................................................integer long<br />

Pointer to first blue value (channel 3).<br />

Example<br />

void NewRGBImage(Hobject *new)<br />

{<br />

unsigned char red[768*525];<br />

unsigned char green[768*525];<br />

unsigned char blue[768*525];<br />

int<br />

r,c;<br />

for (r=0; r


5.2. CREATION 301<br />

See Also<br />

reduce domain, paint gray, paint region, (T )set grayval, get image pointer1,<br />

decompose3<br />

Module<br />

Image / region / XLD management<br />

gen image const ( Hobject *Image, const char *Type, long Width,<br />

long Height )<br />

Create an image with constant gray value.<br />

The operator gen image const creates an image of the indicated size. The height and width of the image are<br />

determined by Height and Width. <strong>HALCON</strong> supports the following image types:<br />

’byte’ 1 byte per pixel (0..255)<br />

’int1’ 1 byte per pixel (-127..127)<br />

’int2’ 2 bytes per pixel (-32767..32767)<br />

’int4’ 4 bytes per pixel (-2147483647..2147483647)<br />

’real’ 4 bytes per pixel, floating point<br />

’complex’ two matrices of the type real<br />

’dvf’ two matrices of the type int1<br />

’dir’ 1 byte per pixel (0..180)<br />

’cyclic’ 1 byte per pixel; cyclic arithmetics (0..255).<br />

The default value 0 is set via the operator set system(’init new image’,).<br />

Parameter<br />

º Image (output object) ............................................................image Hobject *<br />

Created image with new image matrix.<br />

º Type (input control) ............................................................string const char *<br />

Pixel type.<br />

Default Value : ’byte’<br />

Value List : Type ¾’int1’, ’int2’, ’int4’, ’byte’, ’real’, ’direction’, ’cyclic’, ’complex’, ’dvf’, ’lut’<br />

º Width (input control) ...............................................................extent.x long<br />

Width of image.<br />

Default Value : 512<br />

Value Suggestions : Width ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Width 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Width 1<br />

º Height (input control) ..............................................................extent.y long<br />

Height of image.<br />

Default Value : 512<br />

Value Suggestions : Height ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Height 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Height 1<br />

Example<br />

gen_image_const(&New,"byte",width,height);<br />

get_image_pointer1(New,(long*)&pointer,"byte",width,height);<br />

for (row=0; row


302 CHAPTER 5. IMAGE<br />

Result<br />

If the parameter values are correct, the operator gen image const returns the value H MSG TRUE. Otherwise<br />

an exception handling is raised.<br />

Parallelization Information<br />

gen image const is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

paint region, reduce domain, get image pointer1, copy obj<br />

gen image1, gen image3<br />

Alternatives<br />

See Also<br />

reduce domain, paint gray, paint region, (T )set grayval, get image pointer1<br />

Image / region / XLD management<br />

Module<br />

gen image gray ramp ( Hobject *ImageGrayRamp, double Alpha,<br />

double Beta, double Mean, long Row, long Column, long Width, long Height )<br />

Create a gray value ramp.<br />

The operator gen image gray ramp creates a gray value ramp according to the following equation:<br />

ÁÑÖÝÊÑÔ ¼´ÖµÐÔ´Ö ÊÓÛµ ·Ø´ ÓÐÙÑÒµ ·ÅÒ<br />

The size of the image is determined by Width and Height The gray values are of the type byte. Grayvalues<br />

outside the valid area are clipped.<br />

Parameter<br />

º ImageGrayRamp (output object) ..........................................image Hobject * : byte<br />

Created image with new image matrix.<br />

º Alpha (input control) .............................................................number double<br />

Gradient in line direction.<br />

Default Value : 1.0<br />

Value Suggestions : Alpha ¾-2.0, -1.0, -0.5, -0.0, 0.5, 1.0, 2.0<br />

Minimal Value Step : 0.000001<br />

Recommended Value Step : -0.005<br />

º Beta (input control) ...............................................................number double<br />

Gradient in column direction.<br />

Default Value : 1.0<br />

Value Suggestions : Beta ¾-2.0, -1.0, -0.5, -0.0, 0.5, 1.0, 2.0<br />

Minimal Value Step : 0.000001<br />

Recommended Value Step : -0.005<br />

º Mean (input control) ...............................................................number double<br />

Mean gray value.<br />

Default Value : 128<br />

Value Suggestions : Mean ¾0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Row (input control) ...................................................................point.y long<br />

Line index of reference point.<br />

Default Value : 256<br />

Value Suggestions : Row ¾128, 256, 512, 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.2. CREATION 303<br />

º Column (input control) ...............................................................point.x long<br />

Column index of reference point.<br />

Default Value : 256<br />

Value Suggestions : Column ¾128, 256, 512, 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Width (input control) ...............................................................extent.x long<br />

Width of image.<br />

Default Value : 512<br />

Value Suggestions : Width ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Width 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Width 1<br />

º Height (input control) ..............................................................extent.y long<br />

Height of image.<br />

Default Value : 512<br />

Value Suggestions : Height ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Height 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Height 1<br />

Result<br />

If the parameter values are correct gen image gray ramp returns the value H MSG TRUE. Otherwise an exception<br />

handling is raised.<br />

Parallelization Information<br />

gen image gray ramp is reentrant and processed without parallelization.<br />

(T )moments gray plane<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

paint region, reduce domain, get image pointer1, copy obj<br />

gen image1<br />

reduce domain, paint gray<br />

Image / region / XLD management<br />

Alternatives<br />

See Also<br />

Module<br />

gen image proto ( Hobject Image, Hobject *ImageCleared, double Grayval )<br />

Set the gray values of an image to a specified value.<br />

gen image proto sets the gray values of the image ImageCleared to the value Grayval. The input image<br />

is not modified. It is merely used to determine the size of the output image.<br />

Parameter<br />

º Image (input object) ..............................................................image Hobject<br />

Image, whose gray values are to be cleared.<br />

º ImageCleared (output object) ..................................................image Hobject *<br />

Image with constant gray value.<br />

º Grayval (input control) ....................................................number double / long<br />

Gray value to be used for the output image.<br />

Default Value : 0<br />

Value Suggestions : Grayval ¾0, 1, 2, 5, 10, 16, 32, 64, 128, 253, 254, 255<br />

<strong>HALCON</strong> 6.0


304 CHAPTER 5. IMAGE<br />

Result<br />

gen image proto returns H MSG TRUE if all parameters are correct. If necessary, an exception is raised.<br />

Parallelization Information<br />

gen image proto is reentrant and processed without parallelization.<br />

test obj def<br />

Possible Predecessor Functions<br />

Alternatives<br />

(T )set grayval, paint gray, gen image const, copy image<br />

get image pointer1<br />

Basic operators<br />

See Also<br />

Module<br />

gen image surface second order ( Hobject *ImageSurface,<br />

const char *Type, double Alpha, double Beta, double Gamma, double Delta,<br />

double Epsilon, double Zeta, double Row, double Col, long Width,<br />

long Height )<br />

Create a curved gray surface with second order polynomial.<br />

The operator gen image surface second order creates a curved gray value surface according to the following<br />

equation:<br />

ÁÑËÙÖ´ÖµÐÔ´Ö ÊÓÛµ££¾·Ø´ Óе££¾·ÑÑ´Ö ÊÓÛµ£´ Óе·ÐØ´Ö ÊÓÛµ·ÐØ´ Óе·Ø<br />

The size of the image is determined by Width and Height. The gray values are of the type Type. Grayvalues<br />

outside the valid area are clipped.<br />

Parameter<br />

º ImageSurface (output object) .......................................image Hobject * : byte / real<br />

Created image with new image matrix.<br />

º Type (input control) ............................................................string const char *<br />

Pixel type.<br />

Default Value : ’byte’<br />

Value List : Type ¾’byte’, ’real’<br />

º Alpha (input control) .............................................................number double<br />

Second order coefficent in line direction.<br />

Default Value : 1.0<br />

Value Suggestions : Alpha ¾-2.0, -1.0, -0.5, -0.0, 0.5, 1.0, 2.0<br />

Minimal Value Step : 0.000001<br />

Recommended Value Step : -0.005<br />

º Beta (input control) ...............................................................number double<br />

Second order coefficent in column direction.<br />

Default Value : 1.0<br />

Value Suggestions : Beta ¾-2.0, -1.0, -0.5, -0.0, 0.5, 1.0, 2.0<br />

Minimal Value Step : 0.000001<br />

Recommended Value Step : -0.005<br />

º Gamma (input control) .............................................................number double<br />

Mixed second order coefficent.<br />

Default Value : 1.0<br />

Value Suggestions : Gamma ¾-2.0, -1.0, -0.5, -0.0, 0.5, 1.0, 2.0<br />

Minimal Value Step : 0.000001<br />

Recommended Value Step : -0.005<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.2. CREATION 305<br />

º Delta (input control) .............................................................number double<br />

First order coefficent in line direction.<br />

Default Value : 1.0<br />

Value Suggestions : Delta ¾-2.0, -1.0, -0.5, -0.0, 0.5, 1.0, 2.0<br />

Minimal Value Step : 0.000001<br />

Recommended Value Step : -0.005<br />

º Epsilon (input control) ..........................................................number double<br />

First order coefficent ibn column direction.<br />

Default Value : 1.0<br />

Value Suggestions : Epsilon ¾-2.0, -1.0, -0.5, -0.0, 0.5, 1.0, 2.0<br />

Minimal Value Step : 0.000001<br />

Recommended Value Step : -0.005<br />

º Zeta (input control) ...............................................................number double<br />

Zero order coefficent<br />

Default Value : 1.0<br />

Value Suggestions : Zeta ¾-2.0, -1.0, -0.5, -0.0, 0.5, 1.0, 2.0<br />

Minimal Value Step : 0.000001<br />

Recommended Value Step : -0.005<br />

º Row (input control) ................................................................number double<br />

line coordinate of the apex of the surface<br />

Default Value : 256.0<br />

Value Suggestions : Row ¾0.0, 128.0, 256.0, 512.0<br />

Minimal Value Step : 0.000001<br />

Recommended Value Step : -0.005<br />

º Col (input control) ................................................................number double<br />

Column coordinate of the apex of the surface<br />

Default Value : 256.0<br />

Value Suggestions : Col ¾0.0, 128.0, 256.0, 512.0<br />

Minimal Value Step : 0.000001<br />

Recommended Value Step : -0.005<br />

º Width (input control) ...............................................................extent.x long<br />

Width of image.<br />

Default Value : 512<br />

Value Suggestions : Width ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Width 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Width 1<br />

º Height (input control) ..............................................................extent.y long<br />

Height of image.<br />

Default Value : 512<br />

Value Suggestions : Height ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Height 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Height 1<br />

Result<br />

If the parameter values are correct gen image surface second order returns the value H MSG TRUE.<br />

Otherwise an exception handling is raised.<br />

Parallelization Information<br />

gen image surface second order is reentrant, local, and processed without parallelization.<br />

gen image gray ramp<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


306 CHAPTER 5. IMAGE<br />

get image time ( Hobject Image, long *MSecond, long *Second,<br />

long *Minute, long *Hour, long *Day, long *YDay, long *Month, long *Year )<br />

Request time at which the image was created.<br />

The operator get image time returns the time at which the image was created.<br />

Parameter<br />

º Image (input object) ..............................................................image Hobject<br />

Input image.<br />

º MSecond (output control) ..........................................................integer long *<br />

Milliseconds (0..999).<br />

º Second (output control) ............................................................integer long *<br />

Seconds (0..59).<br />

º Minute (output control) ............................................................integer long *<br />

Minutes (0..59).<br />

º Hour (output control) ...............................................................integer long *<br />

Hours (0..11).<br />

º Day (output control) ................................................................integer long *<br />

Day of the month (1..31).<br />

º YDay (output control) ...............................................................integer long *<br />

Day of the year (1..365).<br />

º Month (output control) .............................................................integer long *<br />

Month (1..12).<br />

º Year (output control) ...............................................................integer long *<br />

Year (xxxx).<br />

Result<br />

The operator get image time returns the value H MSG TRUE if exactly one image was passed. The<br />

behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

get image time is reentrant, local, and processed without parallelization.<br />

read image, grab image<br />

count seconds<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

region to bin ( Hobject Region, Hobject *BinImage, long ForegroundGray,<br />

long BackgroundGray, long Width, long Height )<br />

Convert a region into a binary byte-image.<br />

region to bin converts the input region given in Region into a byte-image and assigns a gray value of<br />

ForegroundGray to all pixels in the region. If the input region is larger than the generated image, it is clipped<br />

at the image borders. The background is set to BackgroundGray.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be converted.<br />

º BinImage (output object) .................................................image Hobject * : byte<br />

Result image of dimension Width ¢ Height containing the converted regions.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.2. CREATION 307<br />

º ForegroundGray (input control) ....................................................integer long<br />

Gray value in which the regions are displayed.<br />

Default Value : 255<br />

Value Suggestions : ForegroundGray ¾0, 1, 50, 100, 128, 150, 200, 254, 255<br />

Typical Range of Values : 0 ForegroundGray 255 (lin)<br />

Recommended Value Step : 1<br />

º BackgroundGray (input control) ....................................................integer long<br />

Gray value in which the background is displayed.<br />

Default Value : 0<br />

Value Suggestions : BackgroundGray ¾0, 1, 50, 100, 128, 150, 200, 254, 255<br />

Typical Range of Values : 0 BackgroundGray 255 (lin)<br />

Recommended Value Step : 1<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the image to be generated.<br />

Default Value : 512<br />

Value Suggestions : Width ¾256, 512, 1024<br />

Typical Range of Values : 1 Width 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 16<br />

Restriction : Width 1<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the image to be generated.<br />

Default Value : 512<br />

Value Suggestions : Height ¾256, 512, 1024<br />

Typical Range of Values : 1 Height 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 16<br />

Restriction : Height 1<br />

Ç´¾ £ ÀØ £ Ïص.<br />

Complexity<br />

Result<br />

region to bin always returns H MSG TRUE. The behavior in case of empty input (no regions given) can be<br />

set via set system(’no object result’,) and the behavior in case of an empty input region<br />

via set system(’empty region result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

region to bin is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring<br />

(T )get grayval<br />

Possible Successor Functions<br />

Alternatives<br />

region to label, paint region, (T )set grayval<br />

gen image proto, paint gray<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

region to label ( Hobject Region, Hobject *ImageLabel, const char *Type,<br />

long Width, long Height )<br />

Convert regions to a label image.<br />

region to label converts the input regions into a label image according to their index (½Ò), i.e., the first<br />

region is painted with the gray value 1, the second the gray value 2, etc. Only positive gray values are used. For<br />

byte-images the index is entered modulo 256.<br />

<strong>HALCON</strong> 6.0


308 CHAPTER 5. IMAGE<br />

Regions larger than the generated image are clipped appropriately. If regions overlap the regions with the higher<br />

image are entered (i.e., they are painted in the order in which they are contained in the input regions). If so desired,<br />

the regions can be made non-overlapping by calling expand region.<br />

The background, i.e., the area not covered by any regions, is set to 0. This can be used to test in which image range<br />

no region is present.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be converted.<br />

º ImageLabel (output object) ....................................image Hobject * : byte / int2 / int4<br />

Result image of dimension Width ¢ Height containing the converted regions.<br />

º Type (input control) ............................................................string const char *<br />

Pixel type of the result image.<br />

Default Value : ’int2’<br />

Value List : Type ¾’byte’, ’int2’, ’int4’<br />

º Width (input control) ...............................................................extent.y long<br />

Width of the image to be generated.<br />

Default Value : 512<br />

Value Suggestions : Width ¾64, 128, 256, 512, 1024<br />

Typical Range of Values : 1 Width 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 16<br />

Restriction : Width 1<br />

º Height (input control) ..............................................................extent.x long<br />

Height of the image to be generated.<br />

Default Value : 512<br />

Value Suggestions : Height ¾64, 128, 256, 512, 1024<br />

Typical Range of Values : 1 Height 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 16<br />

Restriction : Height 1<br />

Ç´¾ £ ÀØ £ Ïص.<br />

Complexity<br />

Result<br />

region to label always returns H MSG TRUE. The behavior in case of empty input (no regions given) can be<br />

set via set system(’no object result’,) and the behavior in case of an empty input region<br />

via set system(’empty region result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

region to label is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, expand region<br />

Possible Successor Functions<br />

(T )get grayval, get image pointer1<br />

region to bin, paint region<br />

label to region<br />

Image / region / XLD management<br />

Alternatives<br />

See Also<br />

Module<br />

region to mean ( Hobject Regions, Hobject Image, Hobject *ImageMean )<br />

Paint regions with their average gray value.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.3. DOMAIN 309<br />

region to mean returns an image in which the regions Regions are painted with their average gray value<br />

basedontheimageImage. This operator is mainly intended to visualize segmentation results.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Input regions.<br />

º Image (input object) .........................................................image Hobject : byte<br />

original gray-value image.<br />

º ImageMean (output object) ................................................image Hobject * : byte<br />

Result image with painted regions.<br />

Example<br />

read_image(&Image,"fabrik");<br />

region_growing(Image,&Regions,3,3,6,100);<br />

region_to_mean(Regions,Image,&Disp);<br />

disp_image(Disp,WindowHandle);<br />

set_draw(WindowHandle,"margin");<br />

set_color(WindowHandle,"black");<br />

disp_region(Regions,WindowHandle);<br />

Result<br />

region to mean returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can be<br />

set via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

region to mean is reentrant and automatically parallelized (on tuple level, channel level).<br />

regiongrowing, connection<br />

disp image<br />

paint region, (T )intensity<br />

Image filters<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

Module<br />

5.3 Domain<br />

add channels ( Hobject Regions, Hobject Image, Hobject *GrayRegions )<br />

Add gray values to regions.<br />

The operator add channels adds the gray values from Image to the regions in Regions. All channels of<br />

Image are adopted. The definition domain is calculated as the average of the definition domain of the image with<br />

the region. Thus the new definition domain can be a subset of the input region. The size of the matrix is not<br />

changed.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Input regions (without gray values).<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image Hobject :any<br />

Gray image for regions.<br />

º GrayRegions (output object) .............................................image(-array) Hobject *<br />

Regions with gray values (also gray images).<br />

Parameter Number : Regions GrayRegions<br />

<strong>HALCON</strong> 6.0


310 CHAPTER 5. IMAGE<br />

Parallelization Information<br />

add channels is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, gen circle, draw region<br />

Possible Successor Functions<br />

threshold, regiongrowing, get domain<br />

change domain, reduce domain<br />

full domain, get domain, intersection<br />

Image / region / XLD management<br />

Alternatives<br />

See Also<br />

Module<br />

change domain ( Hobject Image, Hobject NewDomain, Hobject *ImageNew )<br />

Change definition domain of an image.<br />

The operator change domain uses the indicated region as new definition domain. Unlike the operator<br />

reduce domain it does not form the intersection of the previous definition domain. This can lead to errors<br />

particularly when the region is larger than the image matrix. The size of the matrix is not changed.<br />

Attention<br />

Due to running time the transferred region is not checked for consistency (i.e., whether it fits with the image<br />

matrix). Incorrect regions lead to system hang-ups during subsequent operations.<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Input image.<br />

º NewDomain (input object) .........................................................region Hobject<br />

New definition domain.<br />

º ImageNew (output object) .................................................image(-array) Hobject *<br />

Image with new definition domain.<br />

Parallelization Information<br />

change domain is reentrant and automatically parallelized (on tuple level).<br />

get domain<br />

reduce domain<br />

full domain, get domain, intersection<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

full domain ( Hobject Image, Hobject *ImageFull )<br />

Expand the domain of an image to maximum.<br />

The operator full domain enters a rectangle with the edge length of the image as new definition domain. This<br />

means that all pixels of the matrix are included in further operations. Thus the same definition domain is obtained<br />

as by reading or generating an image. The size of the matrix is not changed.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.3. DOMAIN 311<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Input image.<br />

º ImageFull (output object) ...............................................image(-array) Hobject *<br />

Image with maximum definition domain.<br />

Parallelization Information<br />

full domain is reentrant and automatically parallelized (on tuple level).<br />

get domain<br />

change domain, reduce domain<br />

get domain, gen rectangle1<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

get domain ( Hobject Image, Hobject *Domain )<br />

Get the domain of an image.<br />

The operator get domain returns the definition domains of all input images as a region.<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Input images.<br />

º Domain (output object) ...................................................region(-array) Hobject *<br />

Definition domains of input images.<br />

Parallelization Information<br />

get domain is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

change domain, reduce domain, full domain<br />

See Also<br />

get domain, change domain, reduce domain, full domain<br />

Image / region / XLD management<br />

Module<br />

rectangle1 domain ( Hobject Image, Hobject *ImageReduced, long Row1,<br />

long Column1, long Row2, long Column2 )<br />

Reduce the domain of an image to a rectangle.<br />

The operator rectangle1 domain reduces the definition domain of the given image to the specified rectangle.<br />

The old domain of the input image is ignored. The size of the matrix is not changed.<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Input image.<br />

º ImageReduced (output object) ...........................................image(-array) Hobject *<br />

Image with reduced definition domain.<br />

º Row1 (input control) ........................................................rectangle.origin.y long<br />

Line index of upper left corner of image area.<br />

Default Value : 100<br />

Value Suggestions : Row1 ¾10, 20, 50, 100, 200, 300, 500<br />

Typical Range of Values : 0 Row1 1024<br />

<strong>HALCON</strong> 6.0


312 CHAPTER 5. IMAGE<br />

º Column1 (input control) ....................................................rectangle.origin.x long<br />

Column index of upper left corner of image area.<br />

Default Value : 100<br />

Value Suggestions : Column1 ¾10, 20, 50, 100, 200, 300, 500<br />

Typical Range of Values : 0 Column1 1024<br />

º Row2 (input control) ........................................................rectangle.origin.y long<br />

Line index of lower right corner of image area.<br />

Default Value : 200<br />

Value Suggestions : Row2 ¾10, 20, 50, 100, 200, 300, 500<br />

Typical Range of Values : 0 Row2 1024<br />

º Column2 (input control) ....................................................rectangle.origin.x long<br />

Column index of lower right corner of image area.<br />

Default Value : 200<br />

Value Suggestions : Column2 ¾10, 20, 50, 100, 200, 300, 500<br />

Typical Range of Values : 0 Column2 1024<br />

Parallelization Information<br />

rectangle1 domain is reentrant and automatically parallelized (on tuple level).<br />

get domain<br />

Possible Predecessor Functions<br />

Alternatives<br />

change domain, reduce domain, add channels<br />

full domain, get domain, intersection<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

reduce domain ( Hobject Image, Hobject Region, Hobject *ImageReduced )<br />

Reduce the domain of an image.<br />

The operator reduce domain reduces the definition domain of the given image to the indicated region. The<br />

new definition domain is calculated as the intersection of the old definition domain with the region. Thus, the new<br />

definition domain can be a subset of the region. The size of the matrix is not changed.<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Input image.<br />

º Region (input object) .............................................................region Hobject<br />

New definition domain.<br />

º ImageReduced (output object) ...........................................image(-array) Hobject *<br />

Image with reduced definition domain.<br />

Parallelization Information<br />

reduce domain is reentrant and automatically parallelized (on tuple level).<br />

get domain<br />

Possible Predecessor Functions<br />

Alternatives<br />

change domain, rectangle1 domain, add channels<br />

full domain, get domain, intersection<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.4. FEATURES 313<br />

5.4 Features<br />

area center gray ( Hobject Regions, Hobject Image, double *Area,<br />

double *Row, double *Column )<br />

T area center gray ( Hobject Regions, Hobject Image, Htuple *Area,<br />

Htuple *Row, Htuple *Column )<br />

Compute the area and center of gravity of a region in a gray value image.<br />

(T )area center gray computes the area and center of gravity of the regions Regions that have gray values<br />

which are defined by the image Image. This operator is similar to area center, but in contrast to that operator,<br />

the gray values of the image are taken into account while computing the area and center of gravity.<br />

The area of a region Ê in the image with the gray values ´Öµ is defined as<br />

<br />

<br />

´Öµ¾Ê<br />

´Öµ<br />

This means that the area is defined by the volume of the gray value function ´Öµ. The center of gravity is defined<br />

by the first two normalized moments of the gray values ´Öµ, i.e., by ´Ñ ½¼ Ñ ¼½ µ,where<br />

Ñ ÔÕ ½ <br />

<br />

´Öµ¾Ê<br />

Parameter<br />

Ö Ô Õ ´Öµ<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region(s) to be examined.<br />

º Image (input object) . . . . . singlechannel-image Hobject : byte / cyclic / direction / int1 / int2 / int4 / real<br />

Gray value image.<br />

º Area (output control) ...............................................real(-array) (Htuple .) double *<br />

Gray value volume of the region.<br />

º Row (output control) .............................................point.y(-array) (Htuple .) double *<br />

Row coordinate of the gray value center of gravity.<br />

º Column (output control) .........................................point.x(-array) (Htuple .) double *<br />

Column coordinate of the gray value center of gravity.<br />

Result<br />

(T )area center gray returns H MSG TRUE if all parameters are correct and no error occurs during execution.<br />

If the input is empty the behavior can be set via set system(’no object result’,). If<br />

necessary, an exception handling is raised.<br />

Parallelization Information<br />

(T )area center gray is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

area center<br />

Alternatives<br />

See Also<br />

area center xld, (T )elliptic axis gray<br />

Image filters<br />

Module<br />

<strong>HALCON</strong> 6.0


314 CHAPTER 5. IMAGE<br />

cooc feature image ( Hobject Regions, Hobject Image, long LdGray,<br />

long Direction, double *Energy, double *Correlation, double *Homogenity,<br />

double *Contrast )<br />

T cooc feature image ( Hobject Regions, Hobject Image, Htuple LdGray,<br />

Htuple Direction, Htuple *Energy, Htuple *Correlation, Htuple *Homogenity,<br />

Htuple *Contrast )<br />

Calculate a co-occurrence matrix and derive gray value features thereof.<br />

The call of (T )cooc feature image corresponds to the consecutive execution of the operators<br />

gen cooc matrix and cooc feature matrix. If several direction matrices of the co-occurrence matrix<br />

are to be evaluated consecutively, it is more efficient to generate the matrix via gen cooc matrix and then<br />

call the operator cooc feature matrix for the resulting matrix. The parameter Direction transfers the<br />

direction of the neighborhood in angle or ’mean’. In the case of ’mean’ the mean value is calculated in all four<br />

directions.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region to be examined.<br />

º Image (input object) .........................................................image Hobject : byte<br />

Corresponding gray values.<br />

º LdGray (input control) .....................................................integer (Htuple .) long<br />

Number of gray values to be distinguished (¾ ÄÖÝ ).<br />

Default Value : 6<br />

Value List : LdGray ¾1, 2, 3, 4, 5, 6, 7, 8<br />

º Direction (input control) ....................................integer (Htuple .) long / const char *<br />

Direction in which the matrix is to be calculated.<br />

Default Value : 0<br />

Value List : Direction ¾0, 45, 90, 135, ’mean’<br />

º Energy (output control) ............................................real(-array) (Htuple .) double *<br />

Gray value energy.<br />

º Correlation (output control) .....................................real(-array) (Htuple .) double *<br />

Correlation of gray values.<br />

º Homogenity (output control) .......................................real(-array) (Htuple .) double *<br />

Local homogenity of gray values.<br />

º Contrast (output control) .........................................real(-array) (Htuple .) double *<br />

Gray value contrast.<br />

Result<br />

The operator (T )cooc feature image returns the value H MSG TRUE if an image with defined gray values<br />

(byte) is entered and the parameters are correct. The behavior in case of empty input (no input images available)<br />

is set via the operator set system(’no object result’,), the behavior in case of empty region<br />

is set via set system(’empty region result’,). If necessary an exception handling is<br />

raised.<br />

Parallelization Information<br />

(T )cooc feature image is reentrant and automatically parallelized (on tuple level).<br />

gen cooc matrix<br />

cooc feature matrix<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

(T )intensity, (T )min max gray, (T )entropy gray, (T )select gray<br />

Image filters<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.4. FEATURES 315<br />

cooc feature matrix ( Hobject CoocMatrix, double *Energy,<br />

double *Correlation, double *Homogenity, double *Contrast )<br />

Calculate gray value features from a co-occurrence matrix.<br />

The procedure calculates from a co-occurence matrix (CoocMatrix) the energy (Energy), correlation<br />

(Correlation), local homogenity (Homogenity) and contrast (Contrast).<br />

The operator cooc feature matrix calculates the gray value features from the part of the input matrix generated<br />

by gen cooc matrix corresponding to the direction matrix indicated by the parameters ÄÖÝ and<br />

ÖØÓÒ according to the following formulae:<br />

Energy:<br />

ÒÖÝ <br />

ÛØ<br />

<br />

¾ <br />

¼<br />

(Measure for image homogenity)<br />

Correlation:<br />

ÓÖÖÐØÓÒ <br />

È ÛØ<br />

¼ ´ ٠ܵ´ Ù Ý µ <br />

× Ü × Ý<br />

(Measure for gray value dependencies)<br />

Local homogenity:<br />

Contrast:<br />

ÀÓÑÓÒØÝ <br />

ÓÒØÖ×Ø <br />

ÛØ<br />

<br />

¼<br />

ÛØ<br />

<br />

½<br />

½·´ µ ¾ <br />

´ µ ¾ <br />

¼<br />

(Measure for the size of the intensity differences)<br />

where<br />

ÛØ Width of CoocMatrix<br />

Entry of co-occurrence matrix<br />

Ù Ü È ÛØ<br />

¼ £ <br />

Ù Ý È ÛØ<br />

¼ £ <br />

× ¾ Ü È ÛØ<br />

¼ ´ ٠ܵ ¾ £ <br />

× ¾ Ý È ÛØ<br />

¼ ´ ٠ݵ ¾ £ <br />

The region of the input image is disregarded.<br />

Attention<br />

Parameter<br />

º CoocMatrix (input object) ..................................................image Hobject :int4<br />

Co-occurrence matrix.<br />

º Energy (output control) .............................................................real double *<br />

Homogenity of the gray values.<br />

º Correlation (output control) ......................................................real double *<br />

Correlation of gray values.<br />

º Homogenity (output control) .......................................................real double *<br />

Local homogenity of gray values.<br />

º Contrast (output control) ..........................................................real double *<br />

Gray value contrast.<br />

Result<br />

The operator cooc feature matrix returns the value H MSG TRUE if an image with defined gray values is<br />

passed and the parameters are correct. The behavior in case of empty input (no input images available) is set via the<br />

operator set system(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

cooc feature matrix is reentrant and automatically parallelized (on tuple level).<br />

<strong>HALCON</strong> 6.0


316 CHAPTER 5. IMAGE<br />

gen cooc matrix<br />

(T )cooc feature image<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

(T )intensity, (T )min max gray, (T )entropy gray, (T )select gray<br />

Image filters<br />

Module<br />

elliptic axis gray ( Hobject Regions, Hobject Image, double *Ra,<br />

double *Rb, double *Phi )<br />

T elliptic axis gray ( Hobject Regions, Hobject Image, Htuple *Ra,<br />

Htuple *Rb, Htuple *Phi )<br />

Compute the orientation and major axes of a region in a gray value image.<br />

The operator (T )elliptic axis gray calculates the length of the axes and the orientation of the ellipse<br />

having the “same orientation” and the “aspect ratio” as the input region. Several input regions can be passed in<br />

Regions as tuples. The length of the major axis Ra and the minor axis Rb as well as the orientation of the<br />

major axis with regard to the x-axis (Phi) are determined. The angle is returned in radians. The calculation is<br />

done analogously to elliptic axis. The only difference is that in (T )elliptic axis gray the gray<br />

value moments are used instead of the region moments. The gray value moments are derived from the input image<br />

Image. For the definition of the gray value moments, see (T )area center gray.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region(s) to be examined.<br />

º Image (input object) . . . . . singlechannel-image Hobject : byte / cyclic / direction / int1 / int2 / int4 / real<br />

Gray value image.<br />

º Ra (output control) ..................................................real(-array) (Htuple .) double *<br />

Major axis of the region.<br />

º Rb (output control) ..................................................real(-array) (Htuple .) double *<br />

Minor axis of the region.<br />

º Phi (output control) ...........................................angle.rad(-array) (Htuple .) double *<br />

Angle enclosed by the major axis and the x-axis.<br />

Result<br />

(T )elliptic axis gray returns H MSG TRUE if all parameters are correct and no error occurs during execution.<br />

If the input is empty the behavior can be set via set system(’no object result’,).<br />

If necessary, an exception handling is raised.<br />

Parallelization Information<br />

(T )elliptic axis gray is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

gen ellipse<br />

elliptic axis<br />

(T )area center gray<br />

Image filters<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.4. FEATURES 317<br />

entropy gray ( Hobject Regions, Hobject Image, double *Entropy,<br />

double *Anisotropy )<br />

T entropy gray ( Hobject Regions, Hobject Image, Htuple *Entropy,<br />

Htuple *Anisotropy )<br />

Determine the entropy and anisotropy of images.<br />

The operator (T )entropy gray creates the histogram of relative frequencies of the gray values in the input<br />

image and calculates from these frequencies the entropy and the anisotropy coefficient for each region from<br />

Regions according to the following formulae:<br />

Entropy:<br />

ÒØÖÓÔÝ <br />

¾<br />

¼<br />

ÖÐ℄ £ ÐÓ ¾´ÖÐ℄µ<br />

Anisotropy coefficient:<br />

Ò×ÓØÖÓÔÝ <br />

È <br />

¼<br />

ÖÐ℄ £ ÐÓ ¾´ÖÐ℄µ<br />

ÒØÖÓÔÝ<br />

where<br />

ÖÐ℄<br />

<br />

<br />

= Histogram of relative gray value frequencies<br />

= Gray value of input image ´¼ ¾µ<br />

È <br />

= Smallest possible gray value with<br />

¼<br />

ÖÐ℄ ¼<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions where the features are to be determined.<br />

º Image (input object) .........................................................image Hobject : byte<br />

Gray value image.<br />

º Entropy (output control) ...........................................real(-array) (Htuple .) double *<br />

Information content (entropy) of the gray values.<br />

Assertion : ´0 Entropyµ ´Entropy 8µ<br />

º Anisotropy (output control) .......................................real(-array) (Htuple .) double *<br />

Measure of the symmetry of gray value distribution.<br />

Complexity<br />

If is the area of the region the runtime complexity is Ç´ · ¾µ.<br />

Result<br />

The operator (T )entropy gray returns the value H MSG TRUE if an image with defined gray values is<br />

entered and the parameters are correct. The behavior in case of empty input (no input images available) is set via<br />

the operator set system(’no object result’,), the behavior in case of empty region is set<br />

via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )entropy gray is reentrant and automatically parallelized (on tuple level).<br />

(T )select gray<br />

Alternatives<br />

See Also<br />

entropy image, T gray histo, (T )fuzzy entropy, (T )fuzzy perimeter<br />

Image filters<br />

Module<br />

<strong>HALCON</strong> 6.0


318 CHAPTER 5. IMAGE<br />

fit surface first order ( Hobject Regions, Hobject Image,<br />

const char *Algorithm, long Iterations, double ClippingFactor,<br />

double *Alpha, double *Beta, double *Gamma )<br />

T fit surface first order ( Hobject Regions, Hobject Image,<br />

Htuple Algorithm, Htuple Iterations, Htuple ClippingFactor, Htuple *Alpha,<br />

Htuple *Beta, Htuple *Gamma )<br />

Calculate gray value moments and approximation by a first order surface (plane).<br />

The operator (T )fit surface first order calculates the gray value moments and the parameters of the<br />

approximation of the gray values by a first order surface. The calculation is done by minimizing the distance<br />

between the gray values and the surface. A first order surface is described by the following formula:<br />

ÁÑ ¼´ÖµÐÔ´Ö Ö ÒØÖµ ·Ø´ ÒØÖµ ·ÑÑ<br />

r center and c center are the coordinates of the center of the input region. By the minimization process the parameters<br />

from Alpha to Gamma is calculated.<br />

The algorithm used for the fitting can be selected via Algorithm:<br />

’regression’ Standard ’least squares’ line fitting.<br />

’huber’ Weighted ’least squares’ fitting, where the impact of outliers is decreased based on the approach of<br />

Huber.<br />

’tukey’ Weighted ’least squares’ fitting, where the impact of outliers is decreased based on the approach of<br />

Tukey.<br />

The parameter ClippingFactor (a scaling factor for the standard deviation) controls the amount of damping<br />

outliers: The smaller the value chosen for ClippingFactor the more outliers are detected. The detection of<br />

outliers is repeated. The parameter Iterations specifies the number of iterations. In the modus ’regression’<br />

this value is ignored.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be checked.<br />

º Image (input object) ...................................................image Hobject : byte / real<br />

Corresponding gray values.<br />

º Algorithm (input control) ...........................................string (Htuple .) const char *<br />

Algorithm for the fitting.<br />

Default Value : ’regression’<br />

Value List : Algorithm ¾’regression’, ’huber’, ’tukey’<br />

º Iterations (input control) ................................................integer (Htuple .) long<br />

Maximum number of iterations (unused for ’regression’).<br />

Default Value : 5<br />

Restriction : Iterations 0<br />

º ClippingFactor (input control) ...........................................real (Htuple .) double<br />

Clipping factor for the elimination of outliers.<br />

Default Value : 2.0<br />

Value List : ClippingFactor ¾1.0, 1.5, 2.0, 2.5, 3.0<br />

Restriction : ClippingFactor 0<br />

º Alpha (output control) .............................................real(-array) (Htuple .) double *<br />

Parameter Alpha of the approximating surface.<br />

º Beta (output control) ...............................................real(-array) (Htuple .) double *<br />

Parameter Beta of the approximating surface.<br />

º Gamma (output control) .............................................real(-array) (Htuple .) double *<br />

Parameter Gamma of the approximating surface.<br />

Result<br />

The operator (T )fit surface second order returns the value H MSG TRUE if an image with the defined<br />

gray values (byte) is entered and the parameters are correct. If necessary an exception handling is raised.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.4. FEATURES 319<br />

Parallelization Information<br />

(T )fit surface first order is reentrant and automatically parallelized (on tuple level).<br />

See Also<br />

(T )moments gray plane, (T )fit surface second order<br />

Image filters<br />

Module<br />

fit surface second order ( Hobject Regions, Hobject Image,<br />

const char *Algorithm, long Iterations, double ClippingFactor,<br />

double *Alpha, double *Beta, double *Gamma, double *Delta,<br />

double *Epsilon, double *Zeta )<br />

T fit surface second order ( Hobject Regions, Hobject Image,<br />

Htuple Algorithm, Htuple Iterations, Htuple ClippingFactor, Htuple *Alpha,<br />

Htuple *Beta, Htuple *Gamma, Htuple *Delta, Htuple *Epsilon,<br />

Htuple *Zeta )<br />

Calculate gray value moments and approximation by a second order surface.<br />

The operator (T )fit surface second order calculates the gray value moments and the parameters of the<br />

approximation of the gray values by a second order surface. The calculation is done by minimizing the distance<br />

between the gray values and the surface. A second order surface is described by the following formula:<br />

ÁÑ´ÖµÐÔ´Ö Ö ÒØÖµ££¾·Ø´ ÒØÖµ££¾·ÑÑ´Ö Ö ÒØÖµ£´ ÒØÖµ·ÐØ´Ö Ö ÒØÖµ·ÐØ<br />

r center and c center are the coordinates of the center of the input region. By the minimization process the parameters<br />

from Alpha to Zeta is calculated.<br />

The algorithm used for the fitting can be selected via Algorithm:<br />

’regression’ Standard ’least squares’ fitting.<br />

’huber’ Weighted ’least squares’ fitting, where the impact of outliers is decreased based on the approach of<br />

Huber.<br />

’tukey’ Weighted ’least squares’ fitting, where the impact of outliers is decreased based on the approach of<br />

Tukey.<br />

The parameter ClippingFactor (a scaling factor for the standard deviation) controls the amount of damping<br />

outliers: The smaller the value chosen for ClippingFactor the more outliers are detected. The detection of<br />

outliers is repeated. The parameter Iterations specifies the number of iterations. In the modus ’regression’<br />

this value is ignored.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be checked.<br />

º Image (input object) ...................................................image Hobject : byte / real<br />

Corresponding gray values.<br />

º Algorithm (input control) ...........................................string (Htuple .) const char *<br />

Algorithm for the fitting.<br />

Default Value : ’regression’<br />

Value List : Algorithm ¾’regression’, ’tukey’, ’huber’<br />

º Iterations (input control) ................................................integer (Htuple .) long<br />

Maximum number of iterations (unused for ’regression’).<br />

Default Value : 5<br />

Restriction : Iterations 0<br />

º ClippingFactor (input control) ...........................................real (Htuple .) double<br />

Clipping factor for the elimination of outliers.<br />

Default Value : 2.0<br />

Value List : ClippingFactor ¾1.0, 1.5, 2.0, 2.5, 3.0<br />

Restriction : ClippingFactor 0<br />

<strong>HALCON</strong> 6.0


320 CHAPTER 5. IMAGE<br />

º Alpha (output control) .............................................real(-array) (Htuple .) double *<br />

Parameter Alpha of the approximating surface.<br />

º Beta (output control) ...............................................real(-array) (Htuple .) double *<br />

Parameter Beta of the approximating surface.<br />

º Gamma (output control) .............................................real(-array) (Htuple .) double *<br />

Parameter Gamma of the approximating surface.<br />

º Delta (output control) .............................................real(-array) (Htuple .) double *<br />

Parameter Deltaa of the approximating surface.<br />

º Epsilon (output control) ...........................................real(-array) (Htuple .) double *<br />

Parameter Epsilon of the approximating surface.<br />

º Zeta (output control) ...............................................real(-array) (Htuple .) double *<br />

Parameter Zeta of the approximating surface.<br />

Result<br />

The operator (T )fit surface second order returns the value H MSG TRUE if an image with the defined<br />

gray values (byte) is entered and the parameters are correct. If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )fit surface second order is reentrant and automatically parallelized (on tuple level).<br />

See Also<br />

(T )moments gray plane, (T )fit surface first order<br />

Image filters<br />

Module<br />

fuzzy entropy ( Hobject Regions, Hobject Image, long Apar, long Cpar,<br />

double *Entropy )<br />

T fuzzy entropy ( Hobject Regions, Hobject Image, Htuple Apar,<br />

Htuple Cpar, Htuple *Entropy )<br />

Determine the fuzzy entropy of regions.<br />

(T )fuzzy entropy calculates the fuzzy entropy of a fuzzy set. To do so, the image is regarded as a fuzzy set.<br />

The entropy then is a measure of how well the image approximates a white or black image. It is defined as follows:<br />

À´µ<br />

<br />

È<br />

½<br />

ÅÆÐÒ¾ Ð Ì ´Ðµ´Ðµ<br />

where Å ¢ Æ is the size of the image, and ´Ðµ is the histogram of the image. Furthermore,<br />

Ì ´Ðµ ´ÐµÐҴе ´½ ´Ðµµ ÐÒ´½ ´Ðµµ<br />

Here, Ù´Ü´Ñ Òµµ is a fuzzy membership function defining the fuzzy set (see (T )fuzzy perimeter). The<br />

same restrictions hold as in (T )fuzzy perimeter.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions for which the fuzzy entropy is to be calculated.<br />

º Image (input object) .........................................................image Hobject : byte<br />

Input image containing the fuzzy membership values.<br />

º Apar (input control) ........................................................integer (Htuple .) long<br />

Start of the fuzzy function.<br />

Default Value : 0<br />

Value Suggestions : Apar ¾0, 5, 10, 20, 50, 100<br />

Typical Range of Values : 0 Apar 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.4. FEATURES 321<br />

º Cpar (input control) ........................................................integer (Htuple .) long<br />

End of the fuzzy function.<br />

Default Value : 255<br />

Value Suggestions : Cpar ¾50, 100, 150, 200, 220, 255<br />

Typical Range of Values : 0 Cpar 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

Restriction : Apar Cpar<br />

º Entropy (output control) ...........................................real(-array) (Htuple .) double *<br />

Fuzzy entropy of a region.<br />

Example<br />

/* To find a Fuzzy Entropy from an Image */<br />

read_image(&Image,’affe’) ;<br />

fuzzy_entropy(Trans,Trans,0,255,&Entro) ;<br />

Result<br />

The operator (T )fuzzy entropy returns the value H MSG TRUE if the parameters are correct. Otherwise an<br />

exception is raised.<br />

Parallelization Information<br />

(T )fuzzy entropy is reentrant and automatically parallelized (on tuple level).<br />

(T )fuzzy perimeter<br />

See Also<br />

Bibliography<br />

M.K. Kundu, S.K. Pal: ‘”Automatic selection of object enhancement operator with quantitative justification based<br />

on fuzzy set theoretic measures”; Pattern Recognition Letters 11; 1990; pp. 811-829.<br />

Module<br />

Image filters<br />

fuzzy perimeter ( Hobject Regions, Hobject Image, long Apar, long Cpar,<br />

double *Perimeter )<br />

T fuzzy perimeter ( Hobject Regions, Hobject Image, Htuple Apar,<br />

Htuple Cpar, Htuple *Perimeter )<br />

Calculate the fuzzy perimeter of a region.<br />

The operator (T )fuzzy perimeter is used to determine the differences of fuzzy membership between an<br />

image point and its neighbor points. The right and lower neighbor are taken into account. The fuzzy perimeter is<br />

then defined as follows:<br />

<br />

Å ½<br />

Ô´µ <br />

Æ<br />

½<br />

ѽ ҽ<br />

´Ü ÑÒ µ ´Ü ÑÒ·½ µ ·<br />

Å<br />

½<br />

Æ<br />

½<br />

ѽ ҽ<br />

´Ü ÑÒ µ ´Ü Ñ·½Ò µ<br />

where Å ¢ Æ is the size of the image, and Ù´Ü´Ñ Òµµ is the fuzzy membership function (i.e., the input image).<br />

This implementation uses Zadeh’s Standard-S function, which is defined as follows:<br />

´Üµ <br />

<br />

<br />

<br />

¼<br />

¾<br />

<br />

Ü <br />

<br />

½ ¾<br />

½<br />

<br />

¾ <br />

Ü <br />

<br />

¾ <br />

Ü <br />

Ü <br />

Ü <br />

Ü<br />

The parameters , and obey the following restrictions: · is the inflection point of the function, ¡ <br />

¾<br />

is the bandwith, and for Ü ´Üµ ¼ holds. In (T )fuzzy perimeter, the parameters<br />

Apar and Cpar are defined as follows: is ÔÖ·ÔÖ .<br />

¾<br />

<strong>HALCON</strong> 6.0


322 CHAPTER 5. IMAGE<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions for which the fuzzy perimeter is to be calculated.<br />

º Image (input object) .........................................................image Hobject : byte<br />

Input image containing the fuzzy membership values.<br />

º Apar (input control) ........................................................integer (Htuple .) long<br />

Start of the fuzzy function.<br />

Default Value : 0<br />

Value Suggestions : Apar ¾0, 5, 10, 20, 50, 100<br />

Typical Range of Values : 0 Apar 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

º Cpar (input control) ........................................................integer (Htuple .) long<br />

End of the fuzzy function.<br />

Default Value : 255<br />

Value Suggestions : Cpar ¾50, 100, 150, 200, 220, 255<br />

Typical Range of Values : 0 Cpar 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

Restriction : Apar Cpar<br />

º Perimeter (output control) ........................................real(-array) (Htuple .) double *<br />

Fuzzy perimeter of a region.<br />

Example<br />

/* To find a Fuzzy Entropy from an Image */<br />

read_image(&Image,"affe");<br />

fuzzy_perimeter(Trans,Trans,Apar,Bpar,&Per);<br />

Result<br />

The operator (T )fuzzy perimeter returns the value H MSG TRUE if the parameters are correct. Otherwise<br />

an exception is raised.<br />

Parallelization Information<br />

(T )fuzzy perimeter is reentrant and automatically parallelized (on tuple level).<br />

(T )fuzzy entropy<br />

See Also<br />

Bibliography<br />

M.K. Kundu, S.K. Pal: ‘”Automatic selection of object enhancement operator with quantitative justification based<br />

on fuzzy set theoretic measures”; Pattern Recognition Letters 11; 1990; pp. 811-829.<br />

Module<br />

Image filters<br />

gen cooc matrix ( Hobject Regions, Hobject Image, Hobject *Matrix,<br />

long LdGray, long Direction )<br />

Calculate the co-occurrence matrix of a region in an image.<br />

The operator gen cooc matrix determines from the input regions how often the gray values and are located<br />

next to each other in a certain direction (0, 45, 90, 135 degrees), stores this number in the co-occurrence matrix at<br />

the locations ´ µ and ´ µ (the matrix is symmetrical), and finally scalse the matrix with the number of entries.<br />

LdGray indicates the number of gray values to be distinguished (namely ¾ ÄÖÝ ).<br />

Example (LdGray = 2, i.e. 4 gray values are distinguished):<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.4. FEATURES 323<br />

Input image<br />

with gray values:<br />

Co-occurrence matrix<br />

(not scaled)<br />

003 2001 0110<br />

112 0220 1011<br />

123 0201 1100<br />

1010 0100<br />

0200 0100<br />

2210 1201<br />

0102 0020<br />

0020 0100<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region to be checked.<br />

º Image (input object) .........................................................image Hobject : byte<br />

Image providing the gray values.<br />

º Matrix (output object) .............................................image(-array) Hobject * :int4<br />

Co-occurrence matrix (matrices).<br />

º LdGray (input control) ...............................................................integer long<br />

Number of gray values to be distinguished (¾ ÄÖÝ ).<br />

Default Value : 6<br />

Value List : LdGray ¾1, 2, 3, 4, 5, 6, 7, 8<br />

Typical Range of Values : 1 LdGray 256 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Direction (input control) ...........................................................integer long<br />

Direction of neighbor relation.<br />

Default Value : 0<br />

Value List : Direction ¾0, 45, 90, 135<br />

Result<br />

The operator gen cooc matrix returns the value H MSG TRUE if an image with defined gray values is entered<br />

and the parameters are correct. The behavior in case of empty input (no input images available) is set via the<br />

operator set system(’no object result’,), the behavior in case of empty region is set via<br />

set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

gen cooc matrix is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

draw region, gen circle, gen ellipse, gen rectangle1, gen rectangle2, threshold,<br />

erosion circle, gauss image, smooth image, sub image<br />

(T )cooc feature image<br />

cooc feature matrix<br />

Image filters<br />

Alternatives<br />

See Also<br />

Module<br />

T gray histo ( Hobject Regions, Hobject Image, Htuple *AbsoluteHisto,<br />

Htuple *RelativeHisto )<br />

Calculate the gray value distribution.<br />

The operator T gray histo calculates for the image (Image) within Regions the absolute<br />

(AbsoluteHisto) and relative (RelativeHisto) histogram of the gray values.<br />

<strong>HALCON</strong> 6.0


324 CHAPTER 5. IMAGE<br />

Both histograms are tupels of 256 values, which — beginning at 0 — contain the frequencies of the individual gray<br />

values of the image.<br />

AbsoluteHisto indicates the absolute frequencies of the gray values in integers, and RelativeHisto indicates<br />

the relative, i.e. the absolute frequencies divided by the area of the image as floating point numbers.<br />

real-, int2-andint4-images are transformed into byte-images (first the largest and smallest gray value in the image<br />

are determined, and then the original gray values are mapped linearly into the area 0..255) and then processed<br />

as mentioned above. The histogram can also be returned directly as a graphic via the operators set paint<br />

(WindowHandle,’histogram’) and disp image.<br />

Attention<br />

Real, int2 and int4 images are reduced to 256 gray values.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region in which the histogram is to be calculated.<br />

º Image (input object) ...................image Hobject : byte / cyclic / direction / int1 / int2 / int4 / real<br />

Image the gray value distribution of which is to be calculated.<br />

º AbsoluteHisto (output control) ..................................histogram-array Htuple . long *<br />

Absolute frequencies of the gray values.<br />

º RelativeHisto (output control) ................................histogram-array Htuple . double *<br />

Frequencies, normalized to the area of the region.<br />

Complexity<br />

If is the area of the region the runtime complexity is Ç´ · ¾µ.<br />

Result<br />

The operator T gray histo returns the value H MSG TRUE if the image has defined gray values and the<br />

parameters are correct. The behavior in case of empty input (no input images available) is set via the operator<br />

set system(’no object result’,), the behavior in case of empty region is set via<br />

set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

T gray histo is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

histo to thresh, gen region histo<br />

(T )min max gray, (T )intensity<br />

Alternatives<br />

See Also<br />

set paint, disp image, histo 2dim, scale image max, (T )entropy gray<br />

Image filters<br />

Module<br />

T gray projections ( Hobject Region, Hobject Image, Htuple Mode,<br />

Htuple *HorProjection, Htuple *VertProjection )<br />

Calculate horizontal and vertical gray-value projections.<br />

T gray projections calculates the horizontal and vertical gray-value projections.<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Region to be processed.<br />

º Image (input object) ..............................................................image Hobject<br />

Grayvalues for projections.<br />

º Mode (input control) ....................................................string Htuple . const char *<br />

Type of invariance.<br />

Default Value : ’simple’<br />

Value List : Mode ¾’simple’, ’rectangle’, ’wave’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.4. FEATURES 325<br />

º HorProjection (output control) ......................................real-array Htuple . double *<br />

Horizontal projections.<br />

º VertProjection (output control) ....................................real-array Htuple . double *<br />

Vertical projections.<br />

Parallelization Information<br />

T gray projections is reentrant and processed without parallelization.<br />

Image filters<br />

Module<br />

histo 2dim ( Hobject Regions, Hobject ImageCol, Hobject ImageRow,<br />

Hobject *Histo2Dim )<br />

Calculate the histogram of two-channel gray value images.<br />

The operator histo 2dim calculates the 2-dimensional histogram of two images within Regions. The gray<br />

values of channel 1 (ImageCol) are interpreted as row index, those of channel 2 (ImageRow) as column index.<br />

The gray value at one point È ´½¾µ in the output image Histo2Dim indicates the frequency of the gray value<br />

combination (½,¾) with ½ indicating the line index and ¾ the column index.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region in which the histogram is to be calculated.<br />

º ImageCol (input object) ..............................image Hobject : byte / direction / cyclic / int1<br />

Channel 1.<br />

º ImageRow (input object) .....................................................image Hobject : byte<br />

Channel 2.<br />

º Histo2Dim (output object) ................................................image Hobject * :int4<br />

Histogram to be calculated.<br />

Example<br />

read_image(&Image,"affe");<br />

texture_laws(Image,&Texture,"el",1,5);<br />

draw_region(&Region,WindowHandle);<br />

histo_2dim(Region,Texture,Image,&Histo2Dim);<br />

set_part(WindowHandle,0,0,255,255);<br />

disp_image(Histo2Dim,WindowHandle);<br />

Complexity<br />

If is the plane of the region, the runtime complexity is Ç´ · ¾ ¾ µ.<br />

Result<br />

The operator histo 2dim returns the value H MSG TRUE if both images have defined gray values.<br />

The behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,), the behavior in case of empty region is set via set system<br />

(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

histo 2dim is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

decompose3, decompose2, draw region<br />

Possible Successor Functions<br />

threshold, class 2dim sup, pouring, local max, gray skeleton<br />

T gray histo<br />

(T )get grayval<br />

Image filters<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


326 CHAPTER 5. IMAGE<br />

intensity ( Hobject Regions, Hobject Image, double *Mean,<br />

double *Deviation )<br />

T intensity ( Hobject Regions, Hobject Image, Htuple *Mean,<br />

Htuple *Deviation )<br />

Calculate the mean and deviation of gray values.<br />

The operator (T )intensity calculates the mean and the deviation of the gray values in the input image within<br />

Regions. IfÊ is a region, Ô a pixel from Ê with the gray value ´Ôµ and the plane ( Ê), the features are<br />

defined by:<br />

ÅÒ <br />

ÚØÓÒ <br />

È<br />

Ô¾Ê ´Ôµ<br />

<br />

× È<br />

Ô¾Ê ´´Ôµ ÅÒµ¾<br />

<br />

Attention<br />

The calculation of Deviation does not follow the usual definition if the region of the image contains only one<br />

pixel. In this case 0.0 is returned.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions the features of which are to be calculated.<br />

º Image (input object) ....................................image Hobject : byte / int1 / int2 / int4 / real<br />

Gray value image.<br />

º Mean (output control) ...............................................real(-array) (Htuple .) double *<br />

Mean gray value of a region.<br />

º Deviation (output control) ........................................real(-array) (Htuple .) double *<br />

Deviation of gray values within a region.<br />

Complexity<br />

If is the area of the region, the runtime complexity is Ç´ µ.<br />

Result<br />

The operator (T )intensity returns the value H MSG TRUE. The behavior in case of empty input (no input<br />

images available) is set via the operator set system(’no object result’,), the behavior<br />

in case of empty region is set via set system(’empty region result’,). If necessary an<br />

exception handling is raised.<br />

Parallelization Information<br />

(T )intensity is reentrant and automatically parallelized (on tuple level).<br />

threshold<br />

(T )select gray, (T )min max gray<br />

mean image, mean image, T gray histo<br />

Image filters<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

min max gray ( Hobject Regions, Hobject Image, double Percent,<br />

double *Min, double *Max, double *Range )<br />

T min max gray ( Hobject Regions, Hobject Image, Htuple Percent,<br />

Htuple *Min, Htuple *Max, Htuple *Range )<br />

Determine the minimum and maximum gray values within regions.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.4. FEATURES 327<br />

The operator (T )min max gray creates the histogram of the absolute frequencies of the gray values within<br />

Regions in the input image Image (see T gray histo) and calculates the number of pixels Percent corresponding<br />

to the area of the input image. Then it goes inwards on both sides of the histogram by this number of<br />

pixels and determines the smallest and the largest gray value:<br />

e.g.:<br />

Area = 60, percent = 5, i.e. 3 pixels<br />

histogram = [2,8,0,7,13,0,0,. . . ,0,10,10,5,3,1,1]<br />

µ Maximum = 255, Minimum = 0, Range = 255<br />

(T )min max gray returns: Maximum = 253, Minimum = 1, Range = 252<br />

If Percent issetat50,Min = Max = Median. If Percent is 0 no histogram is calculated in order to enhance<br />

the runtime.<br />

Attention<br />

In case of int2, int4- and real-images Percent has to be 0.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions, the features of which are to be calculated.<br />

º Image (input object) ....................................image Hobject : byte / int1 / int2 / int4 / real<br />

Gray value image.<br />

º Percent (input control) ...........................................number (Htuple .) double / long<br />

Percentage below (above) the absolute maximum (minimum).<br />

Default Value : 0<br />

Value Suggestions : Percent ¾0, 1, 2, 5, 7, 10, 15, 20, 30, 40, 50<br />

Restriction : ´0 Percentµ ´Percent 50µ<br />

º Min (output control) ................................................real(-array) (Htuple .) double *<br />

“Minimum” gray value.<br />

º Max (output control) ................................................real(-array) (Htuple .) double *<br />

“Maximum” gray value.<br />

Assertion : Max Min<br />

º Range (output control) .............................................real(-array) (Htuple .) double *<br />

Difference between Max and Min.<br />

Assertion : Range 0<br />

Example<br />

/* Threshold segmentation with training region: */<br />

read_image(&Image,"fabrik");<br />

draw_region(&Region,WindowHandle);<br />

min_max_gray(Region,Image,5.0,&Min,&Max,_);<br />

threshold(Bild,&Seg,Min,Max);<br />

disp_region(Seg,WindowHandle);<br />

Complexity<br />

If is the area of the region the runtime complexity is Ç´ µ if Percent =0,Ç´ · ¾µ otherwise.<br />

Result<br />

The operator (T )min max gray returns the value H MSG TRUE if the input image has the defined gray values<br />

and the parameters are correct. The behavior in case of empty input (no input images available) is set via the<br />

operator set system(’no object result’,). The behaviour in case of an empty region is set<br />

via the operator set system(’empty region result’,). If necessary an exception handling<br />

is raised.<br />

Parallelization Information<br />

(T )min max gray is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

draw region, gen circle, gen ellipse, gen rectangle1, threshold, regiongrowing<br />

threshold<br />

Possible Successor Functions<br />

<strong>HALCON</strong> 6.0


328 CHAPTER 5. IMAGE<br />

(T )select gray, (T )intensity<br />

Alternatives<br />

See Also<br />

T gray histo, scale image, scale image max, learn ndim norm<br />

Image filters<br />

Module<br />

moments gray plane ( Hobject Regions, Hobject Image, double *MRow,<br />

double *MCol, double *Alpha, double *Beta, double *Mean )<br />

T moments gray plane ( Hobject Regions, Hobject Image, Htuple *MRow,<br />

Htuple *MCol, Htuple *Alpha, Htuple *Beta, Htuple *Mean )<br />

Calculate gray value moments and approximation by a plane.<br />

The operator (T )moments gray plane calculates the gray value moments and the parameters of the approximation<br />

of the gray values by a plane. The calculation is carried out according to the following formula:<br />

ÅÊÓÛ <br />

½<br />

<br />

¾<br />

´Öµ¾ÊÓÒ×<br />

´Ö Öµ´ÁÑ´Öµ ÅÒµ ÅÓÐ ½<br />

¾<br />

<br />

´Öµ¾ÊÓÒ×<br />

´ µ´ÁÑ´Öµ ÅÒµ<br />

ÐÔ ÅÊÓÛÑ ¼¾ Ñ ½½ ÅÓÐ<br />

Ñ ¾¼ Ñ ¼¾ Ñ ¾ ½½<br />

<br />

Ø Ñ ¾¼ÅÓÐ ÅÊÓÛÑ ½½<br />

Ñ ¾¼ Ñ ¼¾ Ñ ¾ ½½<br />

where is the plane, Ö, the center, and Ñ ½½ , Ñ ¾¼ ,andÑ ¼¾ the scaled moments of Regions.<br />

The parameters Alpha, Beta and Mean describe a plane above the region:<br />

ÁÑ ¼´ÖµÐÔ´Ö<br />

Öµ ·Ø´ µ ·ÅÒ<br />

Thus Alpha indicates the gradient in the direction of the line axis (“down”), Beta the gradient in the direction of<br />

the column axis (to the “right”).<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be checked.<br />

º Image (input object) ...................................................image Hobject : byte / real<br />

Corresponding gray values.<br />

º MRow (output control) ...............................................real(-array) (Htuple .) double *<br />

Mixed moments along a line.<br />

º MCol (output control) ...............................................real(-array) (Htuple .) double *<br />

Mixed moments along a column.<br />

º Alpha (output control) .............................................real(-array) (Htuple .) double *<br />

Parameter Alpha of the approximating plane.<br />

º Beta (output control) ...............................................real(-array) (Htuple .) double *<br />

Parameter Beta of the approximating plane.<br />

º Mean (output control) ...............................................real(-array) (Htuple .) double *<br />

Mean gray value.<br />

Result<br />

The operator (T )moments gray plane returns the value H MSG TRUE if an image with the defined gray<br />

values (byte) is entered and the parameters are correct. The behavior in case of empty input (no input images<br />

available) is set via the operator set system(’no object result’,), the behavior in case of<br />

emptyregionissetviaset system(’empty region result’,). If necessary an exception<br />

handling is raised.<br />

Parallelization Information<br />

(T )moments gray plane is reentrant and automatically parallelized (on tuple level).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.4. FEATURES 329<br />

Possible Predecessor Functions<br />

draw region, gen circle, gen ellipse, gen rectangle1, gen rectangle2, threshold,<br />

regiongrowing<br />

See Also<br />

(T )intensity, moments region 2nd<br />

Bibliography<br />

R. Haralick, L. Shapiro; “Computer and Robot Vision”; Addison-Wesley, 1992, pp 75-76<br />

Image filters<br />

Module<br />

plane deviation ( Hobject Regions, Hobject Image, double *Deviation )<br />

T plane deviation ( Hobject Regions, Hobject Image, Htuple *Deviation )<br />

Calculate the deviation of the gray values from the approximating image plane.<br />

The operator (T )plane deviation calculates the deviation of the gray values in Image from the approximation<br />

of the gray values through a plane. Contrary to the standard deviation in case of (T )intensity<br />

slanted gray value planes also receive the value zero. The gray value plane is calculated according to<br />

gen image gray ramp.<br />

If is the plane, «, ¬, the parameters of the image plane and ´Ö ¼ ¼ µ the center, Deviation is defined by:<br />

ÚØÓÒ <br />

Ö<br />

×ÙÑ´Öµ¾ÊÓÒ×´´«´Ö Ö ¼ µ·¬´ ¼ µ·µ ÁÑ´Öµµ ¾<br />

<br />

<br />

Attention<br />

It should be noted that the calculation of Deviation does not follow the usual definition. It is defined to return<br />

the value 0.0 for an image with only one pixel.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions, of which the plane deviation is to be calculated.<br />

º Image (input object) .........................................................image Hobject : byte<br />

Gray value image.<br />

º Deviation (output control) ........................................real(-array) (Htuple .) double *<br />

Deviation of the gray values within a region.<br />

Complexity<br />

If is the area of the region the runtime complexity amounts to Ç´ µ.<br />

Result<br />

The operator (T )plane deviation returns the value H MSG TRUE if Image is of the type byte.<br />

The behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,), the behavior in case of empty region is set via set system<br />

(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )plane deviation is reentrant and automatically parallelized (on tuple level).<br />

Alternatives<br />

(T )intensity, gen image gray ramp, sub image<br />

(T )moments gray plane<br />

Image filters<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


330 CHAPTER 5. IMAGE<br />

select gray ( Hobject Regions, Hobject Image, Hobject *SelectedRegions,<br />

const char *Features, const char *Operation, double Min, double Max )<br />

T select gray ( Hobject Regions, Hobject Image,<br />

Hobject *SelectedRegions, Htuple Features, Htuple Operation, Htuple Min,<br />

Htuple Max )<br />

Select regions based on gray value features.<br />

The operator (T )select gray has a number of regions (Regions) as input. For each of these regions the<br />

features (Features) are calculated. If each (Operation = ’and’) or at least one (Operation = ’or’) of the<br />

calculated features is within the limits determined by the parameter, the region is transferred (duplicated) into the<br />

output. The parameter Image contains an image which returns the gray values for calculating the features.<br />

Condition:<br />

ÅÒ ØÙÖ× ´ÊÓÒ× Áѵ ÅÜ <br />

Possble values for Features:<br />

’area’<br />

Gray value volume of region (see (T )area center gray)<br />

’row’<br />

Rowindexofthecenterofgravity(see(T )area center gray)<br />

’column’ Column index of the center of gravity (see (T )area center gray)<br />

’ra’<br />

Major axis of equivallent ellipse (see (T )elliptic axis gray)<br />

’rb’<br />

Minor axis of equivallent ellipse (see (T )elliptic axis gray)<br />

’phi’<br />

Orientation of equivallent ellipse (see (T )elliptic axis gray)<br />

’min’<br />

Minimum gray value (see (T )min max gray)<br />

’max’<br />

Maximum gray value (see (T )min max gray)<br />

’mean’<br />

Mean gray value (see (T )intensity)<br />

’deviation’ Deviationofgrayvalues(see(T )intensity)<br />

’plane deviation’ Deviation from the approximating plane (see (T )plane deviation)<br />

’anisotropy’ Anisotropy (see (T )entropy gray)<br />

’entropy’ Entropy (see (T )entropy gray)<br />

’fuzzy entropy’ Fuzzy entropie of region (see (T )fuzzy entropy, with a fuzzy function from Apar=0 to<br />

Cpar=255)<br />

’fuzzy perimeter’ Fuzzy perimeter of region (see (T )fuzzy perimeter, with a fuzzy function from<br />

Apar=0 to Cpar=255)<br />

’moments row’ Mixed moments along a row (see (T )moments gray plane)<br />

’moments column’ Mixed moments along a column (see (T )moments gray plane)<br />

’alpha’<br />

Approximating plane, parameter Alpha (see (T )moments gray plane)<br />

’beta’<br />

Approximating plane, parameter Beta (see (T )moments gray plane)<br />

Attention<br />

If only one feature is used the value of Operation is meaningless. Several features are processed in the order in<br />

which they are entered.<br />

Parameter<br />

º Regions (input object) ......................................................region-array Hobject<br />

Regions to be examined.<br />

º Image (input object) .........................................image Hobject : byte / int2 / int4 / real<br />

Gray value image.<br />

º SelectedRegions (output object) ........................................region-array Hobject *<br />

Regions having features within the limits.<br />

º Features (input control) ......................................string(-array) (Htuple .) const char *<br />

Names of the features.<br />

Default Value : ’mean’<br />

Value List : Features ¾’area’, ’row’, ’column’, ’ra’, ’rb’, ’phi’, ’min’, ’max’, ’mean’, ’deviation’,<br />

’plane deviation’, ’anisotropy’, ’entropy’, ’fuzzy entropy’, ’fuzzy perimeter’, ’moments row’,<br />

’moments column’, ’alpha’, ’beta’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.4. FEATURES 331<br />

º Operation (input control) ...........................................string (Htuple .) const char *<br />

Logical connection of features.<br />

Default Value : ’and’<br />

Value List : Operation ¾’and’, ’or’<br />

º Min (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Lower limit(s) of features.<br />

Default Value : 128.0<br />

Value Suggestions : Min ¾0.5, 1.0, 10.0, 20.0, 50.0, 128.0, 255.0, 1000.0<br />

º Max (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Upper limit(s) of features.<br />

Default Value : 255.0<br />

Value Suggestions : Max ¾0.5, 1.0, 10.0, 20.0, 50.0, 128.0, 255.0, 1000.0<br />

Complexity<br />

If is the area of the region and Æ the number of features the runtime complexity is Ç´ £ Æ µ.<br />

Result<br />

The operator (T )select gray returns the value H MSG TRUE if the input image has the defined gray values<br />

and the parameters are correct. The behavior in case of empty input (no input images available) is set via the<br />

operator set system(’no object result’,), the behavior in case of empty region is set via<br />

set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )select gray is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

connection, mean image, entropy image, sobel amp, median separate<br />

Possible Successor Functions<br />

select shape, (T )select gray, shape trans, reduce domain, count obj<br />

See Also<br />

deviation image, (T )entropy gray, (T )intensity, mean image, (T )min max gray,<br />

select obj<br />

Module<br />

Image filters<br />

T shape histo all ( Hobject Region, Hobject Image, Htuple Feature,<br />

Htuple *AbsoluteHisto, Htuple *RelativeHisto )<br />

Determine a histogram of features along all threshold values.<br />

The operator T shape histo all carries out 255 threshold operations within Region with the gray values<br />

of Image. The entry in the histogram corresponds to the number of connected components/holes of this image<br />

segmented with the threshold (Feature = ’connected components’, ’holes’) orthemeanvalueofthe<br />

feature values of the regions segmented in this way (Feature = ’convexity’, ’compactness’, ’ansisometry’),<br />

respectively.<br />

The histogram can also be displayed directly as a graphic via the operators set paint<br />

(WindowHandle,’component histogram’) and disp image.<br />

Attention<br />

The operator T shape histo all expects a region and exactly one gray value image as input. Because of the<br />

power of this operator the runtime of T shape histo all is relatively large!<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Region in which the features are to be examined.<br />

º Image (input object) .........................................................image Hobject : byte<br />

Gray value image.<br />

º Feature (input control) ...............................................string Htuple . const char *<br />

Feature to be examined.<br />

Default Value : ’connected components’<br />

Value List : Feature ¾’connected components’, ’convexity’, ’compactness’, ’anisometry’, ’holes’<br />

<strong>HALCON</strong> 6.0


332 CHAPTER 5. IMAGE<br />

º AbsoluteHisto (output control) ........................histogram-array Htuple . double * / long *<br />

Absolute distribution of the feature.<br />

º RelativeHisto (output control) ................................histogram-array Htuple . double *<br />

Relative distribution of the feature.<br />

Example<br />

/* Simulation von shape_histo_all mit Merkmal ’connected_components’: */<br />

my_shape_histo_all(Hobject Region,Hobject Image,<br />

long AbsHisto[], double RelHisto[])<br />

{<br />

long i,sum;<br />

Hobject RegionGray,Seg;<br />

}<br />

reduce_domain(Region,Image,&RegionGray);<br />

for (i=0; i


5.5. FORMAT 333<br />

The histogram can also be displayed directly as a graphic via the operators set paint<br />

(WindowHandle,’component histogram’) and disp image.<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Region in which the features are to be examined.<br />

º Image (input object) .........................................................image Hobject : byte<br />

Gray value image.<br />

º Feature (input control) ...............................................string Htuple . const char *<br />

Feature to be examined.<br />

Default Value : ’convexity’<br />

Value List : Feature ¾’convexity’, ’compactness’, ’anisometry’, ’holes’<br />

º Row (input control) ...........................................................point.y Htuple . long<br />

Row of the pixel which the region must contain.<br />

Default Value : 256<br />

Value Suggestions : Row ¾10, 50, 100, 200, 300, 400<br />

º Column (input control) .......................................................point.x Htuple . long<br />

Column of the pixel which the region must contain.<br />

Default Value : 256<br />

Value Suggestions : Column ¾10, 50, 100, 200, 300, 400<br />

º AbsoluteHisto (output control) ........................histogram-array Htuple . double * / long *<br />

Absolute distribution of the feature.<br />

º RelativeHisto (output control) ................................histogram-array Htuple . double *<br />

Relative distribution of the feature.<br />

Result<br />

The operator T shape histo point returns the value H MSG TRUE if an image with defined gray values<br />

is entered. The behavior in case of empty input (no input images available) is set via the operator<br />

set system(’no object result’,), the behavior in case of empty region is set via<br />

set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

T shape histo point is reentrant and processed without parallelization.<br />

get mbutton, area center<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

histo to thresh, threshold, gen region histo<br />

T shape histo all<br />

Alternatives<br />

See Also<br />

connection, connect and holes, convexity, compactness, set paint<br />

Image filters<br />

Module<br />

5.5 Format<br />

change format ( Hobject Image, Hobject *ImagePart, long Width,<br />

long Height )<br />

Change image size.<br />

The operator change format increases or decreases the size of the input images to the indicated height or width,<br />

respectively. If the image is reduced parts are cut off at the “right” or “lower” edge of the image, respectively. If<br />

the image is enlarged the additional areas are set to 0. The definition domain includes all pixels of the new image.<br />

No zooming is carried out.<br />

<strong>HALCON</strong> 6.0


334 CHAPTER 5. IMAGE<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Input image.<br />

º ImagePart (output object) ...............................................image(-array) Hobject *<br />

Image with new format.<br />

º Width (input control) ...............................................................extent.x long<br />

Width of new image.<br />

Default Value : 512<br />

Value Suggestions : Width ¾32, 64, 128, 256, 512, 768, 1024<br />

º Height (input control) ..............................................................extent.y long<br />

Height of new image.<br />

Default Value : 512<br />

Value Suggestions : Height ¾32, 64, 128, 256, 512, 525, 1024<br />

Parallelization Information<br />

change format is reentrant and automatically parallelized (on tuple level).<br />

disp image<br />

crop part<br />

zoom image size, zoom image factor<br />

Image / region / XLD management<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

crop domain ( Hobject Image, Hobject *ImagePart )<br />

Cut out of defined gray values.<br />

The operator crop domain cuts a rectangular area from the input images. This rectangle is the smallest surrounding<br />

rectangle of the domain of the imput image. The new definition domain includes all pixels of the new<br />

image. The new image matrix has the size of the rectangle.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject<br />

Input image.<br />

º ImagePart (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject *<br />

Image area.<br />

Parallelization Information<br />

crop domain is reentrant and automatically parallelized (on tuple level).<br />

disp image<br />

Possible Successor Functions<br />

Alternatives<br />

crop part, crop rectangle1, change format, reduce domain<br />

zoom image size, zoom image factor<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

crop part ( Hobject Image, Hobject *ImagePart, long Row, long Column,<br />

long Width, long Height )<br />

Cut out a rectangular image area.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.5. FORMAT 335<br />

The operator crop part cuts a rectangular area from the input images. The area is indicated by a rectangle<br />

(upper left corner and size). The area must be within the image. The definition domain includes all pixels of the<br />

new image. The new image matrix has the size of a rectangle.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject<br />

Input image.<br />

º ImagePart (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject *<br />

Image area.<br />

º Row (input control) .........................................................rectangle.origin.y long<br />

Line index of upper left corner of image area.<br />

Default Value : 100<br />

Value Suggestions : Row ¾10, 20, 50, 100, 200, 300, 500<br />

Typical Range of Values : 0 Row 1024<br />

º Column (input control) .....................................................rectangle.origin.x long<br />

Column index of upper left corner of image area.<br />

Default Value : 100<br />

Value Suggestions : Column ¾10, 20, 50, 100, 200, 300, 500<br />

Typical Range of Values : 0 Column 1024<br />

º Width (input control) ......................................................rectangle.extent.x long<br />

Width of new image.<br />

Default Value : 128<br />

Value Suggestions : Width ¾32, 64, 128, 256, 512, 768<br />

Typical Range of Values : 0 Width 1024<br />

º Height (input control) .....................................................rectangle.extent.y long<br />

Height of new image.<br />

Default Value : 128<br />

Value Suggestions : Height ¾32, 64, 128, 256, 512, 525<br />

Typical Range of Values : 0 Height 1024<br />

Parallelization Information<br />

crop part is reentrant and automatically parallelized (on tuple level).<br />

disp image<br />

Possible Successor Functions<br />

Alternatives<br />

crop rectangle1, crop domain, change format, reduce domain<br />

zoom image size, zoom image factor<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

crop rectangle1 ( Hobject Image, Hobject *ImagePart, long Row1,<br />

long Column1, long Row2, long Column2 )<br />

Cut out a rectangular image area.<br />

The operator crop rectangle1 cuts a rectangular area from the input images. The area is indicated by a<br />

rectangle (upper left and lower right corner). The area must be within the image. The definition domain includes<br />

all pixels of the new image. The new image matrix has the size of a rectangle.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject<br />

Input image.<br />

º ImagePart (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject *<br />

Image area.<br />

<strong>HALCON</strong> 6.0


336 CHAPTER 5. IMAGE<br />

º Row1 (input control) ........................................................rectangle.origin.y long<br />

Line index of upper left corner of image area.<br />

Default Value : 100<br />

Value Suggestions : Row1 ¾10, 20, 50, 100, 200, 300, 500<br />

Typical Range of Values : 0 Row1 1024<br />

º Column1 (input control) ....................................................rectangle.origin.x long<br />

Column index of upper left corner of image area.<br />

Default Value : 100<br />

Value Suggestions : Column1 ¾10, 20, 50, 100, 200, 300, 500<br />

Typical Range of Values : 0 Column1 1024<br />

º Row2 (input control) .......................................................rectangle.corner.y long<br />

Line index of lower right corner of image area.<br />

Default Value : 200<br />

Value Suggestions : Row2 ¾10, 20, 50, 100, 200, 300, 500<br />

Typical Range of Values : 0 Row2 1024<br />

º Column2 (input control) ...................................................rectangle.corner.x long<br />

Column index of lower right corner of image area.<br />

Default Value : 200<br />

Value Suggestions : Column2 ¾10, 20, 50, 100, 200, 300, 500<br />

Typical Range of Values : 0 Column2 1024<br />

Parallelization Information<br />

crop rectangle1 is reentrant and automatically parallelized (on tuple level).<br />

disp image<br />

Possible Successor Functions<br />

Alternatives<br />

crop part, crop domain, change format, reduce domain<br />

zoom image size, zoom image factor<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

tile channels ( Hobject Image, Hobject *TiledImage, long NumColumns,<br />

const char *TileOrder )<br />

Tile multiple images into a large image.<br />

tile channels tiles an image consisting of multiple channels into a large single-channel image. The input<br />

image Image contains Num images of the same size, which are stored in the individual channels. The output<br />

image TiledImage contains a single channel image, where the Num input channels have been tiled into<br />

NumColumns columns. In particular, this means that tile channels cannot tile color images. For this purpose,<br />

tile images can be used. The parameter TileOrder determines the order in which the images are<br />

copied into the output in the cases in which this is not already determined by NumColumns (i.e., if NumColumns<br />

!= 1 and NumColumns != Num). If TileOrder = ’horizontal’ the images are copied in the horizontal direction,<br />

i.e., the second channel of Image will be to the right of the first channel. If TileOrder = ’vertical’ the images<br />

are copied in the vertical direction, i.e., the second channel of Image will be below the first channel. The domain<br />

of TiledImage is obtained by copying the domain of Image to the corresponding locations in the output image.<br />

If Num is not a multiple of NumColumns the output image will have undefined gray values in the lower right<br />

corner of the image. The output domain will reflect this.<br />

Parameter<br />

º Image (input object) multichannel-image(-array) Hobject : byte / int1 / cyclic / direction / int2 / int4 / real<br />

Input image.<br />

º TiledImage (output object) .................................singlechannel-image(-array) Hobject *<br />

Tiled output image.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.5. FORMAT 337<br />

º NumColumns (input control) .........................................................integer long<br />

Number of columns to use for the output image.<br />

Default Value : 1<br />

Value Suggestions : NumColumns ¾1, 2, 3, 4, 5, 6, 7<br />

º TileOrder (input control) .....................................................string const char *<br />

Order of the input images in the output image.<br />

Default Value : ’vertical’<br />

Value List : TileOrder ¾’horizontal’, ’vertical’<br />

Example<br />

/* Grab 5 single-channel images and stack them vertically. */<br />

gen_rectangle1 (Image, 0, 0, Height-1, Width-1)<br />

for I := 1 to 5 by 1<br />

grab_image_async (ImageGrabbed, FGHandle, -1)<br />

append_channel (Image, ImageGrabbed, Image)<br />

endfor<br />

tile_channels (Image, TiledImage, 1, ’vertical’)<br />

Result<br />

tile channels returns H MSG TRUE if all parameters are correct and no error occurs during execution. If the<br />

input is empty the behavior can be set via set system(’no object result’,). If necessary,<br />

an exception handling is raised.<br />

Parallelization Information<br />

tile channels is reentrant and automatically parallelized (on tuple level).<br />

append channel<br />

tile images, T tile images offset<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

change format, crop part, crop rectangle1<br />

Image / region / XLD management<br />

Module<br />

tile images ( Hobject Images, Hobject *TiledImage, long NumColumns,<br />

const char *TileOrder )<br />

Tile multiple image objects into a large image.<br />

tile images tiles multiple input image objects, which must contain the same number of channels, into a large<br />

image. The input image object Images contains Num images, which may be of different size. The output image<br />

TiledImage contains as many channels as the input images. In the output image the Num input images have been<br />

tiled into NumColumns columns. Each tile has the same size, which is determined by the maximum width and<br />

height of all input images. If an input image is smaller than the tile size it is copied to the center of the respective<br />

tile. The parameter TileOrder determines the order in which the images are copied into the output in the cases<br />

in which this is not already determined by NumColumns (i.e., if NumColumns != 1 and NumColumns != Num).<br />

If TileOrder = ’horizontal’ the images are copied in the horizontal direction, i.e., the second image of Images<br />

will be to the right of the first image. If TileOrder = ’vertical’ the images are copied in the vertical direction,<br />

i.e., the second image of Images will be below the first image. The domain of TiledImage is obtained by<br />

copying the domains of Images to the corresponding locations in the output image. If Num is not a multiple of<br />

NumColumns the output image will have undefined gray values in the lower right corner of the image. The output<br />

domain will reflect this.<br />

Parameter<br />

º Images (input object) . .(multichannel-)image-array Hobject : byte / int1 / cyclic / direction / int2 / int4 /<br />

real<br />

Input images.<br />

<strong>HALCON</strong> 6.0


338 CHAPTER 5. IMAGE<br />

º TiledImage (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image Hobject *<br />

Tiled output image.<br />

º NumColumns (input control) .........................................................integer long<br />

Number of columns to use for the output image.<br />

Default Value : 1<br />

Value Suggestions : NumColumns ¾1, 2, 3, 4, 5, 6, 7<br />

º TileOrder (input control) .....................................................string const char *<br />

Order of the input images in the output image.<br />

Default Value : ’vertical’<br />

Value List : TileOrder ¾’horizontal’, ’vertical’<br />

Example<br />

/* Grab 5 (multi-channel) images and stack them vertically. */<br />

gen_empty_obj (Images)<br />

for I := 1 to 5 by 1<br />

grab_image_async (ImageGrabbed, FGHandle, -1)<br />

concat_obj (Images, ImageGrabbed, Images)<br />

endfor<br />

tile_images (Images, TiledImage, 1, ’vertical’)<br />

Result<br />

tile images returns H MSG TRUE if all parameters are correct and no error occurs during execution. If the<br />

input is empty the behavior can be set via set system(’no object result’,). If necessary,<br />

an exception handling is raised.<br />

Parallelization Information<br />

tile images is reentrant and automatically parallelized (on channel level).<br />

append channel<br />

tile channels, T tile images offset<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

change format, crop part, crop rectangle1<br />

Image / region / XLD management<br />

Module<br />

T tile images offset ( Hobject Images, Hobject *TiledImage,<br />

Htuple OffsetRow, Htuple OffsetCol, Htuple Row1, Htuple Col1, Htuple Row2,<br />

Htuple Col2, Htuple Width, Htuple Height )<br />

Tile multiple image objects into a large image with explicit positioning information.<br />

T tile images offset tiles multiple input image objects, which must contain the same number of channels,<br />

into a large image. The input image object Images contains Num images, which may be of different size. The<br />

output image TiledImage contains as many channels as the input images. The size of the output image is<br />

determined by the parameters Width and Height. The position of the upper left corner of the input images in<br />

the output images is determined by the parameters OffsetRow and OffsetCol. Both parameters must contain<br />

exactly Num values. Optionally, each input image can be cropped to an arbitrary rectangle that is smaller than the<br />

input image. To do so, the parameters Row1, Col1, Row2,andCol2 must be set accordingly. If any of these four<br />

parameters is set to -1, the corresponding input image is not cropped. In any case, all four parameters must contain<br />

Num values. If the input images are cropped the position parameters OffsetRow and OffsetCol refer to the<br />

upper left corner of the cropped image. If the input images overlap each other in the output image (while taking<br />

into account their respective domains), the image with the higher index in Images overwrites the image data of<br />

the image with the lower index. The domain of TiledImage is obtained by copying the domains of Images to<br />

the corresponding locations in the output image.<br />

Attention<br />

If the input images all have the same size and tile the output image exactly, the operator tile images usually<br />

will be slightly faster.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.5. FORMAT 339<br />

Parameter<br />

º Images (input object) . .(multichannel-)image-array Hobject : byte / int1 / cyclic / direction / int2 / int4 /<br />

real<br />

Input images.<br />

º TiledImage (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image Hobject *<br />

Tiled output image.<br />

º OffsetRow (input control) .............................................point.y-array Htuple . long<br />

Row coordinate of the upper left corner of the input images in the output image.<br />

Default Value : 0<br />

Value Suggestions : OffsetRow ¾0, 50, 100, 150, 200, 250<br />

º OffsetCol (input control) .............................................point.x-array Htuple . long<br />

Column coordinate of the upper left corner of the input images in the output image.<br />

Default Value : 0<br />

Value Suggestions : OffsetCol ¾0, 50, 100, 150, 200, 250<br />

º Row1 (input control) ..........................................rectangle.origin.y-array Htuple . long<br />

Row coordinate of the upper left corner of the copied part of the respective input image.<br />

Default Value : -1<br />

Value Suggestions : Row1 ¾-1, 0, 10, 20, 50, 100, 200, 300, 500<br />

º Col1 (input control) ..........................................rectangle.origin.x-array Htuple . long<br />

Column coordinate of the upper left corner of the copied part of the respective input image.<br />

Default Value : -1<br />

Value Suggestions : Col1 ¾-1, 0, 10, 20, 50, 100, 200, 300, 500<br />

º Row2 (input control) ..........................................rectangle.corner.y-array Htuple . long<br />

Row coordinate of the lower right corner of the copied part of the respective input image.<br />

Default Value : -1<br />

Value Suggestions : Row2 ¾-1, 0, 10, 20, 50, 100, 200, 300, 500<br />

º Col2 (input control) ..........................................rectangle.corner.x-array Htuple . long<br />

Column coordinate of the lower right corner of the copied part of the respective input image.<br />

Default Value : -1<br />

Value Suggestions : Col2 ¾-1, 0, 10, 20, 50, 100, 200, 300, 500<br />

º Width (input control) .......................................................extent.x Htuple . long<br />

Width of the output image.<br />

Default Value : 512<br />

Value Suggestions : Width ¾32, 64, 128, 256, 512, 768, 1024, 2048, 4096<br />

º Height (input control) ......................................................extent.y Htuple . long<br />

Height of the output image.<br />

Default Value : 512<br />

Value Suggestions : Height ¾32, 64, 128, 256, 512, 525, 1024, 2048, 4096<br />

Example<br />

/* Grab 2 (multi-channel) NTSC images, crop the bottom 5 lines off */<br />

/* of each image, the right 5 columns off of the first image, and */<br />

/* the left five lines off of the second image, and put the cropped */<br />

/* images side-by-side. */<br />

gen_empty_obj (Images)<br />

for I := 1 to 2 by 1<br />

grab_image_async (ImageGrabbed, FGHandle, -1)<br />

concat_obj (Images, ImageGrabbed, Images)<br />

endfor<br />

tile_images_offset (Images, TiledImage, [0,635], [0,0], [0,0],<br />

[0,5], [474,474], [634,639])<br />

Result<br />

T tile images offset returns H MSG TRUE if all parameters are correct and no error occurs during execution.<br />

If the input is empty the behavior can be set via set system(’no object result’,). If<br />

necessary, an exception handling is raised.<br />

<strong>HALCON</strong> 6.0


340 CHAPTER 5. IMAGE<br />

Parallelization Information<br />

T tile images offset is reentrant and automatically parallelized (on channel level).<br />

append channel<br />

tile channels, tile images<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

change format, crop part, crop rectangle1<br />

Image / region / XLD management<br />

Module<br />

5.6 Framegrabber<br />

close all framegrabbers ( )<br />

Close all frame grabbers.<br />

The operator close all framegrabbers closes all frame grabbers. It is used to cope with deadlocks resulting<br />

from damaged frame grabber handles (in that case the use of close framegrabber is impossible).<br />

Attention<br />

Since all frame grabbers are closed by close all framegrabbers all frame grabber handles become invalid.<br />

Result<br />

If it is possible to close the frame grabbers the operator close all framegrabbers returns the value<br />

H MSG TRUE. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

close all framegrabbers is local and processed completely exclusively without parallelization.<br />

grab image<br />

(T )open framegrabber<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

close framegrabber ( long FGHandle )<br />

Close specified frame grabber.<br />

The operator close framegrabber closes the frame grabber specified by FGHandle. In particular possible<br />

storage space for data buffers is released and the frame grabber is made available for other processes.<br />

Parameter<br />

º FGHandle (input control) ......................................................framegrabber long<br />

Handle of the frame grabber to be closed.<br />

Result<br />

If the frame grabber is open the operator close framegrabber returns the value H MSG TRUE. Otherwise<br />

an exception handling is raised.<br />

Parallelization Information<br />

close framegrabber is local and processed completely exclusively without parallelization.<br />

grab image<br />

Possible Predecessor Functions<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.6. FRAMEGRABBER 341<br />

(T )open framegrabber<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

T get framegrabber lut ( Htuple FGHandle, Htuple *ImageRed,<br />

Htuple *ImageGreen, Htuple *ImageBlue )<br />

Query frame grabber lut.<br />

The operator T get framegrabber lut queries the lut of the frame grabber specified by FGHandle. This<br />

operation is not supported for all kinds of frame grabbers.<br />

Parameter<br />

º FGHandle (input control) ..............................................framegrabber Htuple . long<br />

Handle of the desired frame grabber.<br />

º ImageRed (output control) ............................................integer-array Htuple . long *<br />

Red level of the lut entries.<br />

º ImageGreen (output control) .........................................integer-array Htuple . long *<br />

Green level of the lut entries.<br />

º ImageBlue (output control) ..........................................integer-array Htuple . long *<br />

Blue level of the lut entries.<br />

Result<br />

The operator T get framegrabber lut returns the value H MSG TRUE if the frame grabber is open.<br />

Parallelization Information<br />

T get framegrabber lut is reentrant and processed without parallelization.<br />

(T )open framegrabber<br />

T set framegrabber lut<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

T set framegrabber lut, (T )open framegrabber<br />

Image / region / XLD management<br />

Module<br />

get framegrabber param ( long FGHandle, const char *Param,<br />

char *Value )<br />

T get framegrabber param ( Htuple FGHandle, Htuple Param,<br />

Htuple *Value )<br />

Get specific parameters for a frame grabber.<br />

The operator (T )get framegrabber param returns specific parameter values for the frame grabber specified<br />

by FGHandle. The standard parameters listed below are available for all frame grabbers. Additional parameters<br />

may be supported by specific frame grabbers. A list of those can be obtained with the query ’parameter’ via<br />

(T )info framegrabber.<br />

Standard values for Param,see(T )open framegrabber:<br />

’name’ Name of the frame grabber.<br />

’horizontal resolution’ Horizontal resolution of the frame grabber.<br />

’vertical resolution’ Vertical resolution of the frame grabber.<br />

’image width’ Width of the image area.<br />

’image height’ Height of the image area.<br />

<strong>HALCON</strong> 6.0


342 CHAPTER 5. IMAGE<br />

’start row’ Line number of upper left corner of the image area.<br />

’start column’ Column number of upper left corner of the image area.<br />

’field’ Selected half image or for full image.<br />

’bits per channel’ Number of transferred bits per pixel and image channel.<br />

’color space’ Color images: color space.<br />

’gain’ Amplification factor for video amplifier.<br />

’external trigger’ External triggering (’true’ / ’false’).<br />

’camera type’ Type of used camera (frame grabber specific).<br />

’device’ Device the frame grabber is linked to.<br />

’port’ Port of the frame grabber the video signal is linked to.<br />

’line in’ Camera input line of multiplexer.<br />

Parameter<br />

º FGHandle (input control) ............................................framegrabber (Htuple .) long<br />

Handle of the frame grabber to be used.<br />

º Param (input control) ..........................................string(-array) (Htuple .) const char *<br />

Parameter of interest.<br />

Default Value : ’name’<br />

Value Suggestions : Param ¾’name’, ’horizontal resolution’, ’vertical resolution’, ’image width’,<br />

’image height’, ’start row’, ’start column’, ’field’, ’bits per channel’, ’color space’, ’gain’, ’external trigger’,<br />

’camera type’, ’device’, ’port’, ’line in’<br />

º Value (output control) .............................string(-array) (Htuple .) char * / double * / long *<br />

Parameter value.<br />

Result<br />

If the frame grabber is open and the specified parameter is supported by the frame grabber, the operator<br />

(T )get framegrabber param returns the value H MSG TRUE. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

(T )get framegrabber param is reentrant and processed without parallelization.<br />

(T )open framegrabber<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

grab image, grab region, grab image start, grab image async, grab region async,<br />

close framegrabber<br />

See Also<br />

(T )open framegrabber, (T )info framegrabber, (T )set framegrabber param<br />

Image / region / XLD management<br />

Module<br />

grab image ( Hobject *Image, long FGHandle )<br />

Grab an image from the specified frame grabber.<br />

The operator grab image grabs an image via the frame grabber specified by FGHandle. The desired<br />

operational mode of the frame grabber as well as a suitable image area can be adjusted via the<br />

operator (T )open framegrabber. Additional (frame grabber specific) settings might be possible via<br />

(T )set framegrabber param.<br />

Parameter<br />

º Image (output object) ............................................................image Hobject *<br />

Grabbed image.<br />

º FGHandle (input control) ......................................................framegrabber long<br />

Handle of the frame grabber to be used.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.6. FRAMEGRABBER 343<br />

Example<br />

/* Select a suitable frame grabber FgName */<br />

info_framegrabber(FgName,"ports",&Information,&Val) ;<br />

/* Choose the port P and the input line L your camera is connected to */<br />

open_framegrabber(FgName,1,1,0,0,0,0,"default",-1,"default",-1.0,<br />

"default","default","default",P,L,&FgHandle) ;<br />

grab_image(&Img,FgHandle) ;<br />

close_framegrabber(FgHandle) ;<br />

Result<br />

If the frame grabber is open the operator grab image returns the value H MSG TRUE. Otherwise an exception<br />

handling is raised.<br />

Parallelization Information<br />

grab image is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

(T )open framegrabber, grab image start<br />

Possible Successor Functions<br />

grab image, grab image start, grab image async, close framegrabber<br />

See Also<br />

(T )open framegrabber, (T )info framegrabber, (T )set framegrabber param<br />

Image / region / XLD management<br />

Module<br />

grab image async ( Hobject *Image, long FGHandle, double MaxDelay )<br />

Grab of an image from the specified frame grabber and start of the asynchronous grab of the next image.<br />

The operator grab image async grabs an image via theframe grabber specified by FGHandle and starts the<br />

asynchronous grab of the next image. The desired operational mode of the frame grabber as well as a suitable<br />

image area can be adjusted via the operator (T )open framegrabber. Additional (frame grabber specific)<br />

settings might be possible via (T )set framegrabber param. The grab of the next image is finished via<br />

grab image or again via grab image async. If more than MaxDelay ms have passed since the asynchronous<br />

grab was started, a new image is grabbed (the asynchronously grabbed image is considered as too old).<br />

If a negative value is assigned to MaxDelay this control mechanism is deactivated.<br />

Parameter<br />

º Image (output object) ............................................................image Hobject *<br />

Grabbed image.<br />

º FGHandle (input control) ......................................................framegrabber long<br />

Handle of the frame grabber to be used.<br />

º MaxDelay (input control) .........................................................number double<br />

Maximum tolerated delay beteween the start of the asynchronous grab and the delivery of the image [ms].<br />

Default Value : -1.0<br />

Value Suggestions : MaxDelay ¾-1.0, 20.0, 33.3, 40.0, 66.6, 80.0, 99.9<br />

Example<br />

/* Select a suitable frame grabber FgName */<br />

info_framegrabber(FgName,"ports",&Information,&Val) ;<br />

/* Choose the port P and the input line L your camera is connected to */<br />

open_framegrabber(FgName,1,1,0,0,0,0,"default",-1,"default",-1.0,<br />

"default","default","default",P,L,&FgHandle) ;<br />

/* grab image + start next grab */<br />

grab_image_async(&Img,FgHandle,-1.0) ;<br />

/* Process Img ... */<br />

<strong>HALCON</strong> 6.0


344 CHAPTER 5. IMAGE<br />

/* Finish asynchronous grab + start next grab */<br />

grab_image_async(Img,FgHandle,-1.0) ;<br />

close_framegrabber(FgHandle) ;<br />

Result<br />

If the frame grabber is open and supports asynchronous grabbing the operator grab image async returns the<br />

value H MSG TRUE. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

grab image async is reentrant and processed without parallelization.<br />

(T )open framegrabber<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

grab image, grab image async, close framegrabber<br />

See Also<br />

grab image start, (T )open framegrabber, (T )info framegrabber,<br />

(T )set framegrabber param<br />

Module<br />

Image / region / XLD management<br />

grab image start ( long FGHandle, double MaxDelay )<br />

Start an asynchronous grab of an image from the specified frame grabber.<br />

The operator grab image start starts an asynchronous grab of an image via the frame grabber specified<br />

by FGHandle. The desired operational mode of the frame grabber as well as a suitable image area can be<br />

adjusted via the operator (T )open framegrabber. Additional (frame grabber specific) settings might be<br />

possible via (T )set framegrabber param. The grab is finished via grab image, grab image async,<br />

grab region, orgrab region async. If one of those operators is called more than MaxDelay ms later, a<br />

new image is grabbed (the asynchronously grabbed image is considered as to old). If a negative value is assigned<br />

to MaxDelay this control mechanism is deactivated.<br />

Parameter<br />

º FGHandle (input control) ......................................................framegrabber long<br />

Handle of the frame grabber to be used.<br />

º MaxDelay (input control) .........................................................number double<br />

Maximum tolerated delay between the start of the asynchronous grab and the delivery of the image [ms].<br />

Default Value : -1.0<br />

Value Suggestions : MaxDelay ¾20.0, 33.3, 40.0, 66.6, 80.0, 99.9<br />

Example<br />

/* Select a suitable frame grabber FgName */<br />

info_framegrabber(FgName,"ports",&Information,&Val) ;<br />

/* Choose the port P and the input line L your camera is connected to */<br />

open_framegrabber(FgName,1,1,0,0,0,0,"default",-1,"default",-1.0,<br />

"default","default","default",P,L,&FgHandle) ;<br />

grab_image(&Img,FgHandle) ;<br />

/* Start next grab */<br />

grab_image_start(FgHandle,-1.0) ;<br />

/* Process Img ... */<br />

/* Finish asynchronous grab */<br />

grab_image(Img,FgHandle) ;<br />

close_framegrabber(FgHandle) ;<br />

Result<br />

If the frame grabber is open and supports asynchronous grabbing the operator grab image start returns the<br />

value H MSG TRUE. Otherwise an exception handling is raised.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.6. FRAMEGRABBER 345<br />

Parallelization Information<br />

grab image start is reentrant and processed without parallelization.<br />

(T )open framegrabber<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

grab image, grab region, grab image async, grab region async, close framegrabber<br />

See Also<br />

(T )open framegrabber, (T )info framegrabber, (T )set framegrabber param<br />

Image / region / XLD management<br />

Module<br />

grab region ( Hobject *Region, long FGHandle )<br />

Grab and segment an image from the specified frame grabber.<br />

The operator grab region grabs an image via the frame grabber specified by FGHandle and segments<br />

it. The desired operational mode of the frame grabber as well as a suitable image area can be adjusted via<br />

the operator (T )open framegrabber. Additional (frame grabber specific) settings might be possible via<br />

(T )set framegrabber param.<br />

Parameter<br />

º Region (output object) ...................................................region(-array) Hobject *<br />

Grabbed and segmented image: Region(s).<br />

º FGHandle (input control) ......................................................framegrabber long<br />

Handle of the frame grabber to be used.<br />

Example<br />

/* Select a suitable frame grabber FgName */<br />

info_framegrabber(FgName,"ports",&Information,&Val) ;<br />

/* Choose the port P and the input line L your camera is connected to */<br />

open_framegrabber(FgName,1,1,0,0,0,0,"default",-1,"default",-1.0,<br />

"default","default","default",P,L,&FgHandle) ;<br />

/* grab and segment image */<br />

grab_region(&Region,FgHandle) ;<br />

/* Process Region ... */<br />

close_framegrabber(FgHandle) ;<br />

Result<br />

If the frame grabber is open the operator grab region returns the value H MSG TRUE. Otherwise an exception<br />

handling is raised.<br />

Parallelization Information<br />

grab region is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

(T )open framegrabber, grab image start<br />

Possible Successor Functions<br />

grab region, grab region async, grab image start, grab image, grab image async,<br />

close framegrabber<br />

See Also<br />

(T )open framegrabber, (T )info framegrabber, (T )set framegrabber param<br />

Image / region / XLD management<br />

Module<br />

<strong>HALCON</strong> 6.0


346 CHAPTER 5. IMAGE<br />

grab region async ( Hobject *Region, long FGHandle, double MaxDelay )<br />

Grab and segment an image from the specified frame grabber and start the asynchronous grab of the next image.<br />

The operator grab region async grabs an image via the frame grabber specified by FGHandle, segments<br />

it, and starts the asynchronous grab of the next image. The desired operational mode of the frame grabber as<br />

well as a suitable image area can be adjusted via the operator (T )open framegrabber. Additional (frame<br />

grabber specific) settings might be possible via (T )set framegrabber param. The grab of the next image<br />

is finished via grab region or again via grab region async. If more than MaxDelay ms have passed<br />

since the asynchronous grab was started, a new image is grabbed (the asynchronously grabbed image is considered<br />

as too old). If a negative value is assigned to MaxDelay this control mechanism is deactivated.<br />

Parameter<br />

º Region (output object) ...................................................region(-array) Hobject *<br />

Grabbed and segmented image: Region(s).<br />

º FGHandle (input control) ......................................................framegrabber long<br />

Handle of the frame grabber to be used.<br />

º MaxDelay (input control) .........................................................number double<br />

Maximum tolerated delay beteween the start of the asynchronous grab and the delivery of the image [ms].<br />

Default Value : -1.0<br />

Value Suggestions : MaxDelay ¾-1.0, 20.0, 33.3, 40.0, 66.6, 80.0, 99.9<br />

Example<br />

/* Select a suitable frame grabber FgName */<br />

info_framegrabber(FgName,"ports",&Information,&Val) ;<br />

/* Choose the port P and the input line L your camera is connected to */<br />

open_framegrabber(FgName,1,1,0,0,0,0,"default",-1,"default",-1.0,<br />

"default","default","default",P,L,&FgHandle) ;<br />

/* grab image, segment it, and start next grab */<br />

grab_region_async(Region,FgHandle,-1.0) ;<br />

/* Process Region ... */<br />

/* Finish asynchronous grab, segment this image, and start next grab */<br />

grab_region_async(Region,FgHandle,-1.0) ;<br />

close_framegrabber(FgHandle) ;<br />

Result<br />

If the frame grabber is open the operator grab region async returns the value H MSG TRUE. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

grab region async is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

(T )open framegrabber, grab image start<br />

Possible Successor Functions<br />

grab region, grab region async, grab image start, grab image, grab image async,<br />

close framegrabber<br />

See Also<br />

(T )open framegrabber, (T )info framegrabber, (T )set framegrabber param<br />

Image / region / XLD management<br />

Module<br />

info framegrabber ( const char *Name, const char *Query,<br />

char *Information, char *ValueList )<br />

T info framegrabber ( Htuple Name, Htuple Query, Htuple *Information,<br />

Htuple *ValueList )<br />

Information about the specified frame grabber.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.6. FRAMEGRABBER 347<br />

The operator (T )info framegrabber returns information about the frame grabber Name. The desired information<br />

is specified via Query. A textual description according to the selected topic is returned in Information.<br />

If applicable, ValueList contains a list of supported values. Up to now, the following queries are possible:<br />

’ports’: Description of the ports (signal, connectors etc.) in Information and the port numbers in<br />

ValueList.<br />

’camera types’: Description of the frame grabber specific parameter ’CameraType’, see<br />

(T )open framegrabber.<br />

’general’: General information (in Information).<br />

’defaults’: Framegrabber specific default values in ValueList,see(T )open framegrabber.<br />

’parameters’: Frame grabber specific parameters accessable via (T )set framegrabber param and<br />

(T )get framegrabber param.<br />

Please check also the directory doc/html/manuals for files describing selected frame grabbers.<br />

Parameter<br />

º Name (input control) ..................................................string (Htuple .) const char *<br />

Frame grabber of interest.<br />

Default Value : ’File’<br />

Value Suggestions : Name ¾’BitFlow’, ’DFG-BW1’, ’DFG-LC’, ’DT315x’, ’File’, ’Fire-i’, ’FlashBus’,<br />

’GINGA’, ’IDS’, ’Inspecta2’, ’MatrixVision’, ’Meteor1’, ’Opteon’, ’PCEye’, ’PicPort’, ’PX’, ’PXC’, ’PXD’,<br />

’Ramses1’, ’TWAIN’, ’VideoPort’<br />

º Query (input control) .................................................string (Htuple .) const char *<br />

Name of the chosen query.<br />

Default Value : ’info boards’<br />

Value List : Query ¾’info boards’, ’ports’, ’camera types’, ’general’, ’defaults’, ’parameters’<br />

º Information (output control) .............................................string (Htuple .) char *<br />

Textual information (according to Query).<br />

º ValueList (output control) .......................string(-array) (Htuple .) char * / long * / double *<br />

If applicable, a list of values (according to Query).<br />

Example<br />

/* Select a suitable frame grabber FgName */<br />

info_framegrabber(FgName,"ports",&Information,&Val) ;<br />

/* Choose the port P and the input line L your camera is connected to */<br />

open_framegrabber(FgName,1,1,0,0,0,0,"default",-1,"default",-1.0,<br />

"default","default","default",P,L,&FgHandle) ;<br />

grab_image(&Img,FgHandle) ;<br />

close_framegrabber(FgHandle) ;<br />

Result<br />

If the parameter values are correct and the desired frame grabber is available at call time,<br />

(T )info framegrabber returns the value H MSG TRUE. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

(T )info framegrabber is local and processed completely exclusively without parallelization.<br />

(T )open framegrabber<br />

(T )open framegrabber<br />

(T )open framegrabber<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


348 CHAPTER 5. IMAGE<br />

open framegrabber ( const char *Name, long HorizontalResolution,<br />

long VerticalResolution, long ImageWidth, long ImageHeight, long StartRow,<br />

long StartColumn, const char *Field, long BitsPerChannel,<br />

const char *ColorSpace, double Gain, const char *ExternalTrigger,<br />

const char *CameraType, const char *Device, long Port, long LineIn,<br />

long *FGHandle )<br />

T open framegrabber ( Htuple Name, Htuple HorizontalResolution,<br />

Htuple VerticalResolution, Htuple ImageWidth, Htuple ImageHeight,<br />

Htuple StartRow, Htuple StartColumn, Htuple Field, Htuple BitsPerChannel,<br />

Htuple ColorSpace, Htuple Gain, Htuple ExternalTrigger, Htuple CameraType,<br />

Htuple Device, Htuple Port, Htuple LineIn, Htuple *FGHandle )<br />

Open and configure a frame grabber.<br />

The operator (T )open framegrabber opens and configures the chosen frame grabber. During this process<br />

the connection to the frame grabber is tested, the frame grabber is (normally) locked for other processes, and<br />

if necessary memory is reserved as data buffer. The image is actually grabbed via the operators grab image,<br />

grab region, grab image async,orgrab region async. If the frame grabber is not needed anymore,<br />

it should be closed via the operator close framegrabber, releasing it for other processes. This automatically<br />

happens when a frame grabber is reopened. Some frame grabbers allow to open several instances of the same<br />

frame grabber class (up to 5).<br />

For some parameters frame grabber specific default values can be chosen explicitly (see the parameter description<br />

below). Additional information for a specific frame grabber is available via (T )info framegrabber. Please<br />

check also the directory doc/html/manuals for files describing selected frame grabbers.<br />

The meaning of the particular parameters is as follows:<br />

HorizontalResolution, VerticalResolution Desired resolution of the frame grabber.<br />

ImageWidth, ImageHeight Size of the image area to be returned by grab image etc.<br />

StartRow, StartColumn StartRow, StartColumn upper left corner of the desired image area.<br />

Field Desired half image (’first’, ’second’,or’next’) or selection of a full image.<br />

BitsPerChannel Number of bits, which are transferred from the frame grabber board per pixel and image channel<br />

(typically 5, 8, 10, 12, or 16 Bits).<br />

ColorSpace Specify to grab single-channel (’gray’) or three-channel images (’rgb’, ’yuv’, ...).<br />

Gain Amplification factor for the video amplifier (if available).<br />

ExternalTrigger Activation of external triggering (if available).<br />

CameraType Frame grabber specific parameter (string type) to specify the type of the used camera, which can be<br />

inquired via (T )info framegrabber.<br />

Device Device name of the frame grabber card.<br />

Port Port of the frame grabber the video signal is connected to.<br />

LineIn Camera input line of multiplexer (if available).<br />

The operator (T )open framegrabber returns a handle (FGHandle) to the opened frame grabber.<br />

Attention<br />

Due to the multitude of supported frame grabbers a large number of parameters is necessary for the operator<br />

(T )open framegrabber. However, not all parameters are needed for a specific frame grabber.<br />

Parameter<br />

º Name (input control) ..................................................string (Htuple .) const char *<br />

<strong>HALCON</strong> frame grabber interface, i.e. name of the corresponding DLL (WindowsNT) or shared library<br />

(UNIX).<br />

Default Value : ’File’<br />

Value Suggestions : Name ¾’BitFlow’, ’DFG-BW1’, ’DFG-LC’, ’DT315x’, ’File’, ’Fire-i’, ’FlashBus’,<br />

’GINGA’, ’IDS’, ’Inspecta2’, ’MatrixVision’, ’Meteor1’, ’Opteon’, ’PCEye’, ’PicPort’, ’PX’, ’PXC’, ’PXD’,<br />

’Ramses1’, ’TWAIN’, ’VideoPort’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.6. FRAMEGRABBER 349<br />

º HorizontalResolution (input control) .................................extent.x (Htuple .) long<br />

Desired horizontal resolution of frame grabber (1: full resolution, 2: half resolution, 4: quarter resolution).<br />

Default Value : 1<br />

Value Suggestions : HorizontalResolution ¾1, 2, 4, 768, 720, 640, 384, 320, 192, 160<br />

º VerticalResolution (input control) ....................................extent.y (Htuple .) long<br />

Desired vertical resolution of frame grabber (1: full resolution, 2: half resolution, 4: quarter resolution).<br />

Default Value : 1<br />

Value Suggestions : VerticalResolution ¾1, 2, 4, 576, 480, 288, 240, 144, 120<br />

º ImageWidth (input control) ......................................rectangle.extent.x (Htuple .) long<br />

Width of desired image part (0: HorizontalResolution -2*StartColumn).<br />

Default Value : 0<br />

Value Suggestions : ImageWidth ¾-1, 0<br />

º ImageHeight (input control) ....................................rectangle.extent.y (Htuple .) long<br />

Height of desired image part (0: VerticalResolution -2*StartRow).<br />

Default Value : 0<br />

Value Suggestions : ImageHeight ¾-1, 0<br />

º StartRow (input control) .........................................rectangle.origin.y (Htuple .) long<br />

Line number of upper left corner of desired image part, for ImageHeight = 0: Height of a border.<br />

Default Value : 0<br />

Value Suggestions : StartRow ¾-1, 0<br />

º StartColumn (input control) .....................................rectangle.origin.x (Htuple .) long<br />

Column number of upper left corner of desired image part, for ImageWidth = 0: Width of a border.<br />

Default Value : 0<br />

Value Suggestions : StartColumn ¾-1, 0<br />

º Field (input control) .................................................string (Htuple .) const char *<br />

Desired half image or for full image.<br />

Default Value : ’default’<br />

Value Suggestions : Field ¾’first’, ’second’, ’next’, ’interlaced’, ’progressive’, ’default’<br />

º BitsPerChannel (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Number of transferred bits per pixel and image channel (-1: frame grabber specific default value).<br />

Default Value : -1<br />

Value Suggestions : BitsPerChannel ¾5, 8, 10, 12, 16, -1<br />

º ColorSpace (input control) ...................................string(-array) (Htuple .) const char *<br />

Specify to grab single-channel (’gray’) or three-channel (’rgb’, ’yuv’, ...) images (’default’: frame grabber<br />

specific default value, mostly ’rgb’).<br />

Default Value : ’default’<br />

Value Suggestions : ColorSpace ¾’gray’, ’rgb’, ’yuv’, ’default’<br />

º Gain (input control) .........................................................real (Htuple .) double<br />

Amplification factor for video amplifier (-1.0: frame grabber specific default value).<br />

Default Value : -1.0<br />

Value Suggestions : Gain ¾0.25, 0.5, 0.75, 1.0, -1.0<br />

º ExternalTrigger (input control) ...................................string (Htuple .) const char *<br />

External triggering.<br />

Default Value : ’default’<br />

Value List : ExternalTrigger ¾’true’, ’false’, ’default’<br />

º CameraType (input control) ...................................string(-array) (Htuple .) const char *<br />

Type of used camera (frame grabber specific) (’default’: frame grabber specific default value).<br />

Default Value : ’default’<br />

Value Suggestions : CameraType ¾’ntsc’, ’pal’, ’auto’, ’default’<br />

º Device (input control) ........................................string(-array) (Htuple .) const char *<br />

Device the frame grabber is linked to (’default’: frame grabber specific default value).<br />

Default Value : ’default’<br />

Value Suggestions : Device ¾’-1’, ’0’, ’1’, ’2’, ’3’, ’default’<br />

º Port (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Port of the frame grabber the video signal is linked to (-1: frame grabber specific default value).<br />

Default Value : -1<br />

Value Suggestions : Port ¾0, 1, 2, 3, -1<br />

<strong>HALCON</strong> 6.0


350 CHAPTER 5. IMAGE<br />

º LineIn (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Camera input line of multiplexer.<br />

Default Value : -1<br />

Value Suggestions : LineIn ¾1, 2, 3, 4, -1<br />

º FGHandle (output control) ..........................................framegrabber (Htuple .) long *<br />

Handle of the opened frame grabber.<br />

Example<br />

/* Select a suitable frame grabber FgName */<br />

info_framegrabber(FgName,"ports",&Information,&Val) ;<br />

/* Choose the port P and the input line L your camera is connected to */<br />

open_framegrabber(FgName,1,1,0,0,0,0,"default",-1,"default",-1.0,<br />

"default","default","default",P,L,&FgHandle) ;<br />

grab_image(&Img,FgHandle) ;<br />

close_framegrabber(FgHandle) ;<br />

Result<br />

If the parameter values are correct and the desired frame grabber is available at call time,<br />

(T )open framegrabber returns the value H MSG TRUE. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

(T )open framegrabber is local and processed completely exclusively without parallelization.<br />

(T )info framegrabber<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

grab image, grab region, grab image start, grab image async, grab region async,<br />

(T )set framegrabber param<br />

See Also<br />

(T )info framegrabber, close framegrabber, grab image<br />

Image / region / XLD management<br />

Module<br />

T set framegrabber lut ( Htuple FGHandle, Htuple ImageRed,<br />

Htuple ImageGreen, Htuple ImageBlue )<br />

Set frame grabber lut.<br />

The operator T set framegrabber lut sets the lut of the frame grabbers spezified by FGHandle. This<br />

operation is not supported for all kinds of frame grabbers.<br />

Parameter<br />

º FGHandle (input control) ..............................................framegrabber Htuple . long<br />

Handle of the desired frame grabber.<br />

º ImageRed (input control) ...............................................integer-array Htuple . long<br />

Red level of the lut entries.<br />

º ImageGreen (input control) ............................................integer-array Htuple . long<br />

Green level of the lut entries.<br />

º ImageBlue (input control) .............................................integer-array Htuple . long<br />

Blue level of the lut entries.<br />

Result<br />

The operator T set framegrabber lut returns the value H MSG TRUE if the transferred lut is correct and<br />

the frame grabber is open.<br />

Parallelization Information<br />

T set framegrabber lut is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

(T )open framegrabber, T get framegrabber lut<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.7. MANIPULATION 351<br />

Possible Successor Functions<br />

grab image, grab region, grab image start, grab image async, grab region async<br />

See Also<br />

T get framegrabber lut, (T )open framegrabber<br />

Image / region / XLD management<br />

Module<br />

set framegrabber param ( long FGHandle, const char *Param,<br />

const char *Value )<br />

T set framegrabber param ( Htuple FGHandle, Htuple Param,<br />

Htuple Value )<br />

Set specific parameters for a frame grabber.<br />

The operator (T )set framegrabber param sets specific parameters for the frame grabber specified by<br />

FGHandle.<br />

Parameter<br />

º FGHandle (input control) ............................................framegrabber (Htuple .) long<br />

Handle of the frame grabber to be used.<br />

º Param (input control) ..........................................string(-array) (Htuple .) const char *<br />

Parameter to be set.<br />

º Value (input control) ............................string(-array) (Htuple .) const char * / double / long<br />

Parameter value.<br />

Result<br />

If the frame grabber is open and the specified parameter / parameter value is supported by the frame grabber, the<br />

operator (T )set framegrabber param returns the value H MSG TRUE. Otherwise an exception handling<br />

is raised.<br />

Parallelization Information<br />

(T )set framegrabber param is reentrant and processed without parallelization.<br />

(T )open framegrabber<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

grab image, grab region, grab image start, grab image async, grab region async,<br />

close framegrabber<br />

See Also<br />

(T )open framegrabber, (T )info framegrabber, (T )get framegrabber param<br />

Image / region / XLD management<br />

Module<br />

5.7 Manipulation<br />

get grayval ( Hobject Image, long Row, long Column, double *Grayval )<br />

T get grayval ( Hobject Image, Htuple Row, Htuple Column,<br />

Htuple *Grayval )<br />

Access the gray values of an image object.<br />

The operator Grayval is a tuple of floating point numbers, integer respectively, which returns the gray values of<br />

several pixels of Image. The line coordinates of the pixels are in the tuple Row,thecolumnsinColumn.<br />

Attention<br />

The type of the values of Grayval depends on the type of the gray values.<br />

<strong>HALCON</strong> 6.0


352 CHAPTER 5. IMAGE<br />

Gray values which do not belong to the image can also be accessedṪhe state of these gray values is not ascertained.<br />

The operator (T )get grayval involves a lot of work. It is not suitable for programming image processing<br />

operations such as filters. In this case it is more useful to use the procedure get image pointer1 or to directly<br />

use the C interface for integrating own procedures.<br />

Parameter<br />

º Image (input object) ..............................................................image Hobject<br />

Image whose gray value is to be accessed.<br />

º Row (input control) ..................................................point.y(-array) (Htuple .) long<br />

Line numbers of pixels to be viewed.<br />

Default Value : 0<br />

Value Suggestions : Row ¾0, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Row 32768 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : ´0 Rowµ ´Row height´Imageµµ<br />

º Column (input control) ..............................................point.x(-array) (Htuple .) long<br />

Column numbers of pixels to be viewed.<br />

Default Value : 0<br />

Value Suggestions : Column ¾0, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Column 32768 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Parameter Number : Column Row<br />

Restriction : ´0 Columnµ ´Column width´Imageµµ<br />

º Grayval (output control) ................................grayval(-array) (Htuple .) double * / long *<br />

Gray values of indicated pixels.<br />

Parameter Number : Grayval Row<br />

Result<br />

If the state of the parameters is correct the operator (T )get grayval returns the value H MSG TRUE.<br />

The behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )get grayval is reentrant and processed without parallelization.<br />

read image<br />

get image pointer1<br />

(T )set grayval<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

get image pointer1 ( Hobject Image, long *Pointer, char *Type,<br />

long *Width, long *Height )<br />

Access the pointer of a channel.<br />

The operator get image pointer1 returns a C pointer to the first channel of the image Image. Additionally<br />

the image type (Type = ’byte’, ’integer’, ’float’ etc.) and the image size (width and height) are returned.<br />

Consequently a direct access to the image data in the <strong>HALCON</strong> databank from the <strong>HALCON</strong> host language<br />

via the pointer is possible. An image is stored in <strong>HALCON</strong> as a vector of image lines. The operator<br />

get image pointer1 is only of interest for <strong>HALCON</strong>/C.<br />

Attention<br />

The operator get image pointer1 should only be used for entry into newly created images, since otherwise<br />

the gray values of other images might be overwritten (see relational structure).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.7. MANIPULATION 353<br />

Parameter<br />

º Image (input object) ..............................................................image Hobject<br />

Input image.<br />

º Pointer (output control) ..........................................................pointer long *<br />

Pointer to the image data in the <strong>HALCON</strong> databank.<br />

º Type (output control) ................................................................string char *<br />

Type of image.<br />

Value List : Type ¾’int1’, ’int2’, ’int4’, ’byte’, ’real’, ’direction’, ’cyclic’, ’complex’, ’dvf’, ’lut’<br />

º Width (output control) ............................................................extent.x long *<br />

Width of image.<br />

º Height (output control) ...........................................................extent.y long *<br />

Height of image.<br />

Hobject Bild;<br />

char typ[128];<br />

long width,height;<br />

unsigned char *ptr;<br />

Example<br />

read_image(&Bild,"fabrik");<br />

get_image_pointer1(Bild,(long*)&ptr,typ,&width,&height);<br />

Result<br />

The operator get image pointer1 returns the value H MSG TRUE if exactly one image was passed.<br />

The behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

get image pointer1 is reentrant and processed without parallelization.<br />

read image<br />

Possible Predecessor Functions<br />

Alternatives<br />

(T )set grayval, (T )get grayval, get image pointer3<br />

paint region, paint gray<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

get image pointer1 rect ( Hobject Image, long *PixelPointer,<br />

long *Width, long *Height, long *VerticalPitch )<br />

Access to the image data pointer and the image data inside the smallest rectangle of the domain of the input image.<br />

The operator get image pointer1 rect returns the pointer PixelPointer which points to the beginning<br />

of the image data inside the smallest rectangle of the domain of Image. The difference between the width of<br />

Image and the width of the smallest rectangle is returned by VerticalPitch. Width and Height correspond<br />

to the size of the smallest rectangle of the input region. get image pointer1 rect is approximately<br />

symmetrical to gen image1 rect.<br />

Attention<br />

The operator get image pointer1 rect should only be used for entry into newly created images, since<br />

otherwise the gray values of other images might be overwritten (see relational structure).<br />

<strong>HALCON</strong> 6.0


354 CHAPTER 5. IMAGE<br />

Parameter<br />

º Image (input object) ..............................................................image Hobject<br />

Input image (Himage).<br />

º PixelPointer (output control) ...................................................pointer long *<br />

Pointer to the image data.<br />

º Width (output control) ............................................................extent.x long *<br />

Width of the output image.<br />

º Height (output control) ...........................................................extent.y long *<br />

Height of the output image.<br />

º VerticalPitch (output control) ..................................................integer long *<br />

Difference between the width of the smallest rectangle of the domain of the input image and the width of the<br />

input image.<br />

Example<br />

Hobject image,reg,imagereduced;<br />

char typ[128];<br />

long width,height,vert_pitch,winID;<br />

unsigned char *ptr;<br />

open_window(0,0,512,512,"black",winID);<br />

read_image(&image,"monkey");<br />

draw_region(&reg,winID);<br />

reduce_domain(image,reg,&imagereduced);<br />

get_image_pointer1_rect(imagereduced,(long*)&ptr,&width,&height,&vert_pitch);<br />

Result<br />

The operator get image pointer1 rect returns the value H MSG TRUE if exactly one image (byte) was<br />

passed. The behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

get image pointer1 rect is reentrant and processed without parallelization.<br />

read image<br />

Possible Predecessor Functions<br />

Alternatives<br />

(T )set grayval, (T )get grayval, get image pointer3, get image pointer1<br />

See Also<br />

paint region, paint gray, gen image1 rect<br />

Image / region / XLD management<br />

Module<br />

get image pointer3 ( Hobject ImageRGB, long *PointerRed,<br />

long *PointerGreen, long *PointerBlue, char *Type, long *Width,<br />

long *Height )<br />

Access the pointers of a colored image.<br />

The operator get image pointer3 returns a C pointer to the three channels of a colored image (ImageRGB).<br />

Additionally the image type (Type = ’byte’, ’int2’,’float’ etc.) and the image size (Width and Height) are<br />

returned. Consequently a direct access to the image data in the <strong>HALCON</strong> databank from the <strong>HALCON</strong> host<br />

language via the pointer is possible. An image is stored in <strong>HALCON</strong> as a vector of image lines. The three<br />

channels must have the same pixel type and the same size. The operator get image pointer3 is only of<br />

interest for <strong>HALCON</strong>/C.<br />

Attention<br />

Only one image can be passed. The operator get image pointer3 should only be used for entry into newly<br />

created images, since otherwise the gray values of other images might be overwritten (see relational structure).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.7. MANIPULATION 355<br />

Parameter<br />

º ImageRGB (input object) ..........................................................image Hobject<br />

Input image.<br />

º PointerRed (output control) ......................................................pointer long *<br />

Pointer to the pixels of the first channel.<br />

º PointerGreen (output control) ...................................................pointer long *<br />

Pointer to the pixels of the second channel.<br />

º PointerBlue (output control) .....................................................pointer long *<br />

Pointer to the pixels of the third channel.<br />

º Type (output control) ................................................................string char *<br />

Type of image.<br />

Value List : Type ¾’int1’, ’int2’, ’int4’, ’byte’, ’real’, ’direction’, ’cyclic’, ’complex’, ’dvf’, ’lut’<br />

º Width (output control) ............................................................extent.x long *<br />

Width of image.<br />

º Height (output control) ...........................................................extent.y long *<br />

Height of image.<br />

Result<br />

The operator get image pointer3 returns the value H MSG TRUE if exactly one image is passed.<br />

The behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

get image pointer3 is reentrant and processed without parallelization.<br />

read image<br />

Possible Predecessor Functions<br />

Alternatives<br />

(T )set grayval, (T )get grayval, get image pointer1<br />

paint region, paint gray<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

paint gray ( Hobject ImageSource, Hobject ImageDestination,<br />

Hobject *MixedImage )<br />

Copy the gray values of an image into another image.<br />

paint gray copies the gray values of the images given in ImageSource into the image in<br />

ImageDestination. Only the gray values of the domain of ImageSource are copied (see<br />

reduce domain).<br />

Parameter<br />

º ImageSource (input object) ......................................................image Hobject<br />

Input image containing the desired gray values.<br />

º ImageDestination (input object) ...............................................image Hobject<br />

Input image to be painted over.<br />

º MixedImage (output object) .....................................................image Hobject *<br />

Result image.<br />

Example<br />

/* Copy of a circle of the image ’affe’ into a new image (New): */<br />

read_image(&Image,"affe");<br />

gen_circle(&Circle,200.0,200.0,150.0);<br />

reduce_domain(Image,Circle,&Mask);<br />

<strong>HALCON</strong> 6.0


356 CHAPTER 5. IMAGE<br />

/* New image with black (0) background */<br />

gen_image_proto(Image,&New1,0.0);<br />

/* Copy of a segment of the image ’affe’ into New1 */<br />

paint_gray(Mask,New1,&New);<br />

Result<br />

paint gray returns H MSG TRUE if all parameters are correct. If necessary, an exception is raised.<br />

Parallelization Information<br />

paint gray is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

read image, gen image const, gen image proto<br />

Alternatives<br />

get image pointer1, (T )set grayval, copy image<br />

paint region<br />

Basic operators<br />

See Also<br />

Module<br />

paint region ( Hobject Region, Hobject Image, Hobject *ImageResult,<br />

double Grayval, const char *Type )<br />

Paint a region in an image with a constant gray value.<br />

paint region paints the regions given in Region with a constant gray value into the image given in Image.<br />

The parameter Type determines whether the region should be painted filled (’fill’) or whether only its boundary<br />

should be painted (’margin’). The resulting image is returned in ImageResult.<br />

Attention<br />

paint region should only be used to paint into newly created images (gen image const), because otherwise<br />

the gray values of other existing images may be overwritten.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be painted into the input image.<br />

º Image (input object) ..............................................................image Hobject<br />

Image in which the regions are to be painted.<br />

º ImageResult (output object) ...................................................image Hobject *<br />

Image containing the result.<br />

º Grayval (input control) ....................................................number double / long<br />

Desired gray value of the region.<br />

Default Value : 255.0<br />

Value Suggestions : Grayval ¾0.0, 1.0, 2.0, 5.0, 10.0, 16.0, 32.0, 64.0, 128.0, 253.0, 254.0, 255.0<br />

Typical Range of Values : 0.0 Grayval 255.0<br />

º Type (input control) ............................................................string const char *<br />

Paint regions filled or as boundaries.<br />

Default Value : ’fill’<br />

Value List : Type ¾’fill’, ’margin’<br />

Example<br />

/* Copy of a rectangle in a new image (New) */<br />

read_image(&Image,"affe");<br />

gen_rectangle1(&Rectangle,100.0,100.0,300.0,300.0);<br />

reduce_domain(Image,Rectangle,&Mask);<br />

/* generate a black image */<br />

gen_image_proto(Image,&New1,0.0);<br />

/* copy a white rectangle */<br />

paint_region(Mask,New1,&New,255.0,"fill");<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.7. MANIPULATION 357<br />

Result<br />

paint region returns H MSG TRUE if all parameters are correct. If the input is empty the behavior can be set<br />

via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

paint region is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

read image, gen image const, gen image proto, reduce domain<br />

(T )set grayval, paint gray<br />

Alternatives<br />

See Also<br />

reduce domain, set draw, gen image const<br />

Basic operators<br />

Module<br />

set grayval ( Hobject Image, long Row, long Column, double Grayval )<br />

T set grayval ( Hobject Image, Htuple Row, Htuple Column,<br />

Htuple Grayval )<br />

Set single gray values in an image.<br />

(T )set grayval sets the gray values of the input image Image at the positions (Row,Column)tothevalues<br />

specified by Grayval. The number of values in Grayval must match the number of points passed to the<br />

operator.<br />

Parameter<br />

º Image (input object) ..............................................................image Hobject<br />

Image to be modified.<br />

º Row (input control) ..................................................point.y(-array) (Htuple .) long<br />

Row coordinates of the pixels to be modified.<br />

Default Value : 0<br />

Value Suggestions : Row ¾0, 10, 50, 127, 255, 511<br />

Typical Range of Values : 0 Row<br />

Restriction : ´0 Rowµ ´Row height´Imageµµ<br />

º Column (input control) ..............................................point.x(-array) (Htuple .) long<br />

Column coordinates of the pixels to be modified.<br />

Default Value : 0<br />

Value Suggestions : Column ¾0, 10, 50, 127, 255, 511<br />

Typical Range of Values : 0 Column<br />

Restriction : ´0 Columnµ ´Column width´Imageµµ<br />

º Grayval (input control) ....................................grayval(-array) (Htuple .) double / long<br />

Gray values to be used.<br />

Default Value : 255.0<br />

Value Suggestions : Grayval ¾0.0, 1.0, 10.0, 128.0, 255.0<br />

Result<br />

(T )set grayval returns H MSG TRUE if all parameters are correct. If the input is empty the behavior can<br />

be set via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

(T )set grayval is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

read image, get image pointer1, gen image proto, gen image1<br />

Alternatives<br />

get image pointer1, paint gray, paint region<br />

See Also<br />

(T )get grayval, gen image const, gen image1, gen image proto<br />

<strong>HALCON</strong> 6.0


358 CHAPTER 5. IMAGE<br />

Basic operators<br />

Module<br />

5.8 Type-Conversion<br />

complex to real ( Hobject ImageComplex, Hobject *ImageReal,<br />

Hobject *ImageImaginary )<br />

Convert a complex image into two real images.<br />

complex to real converts a complex image ImageComplex into two real images ImageReal and<br />

ImageImaginary, which contain the real and imaginary part of the complex image.<br />

Parameter<br />

º ImageComplex (input object) ....................................image(-array) Hobject : complex<br />

Complex image.<br />

º ImageReal (output object) .........................................image(-array) Hobject * : real<br />

Real part.<br />

º ImageImaginary (output object) ...................................image(-array) Hobject * : real<br />

Imaginary part.<br />

Parallelization Information<br />

complex to real is reentrant and automatically parallelized (on tuple level).<br />

real to complex<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

convert image type ( Hobject Image, Hobject *ImageConverted,<br />

const char *NewType )<br />

Convert the type of an image.<br />

convert image type converts images of an arbitrary type into an arbitrary new image type. If the conversion<br />

is done from a larger to a smaller gray value range (e.g., from ’int4’ to ’byte’), too large or too small values are<br />

simply “clipped.” It is therefore advisable to adapt the range of gray values by calling scale image before<br />

calling this operator.<br />

Attention<br />

If the source and destination image type are identical, no new image matrix is allocated.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject :any<br />

Image whose image type is to be changed.<br />

º ImageConverted (output object) . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject * :any<br />

Converted image.<br />

º NewType (input control) .......................................................string const char *<br />

Desired image type (i.e., type of the gray values).<br />

Default Value : ’byte’<br />

Value List : NewType ¾’int1’, ’int2’, ’int4’, ’byte’, ’real’, ’direction’, ’cyclic’, ’complex’, ’dvf’, ’lut’<br />

Result<br />

convert image type returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour<br />

can be set via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

convert image type is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


5.8. TYPE-CONVERSION 359<br />

scale image<br />

scale image, abs image<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

dvf to int1 ( Hobject VectorField, Hobject *Row, Hobject *Col )<br />

Convert a displacement vector field into two int1-images.<br />

dvf to int1 converts the displacement vector field VectorField into two int1-images Row and Col. The<br />

output images contain the displacements in Ü- andÝ-direction, respectively.<br />

Parameter<br />

º VectorField (input object) ..........................................image(-array) Hobject : dvf<br />

Displacement vector field.<br />

º Row (output object) .................................................image(-array) Hobject * :int1<br />

Displacement along y.<br />

º Col (output object) .................................................image(-array) Hobject * :int1<br />

Displacement along x.<br />

Parallelization Information<br />

dvf to int1 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

mean image, optical flow match, fill dvf<br />

optical flow match<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

int1 to dvf ( Hobject Row, Hobject Col, Hobject *VectorField )<br />

Convert two int1-images into a displacement vector field.<br />

int1 to dvf converts two int1-images Row and Col into a displacement vector field VectorField. The<br />

input images contain the displacements in Ü- andÝ-direction, respectively.<br />

Parameter<br />

º Row (input object) .....................................................image(-array) Hobject :int1<br />

Displacement along y.<br />

º Col (input object) .....................................................image(-array) Hobject :int1<br />

Displacement along x.<br />

º VectorField (output object) .......................................image(-array) Hobject * : dvf<br />

Displacement vector field.<br />

Parallelization Information<br />

int1 to dvf is reentrant and automatically parallelized (on tuple level).<br />

dvf to int1<br />

optical flow match, fill dvf<br />

Image / region / XLD management<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Module<br />

<strong>HALCON</strong> 6.0


360 CHAPTER 5. IMAGE<br />

real to complex ( Hobject ImageReal, Hobject ImageImaginary,<br />

Hobject *ImageComplex )<br />

Convert two real images into a complex image.<br />

real to complex converts two real images ImageReal and ImageImaginary, which contain the real and<br />

imaginary part of a complex image, into a complex image ImageComplex.<br />

Parameter<br />

º ImageReal (input object) .............................................image(-array) Hobject : real<br />

Real part.<br />

º ImageImaginary (input object) ......................................image(-array) Hobject : real<br />

Imaginary part.<br />

º ImageComplex (output object) .................................image(-array) Hobject * : complex<br />

Complex image.<br />

Parallelization Information<br />

real to complex is reentrant and automatically parallelized (on tuple level).<br />

complex to real<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Chapter 6<br />

Lines<br />

6.1 Access<br />

T approx chain ( Htuple Row, Htuple Column, Htuple MinWidthCoord,<br />

Htuple MaxWidthCoord, Htuple ThreshStart, Htuple ThreshEnd,<br />

Htuple ThreshStep, Htuple MinWidthSmooth, Htuple MaxWidthSmooth,<br />

Htuple MinWidthCurve, Htuple MaxWidthCurve, Htuple Weight1,<br />

Htuple Weight2, Htuple Weight3, Htuple *ArcCenterRow,<br />

Htuple *ArcCenterCol, Htuple *ArcAngle, Htuple *ArcBeginRow,<br />

Htuple *ArcBeginCol, Htuple *LineBeginRow, Htuple *LineBeginCol,<br />

Htuple *LineEndRow, Htuple *LineEndCol, Htuple *Order )<br />

Approximate a contour by arcs and lines.<br />

The coordinates of a curve are approximated by a row of lines and arcs. The procedure tries values from<br />

a user-definable range for certain parameters. The limits of these ranges are explicitly stated in the parameter<br />

list of the function (MinWidthCoord ... MaxWidthCoord, ThreshStart ... ThreshEnd, MinWidthSmooth ...<br />

MaxWidthSmooth, MinWidthCurve ... MaxWidthCurve). Additionally, the step width for the parameter area of<br />

the threshold value for pointed corners has to be indicated (ThreshStep). By narrowing the covered areas the<br />

runtime of the calculation can be shortened, but the result may deteriorate.<br />

The parameters Weight1, Weight2 and Weight3 indicate whether the desired weighting is placed more on precision<br />

of the approximation, obtaining as much large segments as possible or as few small segments as possible. Thus,<br />

for (Weight1,Weight2,Weight3) (1,0,0) creates a very precise approximation and (0,1,1) an approximation with as<br />

few large segments as possible.<br />

The result of the procedure is returned separately as arcs and lines. If one is interested in the sequence of the<br />

segments the individual resulting elements can be read successively from the resulting tuples; the sequence can be<br />

taken from the return parameter order (0: next element is next line segment, 1: next element is next arc segment).<br />

Attention<br />

Contours which can possibly consist of only one segment should also be examined with a threshold maximum<br />

(ThreshEnd) 1.0, because otherwise at least one “corner point” is determined in any case.<br />

Parameter<br />

º Row (input control) ...........................................................point.y Htuple . long<br />

Row of the contour.<br />

Default Value : 32<br />

º Column (input control) .......................................................point.x Htuple . long<br />

Column of the contour.<br />

Default Value : 32<br />

361


362 CHAPTER 6. LINES<br />

º MinWidthCoord (input control) ..............................................real Htuple . double<br />

Minimum width of Gauss operator for coordinate smoothing ( 0.4).<br />

Default Value : 0.5<br />

Value Suggestions : MinWidthCoord ¾0.5, 0.7, 1.0, 1.2, 1.5, 1.7<br />

Typical Range of Values : 0.4 MinWidthCoord 3.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

º MaxWidthCoord (input control) ..............................................real Htuple . double<br />

Maximum width of Gauss operator for coordinate smoothing ( 0.4).<br />

Default Value : 2.4<br />

Value Suggestions : MaxWidthCoord ¾0.5, 0.7, 1.0, 1.2, 1.5, 1.7<br />

Typical Range of Values : 0.4 MaxWidthCoord 3.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

º ThreshStart (input control) .................................................real Htuple . double<br />

Minimum threshold value of the curvature for accepting a corner (relative to the largest curvature present).<br />

Default Value : 0.3<br />

Value Suggestions : ThreshStart ¾0.3, 0.4, 0.5, 0.6, 0.7, 0.8<br />

Typical Range of Values : 0.1 ThreshStart 0.9 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

º ThreshEnd (input control) ...................................................real Htuple . double<br />

Maximum threshold value of the curvature for accepting a corner (relative to the largest curvature present).<br />

Default Value : 0.9<br />

Value Suggestions : ThreshEnd ¾0.3, 0.4, 0.5, 0.6, 0.7, 0.8<br />

Typical Range of Values : 0.1 ThreshEnd 0.9 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

º ThreshStep (input control) ..................................................real Htuple . double<br />

Step width for threshold increase.<br />

Default Value : 0.2<br />

Value Suggestions : ThreshStep ¾0.3, 0.4, 0.5<br />

Typical Range of Values : 0.1 ThreshStep 0.9 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

º MinWidthSmooth (input control) ............................................real Htuple . double<br />

Minimum width of Gauss operator for smoothing the curvature function ( 0.4).<br />

Default Value : 0.5<br />

Value Suggestions : MinWidthSmooth ¾0.5, 0.7, 1.0, 1.2, 1.5, 1.7<br />

Typical Range of Values : 0.4 MinWidthSmooth 3.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

º MaxWidthSmooth (input control) ............................................real Htuple . double<br />

Maximum width of Gauss operator for smoothing the curvature function.<br />

Default Value : 2.4<br />

Value Suggestions : MaxWidthSmooth ¾0.5, 0.7, 1.0, 1.2, 1.5, 1.7<br />

Typical Range of Values : 0.4 MaxWidthSmooth 3.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

º MinWidthCurve (input control) .............................................integer Htuple . long<br />

Minimum width of curve area for curvature determination ( 0.4).<br />

Default Value : 2<br />

Value Suggestions : MinWidthCurve ¾2, 5, 7<br />

Typical Range of Values : 1 MinWidthCurve 12 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


6.1. ACCESS 363<br />

º MaxWidthCurve (input control) .............................................integer Htuple . long<br />

Maximum width of curve area for curvature determination.<br />

Default Value : 12<br />

Value Suggestions : MaxWidthCurve ¾2, 5, 7<br />

Typical Range of Values : 1 MaxWidthCurve 20 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

º Weight1 (input control) ......................................................real Htuple . double<br />

Weighting factor for approximation precision.<br />

Default Value : 1.0<br />

Value Suggestions : Weight1 ¾0.0, 0.5, 1.0<br />

Typical Range of Values : 0.0 Weight1 1.0 (lin)<br />

Minimal Value Step : 0.1<br />

Recommended Value Step : 0.5<br />

º Weight2 (input control) ......................................................real Htuple . double<br />

Weighting factor for large segments.<br />

Default Value : 1.0<br />

Value Suggestions : Weight2 ¾0.0, 0.5, 1.0<br />

Typical Range of Values : 0.0 Weight2 1.0 (lin)<br />

Minimal Value Step : 0.1<br />

Recommended Value Step : 0.5<br />

º Weight3 (input control) ......................................................real Htuple . double<br />

Weighting factor for small segments.<br />

Default Value : 1.0<br />

Value Suggestions : Weight3 ¾0.0, 0.5, 1.0<br />

Typical Range of Values : 0.0 Weight3 1.0 (lin)<br />

Minimal Value Step : 0.1<br />

Recommended Value Step : 0.5<br />

º ArcCenterRow (output control) ..................................arc.center.y-array Htuple . long *<br />

Rowofthecenterofanarc.<br />

º ArcCenterCol (output control) ..................................arc.center.x-array Htuple . long *<br />

Column of the center of an arc.<br />

º ArcAngle (output control) ....................................arc.angle.rad-array Htuple . double *<br />

Angle of an arc.<br />

º ArcBeginRow (output control) ....................................arc.begin.y-array Htuple . long *<br />

Row of the starting point of an arc.<br />

º ArcBeginCol (output control) ....................................arc.begin.x-array Htuple . long *<br />

Column of the starting point of an arc.<br />

º LineBeginRow (output control) ..................................line.begin.y-array Htuple . long *<br />

Row of the starting point of a line segment.<br />

º LineBeginCol (output control) ..................................line.begin.x-array Htuple . long *<br />

Column of the starting point of a line segment.<br />

º LineEndRow (output control) ......................................line.end.y-array Htuple . long *<br />

Row of the ending point of a line segment.<br />

º LineEndCol (output control) ......................................line.end.x-array Htuple . long *<br />

Column of the ending point of a line segment.<br />

º Order (output control) ................................................integer-array Htuple . long *<br />

Sequence of line (value 0) and arc segments (value 1).<br />

Example<br />

/* read edge image */<br />

read_image(&Image,"fig1_kan");<br />

/* construct edge region */<br />

hysteresis_threshold(Image,&RK1,64,255,40,1);<br />

connection(RK1,&Rand);<br />

/* fetch chain code */<br />

T_get_region_contour(Rand,&Rows,&Columns);<br />

<strong>HALCON</strong> 6.0


364 CHAPTER 6. LINES<br />

firstline = get_i(Tline,0);<br />

firstcol = get_i(Tcol,0);<br />

/* approximation with lines and circular arcs */<br />

set_d(t1,0.4,0);<br />

set_d(t2,2.4,0);<br />

set_d(t3,0.3,0);<br />

set_d(t4,0.9,0);<br />

set_d(t5,0.2,0);<br />

set_d(t6,0.4,0);<br />

set_d(t7,2.4,0);<br />

set_i(t8,2,0);<br />

set_i(t9,12,0);<br />

set_d(t10,1.0,0);<br />

set_d(t11,1.0,0);<br />

set_d(t12,1.0,0);<br />

T_approx_chain(Rows,Columns,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,<br />

&Bzl,&Bzc,&Br,&Bwl,&Bwc,&Ll0,&Lc0,&Ll1,&Lc1,&order);<br />

nob = length_tuple(Bzl);<br />

nol = length_tuple(Ll0);<br />

/* draw lines and arcs */<br />

set_i(WindowHandleTuple,WindowHandle,0) ;<br />

set_line_width(WindowHandle,4);<br />

if (nob>0) T_disp_arc(Bzl,Bzc,Br,Bwl,Bwc);<br />

set_line_width(WindowHandle,1);<br />

if (nol>0) T_disp_line(WindowHandleTuple,Ll0,Lc0,Ll1,Lc1);<br />

Result<br />

The operator T approx chain returns the value H MSG TRUE if the parameters are correct. Otherwise an<br />

exception is raised.<br />

Parallelization Information<br />

T approx chain is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

sobel amp, edges image, get region contour, threshold, hysteresis threshold<br />

Possible Successor Functions<br />

set line width, disp arc, disp line<br />

Alternatives<br />

get region polygon, T approx chain simple<br />

See Also<br />

get region chain, smallest circle, disp circle, disp line<br />

Region processing<br />

Module<br />

T approx chain simple ( Htuple Row, Htuple Column,<br />

Htuple *ArcCenterRow, Htuple *ArcCenterCol, Htuple *ArcAngle,<br />

Htuple *ArcBeginRow, Htuple *ArcBeginCol, Htuple *LineBeginRow,<br />

Htuple *LineBeginCol, Htuple *LineEndRow, Htuple *LineEndCol,<br />

Htuple *Order )<br />

Approximate a contour by arcs and lines.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


6.1. ACCESS 365<br />

The contour of a curve is approximated by a sequence of lines and arcs.<br />

The result of the procedure is returned separately as arcs and lines. If one is interested in the sequence of the<br />

segments the individual resulting elements can be read successively from the resulting tuplesṪhe sequence can be<br />

taken from the return parameter order (0: next element is next line segment, 1: next element is next arc segment).<br />

The operator T approx chain simple behaves similarly as T approx chain except that in the case of<br />

T approx chain simple the missing parameters are internally allocated as follows: MinWidthCoord =<br />

1.0, MaxWidthCoord = 3.0, ThreshStart = 0.5, ThreshEnd = 0.9, ThreshStep = 0.3, MinWidthSmooth = 1.0,<br />

MaxWidthSmooth = 3.0, MinWidthCurve = 2, MaxWidthCurve = 9, Weight1 = 1.0, Weight2 = 1.0, Weight3 = 1.0.<br />

Parameter<br />

º Row (input control) ...........................................................point.y Htuple . long<br />

Row of the contour.<br />

Default Value : 32<br />

º Column (input control) .......................................................point.x Htuple . long<br />

Column of the contour.<br />

Default Value : 32<br />

º ArcCenterRow (output control) ..................................arc.center.y-array Htuple . long *<br />

Rowofthecenterofanarc.<br />

º ArcCenterCol (output control) ..................................arc.center.x-array Htuple . long *<br />

Column of the center of an arc.<br />

º ArcAngle (output control) ....................................arc.angle.rad-array Htuple . double *<br />

Angle of an arc.<br />

º ArcBeginRow (output control) ....................................arc.begin.y-array Htuple . long *<br />

Row of the starting point of an arc.<br />

º ArcBeginCol (output control) ....................................arc.begin.x-array Htuple . long *<br />

Column of the starting point of an arc.<br />

º LineBeginRow (output control) ..................................line.begin.y-array Htuple . long *<br />

Row of the starting point of a line segment.<br />

º LineBeginCol (output control) ..................................line.begin.x-array Htuple . long *<br />

Column of the starting point of a line segment.<br />

º LineEndRow (output control) ......................................line.end.y-array Htuple . long *<br />

Row of the ending point of a line segment.<br />

º LineEndCol (output control) ......................................line.end.x-array Htuple . long *<br />

Column of the ending point of a line segment.<br />

º Order (output control) ................................................integer-array Htuple . long *<br />

Sequence of line (value 0) and arc segments (value 1).<br />

Example<br />

/* read edge image */<br />

read_image(&Image,"fig1_kan");<br />

/* construct edge region */<br />

hysteresis_threshold(Image,&RK1,64,255,40,1);<br />

connection(RK1,&Rand);<br />

/* fetch chain code */<br />

T_get_region_contour(Rand,&Rows,&Columns);<br />

firstline = get_i(Tline,0);<br />

firstcol = get_i(Tcol,0);<br />

/* approximation with lines and circular arcs */<br />

T_approx_chain_simple(Rows,Columns,<br />

&Bzl,&Bzc,&Br,&Bwl,&Bwc,&Ll0,&Lc0,&Ll1,&Lc1,&order);<br />

nob = length_tuple(Bzl);<br />

nol = length_tuple(Ll0);<br />

/* draw lines and arcs */<br />

set_i(WindowHandleTuple,WindowHandle,0) ;<br />

set_line_width(WindowHandle,4);<br />

if (nob>0) T_disp_arc(Bzl,Bzc,Br,Bwl,Bwc);<br />

set_line_width(WindowHandle,1);<br />

if (nol>0) T_disp_line(WindowHandleTuple,Ll0,Lc0,Ll1,Lc1);<br />

<strong>HALCON</strong> 6.0


366 CHAPTER 6. LINES<br />

Result<br />

The operator T approx chain simple returns the value H MSG TRUE if the parameters are correct. Otherwise<br />

an exception is raised.<br />

Parallelization Information<br />

T approx chain simple is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

sobel amp, edges image, get region contour, threshold, hysteresis threshold<br />

Possible Successor Functions<br />

set line width, disp arc, disp line<br />

get region polygon, T approx chain<br />

Alternatives<br />

See Also<br />

get region chain, smallest circle, disp circle, disp line<br />

Region processing<br />

Module<br />

6.2 Features<br />

line orientation ( double RowBegin, double ColBegin, double RowEnd,<br />

double ColEnd, double *Phi )<br />

T line orientation ( Htuple RowBegin, Htuple ColBegin, Htuple RowEnd,<br />

Htuple ColEnd, Htuple *Phi )<br />

Calculate the orientation of lines.<br />

The operator (T )line orientation returns the orientation ( ¾ È ¾)ofthegivenlines.Ifmore<br />

than one line is to be treated the line and column indices can be passed as tuples. In this case Phi is, of course,<br />

also a tuple and contains the corresponding orientations.<br />

The procedure is typically applied to model lines in order to select parallel image lines, which were found, e.g., by<br />

detect edge segments, via the operator T select lines.<br />

Parameter<br />

º RowBegin (input control) ...............................line.begin.y(-array) (Htuple .) double / long<br />

Row coordinates of the starting points of the input lines.<br />

º ColBegin (input control) ...............................line.begin.x(-array) (Htuple .) double / long<br />

Column coordinates of the starting points of the input lines.<br />

º RowEnd (input control) ...................................line.end.y(-array) (Htuple .) double / long<br />

Row coordinates of the ending points of the input lines.<br />

º ColEnd (input control) ...................................line.end.x(-array) (Htuple .) double / long<br />

Column coordinates of the ending points of the input lines.<br />

º Phi (output control) ...........................................angle.rad(-array) (Htuple .) double *<br />

Orientation of the input lines.<br />

Result<br />

(T )line orientation always returns the value H MSG TRUE.<br />

Parallelization Information<br />

(T )line orientation is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

sobel amp, edges image, threshold, hysteresis threshold, split skeleton region,<br />

split skeleton lines<br />

Possible Successor Functions<br />

set line width, disp line<br />

Alternatives<br />

(T )line position, T select lines, T partition lines<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


6.2. FEATURES 367<br />

See Also<br />

(T )line position, T select lines, T partition lines, detect edge segments<br />

Region processing<br />

Module<br />

line position ( long RowBegin, long ColBegin, long RowEnd, long ColEnd,<br />

double *RowCenter, double *ColCenter, double *Length, double *Phi )<br />

T line position ( Htuple RowBegin, Htuple ColBegin, Htuple RowEnd,<br />

Htuple ColEnd, Htuple *RowCenter, Htuple *ColCenter, Htuple *Length,<br />

Htuple *Phi )<br />

Calculate the center of gravity, length, and orientation of a line.<br />

The operator (T )line position returns the center (RowCenter, ColCenter), the (Euclidean) length<br />

(Length) and the orientation ( ¾ È ¾) of the given lines. If more than one line is to be treated<br />

the line and column indices can be passed as tuples. In this case the output parameters, of course, are also tuples.<br />

The routine is applied, for example, to model lines in order to determine search regions for the edge detection<br />

(detect edge segments).<br />

Parameter<br />

º RowBegin (input control) .......................................line.begin.y(-array) (Htuple .) long<br />

Row coordinates of the starting points of the input lines.<br />

º ColBegin (input control) .......................................line.begin.x(-array) (Htuple .) long<br />

Column coordinates of the starting points of the input lines.<br />

º RowEnd (input control) ............................................line.end.y(-array) (Htuple .) long<br />

Row coordinates of the ending points of the input lines.<br />

º ColEnd (input control) ............................................line.end.x(-array) (Htuple .) long<br />

Column coordinates of the ending points of the input lines.<br />

º RowCenter (output control) .....................................point.y(-array) (Htuple .) double *<br />

Row coordinates of the centers of gravity of the input lines.<br />

º ColCenter (output control) .....................................point.x(-array) (Htuple .) double *<br />

Column coordinates of the centers of gravity of the input lines.<br />

º Length (output control) ............................................real(-array) (Htuple .) double *<br />

Euclidean length of the input lines.<br />

º Phi (output control) ...........................................angle.rad(-array) (Htuple .) double *<br />

Orientation of the input lines.<br />

Result<br />

(T )line position always returns the value H MSG TRUE.<br />

Parallelization Information<br />

(T )line position is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

sobel amp, edges image, threshold, hysteresis threshold, split skeleton region,<br />

split skeleton lines<br />

Possible Successor Functions<br />

set line width, disp line<br />

Alternatives<br />

(T )line orientation, T select lines, T partition lines<br />

See Also<br />

(T )line orientation, T select lines, T partition lines, detect edge segments<br />

Region processing<br />

Module<br />

<strong>HALCON</strong> 6.0


368 CHAPTER 6. LINES<br />

T partition lines ( Htuple RowBeginIn, Htuple ColBeginIn,<br />

Htuple RowEndIn, Htuple ColEndIn, Htuple Feature, Htuple Operation,<br />

Htuple Min, Htuple Max, Htuple *RowBeginOut, Htuple *ColBeginOut,<br />

Htuple *RowEndOut, Htuple *ColEndOut, Htuple *FailRowBOut,<br />

Htuple *FailColBOut, Htuple *FailRowEOut, Htuple *FailColEOut )<br />

Partition lines according to various criteria.<br />

The operator T partition lines divides lines into two sets according to various criteria. For each input line<br />

the indicated features (Feature) are calculated. If each (Operation = ’and’) or at least one (Operation<br />

= ’or’) of the calculated features is within the given limits (Min,Max) the line is transferred into the first set<br />

(parameters RowBeginOut to ColEndOut), otherwise into the second set (parameters FailRowBOut to<br />

FailColEOut).<br />

Condition:<br />

ÅÒ ØÙÖ ´ÄÒµ ÅÜ <br />

Possible values for Feature:<br />

’length’ (Euclidean) length of the line<br />

’row’ Line index of the center<br />

’column’ Column index of the center<br />

<br />

’phi’ Orientation of the line ( ³ )<br />

¾ ¾<br />

Attention<br />

If only one feature is used the value of Operation is meaningless. Several features are processed according to<br />

the sequence in which they are passed.<br />

Parameter<br />

º RowBeginIn (input control) .......................................line.begin.y-array Htuple . long<br />

Row coordinates of the starting points of the input lines.<br />

º ColBeginIn (input control) .......................................line.begin.x-array Htuple . long<br />

Column coordinates of the starting points of the input lines.<br />

º RowEndIn (input control) ............................................line.end.y-array Htuple . long<br />

Row coordinates of the ending points of the input lines.<br />

º ColEndIn (input control) ............................................line.end.x-array Htuple . long<br />

Column coordinates of the ending points of the input lines.<br />

º Feature (input control).........................................string(-array) Htuple . const char *<br />

Features to be used for selection.<br />

Value List : Feature ¾’length’, ’row’, ’column’, ’phi’<br />

º Operation (input control) .............................................string Htuple . const char *<br />

Desired combination of the features.<br />

Value List : Operation ¾’and’, ’or’<br />

º Min (input control) ................................string(-array) Htuple . const char * / long / double<br />

Lower limits of the features or ’min’.<br />

Default Value : ’min’<br />

º Max (input control) ................................string(-array) Htuple . const char * / long / double<br />

Upper limits of the features or ’max’.<br />

Default Value : ’max’<br />

º RowBeginOut (output control) ...................................line.begin.y-array Htuple . long *<br />

Row coordinates of the starting points of the lines fulfilling the conditions.<br />

º ColBeginOut (output control) ...................................line.begin.x-array Htuple . long *<br />

Column coordinates of the starting points of the lines fulfilling the conditions.<br />

º RowEndOut (output control) ........................................line.end.y-array Htuple . long *<br />

Row coordinates of the ending points of the lines fulfilling the conditions.<br />

º ColEndOut (output control) ......................................line.begin.x-array Htuple . long *<br />

Column coordinates of the ending points of the lines fulfilling the conditions.<br />

º FailRowBOut (output control) ...................................line.begin.y-array Htuple . long *<br />

Row coordinates of the starting points of the lines not fulfilling the conditions.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


6.2. FEATURES 369<br />

º FailColBOut (output control) ...................................line.begin.x-array Htuple . long *<br />

Column coordinates of the starting points of the lines not fulfilling the conditions.<br />

º FailRowEOut (output control) .....................................line.end.y-array Htuple . long *<br />

Row coordinates of the ending points of the lines not fulfilling the conditions.<br />

º FailColEOut (output control) .....................................line.end.x-array Htuple . long *<br />

Column coordinates of the ending points of the lines not fulfilling the conditions.<br />

Result<br />

The operator T partition lines returns the value H MSG TRUE if the parameter values are correct. Otherwise<br />

an exception is raised.<br />

Parallelization Information<br />

T partition lines is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

sobel amp, edges image, threshold, hysteresis threshold, split skeleton region,<br />

split skeleton lines<br />

Possible Successor Functions<br />

set line width, disp line<br />

Alternatives<br />

(T )line orientation, (T )line position, T select lines, T select lines longest<br />

See Also<br />

T select lines, T select lines longest, detect edge segments, select shape<br />

Region processing<br />

Module<br />

T select lines ( Htuple RowBeginIn, Htuple ColBeginIn, Htuple RowEndIn,<br />

Htuple ColEndIn, Htuple Feature, Htuple Operation, Htuple Min, Htuple Max,<br />

Htuple *RowBeginOut, Htuple *ColBeginOut, Htuple *RowEndOut,<br />

Htuple *ColEndOut )<br />

Select lines according to various criteria.<br />

The operator T select lines chooses lines according to various criteria. For every input line the indicated<br />

features (Feature) are calculated. If each (Operation = ’and’) or at least one (Operation = ’or’) of the<br />

calculated features is within the given limits (Min,Max) the line is transferred into the output.<br />

Condition:<br />

Possible values for Feature:<br />

ÅÒ ØÙÖ ´ÄÒµ ÅÜ <br />

’length’ (Euclidean) length of the line<br />

’row’ Line index of the center<br />

’column’ Column index of the center<br />

<br />

’phi’ Orientation of the line ( ³ )<br />

¾ ¾<br />

Attention<br />

If only one feature is used the value of Operation is meaningless. Several features are processed according to<br />

the sequence in which they are passed.<br />

Parameter<br />

º RowBeginIn (input control) .......................................line.begin.y-array Htuple . long<br />

Row coordinates of the starting points of the input lines.<br />

º ColBeginIn (input control) .......................................line.begin.x-array Htuple . long<br />

Column coordinates of the starting points of the input lines.<br />

º RowEndIn (input control) ............................................line.end.y-array Htuple . long<br />

Row coordinates of the ending points of the input lines.<br />

<strong>HALCON</strong> 6.0


370 CHAPTER 6. LINES<br />

º ColEndIn (input control) ............................................line.end.x-array Htuple . long<br />

Column coordinates of the ending points of the input lines.<br />

º Feature (input control).........................................string(-array) Htuple . const char *<br />

Features to be used for selection.<br />

Default Value : ’length’<br />

Value List : Feature ¾’length’, ’row’, ’column’, ’phi’<br />

º Operation (input control) .............................................string Htuple . const char *<br />

Desired combination of the features.<br />

Default Value : ’and’<br />

Value List : Operation ¾’and’, ’or’<br />

º Min (input control) ................................string(-array) Htuple . const char * / long / double<br />

Lower limits of the features or ’min’.<br />

Default Value : ’min’<br />

º Max (input control) ................................string(-array) Htuple . const char * / long / double<br />

Upper limits of the features or ’max’.<br />

Default Value : ’max’<br />

º RowBeginOut (output control) ...................................line.begin.y-array Htuple . long *<br />

Row coordinates of the starting points of the output lines.<br />

º ColBeginOut (output control) ...................................line.begin.x-array Htuple . long *<br />

Column coordinates of the starting points of the output lines.<br />

º RowEndOut (output control) ........................................line.end.y-array Htuple . long *<br />

Row coordinates of the ending points of the output lines.<br />

º ColEndOut (output control) ........................................line.end.x-array Htuple . long *<br />

Column coordinates of the ending points of the output lines.<br />

Result<br />

The operator T select lines returns the value H MSG TRUE if the parameter values are correct. Otherwise<br />

an exception is raised.<br />

Parallelization Information<br />

T select lines is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

sobel amp, edges image, threshold, hysteresis threshold, split skeleton region,<br />

split skeleton lines<br />

Possible Successor Functions<br />

set line width, disp line<br />

Alternatives<br />

(T )line orientation, (T )line position, T partition lines<br />

See Also<br />

T partition lines, T select lines longest, detect edge segments, select shape<br />

Region processing<br />

Module<br />

T select lines longest ( Htuple RowBeginIn, Htuple ColBeginIn,<br />

Htuple RowEndIn, Htuple ColEndIn, Htuple Num, Htuple *RowBeginOut,<br />

Htuple *ColBeginOut, Htuple *RowEndOut, Htuple *ColEndOut )<br />

Select the longest input lines.<br />

The operator T select lines longest selects the Num longest input lines from the input lines described by<br />

the tuples RowBeginIn, ColBeginIn, RowEndIn and ColEndIn.<br />

Parameter<br />

º RowBeginIn (input control) .......................................line.begin.y-array Htuple . long<br />

Row coordinates of the starting points of the input lines.<br />

º ColBeginIn (input control) .......................................line.begin.x-array Htuple . long<br />

Column coordinates of the starting points of the input lines.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


6.2. FEATURES 371<br />

º RowEndIn (input control) ............................................line.end.y-array Htuple . long<br />

Row coordinates of the ending points of the input lines.<br />

º ColEndIn (input control) ............................................line.end.x-array Htuple . long<br />

Column coordinates of the ending points of the input lines.<br />

º Num (input control) ...........................................................integer Htuple . long<br />

(Maximum) desired number of output lines.<br />

Default Value : 10<br />

º RowBeginOut (output control) ...................................line.begin.y-array Htuple . long *<br />

Row coordinates of the starting points of the output lines.<br />

º ColBeginOut (output control) ...................................line.begin.x-array Htuple . long *<br />

Column coordinates of the starting points of the output lines.<br />

º RowEndOut (output control) ........................................line.end.y-array Htuple . long *<br />

Row coordinates of the ending points of the output lines.<br />

º ColEndOut (output control) ........................................line.end.x-array Htuple . long *<br />

Column coordinates of the ending points of the output lines.<br />

Result<br />

The operator T select lines longest returns the value H MSG TRUE if the parameter values are correct.<br />

Otherwise an exception is raised.<br />

Parallelization Information<br />

T select lines longest is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

sobel amp, edges image, threshold, hysteresis threshold, split skeleton region,<br />

split skeleton lines<br />

Possible Successor Functions<br />

set line width, disp line<br />

Alternatives<br />

(T )line orientation, (T )line position, T select lines, T partition lines<br />

See Also<br />

T select lines, T partition lines, detect edge segments, select shape<br />

Region processing<br />

Module<br />

<strong>HALCON</strong> 6.0


372 CHAPTER 6. LINES<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Chapter 7<br />

Morphology<br />

7.1 Gray-Values<br />

dual rank ( Hobject Image, Hobject *ImageRank, const char *MaskType,<br />

long Radius, long ModePercent, long Margin )<br />

Opening, Median and Closing with circle or rectangle mask.<br />

The operator dual rank carries out a non-linear transformation of the gray values of all input images (Image).<br />

Circles or squares can be used as structuring elements. The operator dual rank effects two consecutive calls of<br />

rank image. At the first call the range gray value is calculated with the indicated range (ModePercent).<br />

The result of this calculation is the input of a further call of rank image, this time using the range value<br />

½¼¼ ModePercent.<br />

When filtering different parameters for margin control (Margin) can be chosen:<br />

0...255 Pixels outside the image edges are assumed to be constant<br />

(with the indicated gray value).<br />

-1 Continuation of edge pixels.<br />

-2 cyclic continuation of image edges.<br />

-3 Reflection of pixels at image edges.<br />

A range filtering is calculated according to the following scheme: The indicated mask is put over the image to be<br />

filtered in such a way that the center of the mask touches all pixels once. For each of these pixels all neighboring<br />

pixels covered by the mask are sorted in an ascending sequence corresponding to their gray values. Each sorted<br />

sequence of gray values contains the same number of gray values like the mask has image points. The n-th highest<br />

element, (= ModePercent, rank values between ¼ ½¼¼ in percent) is selected and set as result gray value in<br />

the corresponding result image.<br />

If ModePercent is ¼, then the operator equals to the gray value opening (gray opening). If ModePercent<br />

is ¼, the operator results in the median filter, which is applied twice (median image). The ModePercent<br />

100 in dual rank means that it calculates the gray value closing (gray closing). Choosing parameter values<br />

inside this range results in a smooth transformation of these operators.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Image to be filtered.<br />

º ImageRank (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .multichannel-image(-array) Hobject *<br />

Filtered Image.<br />

º MaskType (input control) ......................................................string const char *<br />

Shape of the mask.<br />

Default Value : ’circle’<br />

Value List : MaskType ¾’circle’, ’rectangle’<br />

373


374 CHAPTER 7. MORPHOLOGY<br />

º Radius (input control) ...............................................................integer long<br />

Radius of the filter mask.<br />

Default Value : 1<br />

Value Suggestions : Radius ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 15, 19, 25, 31, 39, 47, 59<br />

Typical Range of Values : 1 Radius 101<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

º ModePercent (input control) ........................................................integer long<br />

Filter Mode: 0 corresponds to a gray value opening , 50 corresponds to a median and 100 to a gray values<br />

closing.<br />

Default Value : 10<br />

Value Suggestions : ModePercent ¾0, 2, 5, 10, 15, 20, 40, 50, 60, 80, 85, 90, 95, 98, 100<br />

Typical Range of Values : 0 ModePercent 100<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

º Margin (input control) ...............................................................integer long<br />

Margin control: 0...255 (constant), -1 (margin points continued), -2 (cyclic continuation), -3 (mirroring).<br />

Default Value : -3<br />

Typical Range of Values : -3 Margin 255<br />

Example<br />

read_image(&Image,"fabrik");<br />

dual_rank(Image,&ImageOpening,"circle",10,10,-3);<br />

disp_image(ImageOpening,WindowHandle);<br />

Complexity<br />

For each pixel: O( Ô £ ½¼) with F = area of the structuring element.<br />

Result<br />

If the parameter values are correct the operator dual rank returns the value H MSG TRUE. The<br />

behavior in case of empty input (no input images available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

dual rank is reentrant and automatically parallelized (on tuple level, channel level).<br />

read image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

threshold, dyn threshold, sub image, regiongrowing<br />

Alternatives<br />

rank image, gray closing, gray opening, median image<br />

See Also<br />

gen circle, gen rectangle1, gray erosion rect, gray dilation rect, sigma image<br />

Bibliography<br />

W. Eckstein, O. Munkelt “Extracting Objects from Digital Terrain Model” Remote Sensing and Reconstruction for<br />

Threedimensional Objects and Scenes, SPIE Symposium on Optical Science, Engeneering, and Instrumentation,<br />

July 1995, San Diego<br />

Module<br />

Image filters<br />

gen disc se ( Hobject *SE, long Width, long Height, long Smax )<br />

Generate ellipsoidal structuring elements for gray morphology.<br />

gen disc se generates an ellipsoidal structuring element (SE) for gray morphology of images. The parameters<br />

Width and Height determine the length of the two major axes of the ellipse. The value of Smax determines<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.1. GRAY-VALUES 375<br />

the maximum gray value of the structuring element. For the generation of arbitrary structuring elements, see<br />

read gray se.<br />

Parameter<br />

º SE (output object) .........................................................image Hobject * : byte<br />

Generated structuring element.<br />

º Width (input control) ................................................................integer long<br />

Width of the structuring element.<br />

Default Value : 5<br />

Value Suggestions : Width ¾0, 1, 2, 3, 4, 5, 10, 15, 20<br />

Typical Range of Values : 0 Width 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Height (input control) ...............................................................integer long<br />

Height of the structuring element.<br />

Default Value : 5<br />

Value Suggestions : Height ¾0, 1, 2, 3, 4, 5, 10, 15, 20<br />

Typical Range of Values : 0 Height 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Smax (input control) .................................................................integer long<br />

Maximum gray value of the structuring element.<br />

Default Value : 0<br />

Value Suggestions : Smax ¾0, 1, 2, 5, 10, 20, 30, 40<br />

Typical Range of Values : 0 Smax 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Result<br />

gen disc se returns H MSG TRUE if all parameters are correct. If necessary, an exception is raised.<br />

Parallelization Information<br />

gen disc se is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

gray erosion, gray dilation, gray opening, gray closing, gray tophat, gray bothat<br />

read gray se<br />

Alternatives<br />

See Also<br />

read image, paint region, paint gray, crop part<br />

Image filters<br />

Module<br />

gray bothat ( Hobject Image, Hobject SE, Hobject *ImageBotHat )<br />

Perform a gray value bottom hat transformation on an image.<br />

gray bothat applies a gray value bottom hat transformation to the input image Image with the structuring<br />

element SE. The gray value bottom hat transformation of an image with a structuring element × is defined as<br />

bothat´ ×µ ´ ¯ ×µ <br />

i.e., the difference of the closing of the image with × and the image (see gray closing). For the generation of<br />

structuring elements, see read gray se.<br />

<strong>HALCON</strong> 6.0


376 CHAPTER 7. MORPHOLOGY<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Input image.<br />

º SE (input object) .............................................................image Hobject : byte<br />

Structuring element.<br />

º ImageBotHat (output object) ......................................image(-array) Hobject * : byte<br />

Bottom hat image.<br />

Result<br />

gray bothat returns H MSG TRUE if the structuring element is not the empty region. Otherwise, an exception<br />

is raised.<br />

Parallelization Information<br />

gray bothat is reentrant and automatically parallelized (on tuple level).<br />

read gray se, gen disc se<br />

threshold<br />

gray closing<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

gray tophat, top hat, gray erosion rect, sub image<br />

Image filters<br />

Module<br />

gray closing ( Hobject Image, Hobject SE, Hobject *ImageClosing )<br />

Performagrayvalueclosingonanimage.<br />

gray closing applies a gray value closing to the input image Image with the structuring element SE. The gray<br />

value closing of an image with a structuring element × is defined as<br />

¯ × ´ ¨ ×µ © × <br />

i.e., a dilation of the image with × followed by an erosion with × (see gray dilation and gray erosion).<br />

For the generation of structuring elements, see read gray se.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Input image.<br />

º SE (input object) .............................................................image Hobject : byte<br />

Structuring element.<br />

º ImageClosing (output object) .....................................image(-array) Hobject * : byte<br />

Gray-closed image.<br />

Result<br />

gray closing returns H MSG TRUE if the structuring element is not the empty region. Otherwise, an exception<br />

is raised.<br />

Parallelization Information<br />

gray closing is reentrant and automatically parallelized (on tuple level).<br />

read gray se<br />

dual rank<br />

closing, gray dilation, gray erosion<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.1. GRAY-VALUES 377<br />

Image filters<br />

Module<br />

gray dilation ( Hobject Image, Hobject SE, Hobject *ImageDilation )<br />

Perform a gray value dilation on an image.<br />

gray dilation applies a gray value dilation to the input image Image with the structuring element SE. The<br />

gray value dilation of an image with a structuring element × at the pixel position Ü is defined as:<br />

´ ¨ ×µ´Üµ ÑÜ ´Ü Þµ ·×´ÞµÞ ¾ Ë<br />

Here, Ë is the domain of the structuring element ×, i.e., the pixels Þ where ×´Þµ ¼ (see read gray se).<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Input image.<br />

º SE (input object) .............................................................image Hobject : byte<br />

Structuring element.<br />

º ImageDilation (output object) ...................................image(-array) Hobject * : byte<br />

Gray-dilated image.<br />

Result<br />

gray dilation returns H MSG TRUE if the structuring element is not the empty region. Otherwise, an exception<br />

is raised.<br />

Parallelization Information<br />

gray dilation is reentrant and automatically parallelized (on tuple level).<br />

read gray se<br />

sub image, gray erosion<br />

gray dilation rect<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

gray opening, gray closing, dilation1, gray skeleton<br />

Image filters<br />

Module<br />

gray dilation rect ( Hobject Image, Hobject *ImageMax, long MaskHeight,<br />

long MaskWidth )<br />

Determine the maximum gray value within a rectangle.<br />

gray dilation rect calculates the maximum gray value of the input image Image within a rectangular mask<br />

of size (MaskHeight, MaskWidth) for each image point. The resulting image is returned in ImageMax. Ifthe<br />

parameters MaskHeight or MaskWidth are even, they are changed to the next larger odd value. At the border<br />

of the image the gray values are mirrored.<br />

Parameter<br />

º Image (input object) .............................image(-array) Hobject : byte / direction / int4 / real<br />

Image for which the maximum gray values are to be calculated.<br />

º ImageMax (output object) ......................image(-array) Hobject * : byte / direction / int4 / real<br />

Image containing the maximum gray values.<br />

<strong>HALCON</strong> 6.0


378 CHAPTER 7. MORPHOLOGY<br />

º MaskHeight (input control) ........................................................extent.y long<br />

Height of the filter mask.<br />

Default Value : 11<br />

Value Suggestions : MaskHeight ¾3, 5, 7, 9, 11, 13, 15<br />

Typical Range of Values : 3 MaskHeight 511<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskHeightµ<br />

º MaskWidth (input control) ..........................................................extent.x long<br />

Width of the filter mask.<br />

Default Value : 11<br />

Value Suggestions : MaskWidth ¾3, 5, 7, 9, 11, 13, 15<br />

Typical Range of Values : 3 MaskWidth 511<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskWidthµ<br />

Result<br />

gray dilation rect returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour<br />

can be set via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

gray dilation rect is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

gray skeleton<br />

Image filters<br />

See Also<br />

Module<br />

gray erosion ( Hobject Image, Hobject SE, Hobject *ImageErosion )<br />

Perform a gray value erosion on an image.<br />

gray erosion applies a gray value erosion to the input image Image with the structuring element SE. The<br />

gray value erosion of an image with a structuring element × at the pixel position Ü is defined as:<br />

´ © ×µ´Üµ ÑÒ ´Ü · Þµ ×´ÞµÞ ¾ Ë<br />

Here, Ë is the domain of the structuring element ×, i.e., the pixels Þ where ×´Þµ ¼ (see read gray se).<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Input image.<br />

º SE (input object) .............................................................image Hobject : byte<br />

Structuring element.<br />

º ImageErosion (output object) .....................................image(-array) Hobject * : byte<br />

Gray-eroded image.<br />

Result<br />

gray erosion returns H MSG TRUE if the structuring element is not the empty region. Otherwise, an exception<br />

is raised.<br />

Parallelization Information<br />

gray erosion is reentrant and automatically parallelized (on tuple level).<br />

read gray se<br />

gray dilation, sub image<br />

gray erosion rect<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.1. GRAY-VALUES 379<br />

See Also<br />

gray opening, gray closing, erosion1, gray skeleton<br />

Image filters<br />

Module<br />

gray erosion rect ( Hobject Image, Hobject *ImageMin, long MaskHeight,<br />

long MaskWidth )<br />

Determine the minimum gray value within a rectangle.<br />

gray erosion rect calculates the minimum gray value of the input image Image within a rectangular mask<br />

of size (MaskHeight, MaskWidth) for each image point. The resulting image is returned in ImageMin. Ifthe<br />

parameters MaskHeight or MaskWidth are even, they are changed to the next larger odd value. At the border<br />

of the image the gray values are mirrored.<br />

Parameter<br />

º Image (input object) .............................image(-array) Hobject : byte / direction / int4 / real<br />

Image for which the minimum gray values are to be calculated.<br />

º ImageMin (output object) ......................image(-array) Hobject * : byte / direction / int4 / real<br />

Image containing the minimum gray values.<br />

º MaskHeight (input control) ........................................................extent.y long<br />

Height of the filter mask.<br />

Default Value : 11<br />

Value Suggestions : MaskHeight ¾3, 5, 7, 9, 11, 13, 15<br />

Typical Range of Values : 3 MaskHeight 511 (lin)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskHeightµ<br />

º MaskWidth (input control) ..........................................................extent.x long<br />

Width of the filter mask.<br />

Default Value : 11<br />

Value Suggestions : MaskWidth ¾3, 5, 7, 9, 11, 13, 15<br />

Typical Range of Values : 3 MaskWidth 511 (lin)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskWidthµ<br />

Result<br />

gray erosion rect returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour<br />

can be set via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

gray erosion rect is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

gray dilation rect<br />

Image filters<br />

See Also<br />

Module<br />

gray opening ( Hobject Image, Hobject SE, Hobject *ImageOpening )<br />

Perform a gray value opening on an image.<br />

gray opening applies a gray value opening to the input image Image with the structuring element SE. The<br />

gray value opening of an image with a structuring element × is defined as<br />

Æ × ´ © ×µ ¨ × <br />

<strong>HALCON</strong> 6.0


380 CHAPTER 7. MORPHOLOGY<br />

i.e., an erosion of the image with × followed by a dilation with × (see gray erosion and gray dilation).<br />

For the generation of structuring elements, see read gray se.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Input image.<br />

º SE (input object) .............................................................image Hobject : byte<br />

Structuring element.<br />

º ImageOpening (output object) .....................................image(-array) Hobject * : byte<br />

Gray-opened image.<br />

Result<br />

gray opening returns H MSG TRUE if the structuring element is not the empty region. Otherwise, an exception<br />

is raised.<br />

Parallelization Information<br />

gray opening is reentrant and automatically parallelized (on tuple level).<br />

read gray se<br />

dual rank<br />

opening, gray dilation, gray erosion<br />

Image filters<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

gray range rect ( Hobject Image, Hobject *ImageResult, long MaskHeight,<br />

long MaskWidth )<br />

Determine the gray value range within a rectangle.<br />

gray range rect calculates the gray value range, i.e., the difference ´ÑÜ ÑÒµ of the maximum and minimum<br />

gray values, of the input image Image within a rectangular mask of size (MaskHeight, MaskWidth)<br />

for each image point. The resulting image is returned in ImageResult. If the parameters MaskHeight or<br />

MaskWidth are even, they are changed to the next larger odd value. At the border of the image the gray values<br />

are mirrored.<br />

Parameter<br />

º Image (input object) .............................image(-array) Hobject : byte / direction / int4 / real<br />

Image for which the gray value range is to be calculated.<br />

º ImageResult (output object) ..................image(-array) Hobject * : byte / direction / int4 / real<br />

Image containing the gray value range.<br />

º MaskHeight (input control) ........................................................extent.y long<br />

Height of the filter mask.<br />

Default Value : 11<br />

Value Suggestions : MaskHeight ¾3, 5, 7, 9, 11, 13, 15<br />

Typical Range of Values : 3 MaskHeight 511 (lin)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskHeightµ<br />

º MaskWidth (input control) ..........................................................extent.x long<br />

Width of the filter mask.<br />

Default Value : 11<br />

Value Suggestions : MaskWidth ¾3, 5, 7, 9, 11, 13, 15<br />

Typical Range of Values : 3 MaskWidth 511 (lin)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : odd´MaskWidthµ<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.1. GRAY-VALUES 381<br />

Result<br />

gray range rect returns H MSG TRUE if all parameters are correct. If the input is empty the behaviour can<br />

be set via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

gray range rect is reentrant and automatically parallelized (on tuple level, channel level, domain level).<br />

Alternatives<br />

gray dilation rect, gray erosion rect, sub image<br />

Image filters<br />

Module<br />

gray tophat ( Hobject Image, Hobject SE, Hobject *ImageTopHat )<br />

Performagrayvaluetophattransformationonanimage.<br />

gray tophat applies a gray value top hat transformation to the input image Image with the structuring element<br />

SE. The gray value top hat transformation of an image with a structuring element × is defined as<br />

tophat´ ×µ ´ Æ ×µ<br />

i.e., the difference of the image and its opening with × (see gray opening). For the generation of structuring<br />

elements, see read gray se.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Input image.<br />

º SE (input object) .............................................................image Hobject : byte<br />

Structuring element.<br />

º ImageTopHat (output object) ......................................image(-array) Hobject * : byte<br />

Top hat image.<br />

Result<br />

gray tophat returns H MSG TRUE if the structuring element is not the empty region. Otherwise, an exception<br />

is raised.<br />

Parallelization Information<br />

gray tophat is reentrant and automatically parallelized (on tuple level).<br />

read gray se, gen disc se<br />

threshold<br />

gray opening<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

gray bothat, top hat, gray erosion rect, sub image<br />

Image filters<br />

Module<br />

read gray se ( Hobject *SE, const char *FileName )<br />

Load a structuring element for gray morphology.<br />

read gray se loads a structuring element for gray morphology from a file. The file names of these structuring<br />

elements must end in ’.gse’ (for gray-scale structuring element). This suffix is automatically appended by<br />

read gray se to the passed file name, and thus must not be passed. The structuring element’s data must be<br />

<strong>HALCON</strong> 6.0


382 CHAPTER 7. MORPHOLOGY<br />

contained in the file in the following format: The first two numbers in the file determine the width and height of<br />

the structuring element, and determine a rectangle enclosing the structuring element. Both values must be greater<br />

than 0. Then, Width*Height integer numbers follow, with the following interpretation: Values smaller than 0 are<br />

regarded as not belonging to the region of the structuring element, i.e., they are not considered in morphological<br />

operations. This allows the creation of irregularly shaped, not connected structuring elements. All other values<br />

are regarded as the corresponding values for gray morphology. Structuring elements are stored internally as byteimages,<br />

with negative values being mapped to 0, and all other values increased by 1. Thus, normal byte-images<br />

can also be used as structuring elements. However, care should be taken not to use too large images, since the<br />

runtime is proportional to the area of the image times the area of the structuring element.<br />

Parameter<br />

º SE (output object) .........................................................image Hobject * : byte<br />

Generated structuring element.<br />

º FileName (input control) ...................................................filename const char *<br />

Name of the file containing the structuring element.<br />

Result<br />

read gray se returns H MSG TRUE if all parameters are correct. If the file cannot be opened, H MSG FAIL<br />

is returned. Otherwise, an exception is raised.<br />

Parallelization Information<br />

read gray se is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

gray erosion, gray dilation, gray opening, gray closing, gray tophat, gray bothat<br />

gen disc se<br />

Alternatives<br />

See Also<br />

read image, paint region, paint gray, crop part<br />

Image filters<br />

Module<br />

7.2 Region<br />

bottom hat ( Hobject Region, Hobject StructElement,<br />

Hobject *RegionBottomHat )<br />

Compute the bottom hat of regions.<br />

bottom hat computes the closing of Region with StructElement. The difference between the result of<br />

the closing and the original region is called the bottom hat. In contrast to closing, which merges regions under<br />

certain circumstances, bottom hat computes the regions generated by such a merge.<br />

The position of StructElement is meaningless, since a closing operation is invariant with respect to the choice<br />

of the reference point.<br />

Structuring elements (StructElement) can be generated with operators such as gen circle,<br />

gen rectangle1, gen rectangle2, gen ellipse, draw region, gen region polygon,<br />

gen region points,etc.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º StructElement (input object) ...................................................region Hobject<br />

Structuring element (position independent).<br />

º RegionBottomHat (output object) .......................................region(-array) Hobject *<br />

Result of the bottom hat operator.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 383<br />

Example<br />

threshold(Image,&Regions,128.0,255.0);<br />

gen_circle(&Circle,128.0,128.0,16.0);<br />

bottom_hat(Regions,Circle,&RegionBottomHat);<br />

set_color(WindowHandle,"red");<br />

disp_region(Regions,WindowHandle);<br />

set_color(WindowHandle,"green");<br />

disp_region(RegionBottomHat,WindowHandle);<br />

Result<br />

bottom hat returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input<br />

region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

bottom hat is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm,<br />

gen circle, gen ellipse, gen rectangle1, gen rectangle2, draw region,<br />

gen region points, gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

closing, difference<br />

Alternatives<br />

See Also<br />

top hat, morph hat, gray bothat, opening<br />

Morphology<br />

Module<br />

boundary ( Hobject Region, Hobject *RegionBorder,<br />

const char *BoundaryType )<br />

Reduce a region to its boundary.<br />

boundary computes the boundary of a region by using morphological operations. The parameter<br />

BoundaryType determines the type of boundary to compute:<br />

’inner’, ’inner filled’ and ’outer’.<br />

boundary computes the contour of each input region. The resulting regions consist only of the minimal border<br />

of the input regions. If BoundaryType is set to ’inner’, the contour lies within the original region, if it is set<br />

to ’outer’, it is one pixel outside of the original region. If BoundaryType is set to ’inner filled’, holes in the<br />

interior of the input region are suppressed.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions for which the boundary is to be computed.<br />

º RegionBorder (output object) ...........................................region(-array) Hobject *<br />

Resulting boundaries.<br />

º BoundaryType (input control) .................................................string const char *<br />

Boundary type.<br />

Default Value : ’inner’<br />

Value List : BoundaryType ¾’inner’, ’outer’, ’inner filled’<br />

<strong>HALCON</strong> 6.0


384 CHAPTER 7. MORPHOLOGY<br />

Example<br />

/* Intersections of two circles: */<br />

gen_circle(&Circle1,200.0,100.0,100.5);<br />

gen_circle(&Circle2,200.0,150.0,100.5);<br />

boundary(Circle1,&Margin1,"inner");<br />

boundary(Circle2,&Margin2,"inner");<br />

intersection(Margin1,Margin2,&Intersections);<br />

connection(Intersections,&Single);<br />

T_area_center(Single,_,&Rows,&Columns);<br />

/* simulation of Mode ’inner’ */<br />

void inner(Hobject Region, Hobject *Border)<br />

{<br />

Hobject Smaller;<br />

erosion_circle(Region,&Smaller,1.5);<br />

difference(Region,Smaller,Border);<br />

clear_obj(Smaller);<br />

}<br />

Complexity<br />

Let be the area of the input region. Then the runtime complexity for one region is<br />

Ç´¿Ô<br />

µ <br />

Result<br />

boundary returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input region<br />

can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

boundary is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

Alternatives<br />

dilation circle, erosion circle, difference<br />

fill up<br />

Morphology<br />

See Also<br />

Module<br />

closing ( Hobject Region, Hobject StructElement,<br />

Hobject *RegionClosing )<br />

Close a region.<br />

A closing operation is defined as a dilation followed by a Minkowsi subtraction. By applying closing to<br />

a region, larger structures remain mostly intact, while small gaps between adjacent regions and holes smaller<br />

than StructElement are closed, and the regions’ boundaries are smoothed. All closing variants share the<br />

property that separate regions are not merged, but remain separate objects. The position of StructElement is<br />

meaningless, since a closing operation is invariant with respect to the choice of the reference point.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 385<br />

Structuring elements (StructElement) can be generated with operators such as gen circle,<br />

gen rectangle1, gen rectangle2, gen ellipse, draw region, gen region polygon,<br />

gen region points,etc.<br />

Attention<br />

closing is applied to each input region separately. If gaps between different regions are to be closed, union1<br />

or union2 has to be called first.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be closed.<br />

º StructElement (input object) ...................................................region Hobject<br />

Structuring element (position-invariant).<br />

º RegionClosing (output object) ..........................................region(-array) Hobject *<br />

Closed regions.<br />

Example<br />

my_closing(Hobject In, Hobject StructElement, Hobject *Out)<br />

{<br />

Hobject tmp;<br />

dilation1(In,StructElement,&tmp,1);<br />

minkowski_sub1(tmp,StructElement,Out,1);<br />

clear_obj(tmp);<br />

}<br />

Complexity<br />

Let ½ be the area of the input region, and ¾ be the area of the structuring element. Then the runtime complexity<br />

for one region is:<br />

Ç´¾ ¡ Ô ½ ¡ Ô ¾µ <br />

Result<br />

closing returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input region<br />

can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

closing is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm,<br />

gen circle, gen ellipse, gen rectangle1, gen rectangle2, draw region,<br />

gen region points, gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

closing circle, closing golay<br />

Alternatives<br />

See Also<br />

dilation1, erosion1, opening, minkowski sub1<br />

Morphology<br />

Module<br />

closing circle ( Hobject Region, Hobject *RegionClosing, double Radius )<br />

Close a region with a circular structuring element.<br />

<strong>HALCON</strong> 6.0


386 CHAPTER 7. MORPHOLOGY<br />

closing circle behaves analogously to closing, i.e., the regions’ boundaries are smoothed and holes<br />

within a region which are smaller than the circular structuring element of radius Radius are closed. The<br />

closing circle operation is defined as a dilation followed by a Minkowski subtraction, both with the same<br />

circular structuring element.<br />

Attention<br />

closing circle is applied to each input region separately. If gaps between different regions are to be closed,<br />

union1 or union2 has to be called first.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be closed.<br />

º RegionClosing (output object) ..........................................region(-array) Hobject *<br />

Closed regions.<br />

º Radius (input control) .........................................................real double / long<br />

Radius of the circular structuring element.<br />

Default Value : 3.5<br />

Value Suggestions : Radius ¾1.5, 2.5, 3.5, 4.5, 5.5, 7.5, 9.5, 12.5, 15.5, 19.5, 25.5, 33.5, 45.5, 60.5,<br />

110.5<br />

Typical Range of Values : 0.5 Radius 511.5 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 1.0<br />

Example<br />

my_closing_circle(Hobject In, double Radius, Hobject *Out)<br />

{<br />

Hobject tmp, StructElement;<br />

gen_circle(StructElement,100.0,100.0,Radius);<br />

dilation1(In,StructElement,&tmp,1);<br />

minkowski_sub1(tmp,StructElement,Out,1);<br />

clear_obj(tmp); clear_obj(StructElement);<br />

}<br />

Complexity<br />

Let ½ be the area of the input region. Then the runtime complexity for one region is:<br />

Ç´ ¡ Ô ½ ¡ ÊÙ×µ <br />

Result<br />

closing circle returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

closing circle is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

Alternatives<br />

rank region, fill up, closing, closing circle, closing golay<br />

See Also<br />

dilation1, minkowski sub1, erosion1, opening<br />

Morphology<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 387<br />

closing golay ( Hobject Region, Hobject *RegionClosing,<br />

const char *GolayElement, long Rotation )<br />

Close a region with an element from the Golay alphabet.<br />

closing golay is defined as a Minkowski addition followed by a Minkowski subtraction. First the Minkowski<br />

addition of the input region (Region) with the structuring element from the Golay alphabet defined by<br />

GolayElement and Rotation is computed. Then the Minkowski subtraction of the result and the structuring<br />

element rotated by 180 Æ is performed.<br />

The following structuring elements are available:<br />

’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’.<br />

The rotation number Rotation determines which rotation of the element should be used, and whether the foreground<br />

(even) or background version (odd) of the selected element should be used. The Golay elements, together<br />

with all possible rotations, are described with the operator golay elements.<br />

closing golay serves to close holes smaller than the structuring element, and to smooth regions’ boundaries.<br />

Attention<br />

Not all values of Rotation are valid for any Golay element. For some of the values of Rotation, the resulting<br />

regions are identical to the input regions.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be closed.<br />

º RegionClosing (output object) ..........................................region(-array) Hobject *<br />

Closed regions.<br />

º GolayElement (input control) .................................................string const char *<br />

Structuring element from the Golay alphabet.<br />

Default Value : ’h’<br />

Value List : GolayElement ¾’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’<br />

º Rotation (input control) ............................................................integer long<br />

Rotation of the Golay elementḊepending on the element, not all rotations are valid.<br />

Default Value : 0<br />

Value List : Rotation ¾0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15<br />

Complexity<br />

Let be the area of an input region. Then the runtime complexity for one region is:<br />

Ç´ ¡ Ô µ <br />

Result<br />

closing golay returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input<br />

region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

closing golay is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

closing<br />

Alternatives<br />

See Also<br />

erosion golay, dilation golay, opening golay, hit or miss golay, thinning golay,<br />

thickening golay, golay elements<br />

<strong>HALCON</strong> 6.0


388 CHAPTER 7. MORPHOLOGY<br />

Morphology<br />

Module<br />

closing rectangle1 ( Hobject Region, Hobject *RegionClosing,<br />

long Width, long Height )<br />

Close a region with a rectangular structuring element.<br />

closing rectangle1 performs a dilation rectangle1 followed by an erosion rectangle1 on<br />

the input region Region. The size of the rectangular structuring element is determined by the parameters Width<br />

and Height. As is the case for all closing variants, regions’ boundaries are smoothed and holes within a region<br />

which are smaller than the rectangular structuring element are closed.<br />

Attention<br />

closing rectangle1 is applied to each input region separately. If gaps between different regions are to be<br />

closed, union1 or union2 has to be called first.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be closed.<br />

º RegionClosing (output object) ..........................................region(-array) Hobject *<br />

Closed regions.<br />

º Width (input control) .......................................................extent.x long / double<br />

Width of the structuring rectangle.<br />

Default Value : 10<br />

Value Suggestions : Width ¾1, 2, 3, 4, 5, 7, 9, 12, 15, 19, 25, 33, 45, 60, 110, 150, 200<br />

Typical Range of Values : 1 Width 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Height (input control) .....................................................extent.y long / double<br />

Height of the structuring rectangle.<br />

Default Value : 10<br />

Value Suggestions : Height ¾1, 2, 3, 4, 5, 7, 9, 12, 15, 19, 25, 33, 45, 60, 110, 150, 200<br />

Typical Range of Values : 1 Height 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let ½ be the area of an input region and À be the height of the rectangle. Then the runtime complexity for one<br />

region is:<br />

Ç´¾ ¡ Ô ½ ¡ ÐÓ ¾´Àµµ <br />

Result<br />

closing rectangle1 returns H MSG TRUE if all parameters are correct. The behavior in case of empty or<br />

no input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

closing rectangle1 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 389<br />

closing<br />

Alternatives<br />

See Also<br />

dilation rectangle1, erosion rectangle1, opening rectangle1, gen rectangle1<br />

Morphology<br />

Module<br />

dilation1 ( Hobject Region, Hobject StructElement,<br />

Hobject *RegionDilation, long Iterations )<br />

Dilate a region.<br />

dilation1 dilates the input regions with a structuring element. By applying dilation1 to a region, its<br />

boundary gets smoothed. In the process, the area of the region is enlarged. Furthermore, disconnected regions<br />

may be merged. Such regions, however, remain logically distinct region. The dilation is a set-theoretic region<br />

operation. It uses the union operation.<br />

Let Å (StructElement) andÊ (Region) be two regions, where Å is the structuring element and Ê is the<br />

region to be processed. Furthermore, let Ñ be a point in Å. Then the displacement vector Ú Ñ ´Ü ݵ is<br />

defined as the difference of the center of gravity of Å and the vector Ñ. LetØ ÚѴʵ denote the translation of a<br />

region Ê by a vector Ú. Then<br />

ÐØÓÒ½´Ê ŵ <br />

<br />

ѾÅ<br />

Ø Ú Ñ ´Êµ<br />

For each point Ñ in Å a translation of the region Ê is performed. The union of all these translations is the dilation<br />

of Ê with Å. dilation1 is similar to the operator minkowski add1, the difference is that in dilation1<br />

the structuring element is mirrored at the origin. The position of StructElement is meaningless, since the<br />

displacement vectors are determined with respect to the center of gravity of Å.<br />

The parameter Iterations determines the number of iterations which are to be performed with the structuring<br />

element. The result of iteration Ò ½ is used as input for iteration Ò. From the above definition it follows that an<br />

empty region is generated in case of an empty structuring element.<br />

Structuring elements (StructElement) can be generated with operators such as gen circle,<br />

gen rectangle1, gen rectangle2, gen ellipse, draw region, gen region polygon,<br />

gen region points,etc.<br />

Attention<br />

A dilation always results in enlarged regions. Closely spaced regions which may touch or overlap as a result of<br />

the dilation are still treated as two separate regions. If the desired behavior is to merge them into one region, the<br />

operator union1 has to be called first.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be dilated.<br />

º StructElement (input object) ...................................................region Hobject<br />

Structuring element.<br />

º RegionDilation (output object) ........................................region(-array) Hobject *<br />

Dilated regions.<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let ½ be the area of the input region, and ¾ be the area of the structuring element. Then the runtime complexity<br />

for one region is:<br />

<strong>HALCON</strong> 6.0


390 CHAPTER 7. MORPHOLOGY<br />

Ç´Ô<br />

½ ¡<br />

Ô<br />

¾ ¡ ÁØÖØÓÒ×µ <br />

Result<br />

dilation1 returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input region<br />

can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

dilation1 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm,<br />

gen circle, gen ellipse, gen rectangle1, gen rectangle2, draw region,<br />

gen region points, gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

reduce domain, add channels, select shape, area center, connection<br />

Alternatives<br />

minkowski add1, minkowski add2, dilation2, dilation golay, dilation seq<br />

erosion1, erosion2, opening, closing<br />

Morphology<br />

See Also<br />

Module<br />

dilation2 ( Hobject Region, Hobject StructElement,<br />

Hobject *RegionDilation, long Row, long Column, long Iterations )<br />

Dilate a region (using a reference point).<br />

dilation2 dilates the input regions with a structuring element (StructElement) having the reference point<br />

(Row,Column). dilation2 has a similar effect as dilation1, the difference is that the reference point of the<br />

structuring element can be chosen arbitrarily. The parameter Iterations determines the number of iterations<br />

which are to be performed with the structuring element. The result of iteration Ò ½ is used as input for iteration<br />

Ò.<br />

An empty region is generated in case of an empty structuring element.<br />

Structuring elements (StructElement) can be generated with operators such as gen circle,<br />

gen rectangle1, gen rectangle2, gen ellipse, draw region, gen region polygon,<br />

gen region points,etc.<br />

Attention<br />

A dilation always results in enlarged regions. Closely spaced regions which may touch or overlap as a result of<br />

the dilation are still treated as two separate regions. If the desired behavior is to merge them into one region, the<br />

operator union1 has to be called first.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be dilated.<br />

º StructElement (input object) ...................................................region Hobject<br />

Structuring element.<br />

º RegionDilation (output object) ........................................region(-array) Hobject *<br />

Dilated regions.<br />

º Row (input control) ...................................................................point.y long<br />

Row coordinate of the reference point.<br />

Default Value : 0<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 391<br />

º Column (input control) ...............................................................point.x long<br />

Column coordinate of the reference point.<br />

Default Value : 0<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 7, 11, 17, 25, 32, 64, 128<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let ½ be the area of the input region, and ¾ be the area of the structuring element. Then the runtime complexity<br />

for one region is:<br />

Ç´Ô<br />

½ ¡<br />

Ô<br />

¾ ¡ ÁØÖØÓÒ×µ <br />

Result<br />

dilation2 returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input region<br />

can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

dilation2 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm,<br />

gen circle, gen ellipse, gen rectangle1, gen rectangle2, draw region,<br />

gen region points, gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

reduce domain, add channels, select shape, area center, connection<br />

Alternatives<br />

minkowski add1, minkowski add2, dilation1, dilation golay, dilation seq<br />

erosion1, erosion2, opening, closing<br />

Morphology<br />

See Also<br />

Module<br />

dilation circle ( Hobject Region, Hobject *RegionDilation,<br />

double Radius )<br />

Dilate a region with a circular structuring element.<br />

dilation circle applies a Minkowski addition with a circular structuring element to the input regions<br />

Region. Because the circular mask is symmetrical, this is identical to a dilation. The size of the circle used<br />

as structuring element is determined by Radius.<br />

The operator results in enlarged regions, smoothed region boundaries, and the holes smaller than the circular mask<br />

in the interior of the region are closed. It is useful to select only values like ¿, , etc.forRadius in order<br />

to avoid a translation of a region, because integer radii result in the circle having a non-integer center of gravity<br />

which is rounded to the next integer.<br />

Attention<br />

dilation circle is applied to each input region separately. If gaps between different regions are to be closed,<br />

union1 or union2 has to be called first.<br />

<strong>HALCON</strong> 6.0


392 CHAPTER 7. MORPHOLOGY<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be dilated.<br />

º RegionDilation (output object) ........................................region(-array) Hobject *<br />

Dilated regions.<br />

º Radius (input control) .........................................................real double / long<br />

Radius of the circular structuring element.<br />

Default Value : 3.5<br />

Value Suggestions : Radius ¾1.5, 2.5, 3.5, 4.5, 5.5, 7.5, 9.5, 12.5, 15.5, 19.5, 25.5, 33.5, 45.5, 60.5,<br />

110.5<br />

Typical Range of Values : 0.5 Radius 511.5 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 1.0<br />

Example<br />

my_dilation_circle(Hobject In, double Radius, Hobject *Out)<br />

{<br />

Hobject Circle;<br />

gen_circle(&Circle,100.0,100.0,Radius);<br />

minkowski_add1(In,Circle,Out,1);<br />

clear_obj(Circle);<br />

}<br />

Complexity<br />

Let ½ be the area of an input region. Then the runtime complexity for one region is:<br />

Ç´¾ ¡ ÊÙ× ¡ Ô ½µ <br />

Result<br />

dilation circle returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

dilation circle is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

Alternatives<br />

minkowski add1, minkowski add2, expand region, dilation1, dilation2,<br />

dilation rectangle1<br />

See Also<br />

gen circle, erosion circle, closing circle, opening circle<br />

Morphology<br />

Module<br />

dilation golay ( Hobject Region, Hobject *RegionDilation,<br />

const char *GolayElement, long Iterations, long Rotation )<br />

Dilate a region with an element from the Golay alphabet.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 393<br />

dilation golay dilates a region with the selected element GolayElement from the Golay alphabet. The<br />

following structuring elements are available:<br />

’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’.<br />

The rotation number Rotation determines which rotation of the element should be used, and whether the foreground<br />

(even) or background version (odd) of the selected element should be used. The Golay elements, together<br />

with all possible rotations, are described with the operator golay elements. The operator works by shifting<br />

the structuring element over the region to be processed (Region). For all positions of the structuring element that<br />

intersect the region, the corresponding reference point (relative to the structuring element) is added to the output<br />

region. This means that the union of all translations of the structuring element within the region is computed.<br />

The parameter Iterations determines the number of iterations which are to be performed with the structuring<br />

element. The result of iteration Ò ½ is used as input for iteration Ò.<br />

Attention<br />

Not all values of Rotation are valid for any Golay element. For some of the values of Rotation, the resulting<br />

regions are identical to the input regions.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be dilated.<br />

º RegionDilation (output object) ........................................region(-array) Hobject *<br />

Dilated regions.<br />

º GolayElement (input control) .................................................string const char *<br />

Structuring element from the Golay alphabet.<br />

Default Value : ’h’<br />

Value List : GolayElement ¾’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Rotation (input control) ............................................................integer long<br />

Rotation of the Golay elementḊepending on the element, not all rotations are valid.<br />

Default Value : 0<br />

Value List : Rotation ¾0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15<br />

Complexity<br />

Let be the area of an input region. Then the runtime complexity for one region is:<br />

Ç´¿ ¡ Ô µ <br />

Result<br />

dilation golay returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

dilation golay is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

dilation1, dilation2, dilation seq<br />

Alternatives<br />

<strong>HALCON</strong> 6.0


394 CHAPTER 7. MORPHOLOGY<br />

See Also<br />

erosion golay, opening golay, closing golay, hit or miss golay, thinning golay,<br />

thickening golay, golay elements<br />

Morphology<br />

Module<br />

dilation rectangle1 ( Hobject Region, Hobject *RegionDilation,<br />

long Width, long Height )<br />

Dilate a region with a rectangular structuring element.<br />

dilation rectangle1 applies a dilation with a rectangular structuring element to the input regions Region.<br />

The size of the structuring rectangle is Width ¢ Height. The operator results in enlarged regions, and the holes<br />

smaller than the rectangular mask in the interior of the regions are closed.<br />

dilation rectangle1 is a very fast operation because the height of the rectangle enters only logarithmically<br />

into the runtime complexity, while the width does not enter at all. This leads to excellent runtime efficiency, even<br />

in the case of very large rectangles (edge length 100).<br />

Attention<br />

dilation rectangle1 is applied to each input region separately. If gaps between different regions are to be<br />

closed, union1 or union2 has to be called first.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be dilated.<br />

º RegionDilation (output object) ........................................region(-array) Hobject *<br />

Dilated regions.<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the structuring rectangle.<br />

Default Value : 10<br />

Value Suggestions : Width ¾1, 2, 3, 4, 6, 10, 15, 20, 30, 50, 70, 100, 150, 200<br />

Typical Range of Values : 1 Width 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the structuring rectangle.<br />

Default Value : 10<br />

Value Suggestions : Height ¾1, 2, 3, 4, 6, 10, 15, 20, 30, 50, 70, 100, 150, 200<br />

Typical Range of Values : 1 Height 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Example<br />

threshold(Image,&Light,220.0,255.0);<br />

dilation_rectangle1(Light,&Wide,50,50);<br />

set_color(WindowHandle,"red");<br />

disp_region(Wide,WindowHandle);<br />

set_color(WindowHandle,"white");<br />

disp_region(Light,WindowHandle);<br />

Complexity<br />

Let ½ be the area of an input region and À be the height of the rectangle. Then the runtime complexity for one<br />

region is:<br />

Ç´Ô<br />

½ ¡ дÀµµ <br />

Result<br />

dilation rectangle1 returns H MSG TRUE if all parameters are correct. The behavior in case of empty or<br />

no input region can be set via:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 395<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

dilation rectangle1 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

Alternatives<br />

minkowski add1, minkowski add2, expand region, dilation1, dilation2,<br />

dilation circle<br />

See Also<br />

gen rectangle1, gen region polygon filled<br />

Morphology<br />

Module<br />

dilation seq ( Hobject Region, Hobject *RegionDilation,<br />

const char *GolayElement, long Iterations )<br />

Dilate a region sequentially.<br />

dilation seq computes the sequential dilation of the input region Region with the selected structuring element<br />

GolayElement from the Golay alphabet. This is done by executing the operator dilation golay with<br />

all rotations of the structuring element Iterations times. The following structuring elements can be selected:<br />

’l’, ’d’, ’c’, ’f’, ’h’, ’k’.<br />

In order to compute the skeleton of a region, usually the elements ’l’ and ’m’ are used. Only the “foreground<br />

elements” (even rotation numbers) are used. The elements ’i’ and ’e’ result in unchanged output regions. The<br />

elements ’l’, ’m’ and ’f2’ are identical for the foreground. The Golay elements, together with all possible rotations,<br />

are described with the operator golay elements.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be dilated.<br />

º RegionDilation (output object) ........................................region(-array) Hobject *<br />

Dilated regions.<br />

º GolayElement (input control) .................................................string const char *<br />

Structuring element from the Golay alphabet.<br />

Default Value : ’h’<br />

Value List : GolayElement ¾’l’, ’d’, ’c’, ’f’, ’h’, ’k’<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let be the area of an input region. Then the runtime complexity for one region is:<br />

Ç´ÁØÖØÓÒ× ¡ ¾¼ ¡ Ô µ <br />

Result<br />

dilation seq returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input<br />

region can be set via:<br />

<strong>HALCON</strong> 6.0


396 CHAPTER 7. MORPHOLOGY<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

dilation seq is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

Alternatives<br />

dilation1, dilation2, dilation golay<br />

See Also<br />

erosion seq, hit or miss seq, thinning seq<br />

Morphology<br />

Module<br />

erosion1 ( Hobject Region, Hobject StructElement,<br />

Hobject *RegionErosion, long Iterations )<br />

Erode a region.<br />

erosion1 erodes the input regions with a structuring element. By applying erosion1 to a region, its boundary<br />

gets smoothed. In the process, the area of the region is reduced. Furthermore, connected regions may be split.<br />

Such regions, however, remain logically one region. The erosion is a set-theoretic region operation. It uses the<br />

intersection operation.<br />

Let Å (StructElement) andÊ (Region) be two regions, where Å is the structuring element and Ê is the<br />

region to be processed. Furthermore, let Ñ be a point in Å. Then the displacement vector Ú Ñ ´Ü ݵ is<br />

defined as the difference of the center of gravity of Å and the vector Ñ. LetØ ÚѴʵ denote the translation of a<br />

region Ê by a vector Ú. Then<br />

ÖÓ×ÓÒ½´Ê ŵ <br />

<br />

ѾÅ<br />

Ø Ú Ñ´Êµ<br />

For each point Ñ in Å a translation of the region Ê is performed. The intersection of all these translations is<br />

the erosion of Ê with Å. erosion1 is similar to the operator minkowski sub1, the difference is that in<br />

erosion1 the structuring element is mirrored at the origin. The position of StructElement is meaningless,<br />

since the displacement vectors are determined with respect to the center of gravity of Å.<br />

The parameter Iterations determines the number of iterations which are to be performed with the structuring<br />

element. The result of iteration Ò ½ is used as input for iteration Ò. From the above definition it follows that the<br />

maximum region is generated in case of an empty structuring element.<br />

Structuring elements (StructElement) can be generated with operators such as gen circle,<br />

gen rectangle1, gen rectangle2, gen ellipse, draw region, gen region polygon,<br />

gen region points,etc.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be eroded.<br />

º StructElement (input object) ...................................................region Hobject<br />

Structuring element.<br />

º RegionErosion (output object) ..........................................region(-array) Hobject *<br />

Eroded regions.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 397<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let ½ be the area of the input region, and ¾ be the area of the structuring element. Then the runtime complexity<br />

for one region is:<br />

Ç´Ô<br />

½ ¡<br />

Ô<br />

¾ ¡ ÁØÖØÓÒ×µ <br />

Result<br />

erosion1 returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input region<br />

can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

erosion1 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, watersheds, class ndim norm, gen circle, gen ellipse,<br />

gen rectangle1, gen rectangle2, draw region, gen region points,<br />

gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

connection, reduce domain, select shape, area center<br />

Alternatives<br />

minkowski sub1, minkowski sub2, erosion2, erosion golay, erosion seq<br />

transpose region<br />

Morphology<br />

See Also<br />

Module<br />

erosion2 ( Hobject Region, Hobject StructElement,<br />

Hobject *RegionErosion, long Row, long Column, long Iterations )<br />

Erode a region (using a reference point).<br />

erosion2 erodes the input regions with a structuring element (StructElement) having the reference point<br />

(Row,Column). erosion2 has a similar effect as erosion1, the difference is that the reference point of the<br />

structuring element can be chosen arbitrarily. The parameter Iterations determines the number of iterations<br />

which are to be performed with the structuring element. The result of iteration Ò ½ is used as input for iteration<br />

Ò.<br />

A maximum region is generated in case of an empty structuring element.<br />

Structuring elements (StructElement) can be generated with operators such as gen circle,<br />

gen rectangle1, gen rectangle2, gen ellipse, draw region, gen region polygon,<br />

gen region points,etc.<br />

<strong>HALCON</strong> 6.0


398 CHAPTER 7. MORPHOLOGY<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be eroded.<br />

º StructElement (input object) ...................................................region Hobject<br />

Structuring element.<br />

º RegionErosion (output object) ..........................................region(-array) Hobject *<br />

Eroded regions.<br />

º Row (input control) ...................................................................point.y long<br />

Row coordinate of the reference point.<br />

Default Value : 0<br />

Typical Range of Values : 0 Row 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Column (input control) ...............................................................point.x long<br />

Column coordinate of the reference point.<br />

Default Value : 0<br />

Typical Range of Values : 0 Column 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let ½ be the area of the input region, and ¾ be the area of the structuring element. Then the runtime complexity<br />

for one region is:<br />

Ç´Ô<br />

½ ¡<br />

Ô<br />

¾ ¡ ÁØÖØÓÒ×µ <br />

Result<br />

erosion2 returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input region<br />

can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

erosion2 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, watersheds, class ndim norm, gen circle, gen ellipse,<br />

gen rectangle1, gen rectangle2, draw region, gen region points,<br />

gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

Alternatives<br />

minkowski sub2, minkowski sub1, erosion1, erosion golay, erosion seq<br />

See Also<br />

transpose region, gen circle, gen rectangle2, gen region polygon<br />

Morphology<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 399<br />

erosion circle ( Hobject Region, Hobject *RegionErosion, double Radius )<br />

Erode a region with a circular structuring element.<br />

erosion circle applies a Minkowski subtraction with a circular structuring element to the input regions<br />

Region. Because the circular mask is symmetrical, this is identical to an erosion. The size of the circle used<br />

as structuring element is determined by Radius.<br />

The operator results in reduced regions, smoothed region boundaries, and the regions smaller than the circular<br />

mask are eliminated. It is useful to select only values like ¿, ,etc.forRadius in order to avoid a translation<br />

of a region, because integer radii result in a circle having a non-integer center of gravity which is rounded to the<br />

next integer.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be eroded.<br />

º RegionErosion (output object) ..........................................region(-array) Hobject *<br />

Eroded regions.<br />

º Radius (input control) .........................................................real double / long<br />

Radius of the circular structuring element.<br />

Default Value : 3.5<br />

Value Suggestions : Radius ¾1.5, 2.5, 3.5, 4.5, 5.5, 7.5, 9.5, 12.5, 15.5, 19.5, 25.5, 33.5, 45.5, 60.5,<br />

110.5<br />

Typical Range of Values : 0.5 Radius 511.5 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 1.0<br />

Example<br />

my_erosion_circle(Hobject In, double Radius, Hobject *Out)<br />

{<br />

Hobject Circle;<br />

gen_circle(&Circle,100.0,100.0,Radius);<br />

minkowski_sub1(In,Circle,Out,1);<br />

clear_obj(Circle);<br />

}<br />

Complexity<br />

Let ½ be the area of an input region. Then the runtime complexity for one region is:<br />

Ç´¾ ¡ ÊÙ× ¡ Ô ½µ <br />

Result<br />

erosion circle returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

erosion circle is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, watersheds, class ndim norm<br />

Possible Successor Functions<br />

connection, reduce domain, select shape, area center<br />

minkowski sub1<br />

Alternatives<br />

<strong>HALCON</strong> 6.0


400 CHAPTER 7. MORPHOLOGY<br />

See Also<br />

gen circle, dilation circle, closing circle, opening circle<br />

Morphology<br />

Module<br />

erosion golay ( Hobject Region, Hobject *RegionErosion,<br />

const char *GolayElement, long Iterations, long Rotation )<br />

Erode a region with an element from the Golay alphabet.<br />

erosion golay erodes a region with the selected element GolayElement from the Golay alphabet. The<br />

following structuring elements are available:<br />

’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’.<br />

The rotation number Rotation determines which rotation of the element should be used, and whether the foreground<br />

(even) or background version (odd) of the selected element should be used. The Golay elements, together<br />

with all possible rotations, are described with the operator golay elements. The operator works by shifting<br />

the structuring element over the region to be processed (Region). For all positions of the structuring element<br />

fully contained in the region, the corresponding reference point (relative to the structuring element) is added to the<br />

output region. This means that the intersection of all translations of the structuring element within the region is<br />

computed.<br />

The parameter Iterations determines the number of iterations which are to be performed with the structuring<br />

element. The result of iteration Ò ½ is used as input for iteration Ò.<br />

Attention<br />

Not all values of Rotation are valid for any Golay element. For some of the values of Rotation, the resulting<br />

regions are identical to the input regions.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be eroded.<br />

º RegionErosion (output object) ..........................................region(-array) Hobject *<br />

Eroded regions.<br />

º GolayElement (input control) .................................................string const char *<br />

Structuring element from the Golay alphabet.<br />

Default Value : ’h’<br />

Value List : GolayElement ¾’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Rotation (input control) ............................................................integer long<br />

Rotation of the Golay elementḊepending on the element, not all rotations are valid.<br />

Default Value : 0<br />

Value List : Rotation ¾0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15<br />

Complexity<br />

Let be the area of an input region. Then the runtime complexity for one region is:<br />

Ç´¿ ¡ Ô µ <br />

Result<br />

erosion golay returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input<br />

region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 401<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

erosion golay is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

erosion seq, erosion1, erosion2<br />

Alternatives<br />

See Also<br />

dilation golay, opening golay, closing golay, hit or miss golay, thinning golay,<br />

thickening golay, golay elements<br />

Morphology<br />

Module<br />

erosion rectangle1 ( Hobject Region, Hobject *RegionErosion,<br />

long Width, long Height )<br />

Erode a region with a rectangular structuring element.<br />

erosion rectangle1 applies an erosion with a rectangular structuring element to the input regions Region.<br />

The size of the structuring rectangle is Width ¢ Height. The operator results in reduced regions, and the areas<br />

smaller than the rectangular mask are eliminated.<br />

erosion rectangle1 is a very fast operation because the height of the rectangle enters only logarithmically<br />

into the runtime complexity, while the width does not enter at all. This leads to excellent runtime efficiency, even<br />

in the case of very large rectangles (edge length 100).<br />

Regions containing small connecting strips between large areas are separated only seemingly. They remain logically<br />

one region.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be eroded.<br />

º RegionErosion (output object) ..........................................region(-array) Hobject *<br />

Eroded regions.<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the structuring rectangle.<br />

Default Value : 10<br />

Value Suggestions : Width ¾1, 2, 3, 4, 6, 10, 15, 20, 30, 50, 70, 100<br />

Typical Range of Values : 1 Width 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the structuring rectangle.<br />

Default Value : 10<br />

Value Suggestions : Height ¾1, 2, 3, 4, 6, 10, 15, 20, 30, 50, 70, 100<br />

Typical Range of Values : 1 Height 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let ½ be the area of an input region and À be the height of the rectangle. Then the runtime complexity for one<br />

region is:<br />

Ô<br />

Ç´ ½ ¡ дÀµµ <br />

<strong>HALCON</strong> 6.0


402 CHAPTER 7. MORPHOLOGY<br />

Result<br />

erosion rectangle1 returns H MSG TRUE if all parameters are correct. The behavior in case of empty or<br />

no input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

erosion rectangle1 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

erosion1, minkowski sub1<br />

gen rectangle1<br />

Morphology<br />

Alternatives<br />

See Also<br />

Module<br />

erosion seq ( Hobject Region, Hobject *RegionErosion,<br />

const char *GolayElement, long Iterations )<br />

Erode a region sequentially.<br />

erosion seq computes the sequential erosion of the input region Region with the selected structuring element<br />

GolayElement from the Golay alphabet. This is done by executing the operator erosion golay with all<br />

rotations of the structuring element Iterations times. The following structuring elements can be selected:<br />

’l’, ’d’, ’c’, ’f’, ’h’, ’k’.<br />

Only the “foreground elements” (even rotation numbers) are used. The elements ’i’ and ’e’ result in unchanged<br />

output regions. The elements ’l’, ’m’ and ’f2’ are identical for the foreground. The Golay elements, together with<br />

all possible rotations, are described with the operator golay elements.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be eroded.<br />

º RegionErosion (output object) ..........................................region(-array) Hobject *<br />

Eroded regions.<br />

º GolayElement (input control) .................................................string const char *<br />

Structuring element from the Golay alphabet.<br />

Default Value : ’h’<br />

Value List : GolayElement ¾’l’, ’d’, ’c’, ’f’, ’h’, ’k’<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let be the area of an input region. Then the runtime complexity for one region is:<br />

Ç´ÁØÖØÓÒ× ¡ ¾¼ ¡ Ô µ <br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 403<br />

Result<br />

erosion seq returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input<br />

region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

erosion seq is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, watersheds, class ndim norm<br />

Possible Successor Functions<br />

connection, reduce domain, select shape, area center<br />

erosion golay, erosion1, erosion2<br />

Alternatives<br />

See Also<br />

dilation seq, hit or miss seq, thinning seq<br />

Morphology<br />

Module<br />

fitting ( Hobject Region, Hobject StructElements,<br />

Hobject *RegionFitted )<br />

Perform a closing after an opening with multiple structuring elements.<br />

fitting performs an opening and a closing successively on the input regions. The eight structuring elements<br />

normally used for this operation can be generated with the operator gen struct elements. However,<br />

other user-defined structuring elements can also be used. Let Ê be the input region(s) and let Å denote the structuring<br />

elements. Furthermore, let È be the result of the opening and É be the final result. Then the operator can<br />

be formalized as follows:<br />

È<br />

É<br />

<br />

<br />

Ò<br />

Ò<br />

½<br />

½<br />

´Ê Æ Å µ<br />

´È ¯ Å µ<br />

Regions larger than the structuring elements are preserved, while small gaps are closed.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º StructElements (input object) ...........................................region(-array) Hobject<br />

Structuring elements.<br />

º RegionFitted (output object) ...........................................region(-array) Hobject *<br />

Fitted regions.<br />

Result<br />

fitting returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input region<br />

can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

<strong>HALCON</strong> 6.0


404 CHAPTER 7. MORPHOLOGY<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

fitting is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen struct elements, gen region points<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

Alternatives<br />

opening, closing, connection, select shape<br />

Morphology<br />

Module<br />

gen struct elements ( Hobject *StructElements, const char *Type,<br />

long Row, long Column )<br />

Generate standard structuring elements.<br />

gen struct elements serves to generate eight structuring elements normally used in the operator fitting.<br />

The default value ’noise’ of the parameter Type generates elements especially suited for the elimination of noise.<br />

<br />

<br />

Ü<br />

<br />

<br />

Ü<br />

Ü<br />

<br />

Ü Ü Ü<br />

<br />

Ü<br />

<br />

<br />

Ü<br />

<br />

<br />

Ü<br />

<br />

<br />

<br />

Ü<br />

<br />

Ü<br />

<br />

<br />

Ü<br />

Å ½<br />

Å ¾<br />

Å ¿<br />

Å <br />

<br />

<br />

Ü <br />

Ü <br />

Ü Ü <br />

Ü Ü<br />

Ü Ü <br />

Ü Ü<br />

Ü <br />

Ü <br />

<br />

<br />

Å <br />

Å <br />

Parameter<br />

Å <br />

Å <br />

º StructElements (output object) ........................................region(-array) Hobject *<br />

Generated structuring elements.<br />

º Type (input control) ............................................................string const char *<br />

Type of structuring element to generate.<br />

Default Value : ’noise’<br />

Value List : Type ¾’noise’<br />

º Row (input control) ...................................................................point.y long<br />

Row coordinate of the reference point.<br />

Default Value : 1<br />

Value Suggestions : Row ¾0, 1, 10, 50, 100, 200, 300, 400<br />

Typical Range of Values : ½ Row ½(lin)<br />

º Column (input control) ...............................................................point.x long<br />

Column coordinate of the reference point.<br />

Default Value : 1<br />

Value Suggestions : Column ¾0, 1, 10, 50, 100, 200, 300, 400<br />

Typical Range of Values : ½ Column ½(lin)<br />

Result<br />

gen struct elements returns H MSG TRUE if all parameters are correct. Otherwise, an exception is raised.<br />

Parallelization Information<br />

gen struct elements is reentrant and processed without parallelization.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 405<br />

Possible Successor Functions<br />

fitting, hit or miss, opening, closing, erosion2, dilation2<br />

golay elements<br />

Morphology<br />

See Also<br />

Module<br />

golay elements ( Hobject *StructElement1, Hobject *StructElement2,<br />

const char *GolayElement, long Rotation, long Row, long Column )<br />

Generate the structuring elements of the Golay alphabet.<br />

golay elements generates the structuring elements from the Golay alphabet. The parameter GolayElement<br />

determines the name of the structuring element, while Rotation determines its rotation. The structuring elements<br />

are intended for use in hit or miss: In StructElement1 the structuring element for the foreground is<br />

returned, while in StructElement2 the structuring element for the background is returned. Row and Column<br />

determine the reference point of the structuring element.<br />

The rotations are numbered from 0 to 15. This does not mean, however, that there are 16 different rotations: Even<br />

values denote rotations of the foreground elements, while odd values denote rotations of the background elements.<br />

For golay elements only even values are accepted, and determine the Golay element for StructElement1.<br />

The next larger odd value is used for StructElement2. There are no rotations for the Golay elements ’h’ and ’i’.<br />

Therefore, only the values 0 and 1 are possible as “rotations” (and hence only 0 for golay elements). The element<br />

’e’ has only four possible rotations, and hence the rotation must be between 0 and 7 (for golay elements<br />

thevalues0,2,4,or6mustbeused).<br />

The tables below show the elements of the Golay alphabet with all possible rotations. The characters used have<br />

the following meaning:<br />

¯ Foreground pixel<br />

Æ Background pixel<br />

¡ Don’t care pixel<br />

The names of the elements and their rotation numbers are displayed below the respective element. The elements<br />

with even number contain the foreground pixels, while the elements with odd numbers contain the background<br />

pixels.<br />

¯ ¯ ¯<br />

¯ ¯ ¯<br />

¯ ¯ ¯<br />

h(0,1)<br />

Æ Æ Æ<br />

Æ Æ Æ<br />

Æ Æ Æ<br />

i(0,1)<br />

¡ ¡ ¡<br />

Æ ¯ Æ<br />

Æ Æ Æ<br />

e(0,1)<br />

Æ Æ ¡<br />

Æ ¯ ¡<br />

Æ Æ ¡<br />

e(2,3)<br />

Æ Æ Æ<br />

Æ ¯ Æ<br />

¡ ¡ ¡<br />

e(4,5)<br />

¡ Æ Æ<br />

¡ ¯ Æ<br />

¡ Æ Æ<br />

e(6,7)<br />

Æ Æ Æ<br />

¡ ¯ ¡<br />

¯ ¯ ¯<br />

l(0,1)<br />

Æ<br />

¡ ¡ Æ<br />

¯ ¡ ¯ ¡ Æ<br />

¯ ¡ ¡<br />

¯<br />

l(2,3)<br />

¯ ¡ Æ<br />

¯ ¯ Æ<br />

¯ ¡ Æ<br />

l(4,5)<br />

¯<br />

¯ ¡ ¡<br />

¯ ¡ ¯ ¡ Æ<br />

¡ ¡ Æ<br />

Æ<br />

l(6,7)<br />

<strong>HALCON</strong> 6.0


406 CHAPTER 7. MORPHOLOGY<br />

¯ ¯ ¯<br />

¡ ¯ ¡<br />

Æ Æ Æ<br />

l(8,9)<br />

¯<br />

¡ ¡ ¯<br />

Æ ¡ ¯ ¡ ¯<br />

Æ ¡ ¡<br />

Æ<br />

l(10,11)<br />

Æ ¡ ¯<br />

Æ ¯ ¯<br />

Æ ¡ ¯<br />

l(12,13)<br />

Æ<br />

Æ ¡ ¡<br />

Æ ¡ ¯ ¯<br />

¡ ¡ ¯<br />

¯<br />

l(14,15)<br />

¯ ¡ ¡<br />

¯ ¯ Æ<br />

¯ ¡ ¡<br />

m(0,1)<br />

¯<br />

¯ ¡ ¡<br />

¯ ¡ ¯ ¡ ¡<br />

¡ ¡ Æ<br />

¡<br />

m(2,3)<br />

¯ ¯ ¯<br />

¡ ¯ ¡<br />

¡ Æ ¡<br />

m(4,5)<br />

¯<br />

¡ ¡ ¯<br />

¡ ¡ ¯ ¡ ¯<br />

Æ ¡ ¡<br />

¡<br />

m(6,7)<br />

¡ ¡ ¯<br />

Æ ¯ ¯<br />

¡ ¡ ¯<br />

m(8,9)<br />

¡<br />

Æ ¡ ¡<br />

¡ ¡ ¯ ¡ ¯<br />

¡ ¡ ¯<br />

¯<br />

m(10,11)<br />

¡ Æ ¡<br />

¡ ¯ ¡<br />

¯ ¯ ¯<br />

m(12,13)<br />

¡<br />

¡ ¡ Æ<br />

¯ ¡ ¯ ¡ ¡<br />

¯ ¡ ¡<br />

¯<br />

m(14,15)<br />

Æ ¡ ¡<br />

Æ ¯ ¯<br />

Æ ¡ ¡<br />

d(0,1)<br />

Æ<br />

Æ ¡ ¡<br />

Æ ¡ ¯ ¡ ¡<br />

¡ ¡ ¯<br />

¡<br />

d(2,3)<br />

Æ Æ Æ<br />

¡ ¯ ¡<br />

¡ ¯ ¡<br />

d(4,5)<br />

Æ<br />

¡ ¡ Æ<br />

¡ ¡ ¯ ¡ Æ<br />

¯ ¡ ¡<br />

¡<br />

d(6,7)<br />

¡ ¡ Æ<br />

¯ ¯ Æ<br />

¡ ¡ Æ<br />

d(8,9)<br />

¡<br />

¯ ¡ ¡<br />

¡ ¡ ¯ ¡ Æ<br />

¡ ¡ Æ<br />

Æ<br />

d(10,11)<br />

¡ ¯ ¡<br />

¡ ¯ ¡<br />

Æ Æ Æ<br />

d(12,13)<br />

¡<br />

¡ ¡ ¯<br />

Æ ¡ ¯ ¡ ¡<br />

Æ ¡ ¡<br />

Æ<br />

d(14,15)<br />

¯ Æ Æ<br />

Æ ¯ ¯<br />

¯ Æ Æ<br />

f(0,1)<br />

¯<br />

Æ ¯ Æ<br />

¯ ¯ ¯ ¡ Æ<br />

Æ ¡ ¯<br />

Æ<br />

f(2,3)<br />

¯ Æ ¯<br />

Æ ¯ Æ<br />

Æ ¯ Æ<br />

f(4,5)<br />

¯<br />

Æ ¯ Æ<br />

Æ ¡ ¯ ¯ ¯<br />

¯ ¡ Æ<br />

Æ<br />

f(6,7)<br />

Æ Æ ¯<br />

¯ ¯ Æ<br />

Æ Æ ¯<br />

f(8,9)<br />

Æ<br />

¯ ¡ Æ<br />

Æ ¡ ¯ ¯ ¯<br />

Æ ¯ Æ<br />

¯<br />

f(10,11)<br />

Æ ¯ Æ<br />

Æ ¯ Æ<br />

¯ Æ ¯<br />

f(12,13)<br />

Æ<br />

Æ ¡ ¯<br />

¯ ¯ ¯ ¡ Æ<br />

Æ ¯ Æ<br />

¯<br />

f(14,15)<br />

¯ ¯ ¯<br />

Æ ¯ Æ<br />

Æ Æ Æ<br />

f2(0,1)<br />

¯<br />

Æ ¡ ¯<br />

Æ ¡ ¯ ¡ ¯<br />

Æ ¡ Æ<br />

Æ<br />

f2(2,3)<br />

Æ Æ ¯<br />

Æ ¯ ¯<br />

Æ Æ ¯<br />

f2(4,5)<br />

Æ<br />

Æ ¡ Æ<br />

Æ ¡ ¯ ¡ ¯<br />

Æ ¡ ¯<br />

¯<br />

f2(6,7)<br />

Æ Æ Æ<br />

Æ ¯ Æ<br />

¯ ¯ ¯<br />

f2(8,9)<br />

Æ<br />

Æ ¡ Æ<br />

¯ ¡ ¯ ¡ Æ<br />

¯ ¡ Æ<br />

¯<br />

f2(10,11)<br />

¯ Æ Æ<br />

¯ ¯ Æ<br />

¯ Æ Æ<br />

f2(12,13)<br />

¯<br />

¯ ¡ Æ<br />

¯ ¡ ¯ ¡ Æ<br />

Æ ¡ Æ<br />

Æ<br />

f2(14,15)<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 407<br />

¯ ¯ Æ<br />

¡ ¯ ¡<br />

¡ ¡ ¡<br />

k(0,1)<br />

¯<br />

¡ ¡ ¯<br />

¡ ¡ ¯ ¡ Æ<br />

¡ ¡ ¡<br />

¡<br />

k(2,3)<br />

¡ ¡ ¯<br />

¡ ¯ ¯<br />

¡ ¡ Æ<br />

k(4,5)<br />

¡<br />

¡ ¡ ¡<br />

¡ ¡ ¯ ¡ ¯<br />

¡ ¡ ¯<br />

Æ<br />

k(6,7)<br />

¡ ¡ ¡<br />

¡ ¯ ¡<br />

Æ ¯ ¯<br />

k(8,9)<br />

¡<br />

¡ ¡ ¡<br />

Æ ¡ ¯ ¡ ¡<br />

¯ ¡ ¡<br />

¯<br />

k(10,11)<br />

Æ ¡ ¡<br />

¯ ¯ ¡<br />

¯ ¡ ¡<br />

k(12,13)<br />

Æ<br />

¯ ¡ ¡<br />

¯ ¡ ¯ ¡ ¡<br />

¡ ¡ ¡<br />

¡<br />

k(14,15)<br />

¯ ¡ ¡<br />

¯ Æ ¡<br />

¯ ¡ ¡<br />

c(0,1)<br />

¯<br />

¯ ¡ ¡<br />

¯ ¡ Æ ¡ ¡<br />

¡ ¡ ¡<br />

¡<br />

c(2,3)<br />

¯ ¯ ¯<br />

¡ Æ ¡<br />

¡ ¡ ¡<br />

c(4,5)<br />

¯<br />

¡ ¡ ¯<br />

¡ ¡ Æ ¡ ¯<br />

¡ ¡ ¡<br />

¡<br />

c(6,7)<br />

¡ ¡ ¯<br />

¡ Æ ¯<br />

¡ ¡ ¯<br />

c(8,9)<br />

¡<br />

¡ ¡ ¡<br />

¡ ¡ Æ ¯<br />

¡ ¡ ¯<br />

¯<br />

c(10,11)<br />

¡ ¡ ¡<br />

¡ Æ ¡<br />

¯ ¯ ¯<br />

c(12,13)<br />

¡<br />

¡ ¡ ¡<br />

¯ Æ ¡ ¡<br />

¯ ¡ ¡<br />

¯<br />

c(14,15)<br />

Parameter<br />

º StructElement1 (output object) ...............................................region Hobject *<br />

Structuring element for the foreground.<br />

º StructElement2 (output object) ...............................................region Hobject *<br />

Structuring element for the background.<br />

º GolayElement (input control) .................................................string const char *<br />

Name of the structuring element.<br />

Default Value : ’l’<br />

Value List : GolayElement ¾’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’<br />

º Rotation (input control) ............................................................integer long<br />

Rotation of the Golay elementḊepending on the element, not all rotations are valid.<br />

Default Value : 0<br />

Value List : Rotation ¾0, 2, 4, 6, 8, 10, 12, 14<br />

º Row (input control) ...................................................................point.y long<br />

Row coordinate of the reference point.<br />

Default Value : 16<br />

Value Suggestions : Row ¾0, 16, 32, 128, 256<br />

Typical Range of Values : 0 Row 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Column (input control) ...............................................................point.x long<br />

Column coordinate of the reference point.<br />

Default Value : 16<br />

Value Suggestions : Column ¾0, 16, 32, 128, 256<br />

Typical Range of Values : 0 Column 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Result<br />

golay elements returns H MSG TRUE if all parameters are correct. Otherwise, an exception is raised.<br />

Parallelization Information<br />

golay elements is reentrant and processed without parallelization.<br />

<strong>HALCON</strong> 6.0


408 CHAPTER 7. MORPHOLOGY<br />

hit or miss<br />

Possible Successor Functions<br />

Alternatives<br />

gen region points, gen struct elements, gen region polygon filled<br />

See Also<br />

dilation golay, erosion golay, opening golay, closing golay, hit or miss golay,<br />

thickening golay<br />

Bibliography<br />

J. Serra: ”‘Image Analysis and Mathematical Morphology”’. Volume I. Academic Press, 1982<br />

Module<br />

Morphology<br />

hit or miss ( Hobject Region, Hobject StructElement1,<br />

Hobject StructElement2, Hobject *RegionHitMiss, long Row, long Column )<br />

Hit-or-miss operation for regions.<br />

hit or miss performs the hit-or-miss-transformation. First, an erosion with the structuring element<br />

StructElement1 is done on the input region Region. Then an erosion with the structuring element<br />

StructElement2 is performed on the complement of the input region. The intersection of the two resulting<br />

regions is the result RegionHitMiss of hit or miss.<br />

The hit-or-miss-transformation selects precisely the points for which the conditions given by the structuring elements<br />

StructElement1 and StructElement2 are fulfilled. StructElement1 determines the condition<br />

for the foreground pixels, while StructElement2 determines the condition for the background pixels. In order<br />

to obtain sensible results, StructElement1 and StructElement2 must fit like key and lock. In any case,<br />

StructElement1 and StructElement2 must be disjunct. Row and Column determine the reference point<br />

of the structuring elements.<br />

Structuring elements (StructElement1, StructElement2) can be generated by calling operators like<br />

gen struct elements, gen region points,etc.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º StructElement1 (input object) ..................................................region Hobject<br />

Erosion mask for the input regions.<br />

º StructElement2 (input object) ..................................................region Hobject<br />

Erosion mask for the complements of the input regions.<br />

º RegionHitMiss (output object) ..........................................region(-array) Hobject *<br />

Result of the hit-or-miss operation.<br />

º Row (input control) ...................................................................point.y long<br />

Row coordinate of the reference point.<br />

Default Value : 16<br />

Value Suggestions : Row ¾0, 16, 32, 128, 256<br />

Typical Range of Values : 0 Row 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Column (input control) ...............................................................point.x long<br />

Column coordinate of the reference point.<br />

Default Value : 16<br />

Value Suggestions : Column ¾0, 16, 32, 128, 256<br />

Typical Range of Values : 0 Column 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let be the area of an input region, ½ the area of the structuring element 1, and ¾ theareaofthestructuring<br />

element 2. Then the runtime complexity for one object is:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 409<br />

Ô Ô <br />

Ç ¡ ½·Ô<br />

¾<br />

<br />

Result<br />

hit or miss returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input<br />

region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

hit or miss is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

golay elements, gen struct elements, threshold, regiongrowing, connection, union1,<br />

watersheds, class ndim norm<br />

Possible Successor Functions<br />

difference, reduce domain, select shape, area center, connection<br />

Alternatives<br />

hit or miss golay, hit or miss seq, erosion2, dilation2<br />

See Also<br />

thinning, thickening, gen region points, gen region polygon filled<br />

Morphology<br />

Module<br />

hit or miss golay ( Hobject Region, Hobject *RegionHitMiss,<br />

const char *GolayElement, long Rotation )<br />

Hit-or-miss operation for regions using the Golay alphabet.<br />

hit or miss golay performs the hit-or-miss-transformation for the input regions Region (using structuring<br />

elements from the Golay alphabet). First, an erosion with the foreground of the structuring element<br />

GolayElement is done on the input region Region. Then an erosion with the background of the structuring<br />

element GolayElement is performed on the complement of the input region. The intersection of the two<br />

resulting regions is the result RegionHitMiss of hit or miss golay. The following structuring elements<br />

are available:<br />

’l’, ’m’, ’d’, ’c’, ’e’,’i’, ’f’, ’f2’, ’h’, ’k’.<br />

The rotation number Rotation determines which rotation of the element should be used. The hit-or-misstransformation<br />

selects precisely the points for which the conditions given by the selected Golay element are fulfilled.<br />

Attention<br />

Not all values of Rotation are valid for any Golay element.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º RegionHitMiss (output object) ..........................................region(-array) Hobject *<br />

Result of the hit-or-miss operation.<br />

º GolayElement (input control) .................................................string const char *<br />

Structuring element from the Golay alphabet.<br />

Default Value : ’h’<br />

Value List : GolayElement ¾’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’<br />

<strong>HALCON</strong> 6.0


410 CHAPTER 7. MORPHOLOGY<br />

º Rotation (input control) ............................................................integer long<br />

Rotation of the Golay elementḊepending on the element, not all rotations are valid.<br />

Default Value : 0<br />

Value List : Rotation ¾0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15<br />

Complexity<br />

Let be the area of an input region. Then the runtime complexity for one region is:<br />

Ç´ ¡ Ô µ <br />

Result<br />

hit or miss golay returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

hit or miss golay is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

hit or miss seq, hit or miss<br />

Alternatives<br />

See Also<br />

erosion golay, dilation golay, opening golay, closing golay, thinning golay,<br />

thickening golay, golay elements<br />

Morphology<br />

Module<br />

hit or miss seq ( Hobject Region, Hobject *RegionHitMiss,<br />

const char *GolayElement )<br />

Hit-or-miss operation for regions using the Golay alphabet (sequential).<br />

hit or miss golay performs the hit-or-miss-transformation for the input regions Region using all rotations<br />

of a structuring element from the Golay alphabet. The result of the operator is the union of all intermediate results<br />

of the respective rotations. The following structuring elements are available:<br />

’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’.<br />

The Golay elements, together with all possible rotations, are described with the operator golay elements.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º RegionHitMiss (output object) ..........................................region(-array) Hobject *<br />

Result of the hit-or-miss operation.<br />

º GolayElement (input control) .................................................string const char *<br />

Structuring element from the Golay alphabet.<br />

Default Value : ’h’<br />

Value List : GolayElement ¾’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’<br />

Complexity<br />

Let be the area of an input region, and Ê be the number of rotations. Then the runtime complexity for one region<br />

is:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 411<br />

Ç´Ê ¡ ¡ Ô µ <br />

Result<br />

hit or miss seq returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

hit or miss seq is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

hit or miss golay, hit or miss<br />

thinning seq, thickening seq<br />

Morphology<br />

Alternatives<br />

See Also<br />

Module<br />

minkowski add1 ( Hobject Region, Hobject StructElement,<br />

Hobject *RegionMinkAdd, long Iterations )<br />

Perform a Minkowski addition on a region.<br />

minkowski add1 dilates the input regions with a structuring element. By applying minkowski add1 to a<br />

region, its boundary gets smoothed. In the process, the area of the region is enlarged. Furthermore, disconnected<br />

regions may be merged. Such regions, however, remain logically distinct region. The Minkowski addition is a<br />

set-theoretic region operation. It is based on translations and union operations.<br />

Let Å (StructElement) andÊ (Region) be two regions, where Å is the structuring element and Ê is the<br />

region to be processed. Furthermore, let Ñ be a point in Å. Then the displacement vector Ú Ñ ´Ü ݵ is<br />

defined as the difference of the center of gravity of Å and the vector Ñ. LetØ ÚѴʵ denote the translation of a<br />

region Ê by a vector Ú. Then<br />

ÑÒÓÛ× ½´Ê ŵ <br />

<br />

ѾÅ<br />

Ø ÚÑ ´Êµ<br />

For each point Ñ in Å a translation of the region Ê is performed. The union of all these translations is the<br />

Minkowski addition of Ê with Å. minkowski add1 is similar to the operator dilation1, the difference<br />

is that in dilation1 the structuring element is mirrored at the origin. The position of StructElement is<br />

meaningless, since the displacement vectors are determined with respect to the center of gravity of Å.<br />

The parameter Iterations determines the number of iterations which are to be performed with the structuring<br />

element. The result of iteration Ò ½ is used as input for iteration Ò. From the above definition it follows that an<br />

empty region is generated in case of an empty structuring element.<br />

Structuring elements (StructElement) can be generated with operators such as gen circle,<br />

gen rectangle1, gen rectangle2, gen ellipse, draw region, gen region polygon,<br />

gen region points,etc.<br />

Attention<br />

A Minkowski addition always results in enlarged regions. Closely spaced regions which may touch or overlap as<br />

<strong>HALCON</strong> 6.0


412 CHAPTER 7. MORPHOLOGY<br />

a result of the dilation are still treated as two separate regions. If the desired behavior is to merge them into one<br />

region, the operator union1 has to be called first.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be dilated.<br />

º StructElement (input object) ...................................................region Hobject<br />

Structuring element.<br />

º RegionMinkAdd (output object) ..........................................region(-array) Hobject *<br />

Dilated regions.<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let ½ be the area of the input region, and ¾ be the area of the structuring element. Then the runtime complexity<br />

for one region is:<br />

Ç´Ô<br />

½ ¡<br />

Ô<br />

¾ ¡ ÁØÖØÓÒ×µ <br />

Result<br />

minkowski add1 returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

minkowski add1 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm,<br />

gen circle, gen ellipse, gen rectangle1, gen rectangle2, draw region,<br />

gen region points, gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

minkowski add2, dilation1<br />

transpose region, minkowski sub1<br />

Morphology<br />

Alternatives<br />

See Also<br />

Module<br />

minkowski add2 ( Hobject Region, Hobject StructElement,<br />

Hobject *RegionMinkAdd, long Row, long Column, long Iterations )<br />

Dilate a region (using a reference point).<br />

minkowski add2 computes the Minkowski addition of the input regions with a structuring element<br />

(StructElement) having the reference point (Row,Column). minkowski add2 has a similar effect as<br />

minkowski add1, the difference is that the reference point of the structuring element can be chosen arbitrarily.<br />

The parameter Iterations determines the number of iterations which are to be performed with the structuring<br />

element. The result of iteration Ò ½ is used as input for iteration Ò.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 413<br />

An empty region is generated in case of an empty structuring element.<br />

Structuring elements (StructElement) can be generated with operators such as gen circle,<br />

gen rectangle1, gen rectangle2, gen ellipse, draw region, gen region polygon,<br />

gen region points,etc.<br />

Attention<br />

A Minkowski addition always results in enlarged regions. Closely spaced regions which may touch or overlap as<br />

a result of the dilation are still treated as two separate regions. If the desired behavior is to merge them into one<br />

region, the operator union1 has to be called first.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be dilated.<br />

º StructElement (input object) ...................................................region Hobject<br />

Structuring element.<br />

º RegionMinkAdd (output object) ..........................................region(-array) Hobject *<br />

Dilated regions.<br />

º Row (input control) ...................................................................point.y long<br />

Row coordinate of the reference point.<br />

Typical Range of Values : 1 Row 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Column (input control) ...............................................................point.x long<br />

Column coordinate of the reference point.<br />

Typical Range of Values : 1 Column 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let ½ be the area of the input region, and ¾ be the area of the structuring element. Then the runtime complexity<br />

for one region is:<br />

Ç´Ô<br />

½ ¡<br />

Ô<br />

¾ ¡ ÁØÖØÓÒ×µ <br />

Result<br />

minkowski add2 returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

minkowski add2 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm,<br />

gen circle, gen ellipse, gen rectangle1, gen rectangle2, draw region,<br />

gen region points, gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

<strong>HALCON</strong> 6.0


414 CHAPTER 7. MORPHOLOGY<br />

minkowski add1, dilation1<br />

transpose region<br />

Morphology<br />

Alternatives<br />

See Also<br />

Module<br />

minkowski sub1 ( Hobject Region, Hobject StructElement,<br />

Hobject *RegionMinkSub, long Iterations )<br />

Erode a region.<br />

minkowski sub1 computes the Minkowski subtraction of the input regions with a structuring element. By<br />

applying minkowski sub1 to a region, its boundary gets smoothed. In the process, the area of the region is<br />

reduced. Furthermore, connected regions may be split. Such regions, however, remain logically one region. The<br />

Minkowski subtraction is a set-theoretic region operation. It uses the intersection operation.<br />

Let Å (StructElement) andÊ (Region) be two regions, where Å is the structuring element and Ê is the<br />

region to be processed. Furthermore, let Ñ be a point in Å. Then the displacement vector Ú Ñ ´Ü ݵ is<br />

defined as the difference of the center of gravity of Å and the vector Ñ. LetØ ÚѴʵ denote the translation of a<br />

region Ê by a vector Ú. Then<br />

ÑÒÓÛ× ×Ù½´Ê ŵ <br />

<br />

ѾÅ<br />

Ø ÚÑ ´Êµ<br />

For each point Ñ in Å a translation of the region Ê is performed. The intersection of all these translations is the<br />

Minkowski subtraction of Ê with Å. minkowski sub1 is similar to the operator erosion1, the difference<br />

is that in erosion1 the structuring element is mirrored at the origin. The position of StructElement is<br />

meaningless, since the displacement vectors are determined with respect to the center of gravity of Å.<br />

The parameter Iterations determines the number of iterations which are to be performed with the structuring<br />

element. The result of iteration Ò ½ is used as input for iteration Ò. From the above definition it follows that the<br />

maximum region is generated in case of an empty structuring element.<br />

Structuring elements (StructElement) can be generated with operators such as gen circle,<br />

gen rectangle1, gen rectangle2, gen ellipse, draw region, gen region polygon,<br />

gen region points,etc.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be eroded.<br />

º StructElement (input object) ...................................................region Hobject<br />

Structuring element.<br />

º RegionMinkSub (output object) ..........................................region(-array) Hobject *<br />

Eroded regions.<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let ½ be the area of the input region, and ¾ be the area of the structuring element. Then the runtime complexity<br />

for one region is:<br />

Ç´Ô<br />

½ ¡<br />

Ô<br />

¾ ¡ ÁØÖØÓÒ×µ <br />

Result<br />

minkowski sub1 returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 415<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

minkowski sub1 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm,<br />

gen circle, gen ellipse, gen rectangle1, gen rectangle2, draw region,<br />

gen region points, gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

minkowski sub2, erosion1<br />

transpose region<br />

Morphology<br />

Alternatives<br />

See Also<br />

Module<br />

minkowski sub2 ( Hobject Region, Hobject StructElement,<br />

Hobject *RegionMinkSub, long Row, long Column, long Iterations )<br />

Erode a region (using a reference point).<br />

minkowski sub2 computes the Minkowski subtraction of the input regions with a structuring element<br />

(StructElement) having the reference point (Row,Column). minkowski sub2 has a similar effect as<br />

minkowski sub1, the difference is that the reference point of the structuring element can be chosen arbitrarily.<br />

The parameter Iterations determines the number of iterations which are to be performed with the structuring<br />

element. The result of iteration Ò ½ is used as input for iteration Ò.<br />

A maximum region is generated in case of an empty structuring element.<br />

Structuring elements (StructElement) can be generated with operators such as gen circle,<br />

gen rectangle1, gen rectangle2, gen ellipse, draw region, gen region polygon,<br />

gen region points,etc.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be eroded.<br />

º StructElement (input object) ...................................................region Hobject<br />

Structuring element.<br />

º RegionMinkSub (output object) ..........................................region(-array) Hobject *<br />

Eroded regions.<br />

º Row (input control) ...................................................................point.y long<br />

Row coordinate of the reference point.<br />

Default Value : 0<br />

Value Suggestions : Row ¾0, 10, 16, 32, 64, 100, 128<br />

Typical Range of Values : 0 Row 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Column (input control) ...............................................................point.x long<br />

Column coordinate of the reference point.<br />

Default Value : 0<br />

Value Suggestions : Column ¾0, 10, 16, 32, 64, 100, 128<br />

Typical Range of Values : 0 Column 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

<strong>HALCON</strong> 6.0


416 CHAPTER 7. MORPHOLOGY<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let ½ be the area of the input region, and ¾ be the area of the structuring element. Then the runtime complexity<br />

for one region is:<br />

Ç´Ô<br />

½ ¡<br />

Ô<br />

¾ ¡ ÁØÖØÓÒ×µ <br />

Result<br />

minkowski sub2 returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

minkowski sub2 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, watersheds, class ndim norm, gen circle, gen ellipse,<br />

gen rectangle1, gen rectangle2, draw region, gen region points,<br />

gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

Alternatives<br />

minkowski sub1, erosion1, erosion2, erosion golay, erosion seq<br />

See Also<br />

gen circle, gen rectangle2, gen region polygon<br />

Morphology<br />

Module<br />

morph hat ( Hobject Region, Hobject StructElement,<br />

Hobject *RegionTopHat )<br />

Compute the union of bottom hat and top hat.<br />

morph hat computes the union of the regions that are removed by an opening operation with the regions that<br />

areaddedbyaclosing operation. Hence this is the union of the results of top hat and bottom hat. The<br />

position of StructElement does not influence the result.<br />

Structuring elements (StructElement) can be generated with operators such as gen circle,<br />

gen rectangle1, gen rectangle2, gen ellipse, draw region, gen region polygon,<br />

gen region points,etc.<br />

The individual regions are processed separately.<br />

Attention<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º StructElement (input object) ...................................................region Hobject<br />

Structuring element (position-invariant).<br />

º RegionTopHat (output object) ...........................................region(-array) Hobject *<br />

Union of top hat and bottom hat.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 417<br />

Example<br />

my_morph_hat(Hobject *In, Hobject StructElement, Hobject *Out)<br />

{<br />

Hobject top, bottom;<br />

top_hat(In,StructElement,&top);<br />

bottom_hat(In,StructElement,&bottom);<br />

union2(top,bottom,Out);<br />

clear_obj(top); clear_obj(bottom);<br />

}<br />

Result<br />

morph hat returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input region<br />

can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

morph hat is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm,<br />

gen circle, gen ellipse, gen rectangle1, gen rectangle2, draw region,<br />

gen region points, gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

top hat, bottom hat, union2<br />

opening, closing<br />

Morphology<br />

Alternatives<br />

See Also<br />

Module<br />

morph skeleton ( Hobject Region, Hobject *RegionSkeleton )<br />

Compute the morphological skeleton of a region.<br />

morph skeleton computes the skeleton of the input regions (Region) using morphological transformations.<br />

The computation yields a disconnected skeleton (gaps in the diagonals) having a width of one or two pixels. The<br />

calculation uses the Golay element ’h’, i.e., an 8-neighborhood. This is equivalent to the maximum-norm.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º RegionSkeleton (output object) ........................................region(-array) Hobject *<br />

Resulting morphological skeleton.<br />

Result<br />

morph skeleton returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

<strong>HALCON</strong> 6.0


418 CHAPTER 7. MORPHOLOGY<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

morph skeleton is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm<br />

Possible Successor Functions<br />

skeleton, reduce domain, select shape, area center, connection<br />

skeleton, thinning<br />

thinning seq, morph skiz<br />

Morphology<br />

Alternatives<br />

See Also<br />

Module<br />

morph skiz ( Hobject Region, Hobject *RegionSkiz, long Iterations1,<br />

long Iterations2 )<br />

Thinning of a region.<br />

morph skiz first performs a sequential thinning (thinning seq) of the input region with the element ’l’ of<br />

the Golay alphabet. The number of iterations is determined by the parameter Iterations1. Then a sequential<br />

thinning of the resulting region with the element ’e’ of the Golay alphabet is carried out. The number of iterations<br />

for this step is determined by the parameter Iterations2. The skiz operation serves to compute a kind of<br />

skeleton of the input regions, and to prune the branches of the resulting skeleton. If the skiz operation is applied to<br />

the complement of the region, the region and the resulting skeleton are separated.<br />

If very large values or ’maximal’ are passed for Iterations1 or Iterations2, the processing stops if no<br />

more changes occur.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be thinned.<br />

º RegionSkiz (output object) ..............................................region(-array) Hobject *<br />

Result of the skiz operator.<br />

º Iterations1 (input control) ...........................................integer long / const char *<br />

Number of iterations for the sequential thinning with the element ’l’ of the Golay alphabet.<br />

Default Value : 100<br />

Value Suggestions : Iterations1 ¾’maximal’, 0, 1, 2, 3, 5, 7, 10, 15, 20, 30, 40, 50, 70, 100, 150, 200,<br />

300, 400<br />

Typical Range of Values : 0 Iterations1 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Iterations2 (input control) ...........................................integer long / const char *<br />

Number of iterations for the sequential thinning with the element ’e’ of the Golay alphabet.<br />

Default Value : 1<br />

Value Suggestions : Iterations2 ¾’maximal’, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50<br />

Typical Range of Values : 0 Iterations2 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let be the area of the input region. Then the runtime complexity for one region is<br />

Ç´´ÁØÖØÓÒ×½ · ÁØÖØÓÒ×¾µ ¡ ¿ ¡ Ô µ <br />

Result<br />

morph skiz returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input<br />

region can be set via:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 419<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

morph skiz is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm<br />

Possible Successor Functions<br />

pruning, reduce domain, select shape, area center, connection, background seg,<br />

complement<br />

Alternatives<br />

skeleton, thinning seq, morph skeleton, interjacent<br />

thinning, hit or miss seq, difference<br />

Morphology<br />

See Also<br />

Module<br />

opening ( Hobject Region, Hobject StructElement,<br />

Hobject *RegionOpening )<br />

Open a region.<br />

An opening operation is defined as an erosion followed by a Minkowsi addition. By applying opening to a<br />

region, larger structures remain mostly intact, while small structures like lines or points are eliminated. In contrast,<br />

a closing operation results in small gaps being retained or filled up (see closing).<br />

opening serves to eliminate small regions (smaller than StructElement) and to smooth the boundaries of a<br />

region. The position of StructElement is meaningless, since an opening operation is invariant with respect to<br />

the choice of the reference point.<br />

Structuring elements (StructElement) can be generated with operators such as gen circle,<br />

gen rectangle1, gen rectangle2, gen ellipse, draw region, gen region polygon,<br />

gen region points,etc.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be opened.<br />

º StructElement (input object) ...................................................region Hobject<br />

Structuring element (position-invariant).<br />

º RegionOpening (output object) ..........................................region(-array) Hobject *<br />

Opened regions.<br />

Example<br />

/* simulation of opening */<br />

my_opening(Hobject In, Hobject StructElement, Hobject *Out)<br />

{<br />

Hobject H;<br />

erosion1(In,StructElement,&H,1);<br />

minkowski_add1(H,StructElement,Out,1);<br />

clear_obj(H);<br />

}<br />

/* Large regions in an aerial picture (beech trees or meadows): */<br />

read_image(&Image,"wald1");<br />

threshold(Image,&Light,80.0,255.0);<br />

gen_circle(&StructElement1,100.0,100.0,2.0);<br />

<strong>HALCON</strong> 6.0


420 CHAPTER 7. MORPHOLOGY<br />

gen_circle(&StructElement2,100.0,100.0,20.0);<br />

/* close the small gap */<br />

closing(Light,StructElement1,&H);<br />

/* selecting the large regions */<br />

opening(H,StructElement2,&Large);<br />

/* Selecting of edges with certain orientation: */<br />

read_image(&Image,"fabrik");<br />

sobel_amp(Image,&Sobel,"sum_abs",3);<br />

threshold(Sobel,Edges,30.0,255.0);<br />

gen_rectangle2(&StructElement,100.0,100.0,3.07819,20.0,1.0);<br />

opening(Edges,StructElement,&Direction);<br />

Complexity<br />

Let ½ be the area of the input region, and ¾ be the area of the structuring element. Then the runtime complexity<br />

for one region is:<br />

Ç´¾ ¡ Ô ½ ¡ Ô ¾µ <br />

Result<br />

opening returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input region<br />

can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

opening is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm,<br />

gen circle, gen ellipse, gen rectangle1, gen rectangle2, draw region,<br />

gen region points, gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

Alternatives<br />

minkowski add1, erosion1, opening circle<br />

See Also<br />

gen circle, gen rectangle2, gen region polygon<br />

Morphology<br />

Module<br />

opening circle ( Hobject Region, Hobject *RegionOpening, double Radius )<br />

Open a region with a circular structuring element.<br />

opening circle is defined as an erosion followed by a Minkowsi addition with a circular structuring element<br />

(see example). opening serves to eliminate small regions (smaller than the circular structuring element) and to<br />

smooth the boundaries of a region.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be opened.<br />

º RegionOpening (output object) ..........................................region(-array) Hobject *<br />

Opened regions.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 421<br />

º Radius (input control) .........................................................real double / long<br />

Radius of the circular structuring element.<br />

Default Value : 3.5<br />

Value Suggestions : Radius ¾1.5, 2.5, 3.5, 4.5, 5.5, 7.5, 9.5, 12.5, 15.5, 19.5, 25.5, 33.5, 45.5, 60.5,<br />

110.5<br />

Typical Range of Values : 0.5 Radius 511.5 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 1.0<br />

Example<br />

/* simulation of opening_circle */<br />

my_opening_circle(Hobject In, double Radius, Hobject *Out)<br />

{<br />

Hobject Circle, tmp;<br />

gen_circle(&Circle,100.0,100.0,Radius);<br />

erosion1(Region,Circle,&tmp,1);<br />

minkowski_add1(tmp,Circle,&Out,1);<br />

clear_obj(Circle); clear_obj(tmp);<br />

}<br />

/* Large regions in an aerial picture (beech trees or meadows): */<br />

read_image(&Image,"wald1");<br />

threshold(Image,&Light,80.0,255.0);<br />

/* close the small gap */<br />

closing_circle(Light,&H,2.5);<br />

/* selecting the large regions */<br />

opening_circle(H,&Large,20.5);<br />

Complexity<br />

Let ½ be the area of the input region. Then the runtime complexity for one region is:<br />

Ç´ ¡ Ô ½ ¡ ÊÙ×µ <br />

Result<br />

opening circle returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

opening circle is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

Alternatives<br />

opening, dilation1, minkowski add1, gen circle<br />

transpose region<br />

Morphology<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


422 CHAPTER 7. MORPHOLOGY<br />

opening golay ( Hobject Region, Hobject *RegionOpening,<br />

const char *GolayElement, long Rotation )<br />

Open a region with an element from the Golay alphabet.<br />

opening golay is defined as a Minkowski subtraction followed by a Minkowski addition. First the Minkowski<br />

subtraction of the input region (Region) with the structuring element from the Golay alphabet defined by<br />

GolayElement and Rotation is computed. Then the Minkowski addition of the result and the structuring<br />

element rotated by 180 Æ is performed.<br />

The following structuring elements are available:<br />

’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’.<br />

The rotation number Rotation determines which rotation of the element should be used, and whether the foreground<br />

(even) or background version (odd) of the selected element should be used. The Golay elements, together<br />

with all possible rotations, are described with the operator golay elements.<br />

opening golay serves to eliminate regions smaller than the structuring element, and to smooth regions’ boundaries.<br />

Attention<br />

Not all values of Rotation are valid for any Golay element. For some of the values of Rotation, the resulting<br />

regions are identical to the input regions.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be opened.<br />

º RegionOpening (output object) ..........................................region(-array) Hobject *<br />

Opened regions.<br />

º GolayElement (input control) .................................................string const char *<br />

Structuring element from the Golay alphabet.<br />

Default Value : ’h’<br />

Value List : GolayElement ¾’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’<br />

º Rotation (input control) ............................................................integer long<br />

Rotation of the Golay elementḊepending on the element, not all rotations are valid.<br />

Default Value : 0<br />

Value List : Rotation ¾0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15<br />

Complexity<br />

Let be the area of an input region. Then the runtime complexity for one region is:<br />

Ç´ ¡ Ô µ <br />

Result<br />

opening golay returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input<br />

region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

opening golay is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

opening seg, opening<br />

Alternatives<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 423<br />

See Also<br />

erosion golay, dilation golay, closing golay, hit or miss golay, thinning golay,<br />

thickening golay, golay elements<br />

Morphology<br />

Module<br />

opening rectangle1 ( Hobject Region, Hobject *RegionOpening,<br />

long Width, long Height )<br />

Open a region with a rectangular structuring element.<br />

opening rectangle1 performs an erosion rectangle1 followedbyadilation rectangle1 on<br />

the input region Region. The size of the rectangular structuring element is determined by the parameters Width<br />

and Height. As is the case for all opening variants, larger structures are preserved, while small regions like<br />

lines or points are eliminated.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be opened.<br />

º RegionOpening (output object) ..........................................region(-array) Hobject *<br />

Opened regions.<br />

º Width (input control) .......................................................extent.x long / double<br />

Width of the structuring rectangle.<br />

Default Value : 10<br />

Value Suggestions : Width ¾1, 2, 3, 4, 5, 7, 9, 12, 15, 19, 25, 33, 45, 60, 110, 150, 200<br />

Typical Range of Values : 1 Width 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Height (input control) .....................................................extent.y long / double<br />

Height of the structuring rectangle.<br />

Default Value : 10<br />

Value Suggestions : Height ¾1, 2, 3, 4, 5, 7, 9, 12, 15, 19, 25, 33, 45, 60, 110, 150, 200<br />

Typical Range of Values : 1 Height 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let ½ be the area of an input region and À be the height of the rectangle. Then the runtime complexity for one<br />

region is:<br />

Ç´¾ ¡ Ô ½ ¡ дÀµµ <br />

Result<br />

opening rectangle1 returns H MSG TRUE if all parameters are correct. The behavior in case of empty or<br />

no input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

opening rectangle1 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, watersheds, class ndim norm<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

<strong>HALCON</strong> 6.0


424 CHAPTER 7. MORPHOLOGY<br />

Alternatives<br />

opening, gen rectangle1, dilation rectangle1, erosion rectangle1<br />

opening seg, opening golay<br />

Morphology<br />

See Also<br />

Module<br />

opening seg ( Hobject Region, Hobject StructElement,<br />

Hobject *RegionOpening )<br />

Separate overlapping regions.<br />

The opening seg operation is defined as a sequence of the following operators: erosion1, connection<br />

and dilation1 (see example). Only one iteration is done in erosion1 and dilation1.<br />

opening seg serves to separate overlapping regions whose area of overlap is smaller than StructElement.<br />

It should be noted that the resulting regions can overlap without actually merging (see expand region).<br />

opening seg uses the center of gravity as the reference point of the structuring element.<br />

Structuring elements (StructElement) can be generated with operators such as gen circle,<br />

gen rectangle1, gen rectangle2, gen ellipse, draw region, gen region polygon,<br />

gen region points,etc.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be opened.<br />

º StructElement (input object) ...................................................region Hobject<br />

Structuring element (position-invariant).<br />

º RegionOpening (output object) ...........................................region-array Hobject *<br />

Opened regions.<br />

Example<br />

/* Simulation of opening_seg */<br />

my_opening_seg(Hobject Region, Hobject StructElement, Hobject *Opening)<br />

{<br />

Hobject H1,H2;<br />

erosion1(Region,StructElement,&H1,1);<br />

connection(H1,&H2);<br />

dilation1(H2,StructElement,Opening,1);<br />

clear_obj(H1); clear_obj(H2);<br />

}<br />

/* separation of circular objects */<br />

gen_random_regions(&Regions,"circle",8.5,10.5,0.0,0.0,0.0,0.0,400,512,512);<br />

union1(Regions,&UnionReg);<br />

gen_circle(&Mask,100,100,8.5);<br />

opening_seg(UnionReg,Mask,&RegionsNew);<br />

Complexity<br />

Let ½ be the area of the input region, and ¾ be the area of the structuring element. Then the runtime complexity<br />

for one region is:<br />

Ç´Ô<br />

½ ¡<br />

Ô<br />

¾ ¡<br />

Õ Ô<br />

½µ <br />

Result<br />

opening seg returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input<br />

region can be set via:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 425<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

opening seg is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm,<br />

gen circle, gen ellipse, gen rectangle1, gen rectangle2, draw region,<br />

gen region points, gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

expand region, reduce domain, select shape, area center, connection<br />

erosion1, connection, dilation1<br />

Morphology<br />

Alternatives<br />

Module<br />

pruning ( Hobject Region, Hobject *RegionPrune, long Length )<br />

Prune the branches of a region.<br />

pruning removes branches from a skeleton (Region) having a length less than Length. All other branches<br />

are preserved.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º RegionPrune (output object) ............................................region(-array) Hobject *<br />

Result of the pruning operation.<br />

º Length (input control) ...............................................................integer long<br />

Length of the branches to be removed.<br />

Default Value : 2<br />

Value Suggestions : Length ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50<br />

Typical Range of Values : 1 Length 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let be the area of the input region. Then the runtime complexity for one region is<br />

Ç´ÄÒØ ¡ ¿ ¡ Ô µ <br />

Result<br />

pruning returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input region<br />

can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

pruning is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

morph skiz, skeleton, thinning seq<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

<strong>HALCON</strong> 6.0


426 CHAPTER 7. MORPHOLOGY<br />

morph skeleton, junctions skeleton<br />

Morphology<br />

See Also<br />

Module<br />

thickening ( Hobject Region, Hobject StructElement1,<br />

Hobject StructElement2, Hobject *RegionThick, long Row, long Column,<br />

long Iterations )<br />

Add the result of a hit-or-miss operation to a region.<br />

thickening performs a thickening of the input regions using morphological operations. The operator first<br />

applies a hit-or-miss-transformation to Region (cf. hit or miss), and then adds the detected points to the<br />

input region. The parameter Iterations determines the number of iterations performed.<br />

For the choice of the structuring elements StructElement1 and StructElement2,aswellasforRow and<br />

Column, the same restrictions described under hit or miss apply.<br />

The structuring elements (StructElement1 and StructElement2) can be generated by calling<br />

golay elements, for example.<br />

Attention<br />

If the reference point is contained in StructElement1 the input region remains unchanged.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º StructElement1 (input object) ..................................................region Hobject<br />

Structuring element for the foreground.<br />

º StructElement2 (input object) ..................................................region Hobject<br />

Structuring element for the background.<br />

º RegionThick (output object) ............................................region(-array) Hobject *<br />

Result of the thickening operator.<br />

º Row (input control) ...................................................................point.y long<br />

Row coordinate of the reference point.<br />

Default Value : 16<br />

Value Suggestions : Row ¾0, 2, 4, 8, 16, 32, 128<br />

Typical Range of Values : 0 Row 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Column (input control) ...............................................................point.x long<br />

Column coordinate of the reference point.<br />

Default Value : 16<br />

Value Suggestions : Column ¾0, 2, 4, 8, 16, 32, 128<br />

Typical Range of Values : 0 Column 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50, 70, 100, 200,<br />

400<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let be the area of an input region, ½ the area of the structuring element 1, and ¾ theareaofthestructuring<br />

element 2. Then the runtime complexity for one object is:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 427<br />

<br />

Ç ÁØÖØÓÒ× ¡ Ô Ô <br />

¡ ½·Ô<br />

¾<br />

<br />

Result<br />

thickening returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input<br />

region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

thickening is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

golay elements, threshold, regiongrowing, connection, union1, watersheds,<br />

class ndim norm, gen circle, gen ellipse, gen rectangle1, gen rectangle2,<br />

draw region, gen region points, gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

thickening golay, thickening seq<br />

hit or miss<br />

Morphology<br />

Alternatives<br />

See Also<br />

Module<br />

thickening golay ( Hobject Region, Hobject *RegionThick,<br />

const char *GolayElement, long Rotation )<br />

Add the result of a hit-or-miss operation to a region (using a Golay structuring element).<br />

thickening golay performs a thickening of the input regions using morphological operations and structuring<br />

elements from the Golay alphabet. The operator first applies a hit-or-miss-transformation to Region (cf.<br />

hit or miss golay), and then adds the detected points to the input region. The following structuring elements<br />

are available:<br />

’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’.<br />

The rotation number Rotation determines which rotation of the element should be used. The Golay elements,<br />

together with all possible rotations, are described with the operator golay elements.<br />

Attention<br />

Not all values of Rotation are valid for any Golay element.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º RegionThick (output object) ............................................region(-array) Hobject *<br />

Result of the thickening operator.<br />

º GolayElement (input control) .................................................string const char *<br />

Structuring element from the Golay alphabet.<br />

Default Value : ’h’<br />

Value List : GolayElement ¾’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’<br />

º Rotation (input control) ............................................................integer long<br />

Rotation of the Golay elementḊepending on the element, not all rotations are valid.<br />

Default Value : 0<br />

Value List : Rotation ¾0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15<br />

<strong>HALCON</strong> 6.0


428 CHAPTER 7. MORPHOLOGY<br />

Complexity<br />

Let be the area of an input region. Then the runtime complexity for one region is:<br />

Ç´ ¡ Ô µ <br />

Result<br />

thickening golay returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

thickening golay is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

thickening, thickening seq<br />

erosion golay, hit or miss golay<br />

Morphology<br />

Alternatives<br />

See Also<br />

Module<br />

thickening seq ( Hobject Region, Hobject *RegionThick,<br />

const char *GolayElement, long Iterations )<br />

Add the result of a hit-or-miss operation to a region (sequential).<br />

thickening seq calculates the sequential thickening of the input regions with a structuring element from the<br />

Golay alphabet (GolayElement). To do so, thickening seq calls the operator thickening golay with<br />

all possible rotations of the structuring element Iterations times. The following structuring elements are<br />

available:<br />

’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’.<br />

The Golay elements, together with all possible rotations, are described with the operator golay elements. For<br />

all elements of the Golay alphabet, except for ’c’, the foreground and background masks are exchanged in order to<br />

have an effect for them on the outer boundary of the region. The element ’c’ can be used to generate the convex<br />

hull of the input region if enough iterations are performed.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º RegionThick (output object) ............................................region(-array) Hobject *<br />

Result of the thickening operator.<br />

º GolayElement (input control) .................................................string const char *<br />

Structuring element from the Golay alphabet.<br />

Default Value : ’h’<br />

Value List : GolayElement ¾’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50, 70, 100, 200<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 429<br />

Complexity<br />

Let be the area of an input region. Then the runtime complexity for one region is:<br />

Ç´ÁØÖØÓÒ× ¡ ¡ Ô µ <br />

Result<br />

thickening seq returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

thickening seq is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

thickening golay, thickening<br />

erosion golay, thinning seq<br />

Morphology<br />

Alternatives<br />

See Also<br />

Module<br />

thinning ( Hobject Region, Hobject StructElement1,<br />

Hobject StructElement2, Hobject *RegionThin, long Row, long Column,<br />

long Iterations )<br />

Remove the result of a hit-or-miss operation from a region.<br />

thinning performs a thinning of the input regions using morphological operations. The operator first applies a<br />

hit-or-miss-transformation to Region (cf. hit or miss), and then removes the detected points from the input<br />

region. The parameter Iterations determines the number of iterations performed.<br />

For the choice of the structuring elements StructElement1 and StructElement2,aswellasforRow and<br />

Column, the same restrictions described under hit or miss apply.<br />

Structuring elements (StructElement1, StructElement2) can be generated with operators<br />

such as gen circle, gen rectangle1, gen rectangle2, gen ellipse, draw region,<br />

gen region polygon, gen region points,etc.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º StructElement1 (input object) ..................................................region Hobject<br />

Structuring element for the foreground.<br />

º StructElement2 (input object) ..................................................region Hobject<br />

Structuring element for the background.<br />

º RegionThin (output object) ..............................................region(-array) Hobject *<br />

Result of the thinning operator.<br />

º Row (input control) ...................................................................point.y long<br />

Row coordinate of the reference point.<br />

Default Value : 0<br />

Typical Range of Values : 0 Row 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

<strong>HALCON</strong> 6.0


430 CHAPTER 7. MORPHOLOGY<br />

º Column (input control) ...............................................................point.x long<br />

Column coordinate of the reference point.<br />

Default Value : 0<br />

Typical Range of Values : 0 Column 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 30, 40, 50<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let be the area of an input region, ½ the area of the structuring element 1, and ¾ theareaofthestructuring<br />

element 2. Then the runtime complexity for one object is:<br />

<br />

Ç ÁØÖØÓÒ× ¡ Ô Ô <br />

¡ ½·Ô<br />

¾ <br />

Result<br />

thinning returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input region<br />

can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

thinning is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm,<br />

gen circle, gen ellipse, gen rectangle1, gen rectangle2, draw region,<br />

gen region points, gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

thinning golay, thinning seq<br />

hit or miss<br />

Morphology<br />

Alternatives<br />

See Also<br />

Module<br />

thinning golay ( Hobject Region, Hobject *RegionThin,<br />

const char *GolayElement, long Rotation )<br />

Remove the result of a hit-or-miss operation from a region (using a Golay structuring element).<br />

thinning golay performs a thinning of the input regions using morphological operations and structuring<br />

elements from the Golay alphabet. The operator first applies a hit-or-miss-transformation to Region (cf.<br />

hit or miss golay), and then removes the detected points from the input region. The following structuring<br />

elements are available:<br />

’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’.<br />

The rotation number Rotation determines which rotation of the element should be used. The Golay elements,<br />

together with all possible rotations, are described with the operator golay elements.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 431<br />

Attention<br />

Not all values of Rotation are valid for any Golay element.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º RegionThin (output object) ..............................................region(-array) Hobject *<br />

Result of the thinning operator.<br />

º GolayElement (input control) .................................................string const char *<br />

Structuring element from the Golay alphabet.<br />

Default Value : ’h’<br />

Value List : GolayElement ¾’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’<br />

º Rotation (input control) ............................................................integer long<br />

Rotation of the Golay elementḊepending on the element, not all rotations are valid.<br />

Default Value : 0<br />

Value List : Rotation ¾0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15<br />

Complexity<br />

Let be the area of an input region. Then the runtime complexity for one region is:<br />

Ç´ ¡ Ô µ <br />

Result<br />

thinning golay returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

thinning golay is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

thinning seq, thinning<br />

erosion golay, hit or miss golay<br />

Morphology<br />

Alternatives<br />

See Also<br />

Module<br />

thinning seq ( Hobject Region, Hobject *RegionThin,<br />

const char *GolayElement, long Iterations )<br />

Remove the result of a hit-or-miss operation from a region (sequential).<br />

thinning seq calculates the sequential thinning of the input regions with a structuring element from the Golay<br />

alphabet (GolayElement). To do so, thinning seq calls the operator thinning golay with all possible<br />

rotations of the structuring element Iterations times. If Iterations is chosen large enough, the operator<br />

calculates the skeleton of a region if the structuring elements ’l’ or ’m’ are used. For the element ’c’ the background<br />

and foreground are exchanged in order to have an effect on the interior boundary of a region. If a very large value<br />

or ’maximal’ is passed for Iterations the iteration stops if no more changes occur. The following structuring<br />

elements are available:<br />

’l’ Skeleton, similar to skeleton. This structuring element is also used in morph skiz.<br />

’m’ A skeleton with many “hairs” and multiple (parallel) branches.<br />

<strong>HALCON</strong> 6.0


432 CHAPTER 7. MORPHOLOGY<br />

’d’ A skeleton without multiple branches, but with many gaps, similar to morph skeleton.<br />

’c’ Uniform erosion of the region.<br />

’e’ One pixel wide lines are shortened. This structuring element is also used in morph skiz.<br />

’i’ Isolated points are removed. (Only Iterations = 1 is useful.)<br />

’f’ Y-junctions are eliminated. (Only Iterations = 1 is useful.)<br />

’f2’ One pixel long branches and corners are removed. (Only Iterations = 1 is useful.)<br />

’h’ A kind of inner boundary, which, however, is thicker than the result of boundary, is generated. (Only<br />

Iterations = 1 is useful.)<br />

’k’ Junction points are eliminated, but also new ones are generated.<br />

The Golay elements, together with all possible rotations, are described with the operator golay elements.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º RegionThin (output object) ..............................................region(-array) Hobject *<br />

Result of the thinning operator.<br />

º GolayElement (input control) .................................................string const char *<br />

Structuring element from the Golay alphabet.<br />

Default Value : ’l’<br />

Value List : GolayElement ¾’l’, ’m’, ’d’, ’c’, ’e’, ’i’, ’f’, ’f2’, ’h’, ’k’<br />

º Iterations (input control) ............................................integer long / const char *<br />

Number of iterationsḞor ’f’, ’f2’, ’h’ and ’i’ the only useful value is 1.<br />

Default Value : 20<br />

Value Suggestions : Iterations ¾’maximal’, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 30, 40, 50, 70, 100, 150,<br />

200<br />

Typical Range of Values : 1 Iterations (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let be the area of an input region. Then the runtime complexity for one region is:<br />

Ç´ÁØÖØÓÒ× ¡ ¡ Ô µ <br />

Result<br />

thinning seq returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input<br />

region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

thinning seq is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm,<br />

gen circle, gen ellipse, gen rectangle1, gen rectangle2, draw region,<br />

gen region points, gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

pruning, reduce domain, select shape, area center, connection, complement<br />

skeleton, morph skiz, expand region<br />

Alternatives<br />

See Also<br />

hit or miss seq, erosion golay, difference, thinning golay, thinning, thickening seq<br />

Morphology<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


7.2. REGION 433<br />

top hat ( Hobject Region, Hobject StructElement, Hobject *RegionTopHat )<br />

Compute the top hat of regions.<br />

top hat computes the opening of Region with StructElement. The difference between the original<br />

region and the result of the opening is called the top hat. In contrast to opening, which splits regions under<br />

certain circumstances, top hat computes the regions removed by such a splitting.<br />

The position of StructElement is meaningless, since an opening operation is invariant with respect to the<br />

choice of the reference point.<br />

Structuring elements (StructElement) can be generated with operators such as gen circle,<br />

gen rectangle1, gen rectangle2, gen ellipse, draw region, gen region polygon,<br />

gen region points,etc.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º StructElement (input object) ...................................................region Hobject<br />

Structuring element (position independent).<br />

º RegionTopHat (output object) ...........................................region(-array) Hobject *<br />

Result of the top hat operator.<br />

Result<br />

top hat returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no input region<br />

can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

top hat is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, union1, watersheds, class ndim norm,<br />

gen circle, gen ellipse, gen rectangle1, gen rectangle2, draw region,<br />

gen region points, gen struct elements, gen region polygon filled<br />

Possible Successor Functions<br />

reduce domain, select shape, area center, connection<br />

opening, difference<br />

Alternatives<br />

See Also<br />

bottom hat, morph hat, gray tophat, opening<br />

Morphology<br />

Module<br />

<strong>HALCON</strong> 6.0


434 CHAPTER 7. MORPHOLOGY<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Chapter 8<br />

Object<br />

8.1 Information<br />

count obj ( Hobject Objects, long *Number )<br />

Number of objects in a tuple.<br />

The operator count obj determines for the object parameter Objects the number of objects it contains. In<br />

this connection it should be noted that object is not the same as connection component (see connection). For<br />

example, the number of objects of a region not consisting of three connected parts is 1.<br />

Attention<br />

In Prolog and Lisp the length of the list is not necessarily identical with the number of objects. This is the case<br />

when object keys are contained which were created in the compact mode (keys from compact and normal mode<br />

can be used as a mixture). See in this connection set system(’compact object’,).<br />

Parameter<br />

º Objects (input object) ......................................................object-array Hobject<br />

Objects to be examined.<br />

º Number (output control) ............................................................integer long *<br />

Number of objects in the tuple Objects.<br />

Runtime complexity: Ç´ÇØ×µ.<br />

Complexity<br />

Result<br />

If the surrogates are correct, i.e. all objects are present in the <strong>HALCON</strong> operator data base, the operator<br />

count obj returns the value H MSG TRUE. The behavior in case of empty input (no input objects available) is<br />

set via the operator set system(’no object result’,).<br />

Parallelization Information<br />

count obj is reentrant and processed without parallelization.<br />

See Also<br />

copy obj, T obj to integer, connection, set system<br />

Basic operators<br />

Module<br />

get channel info ( Hobject Object, const char *Request, long Channel,<br />

char *Information )<br />

T get channel info ( Hobject Object, Htuple Request, Htuple Channel,<br />

Htuple *Information )<br />

Informations about the components of an image object.<br />

435


436 CHAPTER 8. OBJECT<br />

The operator (T )get channel info gives information about the components of an image object. The following<br />

requests (Request) are currently possible:<br />

’creator’ Output of the names of the procedures which initially created the image components (not the object).<br />

’type’ Output of the type of image component (’byte’, ’int1’, ’int2’, ’int4’, ’real’, ’direction’, ’cyclic’, ’complex’,<br />

’dvf’, ’lut’). The component 0 is of type ’region’ or ’xld’.<br />

In the tuple Channel the numbers of the components about which information is required are stated. After carrying<br />

out (T )get channel info, Information contains a tuple of strings (one string per entry in Channel)<br />

with the required information.<br />

Parameter<br />

º Object (input object) .............................................................object Hobject<br />

Image object to be examined.<br />

º Request (input control) ..............................................string (Htuple .) const char *<br />

Required information about object components.<br />

Default Value : ’creator’<br />

Value List : Request ¾’creator’, ’type’<br />

º Channel (input control) ............................................channel(-array) (Htuple .) long<br />

Components to be examined (0 for region/XLD).<br />

Default Value : 0<br />

Value Suggestions : Channel ¾0, 1, 2, 3, 4, 5, 6, 7, 8<br />

º Information (output control) ......................................string(-array) (Htuple .) char *<br />

Requested information.<br />

Result<br />

If the parameters are correct the operator (T )get channel info returns the value H MSG TRUE. Otherwise<br />

an exception is raised.<br />

Parallelization Information<br />

(T )get channel info is reentrant and processed without parallelization.<br />

read image<br />

count relation<br />

Basic operators<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

get obj class ( Hobject Object, char *Class )<br />

T get obj class ( Hobject Object, Htuple *Class )<br />

Name of the class of an image object.<br />

(T )get obj class returns the name of the corresponding class to each object. The following classes are<br />

possible:<br />

’image’ Object with region (definition domain) and at least one channel.<br />

’region’ Object with a region without gray values.<br />

’xld cont’ XLD object as contour<br />

’xld poly’ XLD object as polygon<br />

’xld parallel’ XLD object with parallel polygons<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


8.1. INFORMATION 437<br />

Parameter<br />

º Object (input object) ......................................................object(-array) Hobject<br />

Image objects to be examined.<br />

º Class (output control) ..............................................string(-array) (Htuple .) char *<br />

Name of class.<br />

Result<br />

If the parameter values are correct the operator (T )get obj class returns the value H MSG TRUE. Otherwise<br />

an exception is raised.<br />

Parallelization Information<br />

(T )get obj class is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

disp image, disp region, disp xld<br />

(T )get channel info, count relation<br />

Basic operators<br />

See Also<br />

Module<br />

test equal obj ( Hobject Objects1, Hobject Objects2 )<br />

Compare image objects regarding equality.<br />

The operator test equal obj compares the regions and gray value components of all objects of the two input<br />

parameters. The n-th object in Objects1 is compared to the n-th object in Objects2 (for all n). If all corresponding<br />

regions are equal and the number of regions is also identical the operator test equal obj returns the<br />

value TRUE, otherwise FALSE.<br />

Attention<br />

Image matrices are not compared regarding their contents. Thus, two images are “equal” if they are at the same<br />

place in the store. If the input parameters are empty and the behavior was set via the operator set system<br />

(’no object result’,’true’), the operator test equal obj returns TRUE, since all input (= empty<br />

set) is equal.<br />

Parameter<br />

º Objects1 (input object) .....................................................object-array Hobject<br />

Test objects.<br />

º Objects2 (input object) .....................................................object-array Hobject<br />

Comparative objects.<br />

Complexity<br />

If is the area of a region the runtime complexity is Ç´½µ or Ç´Ô<br />

µ if the result is TRUE and Ç´Ô<br />

µ if the<br />

result is FALSE.<br />

Result<br />

The operator test equal obj returns the value H MSG TRUE if both object tuples are identical. If the tuples<br />

differ in at least one place test equal obj returns H MSG FALSE. The behavior in case of empty input<br />

(no input objects available) is set via the operator set system(’no object result’,). Ifthe<br />

number of objects differs an exception is raised.<br />

Parallelization Information<br />

test equal obj is reentrant and processed without parallelization.<br />

test equal region<br />

bool<br />

Basic operators<br />

See Also<br />

Return Value<br />

Module<br />

<strong>HALCON</strong> 6.0


438 CHAPTER 8. OBJECT<br />

test equal region ( Hobject Regions1, Hobject Regions2 )<br />

Test whether the regions of two objects are identical.<br />

The operator test equal region compares the regions of the two input parameters. The n-th element in<br />

Regions1 is compared to the n-th object in Regions2 (for all n). If all regions are equal and the number of<br />

regions is identical the operator test equal region returns the value TRUE, otherwise FALSE.<br />

Parameter<br />

º Regions1 (input object) ...................................................region(-array) Hobject<br />

Test regions.<br />

º Regions2 (input object) ...................................................region(-array) Hobject<br />

Comparative regions.<br />

Parameter Number : Regions1 Regions2<br />

Complexity<br />

If is the area of a region the runtime complexity is Ç´½µ or Ç´Ô<br />

µ if the result is TRUE, Ç´Ô<br />

µ if the result is<br />

FALSE.<br />

Result<br />

The operator test equal region returns the value H MSG TRUE if both object tuples are identical. If the<br />

tuples differ in at least one place test equal region returns H MSG FALSE. The behavior in case of empty<br />

input (no input objects available) is set via the operator set system(’no object result’,).<br />

If the number of objects differs an exception is raised.<br />

Parallelization Information<br />

test equal region is reentrant and processed without parallelization.<br />

Alternatives<br />

intersection, complement, area center<br />

test equal obj<br />

bool<br />

Basic operators<br />

See Also<br />

Return Value<br />

Module<br />

test obj def ( Hobject Object )<br />

Test whether an object is already deleted.<br />

The operator test obj def checks whether the object still exists in the <strong>HALCON</strong> operator data base (i.e.<br />

whether the surrogate is still valid). This check especially makes sense before deleting an object if it is not sure<br />

that the object has already been deleted by a prior deleting operator (clear obj).<br />

Attention<br />

The operator test obj def can return TRUE even if the object was already deleted because the surrogates of<br />

deleted objects are re-used for new objects. In this context see the example.<br />

Parameter<br />

º Object (input object) .............................................................object Hobject<br />

Object to be checked.<br />

Example<br />

Herror err;<br />

circle(&Circle,100.0,100.0,100.0);<br />

err = test_obj_def(Circle);<br />

printf("Result for test_obj_def (H_MSG_TRUE): %d\n",err);<br />

clear_obj(Circle);<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


8.2. MANIPULATION 439<br />

err = test_obj_def(Circle);<br />

printf("Result for test_obj_def (H_MSG_FALSE): %d\n",err);<br />

gen_rectangle1(&Rectangle,200.0,200.0,300.0,300.0);<br />

err = test_obj_def(Circle);<br />

printf("Result for test_obj_def (H_MSG_TRUE!!!): %d\n",err);<br />

The runtime complexity is Ç´½µ.<br />

Complexity<br />

Result<br />

The operator test obj def returns the value H MSG TRUE if an object with this surrogate is present in the<br />

<strong>HALCON</strong> operator data base, otherwise the value H MSG FALSE is returned. The behavior in case of empty<br />

input (no input objects available) is set via the operator set system(’no object result’,).<br />

Parallelization Information<br />

test obj def is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

clear obj, gen circle, gen rectangle1<br />

set check, clear obj, reset obj db<br />

bool<br />

Basic operators<br />

See Also<br />

Return Value<br />

Module<br />

8.2 Manipulation<br />

clear obj ( Hobject Objects )<br />

Delete an iconic object from the <strong>HALCON</strong> database.<br />

clear obj deletes iconic objects, which are no longer needed, from the <strong>HALCON</strong> database. It should be noted<br />

that clear obj is the only way to delete objects from the database, and hence to reclaim their memory, in all<br />

host languages except Smalltalk and C++.<br />

Images and regions are normally used by several iconic objects at the same time (uses less memory!). This has the<br />

consequence that a region or an image is only deleted if all objects using it have been deleted.<br />

The operator reset obj db can be used to reset the system and clear all remaining iconic objects.<br />

Attention<br />

Regarding the use of local variables: Because only local variables are deleted on exit of a subroutine (or a rule<br />

in Prolog), while the <strong>HALCON</strong> database is not updated, it is necessary to clear local objects before exiting the<br />

subroutine. Special care has to be taken if backtracking is possible in Prolog (before reaching the clear obj<br />

statements).<br />

Parameter<br />

º Objects (input object) .....................................................object(-array) Hobject<br />

Objects to be deleted.<br />

Result<br />

clear obj returns H MSG TRUE if all objects are contained in the <strong>HALCON</strong> database. If not all objects are<br />

valid (e.g., already cleared), an exception is raised, which also clears all valid objects. The operator set check<br />

(’˜clear’:) can be used to suppress the raising of this exception. If the input is empty the behavior can be set<br />

via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

clear obj is reentrant and processed without parallelization.<br />

test obj def<br />

Possible Predecessor Functions<br />

<strong>HALCON</strong> 6.0


440 CHAPTER 8. OBJECT<br />

reset obj db<br />

test obj def, set check<br />

Basic operators<br />

Alternatives<br />

See Also<br />

Module<br />

concat obj ( Hobject Objects1, Hobject Objects2,<br />

Hobject *ObjectsConcat )<br />

Concatenate two iconic object tuples.<br />

concat obj concatenates the two tuples of iconic objects Objects1 and Objects2 into a new object tuple<br />

ObjectsConcat. Hence, this tuple contains all the objects of the two input tuples:<br />

ObjectsConcat =[Objects1,Objects2]<br />

In ObjectsConcat the objects of Objects1 are stored first, followed by the objects of Objects2. The<br />

order of the objects is preserved. As usual, only the objects are copied, and not the corresponding images and<br />

regions, i.e., no new memory is allocated. concat obj is designed especially for <strong>HALCON</strong>/C. In languages like<br />

Smalltalk, Prolog, and C++ it is not needed.<br />

concat obj should not be confused with union1 or union2, in which regions are merged, i.e., in which the<br />

number of objects is modified.<br />

concat obj can be used to concatenate objects of different image object types (e.g., images and XLD contours)<br />

into a single object. This is only recommended if it is necessary to accumulate in a single object variable, for<br />

example, the results of an image processing sequence. It should be noted that the only operators that can handle<br />

such object tuples of mixed type are concat obj, copy obj, select obj, anddisp obj. For technical<br />

reasons, object tuples of mixed type must not be created in HDevelop.<br />

Parameter<br />

º Objects1 (input object) ...................................................object(-array) Hobject<br />

Object tuple 1.<br />

º Objects2 (input object) ...................................................object(-array) Hobject<br />

Object tuple 2.<br />

º ObjectsConcat (output object) ...........................................object-array Hobject *<br />

Concatenated objects.<br />

Example<br />

/* generate a tuple of a circle and a rectangle */<br />

gen_circle(&Circle,200.0,400.0,23.0);<br />

gen_rectangle1(&Rectangle,23.0,44.0,203.0,201.0);<br />

concat_obj(Circle,Rectangle,&CirclAndRectangle);<br />

clear_obj(Circle); clear_obj(Rectangle);<br />

disp_region(CircleAndRectangle,WindowHandle);<br />

Complexity<br />

Runtime complexity: Ç´ÇØ×½ · ÇØ×¾µ;<br />

Memory complexity of the result objects: Ç´ÇØ×½ · ÇØ×¾µ<br />

Result<br />

concat obj returns H MSG TRUE if all objects are contained in the <strong>HALCON</strong> database. If the input is empty<br />

the behavior can be set via set system(’no object result’,). If necessary, an exception is<br />

raised.<br />

Parallelization Information<br />

concat obj is reentrant and processed without parallelization.<br />

See Also<br />

count obj, copy obj, select obj, disp obj<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


8.2. MANIPULATION 441<br />

Basic operators<br />

Module<br />

copy obj ( Hobject Objects, Hobject *ObjectsSelected, long Index,<br />

long NumObj )<br />

Copy an iconic object in the <strong>HALCON</strong> database.<br />

copy obj copies NumObj iconic objects beginning with index Index (starting with 1) from the iconic input<br />

object tuple Objects to the output object ObjectsSelected.If-1ispassedforNumObj all objects beginning<br />

with Index are copied. No new storage is allocated for the regions and images. Instead, new objects containing<br />

references to the existing objects are created. The number of objects in an object tuple can be queried with the<br />

operator count obj.<br />

Parameter<br />

º Objects (input object) .....................................................object(-array) Hobject<br />

Objects to be copied.<br />

º ObjectsSelected (output object) .......................................object(-array) Hobject *<br />

Copied objects.<br />

º Index (input control) ................................................................integer long<br />

Starting index of the objects to be copied.<br />

Default Value : 1<br />

Value Suggestions : Index ¾1, 2, 3, 4, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000<br />

Typical Range of Values : 1 Index<br />

Restriction : Index number´Objectsµ<br />

º NumObj (input control) ...............................................................integer long<br />

Number of objects to be copied or -1.<br />

Default Value : 1<br />

Value Suggestions : NumObj ¾-1, 1, 2, 3, 4, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000<br />

Typical Range of Values : -1 NumObj<br />

Restriction : ´´NumObj · Indexµ number´Objectsµµ ´NumObj 0µ<br />

Example<br />

/* Access all regions */<br />

count_obj(Regions,&Num);<br />

for (i=1; i


442 CHAPTER 8. OBJECT<br />

select obj<br />

Alternatives<br />

See Also<br />

count obj, concat obj, T obj to integer, copy image<br />

Basic operators<br />

Module<br />

gen empty obj ( Hobject *EmptyObject )<br />

Create an empty object tuple.<br />

The operator gen empty obj creates an empty tuple. This means that the output parameter does not contain any<br />

objects. Thus, the operator count obj returns 0. However, clear obj can be called for the output. It should<br />

be noted that no objects must not be confused with an empty region. In case of an empty region, i.e. a region with<br />

0pixelscount obj returns the value 1.<br />

Parameter<br />

º EmptyObject (output object) ...................................................object Hobject *<br />

No objects.<br />

Parallelization Information<br />

gen empty obj is reentrant and processed without parallelization.<br />

Image / region / XLD management<br />

Module<br />

T integer to obj ( Hobject *Objects, Htuple SurrogateTuple )<br />

Convert an “integer number” into an iconic object.<br />

T integer to obj is the inverse operator to T obj to integer. All surrogates of objects passed in<br />

SurrogateTuple are stored as objects. In contrast to T obj to integer, the objects are duplicated.<br />

T integer to obj is intended especially for use in <strong>HALCON</strong>/C, because iconic objects and control parameters<br />

are treated differently in C.<br />

Attention<br />

The objects are duplicated in the database.<br />

Parameter<br />

º Objects (output object) ...................................................object-array Hobject *<br />

Created objects.<br />

º SurrogateTuple (input control) ......................................integer-array Htuple . long<br />

Tuple of object surrogates.<br />

Default Value : 1<br />

Result<br />

T integer to obj returns H MSG TRUE if all parameters are correct, i.e., if they are valid object keys. If the<br />

input is empty the behavior can be set via set system(’no object result’,). If necessary,<br />

an exception is raised.<br />

Parallelization Information<br />

T integer to obj is reentrant and processed without parallelization.<br />

T obj to integer<br />

Basic operators<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


8.2. MANIPULATION 443<br />

T obj to integer ( Hobject Objects, Htuple Index, Htuple Number,<br />

Htuple *SurrogateTuple )<br />

Convert an iconic object into an “integer number.”<br />

T obj to integer stores Number, starting at index Index, of the database keys of the input object Objects<br />

as integer numbers in the output parameter SurrogateTuple. This facilitates a direct access to an arbitrary<br />

element of Objects. In conjunction with count obj (returns the number of objects in Objects) the elements<br />

of Objects can be processed successively. The objects are not duplicated by T obj to integer and thus<br />

must not be cleared by clear obj.<br />

The objects’ data is not duplicated.<br />

Attention<br />

Parameter<br />

º Objects (input object) ......................................................object-array Hobject<br />

Objects for which the surrogates are to be returned.<br />

º Index (input control) ........................................................integer Htuple . long<br />

Starting index of the surrogates to be returned.<br />

Default Value : 1<br />

Typical Range of Values : 1 Index<br />

º Number (input control) .......................................................integer Htuple . long<br />

Number of surrogates to be returned.<br />

Default Value : 1<br />

Restriction : ´Number · Indexµ number´Objectsµ<br />

º SurrogateTuple (output control) ....................................integer-array Htuple . long *<br />

Tuple containing the surrogates.<br />

Example<br />

/* Access the i-th element: */<br />

long i,Surrogate;<br />

obj_to_integer(Objects,i,1,&Surrogat);<br />

Runtime complexity: Ç´ÇØ× · ÆÙÑÖµ<br />

Complexity<br />

Result<br />

T obj to integer returns H MSG TRUE if all parameters are correct. If the input is empty the behavior can<br />

be set via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

T obj to integer is reentrant and processed without parallelization.<br />

test obj def<br />

Possible Predecessor Functions<br />

Alternatives<br />

copy obj, select obj, copy image, gen image proto<br />

T integer to obj, count obj<br />

Basic operators<br />

See Also<br />

Module<br />

select obj ( Hobject Objects, Hobject *ObjectSelected, long Index )<br />

Select an object from an object tuple.<br />

select obj copies the iconic object with index Index (starting with 1) from the iconic input object tuple<br />

Objects to the output object ObjectSelected. No new storage is allocated for the regions and images.<br />

<strong>HALCON</strong> 6.0


444 CHAPTER 8. OBJECT<br />

Instead, new objects containing references to the existing objects are created. The number of objects in an object<br />

tuple can be queried with the operator count obj.<br />

Parameter<br />

º Objects (input object) .....................................................object(-array) Hobject<br />

Objects, of which one is to be selected.<br />

º ObjectSelected (output object) ...............................................object Hobject *<br />

Selected object.<br />

º Index (input control) ................................................................integer long<br />

Index of the object to be selected.<br />

Default Value : 1<br />

Value Suggestions : Index ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 50, 100, 200, 500, 1000, 2000, 5000<br />

Typical Range of Values : 1 Index<br />

/* Access to all Regions */<br />

Example<br />

count_obj(Regions,&Num);<br />

for (i=1; i


Chapter 9<br />

Regions<br />

9.1 Access<br />

T get region chain ( Hobject Region, Htuple *Row, Htuple *Column,<br />

Htuple *Chain )<br />

Contour of an object as chain code.<br />

The operator T get region chain returns the contour of a region. A contour is a series of pixels describing<br />

the outline of the region. The contour “lies on” the region. It starts at the smallest line number; in that line at the<br />

pixel with the largest column index. The rotation occurs clockwise. Holes of the region are ignored. The direction<br />

code (chain code) is defined as follows:<br />

¿ ¾ ½<br />

£ ¼<br />

<br />

The operator T get region chain returns the code in the form of a tuple. In case of an empty region the<br />

parameters Row and Column are zero and Chain is the empty tuple.<br />

Attention<br />

Holes of the region are ignored. Only one region may be passed, and it must have exactly one connection component.<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Region to be transformed.<br />

º Row (output control) ..................................................chain.begin.y Htuple . long *<br />

Line of starting point.<br />

º Column (output control) ..............................................chain.begin.x Htuple . long *<br />

Column of starting point.<br />

º Chain (output control) ............................................chain.code-array Htuple . long *<br />

Direction code of the contour (from starting point).<br />

Typical Range of Values : 0 Chain 7<br />

Result<br />

The operator T get region chain normally returns the value H MSG TRUE. If more than one connection<br />

component is passed an exception handling is caused. The behavior in case of empty input (no input<br />

regions available) is set via the operator set system(’no object result’,). The<br />

behavior in case of empty region (the region is the empty set) is set via the operator set system<br />

(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

T get region chain is reentrant and processed without parallelization.<br />

445


446 CHAPTER 9. REGIONS<br />

Possible Predecessor Functions<br />

sobel amp, threshold, skeleton, edges image, (T )gen rectangle1, (T )gen circle<br />

Possible Successor Functions<br />

approx chain, approx chain simple<br />

See Also<br />

copy obj, T get region contour, T get region polygon<br />

Region processing<br />

Module<br />

T get region contour ( Hobject Region, Htuple *Rows, Htuple *Columns )<br />

Access the contour of an object.<br />

The operator T get region contour returns the contour of a region. A contour is a result of line (Rows)<br />

and column coordinates (Columns), describing the boundary of the region. The contour lies on the region. It<br />

starts at the smallest line numberİn that line at the pixel with the largest column index. The rotation direction is<br />

clockwise. The first pixel of the contour is identical with the last. Holes of the region are ignored. The operator<br />

T get region contour returns the coordinates in the form of tuples. An empty region is passed as empty<br />

tuple.<br />

Attention<br />

Holes of the region are ignored. Only one region may be passed, and this region must have exactly one connection<br />

component.<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Output region.<br />

º Rows (output control) ...............................................contour.y-array Htuple . long *<br />

Line numbers of the contour pixels.<br />

º Columns (output control) ...........................................contour.x-array Htuple . long *<br />

Column numbers of the contour pixels.<br />

Parameter Number : Columns Rows<br />

Result<br />

The operator T get region contour normally returns the value H MSG TRUE. If more than one connection<br />

component is passed an exception handling is caused. The behavior in case of empty input (no input regions<br />

available) is set via the operator set system(’no object result’,).<br />

Parallelization Information<br />

T get region contour is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

sobel amp, threshold, skeleton, edges image, (T )gen rectangle1, (T )gen circle<br />

See Also<br />

copy obj, T get region chain, T get region polygon<br />

Region processing<br />

Module<br />

T get region convex ( Hobject Region, Htuple *Rows, Htuple *Columns )<br />

Access convex hull as contour.<br />

The operator T get region convex returns the convex hull of a region as polygon. The polygon is the minimum<br />

result of line (Rows) and column coordinates (Columns) describing the hull of the region. The polygon<br />

pixels lie on the region. The polygon starts at the smallest line number; in this line at the pixel with the largest<br />

column index. The rotation direction is clockwise. The first pixel of the polygon is identical with the last. The<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.1. ACCESS 447<br />

operator T get region convex returns the coordinates in the form of tuples. An empty region is passed as<br />

empty tuple.<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Output region.<br />

º Rows (output control) ...............................................contour.y-array Htuple . long *<br />

Line numbers of contour pixels.<br />

º Columns (output control) ...........................................contour.x-array Htuple . long *<br />

Column numbers of the contour pixels.<br />

Parameter Number : Columns Rows<br />

Result<br />

The operator T get region convex returns the value H MSG TRUE.<br />

Parallelization Information<br />

T get region convex is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, skeleton, dyn threshold<br />

disp polygon<br />

shape trans<br />

select obj, T get region contour<br />

Region processing<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

T get region points ( Hobject Region, Htuple *Rows, Htuple *Columns )<br />

Access the pixels of a region.<br />

The operator T get region points returns the region data in the form of coordinate lists. The coordinates<br />

are sorted in the following order:<br />

´Ö ½ ½ µ ´Ö ¾ ¾ µ´Ö ½ Ö ¾ µ ´Ö ½ Ö ¾ µ ´½ ¾µ<br />

T get region points returns the coordinates in the form of tuples. An empty region is passed as empty tuple.<br />

Only one region may be passed.<br />

Attention<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

This region is accessed.<br />

º Rows (output control) ...........................................coordinates.y-array Htuple . long *<br />

Line numbers of the pixels in the region<br />

º Columns (output control) .......................................coordinates.x-array Htuple . long *<br />

Column numbers of the pixels in the region.<br />

Parameter Number : Columns Rows<br />

Result<br />

The operator T get region points normally returns the value H MSG TRUE. If more than one connection<br />

component is passed an exception handling is caused. The behavior in case of empty input (no input regions<br />

available) is set via the operator set system(’no object result’,).<br />

Parallelization Information<br />

T get region points is reentrant and processed without parallelization.<br />

<strong>HALCON</strong> 6.0


448 CHAPTER 9. REGIONS<br />

Possible Predecessor Functions<br />

sobel amp, threshold, connection<br />

T get region runs<br />

copy obj, (T )gen region points<br />

Region processing<br />

Alternatives<br />

See Also<br />

Module<br />

T get region polygon ( Hobject Region, Htuple Tolerance, Htuple *Rows,<br />

Htuple *Columns )<br />

Polygon approximation of a region.<br />

The operator T get region polygon calculates a polygon to approximate the edge of a region. A polygon<br />

is a sequence of line (Rows) and column coordinates (Columns). It describes the contour of the region. Only<br />

the base points of the polygon are returned. The parameter Tolerance indicates how large the maximum distance<br />

between the polygon and the edge of the region may be. Holes of the region are ignored. The operator<br />

T get region polygon returns the coordinates in the form of tuples.<br />

Attention<br />

Holes of the region are ignored. Only one region may be passed, and this region must have exactly one connection<br />

component.<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Region to be approximated.<br />

º Tolerance (input control) .........................................number Htuple . double / long<br />

Maximum distance between the polygon and the edge of the region.<br />

Default Value : 5.0<br />

Value Suggestions : Tolerance ¾0.0, 2.0, 5.0, 10.0<br />

Typical Range of Values : 0.0 Tolerance (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 1.0<br />

º Rows (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . polygon.y-array Htuple . long *<br />

Line numbers of the base points of the contour.<br />

º Columns (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . polygon.x-array Htuple . long *<br />

Column numbers of the base points of the contour.<br />

Parameter Number : Columns Rows<br />

Result<br />

The operator T get region polygon normally returns the value H MSG TRUE. If more than one connection<br />

component is passed an exception handling is caused. The behavior in case of empty input (no input regions<br />

available) is set via the operator set system(’no object result’,).<br />

Parallelization Information<br />

T get region polygon is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

sobel amp, threshold, skeleton, edges image<br />

See Also<br />

copy obj, T gen region polygon, disp polygon, T get region chain,<br />

T get region contour, set line approx<br />

Region processing<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.2. AFFINE-TRANSFORMATIONS 449<br />

T get region runs ( Hobject Region, Htuple *Row, Htuple *ColumnBegin,<br />

Htuple *ColumnEnd )<br />

Access the runlength coding of a region.<br />

The operator T get region runs returns the region data in the form of chord tuples. The chord representation<br />

is caused by examining a region line by line with ascending line number (= from “top” to “bottom”). Every line is<br />

passed from left to right (ascending column number); storing all starting and ending points of region segments (=<br />

chords). Thus a region can be described by a sequence of chords, a chord being defined by line number, starting<br />

and ending points (column number). The operator T get region runs returns the three components of the<br />

chords in the form of tuples. In case of an empty region three empty tuples are returned.<br />

Attention<br />

Only one region may be passed.<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Output region.<br />

º Row (output control) ..................................................chord.y-array Htuple . long *<br />

Line numbers of the chords.<br />

º ColumnBegin (output control) ......................................chord.x1-array Htuple . long *<br />

Column numbers of the starting points of the chords.<br />

Parameter Number : ColumnBegin Row<br />

º ColumnEnd (output control) .........................................chord.x2-array Htuple . long *<br />

Column numbers of the ending points of the chords.<br />

Parameter Number : ColumnEnd Row<br />

Result<br />

The operator T get region runs normally returns the value H MSG TRUE. If more than one region is passed<br />

an exception handling is caused. The behavior in case of empty input (no input regions available) is set via the<br />

operator set system(’no object result’,).<br />

Parallelization Information<br />

T get region runs is reentrant and processed without parallelization.<br />

threshold, connection<br />

T get region points<br />

copy obj, (T )gen region runs<br />

Region processing<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

9.2 Affine-Transformations<br />

T affine trans region ( Hobject Region, Hobject *RegionAffineTrans,<br />

Htuple HomMat2D, Htuple Interpolate )<br />

Transform a region using an affine transformation.<br />

T affine trans region applies an arbitrary affine transformation, i.e., scaling, rotation, translation, and<br />

skewing, to a region. The affine map is described by the transformation matrix given in HomMat2D<br />

, which is built up by using hom mat2d identity, hom mat2d scale, hom mat2d rotate, and<br />

hom mat2d translate. The components of the homogeneous transformation matrix are interpreted as follows:<br />

the row coordinate of the image corresponds to the Ü coordinate of the matrix, while the column coordinate<br />

of the image corresponds to the Ý coordinate of the matrix. This is necessary to obtain a right-handed coordinate<br />

system, which is assumed for the homogeneous transformation matrices, also for the image. In particular, by doing<br />

so roatations are performed in the correct direction. Note that the (Ü,Ý) order of the matrices quite naturally<br />

corresponds to the usual (row,column) order for coordinates in the image.<br />

<strong>HALCON</strong> 6.0


450 CHAPTER 9. REGIONS<br />

The parameter Interpolate determines whether the transformation is to be done by using interpolation internally.<br />

This can lead to smoother region boundaries, especially if regions are enlarged. However, the runtime<br />

increases drastically.<br />

Attention<br />

T affine trans region in general is not reversible (clipping and discretization during rotation and scaling).<br />

The components of the homogeneous transformation matrix are interpreted as follows: the row coordinate of the<br />

image corresponds to the Ü coordinate of the matrix, while the column coordinate of the image corresponds to the<br />

Ý coordinate of the matrix. This is necessary to obtain a right-handed coordinate system, which is assumed for the<br />

homogeneous transformation matrices, also for the image. In particular, by doing so roatations are performed in<br />

the correct direction. Note that the (Ü,Ý) order of the matrices quite naturally corresponds to the usual (row,column)<br />

order for coordinates in the image.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Region(s) to be rotated and scaled.<br />

º RegionAffineTrans (output object) ....................................region(-array) Hobject *<br />

Transformed output region(s).<br />

Parameter Number : RegionAffineTrans Region<br />

º HomMat2D (input control) ...........................................affine2d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 6<br />

º Interpolate (input control) ..........................................string Htuple . const char *<br />

Should the transformation be done using interpolation?<br />

Default Value : ’false’<br />

Value List : Interpolate ¾’true’, ’false’<br />

Result<br />

T affine trans region returns H MSG TRUE if all parameters are correct. The behavior in case of empty<br />

input (no regions given) can be set via set system(’no object result’,), the behavior in<br />

case of an empty input region via set system(’empty region result’,), and the behavior<br />

in case of an empty result region via set system(’store empty region’,). If necessary,<br />

an exception handling is raised.<br />

Parallelization Information<br />

T affine trans region is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

hom mat2d identity, hom mat2d scale, hom mat2d translate, hom mat2d invert,<br />

hom mat2d rotate<br />

Possible Successor Functions<br />

(T )select shape<br />

Alternatives<br />

move region, mirror region, zoom region<br />

affine trans image<br />

Region processing<br />

See Also<br />

Module<br />

mirror region ( Hobject Region, Hobject *RegionMirror,<br />

const char *RowColumn, long WidthHeight )<br />

Reflect a region about the x- or y-axis.<br />

mirror region reflects a region about the x- or y-axis (parameter RowColumn). The parameter<br />

WidthHeight specifies the corresponding image width or height respectively, i.e., it is two times the coordinate<br />

of the axis of symmetry.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.2. AFFINE-TRANSFORMATIONS 451<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Region(s) to be reflected.<br />

º RegionMirror (output object) ...........................................region(-array) Hobject *<br />

Reflected region(s).<br />

Parameter Number : RegionMirror Region<br />

º RowColumn (input control) .....................................................string const char *<br />

Coordinate of the axis of symmetry.<br />

Default Value : ’row’<br />

Value List : RowColumn ¾’column’, ’row’<br />

º WidthHeight (input control) ........................................................integer long<br />

Height or width of the corresponding image.<br />

Default Value : 512<br />

Value Suggestions : WidthHeight ¾128, 256, 512, 525, 768, 1024<br />

Typical Range of Values : 1 WidthHeight 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : WidthHeight 0<br />

read_image(&Image,"affe");<br />

threshold(Image,&Seg,128.0,255.0);<br />

mirror_region(Seg,&Mirror,"row",512);<br />

disp_region(Mirror,WindowHandle);<br />

Example<br />

Parallelization Information<br />

mirror region is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring<br />

(T )select shape, disp region<br />

T affine trans region<br />

zoom region<br />

Region processing<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

move region ( Hobject Region, Hobject *RegionMoved, long Row,<br />

long Column )<br />

Translate a region.<br />

move region translates the input regions by the vector given by (Row, Column). If necessary, the resulting<br />

regions are clipped with the current image format.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Region(s) to be moved.<br />

º RegionMoved (output object) ............................................region(-array) Hobject *<br />

Translated region(s).<br />

Parameter Number : RegionMoved Region<br />

<strong>HALCON</strong> 6.0


452 CHAPTER 9. REGIONS<br />

º Row (input control) ...................................................................point.y long<br />

Row coordinate of the vector by which the region is to be moved.<br />

Default Value : 30<br />

Value Suggestions : Row ¾-128, -64, -32, -16, -10, -8, -4, -2, -1, 0, 1, 2, 4, 5, 8, 10, 16, 32, 64, 128<br />

Typical Range of Values : -512 Row 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Column (input control) ...............................................................point.x long<br />

Row coordinate of the vector by which the region is to be moved.<br />

Default Value : 30<br />

Value Suggestions : Column ¾-128, -64, -32, -16, -10, -8, -4, -2, -1, 0, 1, 2, 4, 5, 8, 10, 16, 32, 64, 128<br />

Typical Range of Values : -512 Column 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Complexity<br />

Let be the area of the input region. Then the runtime complexity is Ç´ µ.<br />

Result<br />

move region always returns the value H MSG TRUE. The behavior in case of empty input (no regions given)<br />

can be set via set system(’no object result’,), the behavior in case of an empty input region<br />

via set system(’empty region result’,), and the behavior in case of an empty result<br />

region via set system(’store empty region’,). If necessary, an exception handling<br />

is raised.<br />

Parallelization Information<br />

move region is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring<br />

(T )select shape, disp region<br />

Possible Successor Functions<br />

See Also<br />

affine trans image, mirror region, zoom region<br />

Region processing<br />

Module<br />

transpose region ( Hobject Region, Hobject *Transposed, long Row,<br />

long Column )<br />

Reflect a region about a point.<br />

transpose region reflects a region about a point. The fixed point is given by Column and Row. Theimage<br />

È ¼ of a point È is determined by the following requirement:<br />

If È Ë,thenÈ ¼ Ë, i.e., the point Ë is the fixed point of the mapping. If È Ë, Ë is the center point of a line<br />

segment connecting È and È ¼ . Therefore, the following equations result:<br />

ÓÐÙÑÒ Ü · ܼ<br />

¾<br />

ÊÓÛ Ý · ݼ<br />

<br />

¾<br />

If Row and Column are set to the origin, the in morphology often used transposition results.<br />

transpose region is often used to reflect (transpose) a structuring element.<br />

Hence<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.2. AFFINE-TRANSFORMATIONS 453<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Region to be reflected.<br />

º Transposed (output object) ..............................................region(-array) Hobject *<br />

Transposed region.<br />

º Row (input control) ...................................................................point.y long<br />

Row coordinate of the reference point.<br />

Default Value : 0<br />

Value Suggestions : Row ¾0, 64, 128, 256, 512<br />

Typical Range of Values : 0 Row 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Column (input control) ...............................................................point.x long<br />

Column coordinate of the reference point.<br />

Default Value : 0<br />

Value Suggestions : Column ¾0, 64, 128, 256, 512<br />

Typical Range of Values : 0 Column 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let be the area of the input region. Then the runtime complexity for one region is<br />

Ç´Ô<br />

µ <br />

Result<br />

transpose region returns H MSG TRUE if all parameters are correct. The behavior in case of empty or no<br />

input region can be set via:<br />

¯ no region: set system(’no object result’,)<br />

¯ empty region: set system(’empty region result’,)<br />

Otherwise, an exception is raised.<br />

Parallelization Information<br />

transpose region is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

reduce domain, (T )select shape, (T )area center, connection<br />

dilation1, opening, closing<br />

Morphology<br />

See Also<br />

Module<br />

zoom region ( Hobject Region, Hobject *RegionZoom, double ScaleWidth,<br />

double ScaleHeight )<br />

Zoom a region.<br />

zoom region enlarges or reduces the regions given in Region in the x- and y-direction by the given scale<br />

factors ScaleWidth and ScaleHeight.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Region(s) to be zoomed.<br />

º RegionZoom (output object) ..............................................region(-array) Hobject *<br />

Zoomed region(s).<br />

Parameter Number : RegionZoom Region<br />

<strong>HALCON</strong> 6.0


454 CHAPTER 9. REGIONS<br />

º ScaleWidth (input control) ......................................................extent.x double<br />

Scale factor in x-direction.<br />

Default Value : 2.0<br />

Value Suggestions : ScaleWidth ¾0.25, 0.5, 1.0, 2.0, 3.0<br />

Typical Range of Values : 0.0 ScaleWidth 100.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.5<br />

º ScaleHeight (input control) .....................................................extent.y double<br />

Scale factor in y-direction.<br />

Default Value : 2.0<br />

Value Suggestions : ScaleHeight ¾0.25, 0.5, 1.0, 2.0, 3.0<br />

Typical Range of Values : 0.0 ScaleHeight 100.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.5<br />

Parallelization Information<br />

zoom region is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring<br />

(T )select shape, disp region<br />

zoom image size, zoom image factor<br />

Region processing<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

9.3 Creation<br />

gen checker region ( Hobject *RegionChecker, long WidthRegion,<br />

long HeightRegion, long WidthPattern, long HeightPattern )<br />

Create a checkered region.<br />

The operator gen checker region returns a checkered region. Every black field of the checkerboard belongs<br />

to the region. The horizontal and vertical expansion of the region is limited by WidthRegion, HeightRegion<br />

respectively, the size of the fields of the checkerboard by WidthPattern ¢ HeightPattern.<br />

Attention<br />

If a very small pattern is chosen (WidthPattern 4) the created region requires much storage.<br />

Parameter<br />

º RegionChecker (output object) .................................................region Hobject *<br />

Created checkerboard region.<br />

º WidthRegion (input control) .......................................................extent.x long<br />

Largest occurring Ü value of the region.<br />

Default Value : 511<br />

Value Suggestions : WidthRegion ¾10, 20, 31, 63, 127, 255, 300, 400, 511<br />

Typical Range of Values : 1 WidthRegion 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : WidthRegion 1<br />

º HeightRegion (input control) ......................................................extent.y long<br />

Largest occurring Ý value of the region.<br />

Default Value : 511<br />

Value Suggestions : HeightRegion ¾10, 20, 31, 63, 127, 255, 300, 400, 511<br />

Typical Range of Values : 1 HeightRegion 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : HeightRegion 1<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.3. CREATION 455<br />

º WidthPattern (input control) ......................................................extent.y long<br />

Width of a field of the checkerboard.<br />

Default Value : 64<br />

Value Suggestions : WidthPattern ¾1, 2, 4, 8, 16, 20, 32, 64, 100, 128, 200, 300, 500<br />

Typical Range of Values : 1 WidthPattern 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : ´WidthPattern 0µ ´WidthPattern WidthRegionµ<br />

º HeightPattern (input control) ....................................................extent.y long<br />

Height of a field of the checkerboard.<br />

Default Value : 64<br />

Value Suggestions : HeightPattern ¾1, 2, 4, 8, 16, 20, 32, 64, 100, 128, 200, 300, 500<br />

Typical Range of Values : 1 HeightPattern 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : ´HeightPattern 0µ ´HeightPattern HeightRegionµ<br />

Example<br />

gen_checker_region(&Checker,512,512,32,64);<br />

set_draw(WindowHandle,"fill");<br />

set_part(WindowHandle,0,0,511,511);<br />

disp_region(Checker,WindowHandle);<br />

The required storage (in bytes) for the region is:<br />

Ç´´ÏØÊÓÒ £ ÀØÊÓÒµÏØÈØØÖÒµ<br />

Complexity<br />

Result<br />

The operator gen checker region returns the value H MSG TRUE if the parameter values are correct. Otherwise<br />

an exception handling is raised. The clipping according to the current image format is set via the operator<br />

set system(’clip region’,).<br />

Parallelization Information<br />

gen checker region is reentrant and processed without parallelization.<br />

paint region<br />

Possible Successor Functions<br />

Alternatives<br />

gen grid region, T gen region polygon filled, (T )gen region points,<br />

(T )gen region runs, (T )gen rectangle1, concat obj, gen random region,<br />

gen random regions<br />

See Also<br />

hamming change region, reduce domain<br />

Region processing<br />

Module<br />

gen circle ( Hobject *Circle, double Row, double Column, double Radius )<br />

T gen circle ( Hobject *Circle, Htuple Row, Htuple Column,<br />

Htuple Radius )<br />

Create a circle.<br />

The operator (T )gen circle generates one or more circles described by the center and Radius. If several<br />

circles shall be generated the coordinates must be passed in the form of tuples.<br />

The coordinate system runs from (0,0) (upper left corner) to (Width-1,Height-1). See get system and<br />

reset obj db in this context.<br />

<strong>HALCON</strong> 6.0


456 CHAPTER 9. REGIONS<br />

If an integer value (1,2,3..) is given for the radius the result is an even-numbered diameter and thus an asymmetrical<br />

circle. In case of an odd-numbered diameter (radius = 1.5,2.5,3.5...) a symmetrical circle is obtained.<br />

If the circle extends beyond the image edge it is clipped to the current image format according to the value of the<br />

system flag ’clip region’ (set system).<br />

Parameter<br />

º Circle (output object) ...................................................region(-array) Hobject *<br />

Generated circle.<br />

º Row (input control) ...................................circle.center.y(-array) (Htuple .) double / long<br />

Line index of center.<br />

Default Value : 200.0<br />

Value Suggestions : Row ¾0.0, 10.0, 50.0, 100.0, 200.0, 300.0<br />

Typical Range of Values : 1.0 Row 1024.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Column (input control) ...............................circle.center.x(-array) (Htuple .) double / long<br />

Column index of center.<br />

Default Value : 200.0<br />

Value Suggestions : Column ¾0.0, 10.0, 50.0, 100.0, 200.0, 300.0<br />

Typical Range of Values : 1.0 Column 1024.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Radius (input control) .................................circle.radius(-array) (Htuple .) double / long<br />

Radius of circle.<br />

Default Value : 100.5<br />

Value Suggestions : Radius ¾1.0, 1.5, 2.0, 2.5, 3, 3.5, 4, 4.5, 5.5, 6.5, 7.5, 9.5, 11.5, 15.5, 20.5, 25.5, 31.5,<br />

50.5<br />

Typical Range of Values : 1.0 Radius 1024.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : Radius 0.0<br />

Example<br />

open_window(0,0,-1,-1,"root","visible","",&WindowHandle);<br />

read_image(&Image,"meer");<br />

gen_circle(&Circle,300.0,200.0,150.5);<br />

reduce_domain(Image,Circle,Mask);<br />

disp_color(Mask,WindowHandle);<br />

Runtime complexity: Ç´ÊÙ× £ ¾µ<br />

Storage complexity (byte): Ç´ÊÙ× £ µ<br />

Complexity<br />

Result<br />

If the parameter values are correct, the operator (T )gen circle returns the value H MSG TRUE.<br />

Otherwise an exception handling is raised. The clipping according to the current image format is<br />

set via the operator set system(’clip region’,). If an empty region is<br />

created by clipping (the circle is completely outside of the image format) the operator set system<br />

(’store gen empty region’,) determines whether the empty region is put out.<br />

Parallelization Information<br />

(T )gen circle is reentrant and processed without parallelization.<br />

paint region, reduce domain<br />

Possible Successor Functions<br />

Alternatives<br />

(T )gen ellipse, T gen region polygon filled, (T )gen region points,<br />

(T )gen region runs, draw circle<br />

See Also<br />

disp circle, set shape, (T )smallest circle, reduce domain<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.3. CREATION 457<br />

Region processing<br />

Module<br />

gen ellipse ( Hobject *Ellipse, double Row, double Column, double Phi,<br />

double Radius1, double Radius2 )<br />

T gen ellipse ( Hobject *Ellipse, Htuple Row, Htuple Column, Htuple Phi,<br />

Htuple Radius1, Htuple Radius2 )<br />

Create an ellipse.<br />

The operator (T )gen ellipse generates one or more ellipses with the center (Row, Column), the orientation<br />

Phi and the half-radii Radius1 and Radius2. The angle is indicated in arc measure according to the Ü axis in<br />

mathematically positive direction. More than one region can be created by passing tuples of parameter values.<br />

The center must be located within the image coordinates. The coordinate system runs from (0,0) (upper left corner)<br />

to (Width-1,Height-1). See get system and reset obj db in this context. If the ellipse reaches beyond the<br />

edge of the image it is clipped to the current image format according to the value of the system flag ’clip region’<br />

(set system).<br />

Parameter<br />

º Ellipse (output object) ..................................................region(-array) Hobject *<br />

Created ellipse(s).<br />

º Row (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.y(-array) (Htuple .) double / long<br />

Line index of center.<br />

Default Value : 200.0<br />

Value Suggestions : Row ¾0.0, 10.0, 20.0, 50.0, 100.0, 256.0, 300.0, 400.0<br />

Typical Range of Values : 1.0 Row 1024.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Column (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.x(-array) (Htuple .) double / long<br />

Column index of center.<br />

Default Value : 200.0<br />

Value Suggestions : Column ¾0.0, 10.0, 20.0, 50.0, 100.0, 256.0, 300.0, 400.0<br />

Typical Range of Values : 1.0 Column 1024.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Phi (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.angle.rad(-array) (Htuple .) double / long<br />

Orientation of the longer radius (Radius1).<br />

Default Value : 0.0<br />

Value Suggestions : Phi ¾-1.178097, -0.785398, -0.392699, 0.0, 0.392699, 0.785398, 1.178097<br />

Typical Range of Values : -1.178097 Phi 1.178097 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

º Radius1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius1(-array) (Htuple .) double / long<br />

Longer radius.<br />

Default Value : 100.0<br />

Value Suggestions : Radius1 ¾2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 256.0, 300.0, 400.0<br />

Typical Range of Values : 1.0 Radius1 1024.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : Radius1 0<br />

<strong>HALCON</strong> 6.0


458 CHAPTER 9. REGIONS<br />

º Radius2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius2(-array) (Htuple .) double / long<br />

Shorter radius.<br />

Default Value : 60.0<br />

Value Suggestions : Radius2 ¾1.0, 2.0, 4.0, 5.0, 10.0, 20.0, 50.0, 100.0, 256.0, 300.0, 400.0<br />

Typical Range of Values : 1.0 Radius2 1024.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : ´Radius2 0µ ´Radius2 Radius1µ<br />

Example<br />

open_window(0,0,-1,-1,"root","visible","",&WindowHandle);<br />

set_insert(WindowHandle,"xor");<br />

do {<br />

get_mbutton(WindowHandle,&Row,&Column,&Button);<br />

gen_ellipse(&Ellipse,(double)Row,(double)Column,Column / 300.0,<br />

(Row % 100)+1.0,(Column % 50) + 1.0);<br />

disp_region(Ellipse,WindowHandle);<br />

clear_obj(Ellipse);<br />

} while(Button != 1);<br />

Runtime complexity: Ç´ÊÙ×½ £ ¾µ<br />

Storage complexity (byte): Ç´ÊÙ×½ £ µ<br />

Complexity<br />

Result<br />

If the parameter values are correct, the operator (T )gen ellipse returns the value H MSG TRUE. Otherwise<br />

an exception handling is raised. The clipping according to the current image format is set via the operator<br />

set system(’clip region’,).<br />

Parallelization Information<br />

(T )gen ellipse is reentrant and processed without parallelization.<br />

paint region, reduce domain<br />

Possible Successor Functions<br />

Alternatives<br />

(T )gen circle, T gen region polygon filled, draw ellipse<br />

See Also<br />

disp ellipse, set shape, (T )smallest circle, reduce domain<br />

Region processing<br />

Module<br />

gen empty region ( Hobject *EmptyRegion )<br />

Create an empty region.<br />

The operator gen empty region creates an empty region. This means that the output parameter contains an<br />

object. Thus, count obj returns 1. The area of the region is 0. Most of the shape features are undefined (0). It<br />

should be noted that an empty region must not be confused with the empty tuple.<br />

Parameter<br />

º EmptyRegion (output object) ...................................................region Hobject *<br />

Empty region (no pixels).<br />

Parallelization Information<br />

gen empty region is reentrant and processed without parallelization.<br />

Region processing<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.3. CREATION 459<br />

gen grid region ( Hobject *RegionGrid, long RowSteps, long ColumnSteps,<br />

const char *Type, long Width, long Height )<br />

Create a region from lines or pixels.<br />

The operator gen grid region creates a grid constructed of lines (Type = ’lines’) or pixels (Type = ’points’).<br />

In case of ’lines’ continuous lines are returned, in case of ’points’ only the intersections of the lines. Starting from<br />

the pixel (0,0) to the pixel (Height-1,Width-1) the grid is built up at stepping width RowSteps in line direction<br />

and ColumnSteps in column direction. In the ’lines’ mode RowSteps, ColumnSteps respectively, can be<br />

set to zero. In this case only columns, lines respectively, are created.<br />

Attention<br />

If a very small pattern is chosen (RowSteps 4 oder ColumnSteps 4) the created region requires much<br />

storage.<br />

In the ’points’ mode RowSteps and ColumnSteps must not be set to zero.<br />

Parameter<br />

º RegionGrid (output object) .....................................................region Hobject *<br />

Created lines/pixel region.<br />

º RowSteps (input control) ..................................................extent.y long / double<br />

Step width in line direction or zero.<br />

Default Value : 10<br />

Value Suggestions : RowSteps ¾0, 2, 3, 4, 5, 7, 10, 15, 20, 30, 50, 100<br />

Typical Range of Values : 0 RowSteps 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : ´RowSteps 1µ ´RowSteps 0µ<br />

º ColumnSteps (input control) ..............................................extent.x long / double<br />

Step width in column direction or zero.<br />

Default Value : 10<br />

Value Suggestions : ColumnSteps ¾0, 2, 3, 4, 5, 7, 10, 15, 20, 30, 50, 100<br />

Typical Range of Values : 0 ColumnSteps 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : ´ColumnSteps 1µ ´ColumnSteps 0µ<br />

º Type (input control) ............................................................string const char *<br />

Type of created pattern.<br />

Default Value : ’lines’<br />

Value List : Type ¾’lines’, ’points’<br />

º Width (input control) ...............................................................extent.x long<br />

Maximum width of pattern.<br />

Default Value : 512<br />

Value Suggestions : Width ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Width 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Width 1<br />

º Height (input control) ..............................................................extent.y long<br />

Maximum height of pattern.<br />

Default Value : 512<br />

Value Suggestions : Height ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Height 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Height 1<br />

Example<br />

read_image(&Image,"fabrik");<br />

gen_grid_region(&Raster,10,10,"lines",512,512);<br />

<strong>HALCON</strong> 6.0


460 CHAPTER 9. REGIONS<br />

reduce_domain(Image,Raster,&Mask);<br />

sobel_amp(Mask,GridSobel,"sum_abs",3);<br />

disp_image(GridSobel,WindowHandle);<br />

Complexity<br />

The necessary storage (in bytes) for the region is:<br />

Ç´´ÁÑÏ ØÓÐÙÑÒËØÔ×µ £ ´ÁÑÀØÊÓÛËØÔ×µµ<br />

Result<br />

If the parameter values are correct the operator gen grid region returns the value H MSG TRUE. Otherwise<br />

an exception handling is raised. The clipping according to the current image format is set via the operator<br />

set system(’clip region’,).<br />

Parallelization Information<br />

gen grid region is reentrant and processed without parallelization.<br />

reduce domain, paint region<br />

Possible Successor Functions<br />

Alternatives<br />

(T )gen region line, T gen region polygon, (T )gen region points,<br />

(T )gen region runs<br />

See Also<br />

gen checker region, reduce domain<br />

Region processing<br />

Module<br />

gen random region ( Hobject *RegionRandom, long Width, long Height )<br />

Create a random region.<br />

The operator gen random region returns a random region. During this process every pixel in the image area<br />

¼ ÏØ ½℄¼ ÀØ ½℄ is adapted into the region with the probability 0.5. The created region can be<br />

imagined as the threshold formation in an image with noise.<br />

This procedure is particularly important for the creation of uncorrelated binary patterns. The random pattern is<br />

created by the C function “nrand48()”.<br />

Attention<br />

If Width and Height are chosen large ( 100) the created region may require much storage space due to the<br />

internally used runlength coding. The gray values of the output region are undefined.<br />

Parameter<br />

º RegionRandom (output object) ..................................................region Hobject *<br />

Created random region with expansion Width x Height.<br />

º Width (input control) ...............................................................extent.x long<br />

Maximum horizontal expansion of random region.<br />

Default Value : 128<br />

Value Suggestions : Width ¾16, 32, 50, 64, 100, 128, 256, 300, 400, 512<br />

Typical Range of Values : 1 Width 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Width 0<br />

º Height (input control) ..............................................................extent.y long<br />

Maximum vertical expansion of random region.<br />

Default Value : 128<br />

Value Suggestions : Height ¾16, 32, 50, 64, 100, 128, 256, 300, 400, 512<br />

Typical Range of Values : 1 Height 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Height 0<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.3. CREATION 461<br />

Complexity<br />

The worst case for the storage complexity for the created region (in byte) is: Ç´Ï Ø £ ÀØ £ ¾µ.<br />

Result<br />

If the parameter values are correct, the operator gen random region returns the value H MSG TRUE. Otherwise<br />

an exception handling is raised. The clipping according to the current image format is set via the operator<br />

set system(’clip region’,).<br />

Parallelization Information<br />

gen random region is reentrant and processed without parallelization.<br />

paint region, reduce domain<br />

Possible Successor Functions<br />

See Also<br />

gen checker region, hamming change region, add noise distribution, add noise white,<br />

reduce domain<br />

Module<br />

Region processing<br />

gen random regions ( Hobject *Regions, const char *Type,<br />

double WidthMin, double WidthMax, double HeightMin, double HeightMax,<br />

double PhiMin, double PhiMax, long NumRegions, long Width, long Height )<br />

Create random regions like circles, rectangles and ellipses.<br />

The operator gen random region generates circles, rectangles and ellipses whose parameters are determined<br />

at random. In each case only one lower, upper limit respectively, is given. The position is always random and<br />

cannot be determined by parameters. The parameter NumRegions indicates how many regions shall be created.<br />

Parameter<br />

º Regions (output object) ...................................................region-array Hobject *<br />

Created regions.<br />

º Type (input control) ............................................................string const char *<br />

Type of regions to be created.<br />

Default Value : ’circle’<br />

Value List : Type ¾’circle’, ’ring’, ’ellipse’, ’rectangle1’, ’rectangle2’<br />

º WidthMin (input control) ...................................................number double / long<br />

Minimum width of the region.<br />

Default Value : 10.0<br />

Value Suggestions : WidthMin ¾1.0, 3.0, 5.0, 10.0, 20.0, 40.0, 80.0<br />

Typical Range of Values : 1.0 WidthMin 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : WidthMin 0<br />

º WidthMax (input control) ...................................................number double / long<br />

Maximum width of the region.<br />

Default Value : 20.0<br />

Value Suggestions : WidthMax ¾1.0, 3.0, 5.0, 10.0, 20.0, 40.0, 80.0<br />

Typical Range of Values : 1.0 WidthMax 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : WidthMax 0<br />

º HeightMin (input control) .................................................number double / long<br />

Minimum height of the region.<br />

Default Value : 10.0<br />

Value Suggestions : HeightMin ¾1.0, 3.0, 5.0, 10.0, 20.0, 40.0, 80.0<br />

Typical Range of Values : 1.0 HeightMin 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : HeightMin 0<br />

<strong>HALCON</strong> 6.0


462 CHAPTER 9. REGIONS<br />

º HeightMax (input control) .................................................number double / long<br />

Maximum height of the region.<br />

Default Value : 30.0<br />

Value Suggestions : HeightMax ¾1.0, 3.0, 5.0, 10.0, 20.0, 40.0, 80.0<br />

Typical Range of Values : 1.0 HeightMax 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : HeightMax 0<br />

º PhiMin (input control) .....................................................number double / long<br />

Minimum rotation angle of the region.<br />

Default Value : -0.7854<br />

Value Suggestions : PhiMin ¾0.0, 0.1, 0.3, 0.6, 0.9, 1.2, 1.5<br />

Typical Range of Values : 0.0 PhiMin 6.28 (lin)<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.10<br />

Restriction : PhiMin 0<br />

º PhiMax (input control) .....................................................number double / long<br />

Maximum rotation angle of the region.<br />

Default Value : 0.7854<br />

Value Suggestions : PhiMax ¾0.0, 0.1, 0.3, 0.6, 0.9, 1.2, 1.5<br />

Typical Range of Values : 0.0 PhiMax 6.28 (lin)<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.10<br />

Restriction : PhiMax 0<br />

º NumRegions (input control) .........................................................integer long<br />

Number of regions.<br />

Default Value : 100<br />

Value Suggestions : NumRegions ¾1, 5, 20, 100, 200, 500, 1000, 2000<br />

Typical Range of Values : 1 NumRegions 2000 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : NumRegions 0<br />

º Width (input control) ................................................................integer long<br />

Maximum horizontal expansion.<br />

Default Value : 512<br />

Value Suggestions : Width ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Width 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Width 0<br />

º Height (input control) ...............................................................integer long<br />

Maximum vertical expansion.<br />

Default Value : 512<br />

Value Suggestions : Height ¾128, 256, 512, 1024<br />

Typical Range of Values : 1 Height 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Height 0<br />

Result<br />

If the parameter values are correct gen random regions returns the value H MSG TRUE. Otherwise an exception<br />

handling is raised. The clipping according to the current image format is determined by the operator<br />

set system(’clip region’,).<br />

Parallelization Information<br />

gen random regions is reentrant and processed without parallelization.<br />

paint region<br />

Region processing<br />

Possible Successor Functions<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.3. CREATION 463<br />

gen rectangle1 ( Hobject *Rectangle, double Row1, double Column1,<br />

double Row2, double Column2 )<br />

T gen rectangle1 ( Hobject *Rectangle, Htuple Row1, Htuple Column1,<br />

Htuple Row2, Htuple Column2 )<br />

Create a rectangle parallel to the coordinate axes.<br />

The operator (T )gen rectangle1 generates one or more rectangles parallel to the coordinate axes which are<br />

described by the upper left corner (Row1, Column1) and the lower right corner (Row2, Column2). More than<br />

one region can be created by passing a tuple of corner points. The coordinate system runs from (0,0) (upper left<br />

corner) to (Width-1,Height-1). See get system and reset obj db in this context.<br />

Parameter<br />

º Rectangle (output object) ...............................................region(-array) Hobject *<br />

Created rectangle.<br />

º Row1 (input control) ...............................rectangle.origin.y(-array) (Htuple .) double / long<br />

Line of upper left corner point.<br />

Default Value : 30.0<br />

Value Suggestions : Row1 ¾0.0, 10.0, 20.0, 50.0, 100.0, 200.0<br />

Typical Range of Values : ½ Row1 ½(lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Column1 (input control) ...........................rectangle.origin.x(-array) (Htuple .) double / long<br />

Column of upper left corner point.<br />

Default Value : 20.0<br />

Value Suggestions : Column1 ¾0.0, 10.0, 20.0, 50.0, 100.0, 200.0<br />

Typical Range of Values : ½ Column1 ½(lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Row2 (input control) ..............................rectangle.corner.y(-array) (Htuple .) double / long<br />

Line of lower right corner point.<br />

Default Value : 100.0<br />

Value Suggestions : Row2 ¾10.0, 20.0, 50.0, 100.0, 200.0, 300.0, 400.0, 500.0, 511.0<br />

Typical Range of Values : ½ Row2 ½(lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : Row2 Row1<br />

º Column2 (input control) ..........................rectangle.corner.x(-array) (Htuple .) double / long<br />

Column of lower right corner point.<br />

Default Value : 200.0<br />

Value Suggestions : Column2 ¾10.0, 20.0, 50.0, 100.0, 200.0, 300.0, 400.0, 500.0, 511.0<br />

Typical Range of Values : ½ Column2 ½(lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : Column2 Column1<br />

Example<br />

/* Contrast improvement in a rectangular region of interest */<br />

read_image(&Image,"fabrik");<br />

open_window(0,0,-1,-1,"root","visible","",&WindowHandle);<br />

disp_image(Image,WindowHandle);<br />

draw_rectangle1(WindowHandle,&Row1,&Column1,&Row2,&Column2);<br />

gen_rectangle1(&Rect,(double)Row1,(double)Column1,<br />

(double)Row2,(double)Column2);<br />

reduce_domain(Image,Rect,&Mask);<br />

emphasize(Mask,&Emphasize,9,9,1.0);<br />

disp_image(Emphasize,WindowHandle);<br />

<strong>HALCON</strong> 6.0


464 CHAPTER 9. REGIONS<br />

Result<br />

If the parameter values are correct, the operator (T )gen rectangle1 returns the value H MSG TRUE. Otherwise<br />

an exception handling is raised. The clipping according to the current image format is set via the operator<br />

set system(’clip region’,).<br />

Parallelization Information<br />

(T )gen rectangle1 is reentrant and processed without parallelization.<br />

paint region, reduce domain<br />

Possible Successor Functions<br />

Alternatives<br />

(T )gen rectangle2, T gen region polygon, fill up, (T )gen region runs,<br />

(T )gen region points, (T )gen region line<br />

See Also<br />

draw rectangle1, reduce domain, (T )smallest rectangle1<br />

Region processing<br />

Module<br />

gen rectangle2 ( Hobject *Rectangle, double Row, double Column,<br />

double Phi, double Length1, double Length2 )<br />

T gen rectangle2 ( Hobject *Rectangle, Htuple Row, Htuple Column,<br />

Htuple Phi, Htuple Length1, Htuple Length2 )<br />

Create a rectangle of any orientation.<br />

The operator (T )gen rectangle2 generates one or more rectangles with the center (Row, Column) ,the<br />

orientation Phi and the half edge lengths Length1 and Length2. The orientation is given in arc measure and<br />

indicates the angle between the horizontal axis and Length1 (mathematically positive). The coordinate system<br />

runs from (0,0) (upper left corner) to (Width-1,Height-1). See get system and reset obj db in this context.<br />

More than one region can be created by passing one tuple of corner points.<br />

Attention<br />

The gray values of the output objects are undefined.<br />

Parameter<br />

º Rectangle (output object) ...............................................region(-array) Hobject *<br />

Created rectangle.<br />

º Row (input control) ...............................rectangle2.center.y(-array) (Htuple .) double / long<br />

Line index of the center.<br />

Default Value : 50.0<br />

Value Suggestions : Row ¾10.0, 20.0, 50.0, 100.0, 200.0, 300.0, 400.0, 500.0<br />

Typical Range of Values : ½ Row ½(lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Column (input control) ...........................rectangle2.center.x(-array) (Htuple .) double / long<br />

Column index of the center.<br />

Default Value : 100.0<br />

Value Suggestions : Column ¾10.0, 20.0, 50.0, 100.0, 200.0, 300.0, 400.0, 500.0<br />

Typical Range of Values : ½ Column ½(lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Phi (input control) ..............................rectangle2.angle.rad(-array) (Htuple .) double / long<br />

Angle of longitudinal axis to horizontal (arc measure).<br />

Default Value : 0.0<br />

Value Suggestions : Phi ¾-1.178097, -0.785398, -0.392699, 0.0, 0.392699, 0.785398, 1.178097<br />

Typical Range of Values : -1.178097 Phi 1.178097 (lin)<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.1<br />

Restriction : ´´ pi2µ Phiµ ´Phi ´pi2µµ<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.3. CREATION 465<br />

º Length1 (input control) ..........................rectangle2.hwidth(-array) (Htuple .) double / long<br />

Half width.<br />

Default Value : 200.0<br />

Value Suggestions : Length1 ¾3.0, 5.0, 10.0, 15.0, 20.0, 50.0, 100.0, 200.0, 300.0, 500.0<br />

Typical Range of Values : ½ Length1 ½(lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Length2 (input control) ..........................rectangle2.hheight(-array) (Htuple .) double / long<br />

Half height.<br />

Default Value : 100.0<br />

Value Suggestions : Length2 ¾1.0, 2.0, 3.0, 5.0, 10.0, 15.0, 20.0, 50.0, 100.0, 200.0<br />

Typical Range of Values : ½ Length2 ½(lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : Length2 Length1<br />

Result<br />

If the parameter values are correct the operator (T )gen rectangle2 returns the value H MSG TRUE. Otherwise<br />

an exception handling is raised. The clipping according to the current image format is set via the operator<br />

set system(’clip region’,).<br />

Parallelization Information<br />

(T )gen rectangle2 is reentrant and processed without parallelization.<br />

paint region, reduce domain<br />

Possible Successor Functions<br />

Alternatives<br />

(T )gen rectangle1, T gen region polygon filled, T gen region polygon,<br />

(T )gen region points, fill up<br />

See Also<br />

draw rectangle2, reduce domain, (T )smallest rectangle2, (T )gen ellipse<br />

Region processing<br />

Module<br />

T gen region histo ( Hobject *Region, Htuple Histogramm, Htuple Row,<br />

Htuple Column, Htuple Scale )<br />

Convert a histogram into a region.<br />

T gen region histo converts a histogram created with gray histo into a region. The effect of the three<br />

control parameters is the same as in disp image and set paint.<br />

Parameter<br />

º Region (output object) ..........................................................region Hobject *<br />

Region containing the histogram.<br />

º Histogramm (input control) .........................................histogram-array Htuple . long<br />

Input histogram.<br />

º Row (input control) ...........................................................point.y Htuple . long<br />

Row coordinate of the center of the histogram.<br />

Default Value : 255<br />

Value Suggestions : Row ¾100, 200, 255, 300, 400<br />

Typical Range of Values : 0 Row 511<br />

º Column (input control) .......................................................point.x Htuple . long<br />

Column coordinate of the center of the histogram.<br />

Default Value : 255<br />

Value Suggestions : Column ¾100, 200, 255, 300, 400<br />

Typical Range of Values : 0 Column 511<br />

<strong>HALCON</strong> 6.0


466 CHAPTER 9. REGIONS<br />

º Scale (input control) ........................................................integer Htuple . long<br />

Scale factor for the histogram.<br />

Default Value : 1<br />

Value List : Scale ¾1, 2, 3, 4, 5, 6, 7<br />

Typical Range of Values : 1 Scale 10 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Result<br />

T gen region histo returns H MSG TRUE if all parameters are correct. If necessary, an exception handling<br />

is raised.<br />

Parallelization Information<br />

T gen region histo is reentrant and processed without parallelization.<br />

gray histo<br />

disp channel, set paint<br />

Region processing<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

gen region hline ( Hobject *Regions, double Orientation,<br />

double Distance )<br />

T gen region hline ( Hobject *Regions, Htuple Orientation,<br />

Htuple Distance )<br />

Store input lines described in Hesse normal shape as regions.<br />

The operator (T )gen region hline stores the lines described in Hesse normal shape as regions. A line is<br />

determined by the distance from the line to the origin (Distance, corresponds to the length of the normal vector)<br />

and the direction of the normal vector (Orientation, corresponds to the orientation of the line ¦¾). The<br />

directions were defined in such a way that at Orientation = 0 the normal vector lies in the direction of the X<br />

axis, which corresponds to a vertical line. At Orientation = ¾ the normal vector points in the direction of<br />

the Y axis, i.e. a horizontal line is described.<br />

Attention<br />

The lines are clipped to the current maximum image format.<br />

Parameter<br />

º Regions (output object) ..................................................region(-array) Hobject *<br />

Created regions (one for every line), clipped to maximum image format.<br />

Parameter Number : Regions Distance<br />

º Orientation (input control) ....................hesseline.angle.rad(-array) (Htuple .) double / long<br />

Orientation of the normal vector in radians.<br />

Default Value : 0.0<br />

Value Suggestions : Orientation ¾-0.78, 0.0, 0.78, 1.57<br />

Typical Range of Values : ½ Orientation ½(lin)<br />

Recommended Value Step : 0.02<br />

Parameter Number : Orientation Distance<br />

º Distance (input control) .........................hesseline.distance(-array) (Htuple .) double / long<br />

Distance from the line to the coordinate origin (0.0).<br />

Default Value : 200<br />

Value Suggestions : Distance ¾10, 50, 100, 200, 300, 400<br />

Typical Range of Values : ½ Distance ½(lin)<br />

Recommended Value Step : 1<br />

Result<br />

The operator (T )gen region hline always returns the value H MSG TRUE.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.3. CREATION 467<br />

Parallelization Information<br />

(T )gen region hline is reentrant and processed without parallelization.<br />

(T )gen region line<br />

hough lines<br />

Region processing<br />

Alternatives<br />

See Also<br />

Module<br />

gen region line ( Hobject *RegionLines, long BeginRow, long BeginCol,<br />

long EndRow, long EndCol )<br />

T gen region line ( Hobject *RegionLines, Htuple BeginRow,<br />

Htuple BeginCol, Htuple EndRow, Htuple EndCol )<br />

Store input lines as regions.<br />

The operator (T )gen region line stores the given lines (with starting point [BeginRow,BeginCol] and<br />

ending point [EndRow, EndCol]) as region.<br />

Parameter<br />

º RegionLines (output object) ............................................region(-array) Hobject *<br />

Created regions.<br />

º BeginRow (input control) .......................................line.begin.y(-array) (Htuple .) long<br />

Line coordinates of the starting points of the input lines.<br />

Default Value : 100<br />

Value Suggestions : BeginRow ¾10, 50, 100, 200, 300, 400<br />

Typical Range of Values : ½ BeginRow ½(lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º BeginCol (input control) .......................................line.begin.x(-array) (Htuple .) long<br />

Column coordinates of the starting points of the input lines.<br />

Default Value : 50<br />

Value Suggestions : BeginCol ¾10, 50, 100, 200, 300, 400<br />

Typical Range of Values : ½ BeginCol ½(lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º EndRow (input control) ............................................line.end.y(-array) (Htuple .) long<br />

Line coordinates of the ending points of the input lines.<br />

Default Value : 150<br />

Value Suggestions : EndRow ¾50, 100, 200, 300, 400, 500<br />

Typical Range of Values : ½ EndRow ½(lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º EndCol (input control) ............................................line.end.x(-array) (Htuple .) long<br />

Column coordinates of the ending points of the input lines.<br />

Default Value : 250<br />

Value Suggestions : EndCol ¾50, 100, 200, 300, 400, 500<br />

Typical Range of Values : ½ EndCol ½(lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Result<br />

The operator (T )gen region line always returns the value H MSG TRUE. The clipping according to the<br />

current image format is determined by the operator set system(’clip region’,).<br />

Parallelization Information<br />

(T )gen region line is reentrant and processed without parallelization.<br />

<strong>HALCON</strong> 6.0


468 CHAPTER 9. REGIONS<br />

T split skeleton lines<br />

(T )gen region hline<br />

Region processing<br />

Possible Predecessor Functions<br />

Alternatives<br />

Module<br />

gen region points ( Hobject *Region, long Rows, long Columns )<br />

T gen region points ( Hobject *Region, Htuple Rows, Htuple Columns )<br />

Store individual pixels as image region.<br />

The operator (T )gen region points creates a region described by a number of pixels. The pixels do not<br />

have to be stored in a fixed order, but the best runtime behavior is obtained when the pixels are stored in ascending<br />

order. The order is as follows:<br />

´Ð ½ ½ µ ´Ð ¾ ¾ µ´Ð ½ Ð ¾ µ ´Ð ½ Ð ¾ µ ´ ½ ¾ µ<br />

The indicated coordinates stand for two consecutive pixels in the tupel.<br />

Attention<br />

The gray values of the output regions are undefined. All pixels must be located within the image format. If no<br />

pixels are passed an empty region is created.<br />

Parameter<br />

º Region (output object) ..........................................................region Hobject *<br />

Created region.<br />

º Rows (input control) ...........................................coordinates.y(-array) (Htuple .) long<br />

Lines of the pixels in the region.<br />

Default Value : 100<br />

Value Suggestions : Rows ¾0, 10, 30, 50, 100, 200, 300, 500<br />

Typical Range of Values : ½ Rows ½(lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Columns (input control) .......................................coordinates.x(-array) (Htuple .) long<br />

Columns of the pixels in the region.<br />

Default Value : 100<br />

Value Suggestions : Columns ¾0, 10, 30, 50, 100, 200, 300, 500<br />

Typical Range of Values : ½ Columns ½(lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Parameter Number : Columns Rows<br />

Complexity<br />

shall be the number of pixels. If the pixels are sorted in ascending order the runtime complexity is: Ç´ µ,<br />

otherwise Ç´ÐÓ´ µ £ µ.<br />

Result<br />

The operator (T )gen region points returns the value H MSG TRUE if the pixels are located within the image<br />

format. Otherwise an exception handling is raised. The clipping according to the current image format is set via<br />

the operator set system(’clip region’,). If an empty region is created (empty<br />

input) the operator set system(’store gen empty region’,) determines whether the<br />

region is returned.<br />

Parallelization Information<br />

(T )gen region points is reentrant, local, and processed without parallelization.<br />

T get region points<br />

Possible Predecessor Functions<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.3. CREATION 469<br />

paint region, reduce domain<br />

Possible Successor Functions<br />

Alternatives<br />

T gen region polygon, (T )gen region runs, (T )gen region line<br />

reduce domain<br />

Region processing<br />

See Also<br />

Module<br />

T gen region polygon ( Hobject *Region, Htuple Rows, Htuple Columns )<br />

Store a polygon as an image object.<br />

The operator T gen region polygon creates a region from a polygon row described by a series of line and<br />

column coordinates. The created region consists of the pixels of the routes defined thereby, wherein it is linearily<br />

interpolated between the base points.<br />

Attention<br />

The region is automatically closed and not filled. The gray values of the output regions are undefined. All base<br />

points must be located within the image format. If no pixels are passed an empty region is created.<br />

Parameter<br />

º Region (output object) ..........................................................region Hobject *<br />

Created region.<br />

º Rows (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . polygon.y-array Htuple . long<br />

Line indices of the base points of the region contour.<br />

Default Value : 100<br />

Value Suggestions : Rows ¾0, 10, 30, 50, 100, 200, 300, 500<br />

Typical Range of Values : ½ Rows ½(lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Columns (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . polygon.x-array Htuple . long<br />

Colum indices of the base points of the region contour.<br />

Default Value : 100<br />

Value Suggestions : Columns ¾0, 10, 30, 50, 100, 200, 300, 500<br />

Typical Range of Values : ½ Columns ½(lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Parameter Number : Columns Rows<br />

Example<br />

/* Polygon-approximation */<br />

T_get_region_polygon(Region,7,&Row,&Column);<br />

/* store it as a region */<br />

T_gen_region_polygon(&Pol,Row,Column);<br />

destroy_tuple(Row);<br />

destroy_tuple(Column);<br />

/* fill up the hole */<br />

fill_up(Pol,&Filled);<br />

Result<br />

If the base points are correct the operator T gen region polygon returns the value H MSG TRUE. Otherwise<br />

an exception handling is raised. The clipping according to the current image format is set via the operator<br />

set system(’clip region’,). If an empty region is created the operator<br />

set system(’store gen empty region’,) determines whether the region is returned.<br />

Parallelization Information<br />

T gen region polygon is reentrant, local, and processed without parallelization.<br />

<strong>HALCON</strong> 6.0


470 CHAPTER 9. REGIONS<br />

Possible Predecessor Functions<br />

T get region polygon, draw polygon<br />

Alternatives<br />

T gen region polygon filled, (T )gen region points, (T )gen region runs<br />

See Also<br />

fill up, reduce domain, T get region polygon, draw polygon<br />

Region processing<br />

Module<br />

T gen region polygon filled ( Hobject *Region, Htuple Rows,<br />

Htuple Columns )<br />

Store a polygon as a “filled” region.<br />

The operator T gen region polygon filled creates a region from a polygon containing the corner<br />

points of the region (line and column coordinates) either clockwise or anti-clockwise. Contrary to<br />

T gen region polygon a “filled” region is returned here.<br />

Attention<br />

All base points must be located within the image format. If no pixels are passed an empty region is created.<br />

Parameter<br />

º Region (output object) ..........................................................region Hobject *<br />

Created region.<br />

º Rows (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . polygon.y-array Htuple . long<br />

Line indices of the base points of the region contour.<br />

Default Value : 100<br />

Value Suggestions : Rows ¾0, 10, 30, 50, 100, 200, 300, 500<br />

Typical Range of Values : ½ Rows ½(lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Columns (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . polygon.x-array Htuple . long<br />

Column indices of the base points of the region contour.<br />

Default Value : 100<br />

Value Suggestions : Columns ¾0, 10, 30, 50, 100, 200, 300, 500<br />

Typical Range of Values : ½ Columns ½(lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Parameter Number : Columns Rows<br />

Example<br />

/* Polygon approximation */<br />

T_get_region_polygon(Region,7,&Row,&Column);<br />

T_gen_region_polygon_filled(&Pol,Row,Column);<br />

/* fill up with original gray value */<br />

reduce_domain(Image,Pol,&New);<br />

Result<br />

If the base points are correct the operator T gen region polygon filled returns the value H MSG TRUE.<br />

Otherwise an exception handling is raised. If an empty region is created the operator set system<br />

(’store gen empty region’,) determines whether the region is returned.<br />

Parallelization Information<br />

T gen region polygon filled is reentrant, local, and processed without parallelization.<br />

Possible Predecessor Functions<br />

T get region polygon, draw polygon<br />

Alternatives<br />

T gen region polygon, (T )gen region points, draw polygon<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.3. CREATION 471<br />

See Also<br />

T gen region polygon, reduce domain, T get region polygon, (T )gen region runs<br />

Region processing<br />

Module<br />

gen region runs ( Hobject *Region, long Row, long ColumnBegin,<br />

long ColumnEnd )<br />

T gen region runs ( Hobject *Region, Htuple Row, Htuple ColumnBegin,<br />

Htuple ColumnEnd )<br />

Create an image region from a runlength coding.<br />

The operator (T )gen region runs creates a region described by the input runlength structure. The runlength<br />

representation is created by examining a region line by line with ascending line number (= from “top” to “bottom”).<br />

Every line runs through from left to right (ascending column number)Ȧll starting and ending points being stored<br />

by region segments (=runs). Thus a region can be described by a sequence of runs, a run being defined by line<br />

number as well as starting and ending points (column number).<br />

The storing is fastest when the runs are sorted. The order is as follows:<br />

.<br />

´Ð ½ ½ ½ µ ´Ð ¾ ¾ ¾ µ´Ð ½ Ð ¾ µ ´Ð ½ Ð ¾ µ ´ ½ ¾ µ<br />

Attention<br />

All pixels must be located within the image format. If no runs are passed an empty region is created.<br />

Parameter<br />

º Region (output object) ..........................................................region Hobject *<br />

Created region.<br />

º Row (input control) ..................................................chord.y(-array) (Htuple .) long<br />

Lines of the runs.<br />

Default Value : 100<br />

Value Suggestions : Row ¾0, 50, 100, 200, 300, 500<br />

Typical Range of Values : ½ Row ½(lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º ColumnBegin (input control) ......................................chord.x1(-array) (Htuple .) long<br />

Columns of the starting points of the runs.<br />

Default Value : 50<br />

Value Suggestions : ColumnBegin ¾0, 50, 100, 200, 300, 500<br />

Typical Range of Values : ½ ColumnBegin ½(lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Parameter Number : ColumnBegin Row<br />

º ColumnEnd (input control) ........................................chord.x2(-array) (Htuple .) long<br />

Columns of the ending points of the runs.<br />

Default Value : 200<br />

Value Suggestions : ColumnEnd ¾50, 100, 200, 300, 500<br />

Typical Range of Values : ½ ColumnEnd ½(lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Parameter Number : ColumnEnd Row<br />

Restriction : ColumnEnd ColumnBegin<br />

Complexity<br />

shall be the number of pixels. If the pixels are sorted in ascending order the runtime complexity is: Ç´ µ,<br />

otherwise it is Ç´ÐÓ´ µ £ µ.<br />

<strong>HALCON</strong> 6.0


472 CHAPTER 9. REGIONS<br />

Result<br />

If the data is correct the operator (T )gen region runs returns the value H MSG TRUE, otherwise an exception<br />

handling is raised. The clipping according to the current image format is set via the operator set system<br />

(’clip region’,). If an empty region is created (= empty input) the operator<br />

set system(’store gen empty region’,) determines whether the region is returned.<br />

Parallelization Information<br />

(T )gen region runs is reentrant, local, and processed without parallelization.<br />

T get region runs<br />

Possible Predecessor Functions<br />

Alternatives<br />

(T )gen region points, T gen region polygon, (T )gen region line,<br />

T gen region polygon filled<br />

See Also<br />

reduce domain<br />

Module<br />

Region processing<br />

label to region ( Hobject LabelImage, Hobject *Regions )<br />

Extract regions with equal gray values from an image.<br />

label to region segments an image into regions of equal gray value. One output region is generated for<br />

each gray value occuring in the image. This is similar to calling threshold multiple times, and accumulating<br />

the results with concat obj. Another related operator is regiongrowing. However,label to region<br />

does not perform a connection operation on the resulting regions, i.e., they may be disconnected. A typical<br />

application of label to region is the segmentation of label images, hence its name.<br />

The number of output regions is limited by the system parameter ’max outp obj par’, which can be read via<br />

get system(::’max outp obj par’:Anzahl).<br />

Attention<br />

label to region is not implemented for images of type ’real’. The input images must not contain negative<br />

gray values.<br />

Parameter<br />

º LabelImage (input object) ................................image(-array) Hobject : byte / int2 / int4<br />

Label image.<br />

º Regions (output object) ...................................................region-array Hobject *<br />

Regions having a constant gray value.<br />

Complexity<br />

Let ܽ be the minimum x-coordinate, ܾ the maximum x-coordinate, ݽ be the minimum y-coordinate, and ݾ the<br />

maximum y-coordinate of a particular gray value. Furthermore, let Æ be the number of different gray values in the<br />

image. Then the runtime complexity is Ç´Æ £ ´Ü¾ ܽ ·½µ£ ´Ý¾ ݽ · ½µµ<br />

Result<br />

label to region returns H MSG TRUE if the gray values lie within a correct range. The behavior with respect<br />

to the input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

label to region is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

min max gray, sobel amp, gauss image, reduce domain, diff of gauss<br />

Possible Successor Functions<br />

connection, dilation1, erosion1, opening, closing, rank region, shape trans, skeleton<br />

See Also<br />

threshold, concat obj, regiongrowing, region to label<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 473<br />

Region processing<br />

Module<br />

9.4 Features<br />

area center ( Hobject Regions, long *Area, double *Row, double *Column )<br />

T area center ( Hobject Regions, Htuple *Area, Htuple *Row,<br />

Htuple *Column )<br />

Area and center of regions.<br />

The operator (T )area center calculates the area and the center of the input regions. The area is defined as<br />

the number of pixels of a region. The center is calculated as the mean value of the line or column coordinates,<br />

respectively, of all pixels.<br />

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to<br />

the index of the input region. In case of empty region all parameters have the value 0.0 if no other behavior was<br />

set (see set system).<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region(s) to be examined.<br />

º Area (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Area of the region.<br />

º Row (output control) .............................................point.y(-array) (Htuple .) double *<br />

Line index of the center.<br />

º Column (output control) .........................................point.x(-array) (Htuple .) double *<br />

Column index of the center.<br />

Example<br />

threshold(&Image,&Seg,120.0,255.0);<br />

connection(Seg,&Connected);<br />

T_area_center(Connected,&Area,&Row,&Column);<br />

Complexity<br />

If is the area of a region the mean runtime complexity is Ç´Ô<br />

µ.<br />

Result<br />

The operator (T )area center returns the value H MSG TRUE if the input is not empty. The<br />

behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )area center is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

(T )select shape<br />

Region processing<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


474 CHAPTER 9. REGIONS<br />

circularity ( Hobject Regions, double *Circularity )<br />

T circularity ( Hobject Regions, Htuple *Circularity )<br />

Shape factor for the circularity (similarity to a circle) of a region.<br />

The operator (T )circularity calculates the similarity of the input region with a circle.<br />

Calculation: If F is the area of the region and max is the maximum distance from the center to all contour pixels,<br />

the shape factor C is defined as:<br />

<br />

<br />

´ÑÜ ¾ £ µ<br />

The shape factor of a circle is 1. If the region is long or has holes is smaller than 1. The operator<br />

(T )circularity especially responds to large bulges, holes and unconnected regions.<br />

In case of an empty region the operator (T )circularity returns the value 0 (if no other behavior was set (see<br />

set system)). If more than one region is passed the numerical values of the shape factor are stored in a tuple,<br />

the position of a value in the tuple corresponding to the position of the region in the input tuple.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region(s) to be examined.<br />

º Circularity (output control) .....................................real(-array) (Htuple .) double *<br />

Roundness of the input region(s).<br />

Assertion : ´0 Circularityµ ´Circularity 1.0µ<br />

Example<br />

/* Comparison between shape factors of rectangle, circle and ellipse */<br />

gen_rectangle1(&R1,10.0,10.0,20.0,20.0);<br />

gen_rectangle2(&R2,100.0,100.0,0.0,100.0,20.0);<br />

gen_ellipse(&E,100.0,100.0,0.0,100.0,20.0);<br />

gen_circle(&C,100.0,100.0,20.0);<br />

circularity(R1,&R1_);<br />

circularity(R2,&R2_);<br />

circularity(E,&E_);<br />

circularity(C,&C_);<br />

printf("quadrate: %g\n",R1_);<br />

printf("rectangle: %g\n",R2_);<br />

printf("ellipse: %g\n",E_);<br />

printf("circle: %g\n",C_);<br />

Result<br />

The operator (T )circularity returns the value H MSG TRUE if the input is not empty. The<br />

behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )circularity is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

Alternatives<br />

(T )roundness, (T )compactness, (T )convexity, (T )eccentricity<br />

(T )area center, (T )select shape<br />

Region processing<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 475<br />

compactness ( Hobject Regions, double *Compactness )<br />

T compactness ( Hobject Regions, Htuple *Compactness )<br />

Shape factor for the compactness of a region.<br />

The operator (T )compactness calculates the compactness of the input regions.<br />

Calculation: If Ä is the length of the contour (see (T )contlength) and the area of the region the shape<br />

factor is defined as:<br />

<br />

ľ<br />

<br />

The shape factor of a circle is 1. If the region is long or has holes is larger than 1. The operator<br />

(T )compactness responds to the course of the contour (roughness) and to holes. In case of an empty region<br />

the operator (T )compactness returns the value 0 if no other behavior was set (see set system). If<br />

more than one region is passed the numerical values of the shape factor are stored in a tuple, the position of a value<br />

in the tuple corresponding to the position of the region in the input tuple.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region(s) to be examined.<br />

º Compactness (output control) .....................................real(-array) (Htuple .) double *<br />

Compactness of the input region(s).<br />

Assertion : ´Compactness 1.0µ ´Compactness 0µ<br />

Result<br />

The operator (T )compactness returns the value H MSG TRUE if the input is not empty. The<br />

behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )compactness is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

Alternatives<br />

(T )compactness, (T )convexity, (T )eccentricity<br />

See Also<br />

(T )contlength, (T )area center, (T )select shape<br />

Region processing<br />

Module<br />

connect and holes ( Hobject Regions, long *NumConnected,<br />

long *NumHoles )<br />

T connect and holes ( Hobject Regions, Htuple *NumConnected,<br />

Htuple *NumHoles )<br />

Number of connection components and holes<br />

The operator (T )connect and holes calculates the number of connection components and the number of<br />

holes of each region of Regions.<br />

If more than one region is passed the numerical values of the output control parameters NumConnected and<br />

NumHoles are each stored in a tuple, the position of a value in the tuple corresponding to the position of the<br />

region in the input tuple.<br />

<strong>HALCON</strong> 6.0


476 CHAPTER 9. REGIONS<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region(s) to be examined.<br />

º NumConnected (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Number of connection components of a region.<br />

º NumHoles (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long *<br />

Number of holes of a region.<br />

Result<br />

The operator (T )connect and holes returns the value H MSG TRUE if the input is not empty.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set)<br />

is set via set system(’empty region result’,).<br />

Parallelization Information<br />

(T )connect and holes is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

(T )euler number<br />

Alternatives<br />

See Also<br />

connection, fill up, fill up shape, union1<br />

Region processing<br />

Module<br />

contlength ( Hobject Regions, double *ContLength )<br />

T contlength ( Hobject Regions, Htuple *ContLength )<br />

Contour length of a region.<br />

The operator (T )contlength calculates the total length of the contour (sum of all connection components of<br />

the region) for each region of Regions. The distance between two neighboring contour points parallel to the<br />

coordinate axes is rated 1, the distance in the diagonal is rated Ô ¾. If more than one region is passed the numerical<br />

values of the contour length are stored in a tuple, the position of a value in the tuple corresponding to the position<br />

of the region in the input tuple. In case of an empty region the operator (T )contlength returns the value 0.<br />

The contour of holes is not calculated.<br />

Attention<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region(s) to be examined.<br />

º ContLength (output control) .......................................real(-array) (Htuple .) double *<br />

Contour length of the input region(s).<br />

Assertion : ContLength 0<br />

Example<br />

#include<br />

#include<br />

<br />

"HalconCpp.h"<br />

int main (int argc, char *argv[])<br />

{<br />

if (argc < 2)<br />

{<br />

cout


9.4. FEATURES 477<br />

}<br />

HWindow w;<br />

HRegionArray reg;<br />

int NumOfElements = atoi (argv[1]);<br />

cout


478 CHAPTER 9. REGIONS<br />

Ó<br />

<br />

The shape factor is 1 if the region is convex (e.g. rectangle, circle etc.). If there are indentations or holes is<br />

smaller than 1.<br />

In case of an empty region the operator (T )convexity returns the value 0 (if no other behavior was set (see<br />

set system)). If more than one region is passed the numerical values of the contour length are stored in a tuple,<br />

the position of a value in the tuple corresponding to the position of the region in the input tuple.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region(s) to be examined.<br />

º Convexity (output control) ........................................real(-array) (Htuple .) double *<br />

Convexity of the input region(s).<br />

Assertion : Convexity 1<br />

Result<br />

The operator (T )convexity returns the value H MSG TRUE if the input is not empty. The behavior<br />

in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )convexity is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

See Also<br />

(T )select shape, (T )area center, shape trans<br />

Region processing<br />

Module<br />

diameter region ( Hobject Regions, long *Row1, long *Column1,<br />

long *Row2, long *Column2, double *Diameter )<br />

T diameter region ( Hobject Regions, Htuple *Row1, Htuple *Column1,<br />

Htuple *Row2, Htuple *Column2, Htuple *Diameter )<br />

Maximal distance between two boundary points of a region.<br />

The operator (T )diameter region calculates the maximal distance between two boundary points of a region.<br />

The coordinates of these two extremes and the distance between them will be returned.<br />

Attention<br />

If the region is empty, the results of Row1, Column1, Row2 and Column2 (all of them = 0) may lead to confusion.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be examined.<br />

º Row1 (output control) ..........................................line.begin.y(-array) (Htuple .) long *<br />

Row index of the first extreme point.<br />

º Column1 (output control) ......................................line.begin.x(-array) (Htuple .) long *<br />

Column index of the first extreme point.<br />

º Row2 (output control) ...........................................line.end.y(-array) (Htuple .) long *<br />

Row index of the second extreme point.<br />

º Column2 (output control) .......................................line.end.x(-array) (Htuple .) long *<br />

Column index of the second extreme point.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 479<br />

º Diameter (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Distance of the two extreme points.<br />

Complexity<br />

If is the area of a region, the runtime complexity amounts to Ç´Ô<br />

µ on average.<br />

Result<br />

The operator (T )diameter region returns the value H MSG TRUE, if the input is not empty. The reaction<br />

to empty input (no input regions are available) may be determined with the help of the operator set system<br />

(’no object result’,). The reaction concerning an empty region (region is the empty set)<br />

will be determined by the operator set system(’empty region result’,). If necessary an<br />

exception handling is raised.<br />

Parallelization Information<br />

(T )diameter region is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, (T )runlength features<br />

disp line<br />

(T )smallest rectangle2<br />

Region processing<br />

Possible Successor Functions<br />

Alternatives<br />

Module<br />

eccentricity ( Hobject Regions, double *Anisometry, double *Bulkiness,<br />

double *StructureFactor )<br />

T eccentricity ( Hobject Regions, Htuple *Anisometry, Htuple *Bulkiness,<br />

Htuple *StructureFactor )<br />

Shape features derived from the ellipse parameters.<br />

The operator (T )eccentricity calculates three shape features derived from the geometric moments.<br />

Definition: If the parameters Á, Á and the area of the region are given (see (T )moments region 2nd,<br />

(T )elliptic axis), the following applies:<br />

Ò×ÓÑØÖÝ Á<br />

Á<br />

ÙÐÒ×× <br />

¡ ¡ Á ¡ Á<br />

¿<br />

ËØÖÙØÙÖØÓÖ Ò×ÓÑØÖÝ ¡ ÙÐÒ××<br />

½<br />

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to<br />

the index of a region in the input.<br />

In case of empty region all parameters have the value 0.0 if no other behavior was set (see set system).<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region(s) to be examined.<br />

º Anisometry (output control) .......................................real(-array) (Htuple .) double *<br />

Shape feature (in case of a circle = 1.0).<br />

Assertion : Anisometry 1.0<br />

º Bulkiness (output control) ........................................real(-array) (Htuple .) double *<br />

Calculated shape feature.<br />

º StructureFactor (output control) ................................real(-array) (Htuple .) double *<br />

Calculated shape feature.<br />

<strong>HALCON</strong> 6.0


480 CHAPTER 9. REGIONS<br />

Complexity<br />

If is the area of the region the mean runtime complexity is Ç´Ô<br />

µ.<br />

Result<br />

The operator (T )eccentricity returns the value H MSG TRUE if the input is not empty. The<br />

behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )eccentricity is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

See Also<br />

(T )elliptic axis, (T )moments region 2nd, (T )select shape, (T )area center<br />

Region processing<br />

Module<br />

elliptic axis ( Hobject Regions, double *Ra, double *Rb, double *Phi )<br />

T elliptic axis ( Hobject Regions, Htuple *Ra, Htuple *Rb, Htuple *Phi )<br />

Parameters of the equivalent ellipse.<br />

The operator (T )elliptic axis calculates the radii and the orientation of the ellipse having the “same orientation”<br />

and the “same side relation” as the input region. Several input regions can be passed in Regions as<br />

tuples. The length of the main radius Ra and the secondary radius Rb as well as the orientation of the main axis<br />

with regard to the horizontal (Phi) are determined. The angle is indicated in arc measure.<br />

Calculation:<br />

If the moments Å ¾¼ , Å ¼¾ and Å ½½ are normalized and passed to the area (see (T )moments region 2nd),<br />

the radii Ra and Rb are calculated as:<br />

Ê <br />

Ê <br />

The orientation Phi is defined by:<br />

Õ<br />

´Å ¾¼ · Å ¼¾ ·<br />

Õ<br />

´Å ¾¼ · Å ¼¾<br />

Ô<br />

´Å ¾¼ Å ¼¾ µ ¾ ·Å ¾ ½½ µ<br />

¾<br />

Ô<br />

´Å ¾¼ Å ¼¾ µ ¾ ·Å½½ ¾ µ<br />

È ¼ØÒ¾´¾Å ½½ Å ¼¾ Å ¾¼ µ<br />

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to<br />

the index of a region in the input.<br />

In case of empty region all parameters have the value 0.0 if no other behavior was set (see set system<br />

(’no object result’,)).<br />

¾<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region(s) to be examined.<br />

º Ra (output control) ..................................................real(-array) (Htuple .) double *<br />

Main radius (normalized to the area).<br />

Assertion : Ra 0.0<br />

º Rb (output control) ..................................................real(-array) (Htuple .) double *<br />

Secondary radius (normalized to the area).<br />

Assertion : ´Rb 0.0µ ´Rb Raµ<br />

º Phi (output control) ................................................real(-array) (Htuple .) double *<br />

Angle between main radius and x axis (arc measure).<br />

Assertion : ´´ pi2µ Phiµ ´Phi ´pi2µµ<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 481<br />

Example<br />

read_image(&Image,"fabrik");<br />

open_window(0,0,-1,-1,0,"visible","",&WindowHandle);<br />

regiongrowing(Image,&Seg,5,5,6.0,100);<br />

T_elliptic_axis(Seg,&Ra,&Rb,&Phi);<br />

T_area_center(Seg,_t,&Row,&Column);<br />

T_gen_ellipse(&Ellipses,Row,Column,Phi,Ra,Rb);<br />

set_draw(WindowHandle,"margin");<br />

disp_region(Ellipses,WindowHandle);<br />

Complexity<br />

If is the area of a region the mean runtime complexity is Ç´Ô<br />

µ.<br />

Result<br />

The operator (T )elliptic axis returns the value H MSG TRUE if the input is not empty. The<br />

behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )elliptic axis is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

(T )gen ellipse<br />

Possible Successor Functions<br />

Alternatives<br />

(T )smallest rectangle2, (T )orientation region<br />

See Also<br />

(T )moments region 2nd, (T )select shape, set shape<br />

Bibliography<br />

R. Haralick, L. Shapiro “Computer and Robot Vision” Addison-Wesley, 1992, pp. 73-75<br />

Region processing<br />

Module<br />

euler number ( Hobject Regions, long *EulerNumber )<br />

T euler number ( Hobject Regions, Htuple *EulerNumber )<br />

Calculate the Euler number.<br />

The procedure (T )euler number calculates the Euler number, i.e. the difference between the number of connection<br />

components and the number of holes.<br />

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to<br />

the index of a region in the input.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region(s) to be examined.<br />

º EulerNumber (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long *<br />

Calculated Euler number.<br />

Result<br />

The operator (T )euler number returns the value H MSG TRUE if the input is not empty. The<br />

behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

<strong>HALCON</strong> 6.0


482 CHAPTER 9. REGIONS<br />

Parallelization Information<br />

(T )euler number is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

(T )connect and holes<br />

Region processing<br />

Alternatives<br />

Module<br />

T find neighbors ( Hobject Regions1, Hobject Regions2,<br />

Htuple MaxDistance, Htuple *RegionIndex1, Htuple *RegionIndex2 )<br />

Search direct neighbors.<br />

The operator T find neighbors determines neighboring regions with Regions1 and Regions2 containing<br />

the regions to be examined. Regions1 can have three different states:<br />

¯ Regions1 is empty:<br />

In this case all regions in Regions2 are permutatively checked for neighborhood.<br />

¯ Regions1 consists of one region:<br />

The regions of Regions1 are compared to all regions in Regions2.<br />

¯ Regions1 consists of the same number of regions as Regions2:<br />

Here all regions at the n-th position in Regions1 and Regions2 are checked for the neighboring relation.<br />

The operator T find neighbors uses the city block distance between neighboring regions. It can be specified<br />

by the parameter MaxDistance. neighboring regions are located at the n-th position in RegionIndex1 and<br />

RegionIndex2, i.e. the region with index RegionIndex1[n] from Regions1 is the neighbor of the region<br />

with index RegionIndex2[n] from Regions2.<br />

Covered regions are not found!<br />

Attention<br />

Parameter<br />

º Regions1 (input object) ...................................................region(-array) Hobject<br />

Starting regions.<br />

º Regions2 (input object) ...................................................region(-array) Hobject<br />

Comparative regions.<br />

º MaxDistance (input control) ................................................integer Htuple . long<br />

Maximal distance of regions.<br />

Default Value : 1<br />

Value Suggestions : MaxDistance ¾1, 2, 3, 4, 5, 6, 7, 8, 10, 15, 20, 50<br />

Typical Range of Values : 1 MaxDistance 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º RegionIndex1 (output control) ......................................integer-array Htuple . long *<br />

Indices of the found regions from Regions1.<br />

º RegionIndex2 (output control) ......................................integer-array Htuple . long *<br />

Indices of the found regions from Regions2.<br />

Result<br />

The operator T find neighbors returns the value H MSG TRUE if the input is not empty. The<br />

behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

T find neighbors is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 483<br />

See Also<br />

T spatial relation, T select region spatial, expand region, interjacent, boundary<br />

Region processing<br />

Module<br />

get region index ( Hobject Regions, long Row, long Column, long *Index )<br />

T get region index ( Hobject Regions, Htuple Row, Htuple Column,<br />

Htuple *Index )<br />

Index of all regions containing a given pixel.<br />

The operator (T )get region index returns the index of all regions in Regions (value range 0 to n-1)<br />

containing the test pixel (Row,Column), i.e.:<br />

ÊÓÒ×Ò℄ ´ÊÓÛ ÓÐÙÑÒµ <br />

Attention<br />

If the regions overlap more than one region might contain the pixel. In this case all these regions are returned. If<br />

no region contains the indicated pixel the empty tuple (= no region) is returned.<br />

Parameter<br />

º Regions (input object) ......................................................region-array Hobject<br />

Regions to be examined.<br />

º Row (input control) .........................................................point.y (Htuple .) long<br />

Line index of the test pixel.<br />

Default Value : 100<br />

Typical Range of Values : ½ Row ½(lin)<br />

º Column (input control) .....................................................point.x (Htuple .) long<br />

Column index of the test pixel.<br />

Default Value : 100<br />

Typical Range of Values : ½ Column ½(lin)<br />

º Index (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Index of the regions containing the test pixel.<br />

Complexity<br />

If is the area of the region and Æ is the number of regions the mean runtime complexity is Ç´ÐÒ´Ô<br />

µ £ Æ µ.<br />

Result<br />

The operator (T )get region index returns the value H MSG TRUE if the parameters are correct.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )get region index is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

select region point<br />

Alternatives<br />

See Also<br />

get mbutton, get mposition, test region point<br />

Region processing<br />

Module<br />

T get region thickness ( Hobject Region, Htuple *Thickness,<br />

Htuple *Histogramm )<br />

Access the thickness of a region along the main axis.<br />

<strong>HALCON</strong> 6.0


484 CHAPTER 9. REGIONS<br />

The operator T get region thickness calculates the thickness of the regions along the main axis (see<br />

(T )elliptic axis) for each pixel of the section. The thickness at one point on the main axis is defined<br />

as the distance between the intersections of the contour with the plumb on the main axis in the respective point<br />

which are the furthest apart. Additionally the operator T get region thickness returns the Histogramm<br />

of the thicknesses of the region. The length of the histogram corresponds to the largest occurring thickness in the<br />

observed region.<br />

Attention<br />

Only one region may be passed. If the region has several connection components, only the first one is investigated.<br />

All other components are ignored.<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Region to be analysed.<br />

º Thickness (output control) ..........................................integer-array Htuple . long *<br />

Thickness of the region along its main axis.<br />

º Histogramm (output control) .........................................integer-array Htuple . long *<br />

Histogram of the thickness of the region along its main axis.<br />

Result<br />

The operator T get region thickness returns the value H MSG TRUE if exactly one region is passed.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,).<br />

Parallelization Information<br />

T get region thickness is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

sobel amp, threshold, connection, (T )select shape, select obj<br />

copy obj, (T )elliptic axis<br />

Region processing<br />

See Also<br />

Module<br />

hamming distance ( Hobject Regions1, Hobject Regions2, long *Distance,<br />

double *Similarity )<br />

T hamming distance ( Hobject Regions1, Hobject Regions2,<br />

Htuple *Distance, Htuple *Similarity )<br />

Hamming distance between two regions.<br />

The operator (T )hamming distance returns the hamming distance between two regions, i.e. the number of<br />

pixels of the regions which are different (Distance), i.e. the number of pixels contained in one region but not in<br />

the other:<br />

×ØÒ ÊÓÒ×½ ÊÓÒ×¾ · ÊÓÒ×¾ ÊÓÒ×½<br />

The parameter Similarity describes the similarity between the two regions based on the hamming distance<br />

Distance:<br />

ËÑÐÖØÝ ½<br />

×ØÒ<br />

ÊÓÒ×½ · ÊÓÒ×¾<br />

If both regions are empty Similarity is set to 0. The regions with the same index from both input parameters<br />

are always compared.<br />

Attention<br />

In both input parameters the same number of regions must be passed.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 485<br />

Parameter<br />

º Regions1 (input object) ...................................................region(-array) Hobject<br />

Regions to be examined.<br />

º Regions2 (input object) ...................................................region(-array) Hobject<br />

Comparative regions.<br />

º Distance (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long *<br />

Hamming distance of two regions.<br />

Assertion : Distance 0<br />

º Similarity (output control) .......................................real(-array) (Htuple .) double *<br />

Similarity of two regions.<br />

Assertion : ´0 Similarityµ ´Similarity 1µ<br />

Complexity<br />

If is the area of a region the mean runtime complexity is Ç´Ô<br />

µ.<br />

Result<br />

hamming distance returns the value H MSG TRUE if the number of objects in both parameters is the same and<br />

is not 0. The behavior in case of empty input (no input objects available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling handling<br />

is raised.<br />

Parallelization Information<br />

(T )hamming distance is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

Alternatives<br />

intersection, complement, (T )area center<br />

hamming change region<br />

Region processing<br />

See Also<br />

Module<br />

hamming distance norm ( Hobject Regions1, Hobject Regions2,<br />

const char *Norm, long *Distance, double *Similarity )<br />

T hamming distance norm ( Hobject Regions1, Hobject Regions2,<br />

Htuple Norm, Htuple *Distance, Htuple *Similarity )<br />

Hamming distance between two regions using normalization.<br />

The operator (T )hamming distance norm returns the hamming distance between two regions, i.e. the number<br />

of pixels of the regions which are different (Distance). Before calculating the different the region in<br />

Regions1 are normalized according to the regions in Regions2. The result is the number of pixels contained<br />

in one region but not in the other:<br />

×ØÒ ÆÓÖÑ´ÊÓÒ×½µ ÊÓÒ×¾ · ÊÓÒ×¾ ÆÓÖÑ´ÊÓÒ×½µ<br />

The parameter Similarity describes the similarity between the two regions based on the hamming distance<br />

Distance:<br />

ËÑÐÖØÝ ½<br />

×ØÒ<br />

ÆÓÖÑ´ÊÓÒ×½µ · ÊÓÒ×¾<br />

The following types of normalization are available:<br />

’center’: The region is moved so that both regions have the save center of gravity.<br />

<strong>HALCON</strong> 6.0


486 CHAPTER 9. REGIONS<br />

If both regions are empty Similarity is set to 0. The regions with the same index from both input parameters<br />

are always compared.<br />

Attention<br />

In both input parameters the same number of regions must be passed.<br />

Parameter<br />

º Regions1 (input object) ...................................................region(-array) Hobject<br />

Regions to be examined.<br />

º Regions2 (input object) ...................................................region(-array) Hobject<br />

Comparative regions.<br />

º Norm (input control) ...........................................string(-array) (Htuple .) const char *<br />

Type of normalization.<br />

Default Value : ’center’<br />

Value List : Norm ¾’center’<br />

º Distance (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long *<br />

Hamming distance of two regions.<br />

Assertion : Distance 0<br />

º Similarity (output control) .......................................real(-array) (Htuple .) double *<br />

Similarity of two regions.<br />

Assertion : ´0 Similarityµ ´Similarity 1µ<br />

Complexity<br />

If is the area of a region the mean runtime complexity is Ç´Ô<br />

µ.<br />

Result<br />

hamming distance norm returns the value H MSG TRUE if the number of objects in both parameters is the same<br />

and is not 0. The behavior in case of empty input (no input objects available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )hamming distance norm is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

Alternatives<br />

intersection, complement, (T )area center<br />

hamming change region<br />

Region processing<br />

See Also<br />

Module<br />

inner circle ( Hobject Regions, double *Row, double *Column,<br />

double *Radius )<br />

T inner circle ( Hobject Regions, Htuple *Row, Htuple *Column,<br />

Htuple *Radius )<br />

Largest inner circle of a region.<br />

The operator (T )inner circle determines the largest inner circle of a region, i.e. the circle with the largest<br />

area of all circles that fit into the region. For this circle the center (Row,Column) and the radius (Radius) are<br />

calculated. The output of the procedure is chosen in such a way that it can be used as input for the <strong>HALCON</strong>procedures<br />

disp circle and (T )gen circle.<br />

If several regions are passed in Regions corresponding tuples are returned as output parameters. In case of empty<br />

region all parameters have the value 0.0 if no other behavior was set (see set system).<br />

Attention<br />

If several inner circles are present at a region only one solution is returned.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 487<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be examined.<br />

º Row (output control) .......................................circle.center.y(-array) (Htuple .) double *<br />

Line index of the center.<br />

º Column (output control) ...................................circle.center.x(-array) (Htuple .) double *<br />

Column index of the center.<br />

º Radius (output control) ....................................circle.radius(-array) (Htuple .) double *<br />

Radius of the inner circle.<br />

Assertion : Radius 0<br />

Example<br />

read_image(&Image,"fabrik");<br />

open_window(0,0,-1,-1,0,"visible","",&WindowHandle);<br />

regiongrowing(Image,&Seg,5,5,6.0,100);<br />

select_shape(Seg,&H,"area","and",100.0,2000.0);<br />

T_inner_circle(H,&Row,&Column,&Radius);<br />

T_gen_circle(&Circles,Row,Column,Radius);<br />

set_draw(WindowHandle,"margin");<br />

disp_region(Circles,WindowHandle);<br />

Complexity<br />

If is the area of the region and Ê is the radius of the inner circle the runtime complexity is Ç´Ô<br />

£ ʵ.<br />

Result<br />

The operator (T )inner circle returns the value H MSG TRUE if the input is not empty. The<br />

behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,), the behavior in case of empty region is set via set system<br />

(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )inner circle is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, (T )runlength features<br />

(T )gen circle, disp circle<br />

erosion circle<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

set shape, (T )select shape, (T )smallest circle<br />

Region processing<br />

Module<br />

moments region 2nd ( Hobject Regions, double *M11, double *M20,<br />

double *M02, double *Ia, double *Ib )<br />

T moments region 2nd ( Hobject Regions, Htuple *M11, Htuple *M20,<br />

Htuple *M02, Htuple *Ia, Htuple *Ib )<br />

Geometric moments of regions.<br />

The operator (T )moments region 2nd calculates the moments (M20, M02) and the product of inertia of the<br />

axes through the center parallel to the coordinate axes (M11). Furthermore the main axes of inertia (Ia, Ib) are<br />

calculated.<br />

<strong>HALCON</strong> 6.0


488 CHAPTER 9. REGIONS<br />

Calculation: ¼ and Ë ¼ are the coordinates of the center of a region Ê with the area . Then the moments Å <br />

are defined by:<br />

<br />

Å ´ ¼ µ ´Ë ¼ ˵ <br />

´Ëµ¾Ê<br />

wherein and Ë run through all pixels of the region Ê.<br />

Furthermore,<br />

Å ¾¼ · Å ¼¾<br />

<br />

¾<br />

then Ia and Ib are defined by:<br />

Ô<br />

Á · <br />

¾<br />

Å ¾¼ £ Å ¼¾ · Å ½½ ¾<br />

Á <br />

Ô<br />

<br />

¾<br />

Å ¾¼ £ Å ¼¾ · Å ½½ ¾<br />

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to<br />

the index of a region in the input.<br />

In case of empty region all parameters have the value 0.0 if no other behavior was set (see set system).<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be examined.<br />

º M11 (output control) ................................................real(-array) (Htuple .) double *<br />

Product of inertia of the axes through the center parallel to the coordinate axes.<br />

º M20 (output control) ................................................real(-array) (Htuple .) double *<br />

Moment of 2nd order (line-dependent).<br />

º M02 (output control) ................................................real(-array) (Htuple .) double *<br />

Moment of 2nd order (column-dependent).<br />

º Ia (output control) ..................................................real(-array) (Htuple .) double *<br />

The one main axis of inertia.<br />

º Ib (output control) ..................................................real(-array) (Htuple .) double *<br />

The other main axis of inertia.<br />

Complexity<br />

If is the area of the region the mean runtime complexity is Ç´Ô<br />

µ.<br />

Result<br />

The operator (T )moments region 2nd returns the value H MSG TRUE if the input is not empty.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (region is the empty set) is set<br />

via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )moments region 2nd is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

(T )moments region 2nd invar<br />

(T )elliptic axis<br />

Region processing<br />

Alternatives<br />

See Also<br />

Module<br />

moments region 2nd invar ( Hobject Regions, double *M11, double *M20,<br />

double *M02 )<br />

T moments region 2nd invar ( Hobject Regions, Htuple *M11, Htuple *M20,<br />

Htuple *M02 )<br />

Geometric moments of regions.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 489<br />

The operator (T )moments region 2nd invar calculates the scaled moments (M20, M02)andtheprocutof<br />

inertia of the axes through the center parallel to the coordinate axes (M11).<br />

Calculation: ¼ and Ë ¼ are the coordinates of the center of a region Ê with the area . Then the moments Å <br />

are defined by:<br />

<br />

Å <br />

½ ´ ¼ µ ´Ë ¼ ˵ <br />

¾<br />

´Ëµ¾Ê<br />

wherein and Ë run through all pixels of the region Ê.<br />

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to<br />

the index of a region in the input.<br />

In case of empty region all parameters have the value 0.0 if no other behavior was set (see set system).<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be examined.<br />

º M11 (output control) ................................................real(-array) (Htuple .) double *<br />

Product of inertia of the axes through the center parallel to the coordinate axes.<br />

º M20 (output control) ................................................real(-array) (Htuple .) double *<br />

Moment of 2nd order (line-dependent).<br />

º M02 (output control) ................................................real(-array) (Htuple .) double *<br />

Moment of 2nd order (column-dependent).<br />

Complexity<br />

If is the area of the region the mean runtime complexity is Ç´Ô<br />

µ.<br />

Result<br />

The operator (T )moments region 2nd invar returns the value H MSG TRUE if the input is not empty.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )moments region 2nd invar is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

(T )moments region 2nd<br />

(T )elliptic axis<br />

Region processing<br />

Alternatives<br />

See Also<br />

Module<br />

moments region 2nd rel invar ( Hobject Regions, double *PHI1,<br />

double *PHI2 )<br />

T moments region 2nd rel invar ( Hobject Regions, Htuple *PHI1,<br />

Htuple *PHI2 )<br />

Geometric moments of regions.<br />

The operator (T )moments region 2nd rel invar calculates the scaled relative moments (PHI1, PHI2).<br />

Calculation: The moments ÈÀÁ ½ and ÈÀÁ ¾ are defined by:<br />

ÈÀÁ ½ Î ¾¼ · Î ¼¾<br />

ÈÀÁ ¾ ´Î ¾¼ · Î ¼¾ µ ¾ · Î ¾<br />

½½<br />

<strong>HALCON</strong> 6.0


490 CHAPTER 9. REGIONS<br />

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to<br />

the index of a region in the input.<br />

In case of empty region all parameters have the value 0.0 if no other behavior was set (see set system).<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be examined.<br />

º PHI1 (output control) ...............................................real(-array) (Htuple .) double *<br />

Moment of 2nd order.<br />

º PHI2 (output control) ...............................................real(-array) (Htuple .) double *<br />

Moment of 2nd order.<br />

Result<br />

The operator (T )moments region 2nd rel invar returns the value H MSG TRUE if the input is not<br />

empty. The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )moments region 2nd rel invar is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

(T )moments region 2nd<br />

(T )elliptic axis<br />

Region processing<br />

Alternatives<br />

See Also<br />

Module<br />

moments region 3rd ( Hobject Regions, double *M21, double *M12,<br />

double *M03, double *M30 )<br />

T moments region 3rd ( Hobject Regions, Htuple *M21, Htuple *M12,<br />

Htuple *M03, Htuple *M30 )<br />

Geometric moments of regions.<br />

The operator (T )moments region 3rd calculates the translation-invariant central moments (M21, M12, M03,<br />

M30)oforder´Ô · Õµ.<br />

Calculation: Ü and Ý are the coordinates of the center of a region Ê with the area . Then the moments Å ÔÕ are<br />

defined by:<br />

<br />

Å ÔÕ Å´Ü Ý µ´Ü ܵ Ô´Ý Ýµ Õ<br />

wherein are Ü Ñ½¼<br />

Ñ ¼¼<br />

and Ý Ñ¼½<br />

Ñ ¼¼<br />

.<br />

½<br />

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to<br />

the index of a region in the input.<br />

In case of empty region all parameters have the value 0.0 if no other behavior was set (see set system).<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be examined.<br />

º M21 (output control) ................................................real(-array) (Htuple .) double *<br />

oment of 3nd order (line-dependent).<br />

º M12 (output control) ................................................real(-array) (Htuple .) double *<br />

Moment of 3nd order (column-dependent).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 491<br />

º M03 (output control) ................................................real(-array) (Htuple .) double *<br />

Moment of 3nd order (column-dependent).<br />

º M30 (output control) ................................................real(-array) (Htuple .) double *<br />

Moment of 3nd order (line-dependent).<br />

Complexity<br />

If is the area of the region the mean runtime complexity is Ç´Ô<br />

µ.<br />

Result<br />

The operator (T )moments region 3rd returns the value H MSG TRUE if the input is not empty.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )moments region 3rd is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

(T )moments region 2nd<br />

(T )elliptic axis<br />

Region processing<br />

Alternatives<br />

See Also<br />

Module<br />

moments region 3rd invar ( Hobject Regions, double *M21, double *M12,<br />

double *M03, double *M30 )<br />

T moments region 3rd invar ( Hobject Regions, Htuple *M21, Htuple *M12,<br />

Htuple *M03, Htuple *M30 )<br />

Geometric moments of regions.<br />

The operator (T )moments region 3rd invar calculates the scale-invariant moments (M21, M12, M03,<br />

M30).<br />

Calculation: Then the moments Å are defined by:<br />

wobei Ô · Õ¾und ¼¼ Ñ ¼¼ sind.<br />

wherein are Ô · Õ¾and ¼¼ Ñ ¼¼ .<br />

Å ÔÕ ÔÕ<br />

¿<br />

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to<br />

the index of a region in the input.<br />

In case of empty region all parameters have the value 0.0 if no other behavior was set (see set system).<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be examined.<br />

º M21 (output control) ................................................real(-array) (Htuple .) double *<br />

Moment of 3nd order (line-dependent).<br />

º M12 (output control) ................................................real(-array) (Htuple .) double *<br />

Moment of 3nd order (column-dependent).<br />

º M03 (output control) ................................................real(-array) (Htuple .) double *<br />

Moment of 3nd order (column-dependent).<br />

º M30 (output control) ................................................real(-array) (Htuple .) double *<br />

Moment of 3nd order (line-dependent).<br />

<strong>HALCON</strong> 6.0


492 CHAPTER 9. REGIONS<br />

Complexity<br />

If is the area of the region the mean runtime complexity is Ç´Ô<br />

µ.<br />

Result<br />

The operator (T )moments region 3rd invar returns the value H MSG TRUE if the input is not empty.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )moments region 3rd invar is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

(T )moments region 2nd<br />

(T )elliptic axis<br />

Region processing<br />

Alternatives<br />

See Also<br />

Module<br />

moments region central ( Hobject Regions, double *I1, double *I2,<br />

double *I3, double *I4 )<br />

T moments region central ( Hobject Regions, Htuple *I1, Htuple *I2,<br />

Htuple *I3, Htuple *I4 )<br />

Geometric moments of regions.<br />

The operator (T )moments region central calculates the central moments (I1, I2, I3, I4).<br />

Calculation: Then the moments Á are defined by: Á ½ ¾¼ ¼¾ ¾ ½½<br />

Á ¾ ´ ¿¼ ¼¿ ¾½ ½¾ µ ¾ ´ ¿¼ ½¾ ¾ ¾½ µ´ ¾½ ¼¿ ¾ ½¾ µ<br />

Á ¿ ¾¼´ ¾½ ¼¿ ¾ ½¾ µ ½½´ ¿¼ ¼¿ ¾½ ½¾ µ· ¼¾´ ¿¼ ½¾ ¾ ¾½ µ<br />

Á ¾ ¿¼ ¿ ¼¾ ¿¼ ¾½ ½½ ¾ · ¼¾ ¿¼ ½¾ ¼¾´¾ ¾ ½½ ¾¼ ¼¾ µ<br />

· ¿¼ ¼¿´ ¾¼ ½½ ¼¾ ¿ ½½ µ·¾ ¾½ ¾¼ ¾ ¼¾ ½ ¾½ ½¾ ¾¼ ½½ ¼¾<br />

· ¾½ ¼¿ ¾¼´¾ ¾ ½½ ¾¼ ¼¾ µ· ¾ ½¾ ¾ ¾¼ ¼¾ ½¾ ¼¿ ½½ ¾ ¾¼ · ¾ ¼¿ ¿ ¾¼<br />

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to<br />

the index of a region in the input.<br />

In case of empty region all parameters have the value 0.0 if no other behavior was set (see set system).<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be examined.<br />

º I1 (output control) ..................................................real(-array) (Htuple .) double *<br />

Moment of 2nd order.<br />

º I2 (output control) ..................................................real(-array) (Htuple .) double *<br />

Moment of 2nd order.<br />

º I3 (output control) ..................................................real(-array) (Htuple .) double *<br />

Moment of 2nd order.<br />

º I4 (output control) ..................................................real(-array) (Htuple .) double *<br />

Moment of 3nd order.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 493<br />

Complexity<br />

If is the area of the region the mean runtime complexity is Ç´Ô<br />

µ.<br />

Result<br />

The operator (T )moments region central returns the value H MSG TRUE if the input is not empty.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )moments region central is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

(T )moments region 2nd<br />

(T )elliptic axis<br />

Region processing<br />

Alternatives<br />

See Also<br />

Module<br />

moments region central invar ( Hobject Regions, double *PSI1,<br />

double *PSI2, double *PSI3, double *PSI4 )<br />

T moments region central invar ( Hobject Regions, Htuple *PSI1,<br />

Htuple *PSI2, Htuple *PSI3, Htuple *PSI4 )<br />

Geometric moments of regions.<br />

The operator (T )moments region central invar calculates the moments (PSI1, PSI2, PSI3, PSI4)<br />

that are invariant under translation and general linear transformations.<br />

Calculation: Then the moments are defined by: ½ Á½<br />

<br />

¾ <br />

Á¾<br />

½ ¼<br />

¿ Á¿<br />

<br />

<br />

Á<br />

½ ½<br />

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to<br />

the index of a region in the input.<br />

In case of empty region all parameters have the value 0.0 if no other behavior was set (see set system).<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be examined.<br />

º PSI1 (output control) ...............................................real(-array) (Htuple .) double *<br />

Moment of 2nd order.<br />

º PSI2 (output control) ...............................................real(-array) (Htuple .) double *<br />

Moment of 2nd order.<br />

º PSI3 (output control) ...............................................real(-array) (Htuple .) double *<br />

Moment of 2nd order.<br />

º PSI4 (output control) ...............................................real(-array) (Htuple .) double *<br />

Moment of 2nd order.<br />

<strong>HALCON</strong> 6.0


494 CHAPTER 9. REGIONS<br />

Complexity<br />

If is the area of the region the mean runtime complexity is Ç´Ô<br />

µ.<br />

Result<br />

The operator (T )moments region central invar returns the value H MSG TRUE if the input is not<br />

empty. The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )moments region central invar is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

(T )moments region 2nd<br />

(T )elliptic axis<br />

Region processing<br />

Alternatives<br />

See Also<br />

Module<br />

orientation region ( Hobject Regions, double *Phi )<br />

T orientation region ( Hobject Regions, Htuple *Phi )<br />

Orientation of a region.<br />

The operator (T )orientation region calculates the orientation of the region. The operator is based on<br />

(T )elliptic axis. In addition the point on the contour with maximal distance to the center of gravity is<br />

calculated. If the column coordinate of this point is less than the column coordinate of the center of gravity the<br />

value of is added to the angle.<br />

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to<br />

the index of a region in the input.<br />

In case of empty region all parameters have the value 0.0 if no other behavior was set (see set system<br />

(’no object result’,)).<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region(s) to be examined.<br />

º Phi (output control) ................................................real(-array) (Htuple .) double *<br />

Orientation of region (arc measure).<br />

Assertion : ´´ pi2µ Phiµ ´Phi ´´3 ¡ piµ2µµ<br />

Complexity<br />

If is the area of a region the mean runtime complexity is Ç´Ô<br />

µ.<br />

Result<br />

The operator (T )orientation region returns the value H MSG TRUE if the input is not empty.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )orientation region is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

disp arrow<br />

Possible Successor Functions<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 495<br />

Alternatives<br />

(T )elliptic axis, (T )smallest rectangle2<br />

See Also<br />

(T )moments region 2nd, line orientation<br />

Region processing<br />

Module<br />

roundness ( Hobject Regions, double *Distance, double *Sigma,<br />

double *Roundness, double *Sides )<br />

T roundness ( Hobject Regions, Htuple *Distance, Htuple *Sigma,<br />

Htuple *Roundness, Htuple *Sides )<br />

Shape factors from contour.<br />

The operator (T )roundness examines the distance between the contour and the center of the area. In particular<br />

the mean distance (Distance), the deviation from the mean distance (Sigma) and two shape features derived<br />

therefrom are determined. Roundness is the relation between mean value and standard deviation, and Sides<br />

indicates the number of polygon pieces if a regular polygon is concerned.<br />

The contour for calculating the features is determined depending on the global neighborhood (see set system).<br />

Calculation:<br />

If Ô is the center of the area, Ô the pixels and the area of the contour.<br />

×ØÒ ½ <br />

<br />

Ô Ô <br />

ËÑ ¾ ½ <br />

<br />

´Ô Ô ×ØÒµ ¾<br />

ËÑ<br />

ÊÓÙÒÒ×× ½<br />

×ØÒ<br />

<br />

×ØÒ<br />

Ë× ½½½½<br />

ËÑ<br />

¼¾<br />

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to<br />

the index of a region in the input.<br />

In case of empty region all parameters have the value 0.0 if no other behavior was set (see set system).<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region(s) to be examined.<br />

º Distance (output control) .........................................real(-array) (Htuple .) double *<br />

Mean distance from the center.<br />

Assertion : Distance 0.0<br />

º Sigma (output control) .............................................real(-array) (Htuple .) double *<br />

Standard deviation of Distance.<br />

Assertion : Sigma 0.0<br />

º Roundness (output control) ........................................real(-array) (Htuple .) double *<br />

Shape factor for roundness.<br />

Assertion : Roundness 1.0<br />

º Sides (output control) .............................................real(-array) (Htuple .) double *<br />

Number of polygon sides.<br />

Assertion : Sides 0<br />

Complexity<br />

If is the area of a region the mean runtime complexity is Ç´Ô<br />

µ.<br />

Result<br />

The operator (T )roundness returns the value H MSG TRUE if the input is not empty. The<br />

<strong>HALCON</strong> 6.0


496 CHAPTER 9. REGIONS<br />

behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,), the behavior in case of empty region is set via set system<br />

(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )roundness is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

(T )compactness<br />

(T )contlength<br />

Alternatives<br />

See Also<br />

Bibliography<br />

R. Haralick, L. Shapiro “Computer and Robot Vision” Addison-Wesley, 1992, pp. 61<br />

Region processing<br />

Module<br />

T runlength distribution ( Hobject Region, Htuple *Foreground,<br />

Htuple *Background )<br />

Distribution of runs needed for runlength encoding of a region.<br />

The operator T runlength distribution calculates the distribution of the runs of a region of the fore- and<br />

background. The frequency of the occurrence of a certain length is calculated. Runs of infinite length are not<br />

counted. Therefore the background are the holes of the region. As many values are passed as set by the maximum<br />

length of fore- or background, respectively. The length of both tuples usually differs. The first entry of the tuples is<br />

always 0 (no runs of the length 0). If there are no blanks the empty tuple is passed at Background. Analogously<br />

the empty tuple is passed in case of an empty region at Foreground.<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Region to be examined.<br />

º Foreground (output control) .........................................integer-array Htuple . long *<br />

Length distribution of the region (foreground).<br />

º Background (output control) .........................................integer-array Htuple . long *<br />

Length distribution of the background.<br />

Complexity<br />

If Ò is the number of runs of the region the runtime complexity is Ç´Òµ.<br />

Result<br />

The operator T runlength distribution returns the value H MSG TRUE if the input is not empty.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). If more than one region is passed an exception handling is raised.<br />

Parallelization Information<br />

T runlength distribution is reentrant and processed without parallelization.<br />

threshold, select obj<br />

(T )runlength features<br />

(T )runlength features<br />

Region processing<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 497<br />

runlength features ( Hobject Regions, long *NumRuns, double *KFactor,<br />

double *LFactor, double *MeanLength, long *Bytes )<br />

T runlength features ( Hobject Regions, Htuple *NumRuns,<br />

Htuple *KFactor, Htuple *LFactor, Htuple *MeanLength, Htuple *Bytes )<br />

Characteristic values for runlength coding of regions.<br />

The operator (T )runlength features calculates for every input region from Regions the number of<br />

runs necessary for storing this region with the aid of runlength coding. Furthermore the so-called ”‘K-factor”’ is<br />

determined, which indicates by how much the number of runs differs from the ideal of the square in which this<br />

value is 1.0.<br />

The K-factor (KFactor) is calculated according to the formula:<br />

ÃØÓÖ ÆÙÑÊÙÒ× Ô<br />

Ö<br />

wherein Ö indicates the area of the region. It should be noted that the K-factor can be smaller than 1.0 (in case<br />

of long horizontal regions).<br />

The L-factor (LFactor) indicates the mean number of runs for each line index occurring in the region.<br />

MeanLength indicates the mean length of the runs. The parameter Bytes indicates how many bytes are necessary<br />

for coding the region with runlengths.<br />

Attention<br />

All features calculated by the operator (T )runlength features are not rotation invariant because the runlength<br />

coding depends on the direction. The operator (T )runlength features does not serve for calculating<br />

shape features but for controlling and analysing the efficiency of the runlength coding.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be examined.<br />

º NumRuns (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Number of runs.<br />

Assertion : 0 NumRuns<br />

º KFactor (output control) ...........................................real(-array) (Htuple .) double *<br />

Storing factor in relation to a square.<br />

Assertion : 0 KFactor<br />

º LFactor (output control) ...........................................real(-array) (Htuple .) double *<br />

Mean number of runs per line.<br />

Assertion : 0 LFactor<br />

º MeanLength (output control) .......................................real(-array) (Htuple .) double *<br />

Mean length of runs.<br />

Assertion : 0 MeanLength<br />

º Bytes (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Number of bytes necessary for coding the region.<br />

Assertion : 0 Bytes<br />

Complexity<br />

The mean runtime complexity is Ç´½µ.<br />

Result<br />

The operator (T )runlength features returns the value H MSG TRUE if the input is not empty. If necessary<br />

an exception handling is raised.<br />

Parallelization Information<br />

(T )runlength features is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, (T )runlength features<br />

See Also<br />

(T )runlength features, T runlength distribution<br />

Region processing<br />

Module<br />

<strong>HALCON</strong> 6.0


498 CHAPTER 9. REGIONS<br />

select region point ( Hobject Regions, Hobject *DestRegions, long Row,<br />

long Column )<br />

Choose all regions containing a given pixel.<br />

The operator select region point selects alle regions from Regions containing the test pixel<br />

(Row,Column), i.e.:<br />

ÊÓÒ×Ò℄ ´ÊÓÛ ÓÐÙÑÒµ ½<br />

Attention<br />

If the regions overlap more than one region might contain the pixel. In this case all these regions are returned. If<br />

no region contains the indicated pixel the empty tuple (= no region) is returned.<br />

Parameter<br />

º Regions (input object) ......................................................region-array Hobject<br />

Regions to be examined.<br />

º DestRegions (output object) ..............................................region-array Hobject *<br />

All regions containing the test pixel.<br />

º Row (input control) ...................................................................point.y long<br />

Line index of the test pixel.<br />

Default Value : 100<br />

Typical Range of Values : ½ Row ½(lin)<br />

º Column (input control) ...............................................................point.x long<br />

Column index of the test pixel.<br />

Default Value : 100<br />

Typical Range of Values : ½ Column ½(lin)<br />

Example<br />

read_image(&Image,"fabrik");<br />

open_window(0,0,-1,-1,0,"visible","",&WindowHandle);<br />

disp_image(Image);<br />

regiongrowing(Image,&Seg,3,3,5.0,0);<br />

set_color(WindowHandle,"red");<br />

set_draw(WindowHandle,"margin");<br />

do {<br />

printf("Select the region with the mouse (End right buttonn \n");<br />

get_mbutton(WindowHandle,&Row,&Column,&Button);<br />

select_region_point(Seg,&Single,Row,Column);<br />

disp_region(Single,WindowHandle);<br />

clear(Single);<br />

} while(Button != 4);<br />

Complexity<br />

If is the area of the region and Æ is the number of regions, the mean runtime complexity is Ç´ÐÒ´Ô<br />

µ £ Æ µ.<br />

Result<br />

The operator select region point returns the value H MSG TRUE if the parameters are correct.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

select region point is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

test region point<br />

get mbutton, get mposition<br />

Alternatives<br />

See Also<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 499<br />

Region processing<br />

Module<br />

T select region spatial ( Hobject Regions1, Hobject Regions2,<br />

Htuple Direction, Htuple *RegionIndex1, Htuple *RegionIndex2 )<br />

Pose relation of regions.<br />

The operator T select region spatial chooses the regions from Regions2 which are sufficient for the<br />

neighboring relation Direction. The regions to be examined have to be passed in Regions1 or Regions2,<br />

respectively. Regions1 can have three different states:<br />

¯ Regions1 is empty:<br />

In this case all regions in Regions2 are permutatively checked for neighborhood.<br />

¯ Regions1 consists of one region:<br />

The regions of Regions1 are compared to all regions in Regions2.<br />

¯ Regions1 consists of the same number of regions as Regions2:<br />

The regions at the n-th position in Regions1 and Regions2 are each checked for a neighboring relation.<br />

Possible values for Direction are:<br />

’left’: Regions2 is left of Regions1<br />

’right’: Regions2 is right of Regions1<br />

’above’: Regions2 is above Regions1<br />

’below’: Regions2 is below Regions1<br />

The operator T select region spatial calculates the centers of the regions to be compared and decides<br />

according to the angle between the center straight lines and the x axis whether the direction relation is fulfilled.<br />

The relation is fulfilled within the area of -45 degree to +45 degree around the coordinate axes. Thus, the direction<br />

relation can be understood in such a way that the center of the second region must be located left (or right, above,<br />

below) of the center of the first region. The indices of the regions fulfilling the direction relation are located at the<br />

n-th position in RegionIndex1 and RegionIndex2, i.e. the region with the index RegionIndex2[n] has<br />

the indicated relation with the region with the index RegionIndex1[n]. Access to regions via the index can be<br />

obtained via the operator copy obj.<br />

Parameter<br />

º Regions1 (input object) ...................................................region(-array) Hobject<br />

Starting regions<br />

º Regions2 (input object) ...................................................region(-array) Hobject<br />

Comparative regions<br />

º Direction (input control) .............................................string Htuple . const char *<br />

Desired neighboring relation.<br />

Default Value : ’left’<br />

Value List : Direction ¾’left’, ’right’, ’above’, ’below’<br />

º RegionIndex1 (output control) ......................................integer-array Htuple . long *<br />

Indices in the input tuples (Regions1 or Regions2), respectively.<br />

º RegionIndex2 (output control) ......................................integer-array Htuple . long *<br />

Indices in the input tuples (Regions1 or Regions2), respectively.<br />

Result<br />

The operator T select region spatial returns the value H MSG TRUE if Regions2 is not empty. The<br />

behavior in case of empty parameter Regions2 (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

T select region spatial is reentrant and processed without parallelization.<br />

<strong>HALCON</strong> 6.0


500 CHAPTER 9. REGIONS<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

(T )area center, intersection<br />

Alternatives<br />

See Also<br />

T spatial relation, T find neighbors, copy obj, obj to integer<br />

Region processing<br />

Module<br />

select shape ( Hobject Regions, Hobject *SelectedRegions,<br />

const char *Features, const char *Operation, double Min, double Max )<br />

T select shape ( Hobject Regions, Hobject *SelectedRegions,<br />

Htuple Features, Htuple Operation, Htuple Min, Htuple Max )<br />

Choose regions with the aid of shape features.<br />

The operator (T )select shape chooses regions according to shape. For each input region from Regions the<br />

indicated features (Features) are calculated. If each (Operation = ’and’) or at least one (Operation = ’or’)<br />

of the calculated features is within the default limits (Min,Max) the region is adapted into the output (duplicated).<br />

Condition: ÅÒ ØÙÖ ´Çص ÅÜ <br />

Possible values for Features:<br />

’area’: Area of the object<br />

’row’: Row index of the center<br />

’column’: Column index of the center<br />

’width’: Width of the region<br />

’height’: Height of the region<br />

’row1’: Row index of upper left corner<br />

’column1’: Column index of upper left corner<br />

’row2’: Row index of lower right corner<br />

’column2’: Column index of lower right corner<br />

’circularity’: Circularity (see (T )circularity)<br />

’compactness’: Compactness (see (T )compactness)<br />

’contlength’: Total length of contour (see operator (T )contlength)<br />

’convexity’: Convexity (see (T )convexity)<br />

’ra’: Main radius of the equivalent ellipse (see (T )elliptic axis)<br />

’rb’: Secondary radius of the equivalent ellipse (see (T )elliptic axis)<br />

’phi’: Orientation of the equivalent ellipse (see (T )elliptic axis)<br />

’anisometry:’ Anisometry (see (T )eccentricity)<br />

’bulkiness:’ Bulkiness (see operator (T )eccentricity)<br />

’struct factor:’ Structur Factor (see operator (T )eccentricity)<br />

’outer radius’: Radius of smallest surrounding circle (see (T )smallest circle)<br />

’inner radius’: Radius of largest inner circle (see (T )inner circle)<br />

’dist mean’: Mean distance from the region border to the center (see operator (T )roundness)<br />

’dist deviation:’ Deviation of the distance from the region border from the center (see operator<br />

(T )roundness)<br />

’roundness’: Roundness (see operator (T )roundness)<br />

’num sides’: Number of polygon sides (see operator (T )roundness)<br />

’connect num’: Number of connection components (see operator (T )connect and holes)<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 501<br />

’holes num’: Number of holes (see operator (T )connect and holes)<br />

’max diameter’: Maximum diameter of the region (see operator (T )diameter region)<br />

’orientation’: Orientation of the region (see operator (T )orientation region)<br />

’euler number’: Euler number (see operator (T )euler number)<br />

’rect2 phi’: Orientation of the smallest surrounding rectangle (see operator (T )smallest rectangle2)<br />

’rect2 len1’: Half the length of the smallest surrounding rectangle (see operator<br />

(T )smallest rectangle2)<br />

’rect2 len2’: Half the width of the smallest surrounding rectangle (see operator (T )smallest rectangle2)<br />

’moments m11’: Geometric moments of the region (see operator (T )moments region 2nd)<br />

’moments m20’: Geometric moments of the region (see operator (T )moments region 2nd)<br />

’moments m02’: Geometric moments of the region (see operator (T )moments region 2nd)<br />

’moments ia’: Geometric moments of the region (see operator (T )moments region 2nd)<br />

’moments ib’: Geometric moments of the region (see operator (T )moments region 2nd)<br />

’moments m11 invar’: Geometric moments of the region (see operator (T )moments region 2nd invar)<br />

’moments m20 invar’: Geometric moments of the region (see operator (T )moments region 2nd invar)<br />

’moments m02 invar’: Geometric moments of the region (see operator (T )moments region 2nd invar)<br />

’moments phi1’: Geometric moments of the region (see operator (T )moments region 2nd rel invar)<br />

’moments phi2’: Geometric moments of the region (see operator (T )moments region 2nd rel invar)<br />

’moments m21’: Geometric moments of the region (see operator (T )moments region 3rd)<br />

’moments m12’: Geometric moments of the region (see operator (T )moments region 3rd)<br />

’moments m03’: Geometric moments of the region (see operator (T )moments region 3rd)<br />

’moments m30’: Geometric moments of the region (see operator (T )moments region 3rd)<br />

’moments m21 invar’: Geometric moments of the region (see operator (T )moments region 3rd invar)<br />

’moments m12 invar’: Geometric moments of the region (see operator (T )moments region 3rd invar)<br />

’moments m03 invar’: Geometric moments of the region (see operator (T )moments region 3rd invar)<br />

’moments m30 invar’: Geometric moments of the region (see operator (T )moments region 3rd invar)<br />

’moments i1’: Geometric moments of the region (see operator (T )moments region central)<br />

’moments i2’: Geometric moments of the region (see operator (T )moments region central)<br />

’moments i3’: Geometric moments of the region (see operator (T )moments region central)<br />

’moments i4’: Geometric moments of the region (see operator (T )moments region central)<br />

’moments psi1’: Geometric moments of the region (see operator (T )moments region central invar)<br />

’moments psi2’: Geometric moments of the region (see operator (T )moments region central invar)<br />

’moments psi3’: Geometric moments of the region (see operator (T )moments region central invar)<br />

’moments psi4’: Geometric moments of the region (see operator (T )moments region central invar)<br />

If only one feature (Features)isusedthevalueofOperation is meaningless. Several features are processed<br />

in the sequence in which they are entered.<br />

Parameter<br />

º Regions (input object) ......................................................region-array Hobject<br />

Regions to be examined.<br />

º SelectedRegions (output object) ........................................region-array Hobject *<br />

Regions fulfilling the condition.<br />

º Features (input control) ......................................string(-array) (Htuple .) const char *<br />

Shape features to be checked.<br />

Default Value : ’area’<br />

Value List : Features ¾’area’, ’row’, ’column’, ’width’, ’height’, ’row1’, ’column1’, ’row2’, ’column2’,<br />

’circularity’, ’compactness’, ’contlength’, ’convexity’, ’ra’, ’rb’, ’phi’, ’anisometry’, ’bulkiness’,<br />

’struct factor’, ’outer radius’, ’inner radius’, ’max diameter’, ’dist mean’, ’dist deviation’, ’roundness’,<br />

<strong>HALCON</strong> 6.0


502 CHAPTER 9. REGIONS<br />

’num sides’, ’orientation’, ’connect num’, ’holes num’, ’euler number’, ’rect2 phi’, ’rect2 len1’, ’rect2 len2’,<br />

’moments m11’, ’moments m20’, ’moments m02’, ’moments ia’, ’moments ib’, ’moments m11 invar’,<br />

’moments m20 invar’, ’moments m02 invar’, ’moments phi1’, ’moments phi2’, ’moments m21’,<br />

’moments m12’, ’moments m03’, ’moments m30’, ’moments m21 invar’, ’moments m12 invar’,<br />

’moments m03 invar’, ’moments m30 invar’, ’moments i1’, ’moments i2’, ’moments i3’, ’moments i4’,<br />

’moments psi1’, ’moments psi2’, ’moments psi3’, ’moments psi4’<br />

º Operation (input control) ...........................................string (Htuple .) const char *<br />

Linkage type of the individual features.<br />

Default Value : ’and’<br />

Value List : Operation ¾’and’, ’or’<br />

º Min (input control) ................................real(-array) (Htuple .) double / long / const char *<br />

Lower limits of the features or ’min’.<br />

Default Value : 150.0<br />

Typical Range of Values : 0.0 Min 99999.0<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 1.0<br />

º Max (input control) ................................real(-array) (Htuple .) double / long / const char *<br />

Upper limits of the features or ’max’.<br />

Default Value : 99999.0<br />

Typical Range of Values : 0.0 Max 99999.0<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 1.0<br />

Restriction : Max Min<br />

Example<br />

/* where are the eyes of the ape ? */<br />

read_image(&Image,"affe");<br />

threshold(Image,&S1,128.0,255.0);<br />

connection(S1,&S2);<br />

select_shape(S2,&S3,"area","and",500.0,50000.0);<br />

select_shape(S3,&Eyes,"anisometry","and",1.0,1.7);<br />

disp_region(Eyes,WindowHandle);<br />

Result<br />

The operator (T )select shape returns the value H MSG TRUE if the input is not empty. The<br />

behavior in case of empty input (no input objects available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )select shape is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, (T )runlength features<br />

Possible Successor Functions<br />

(T )select shape, select gray, shape trans, reduce domain, count obj<br />

See Also<br />

(T )area center, (T )circularity, (T )compactness, (T )contlength, (T )convexity,<br />

(T )elliptic axis, (T )eccentricity, (T )inner circle, (T )smallest circle,<br />

(T )smallest rectangle1, (T )smallest rectangle2, (T )roundness,<br />

(T )connect and holes, (T )diameter region, (T )orientation region,<br />

(T )moments region 2nd, (T )moments region 2nd invar,<br />

(T )moments region 2nd rel invar, (T )moments region 3rd,<br />

(T )moments region 3rd invar, (T )moments region central,<br />

(T )moments region central invar, select obj<br />

Region processing<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 503<br />

select shape proto ( Hobject Regions, Hobject Pattern,<br />

Hobject *SelectedRegions, const char *Feature, double Min, double Max )<br />

T select shape proto ( Hobject Regions, Hobject Pattern,<br />

Hobject *SelectedRegions, Htuple Feature, Htuple Min, Htuple Max )<br />

Choose regions having a certain relation to each other.<br />

The operator (T )select shape proto puts two regions in relation to each other. Every i-th region from<br />

Regions is compared to the combination of regions from Pattern. The limits (Min and Max) are indicated<br />

absolutely or in percent (0..100) depending on the feature. Possible values for Feature are:<br />

’distance dilate’ The minimum distance in the maximum norm from the edge of Pattern to the edge of every<br />

region from Regions is determined (see distance rr min dil).<br />

’distance contour’ The minimum Euclidean distance from the edge of Pattern to the edge of every region<br />

from Regions is determined. (see distance rr min).<br />

’distance center’ The Euclidean distance from the center of Pattern to the center of every region from<br />

Regions is determined.<br />

’covers’ It is examined how well the region Pattern fits into the regions from Regions. If there is no shift<br />

so that Pattern is a subset of Regions the overlap is 0. If Pattern corresponds to the region after a<br />

corresponding shift the overlap is 100. Otherwise the area of the opening of Regions with Pattern is put<br />

into relation with the area of Regions (in percent).<br />

’fits’ It is examined whether Pattern can be shifted in such a way that it fits in Regions. If this is possible the<br />

corresponding region is copied from Regions. The parameters Min and Max have no meaning here.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be examined.<br />

º Pattern (input object) .....................................................region(-array) Hobject<br />

Region compared to Regions.<br />

º SelectedRegions (output object) .......................................region(-array) Hobject *<br />

Regions fulfilling the condition.<br />

º Feature (input control) .......................................string(-array) (Htuple .) const char *<br />

Shape features to be checked.<br />

Default Value : ’covers’<br />

Value List : Feature ¾’distance center’, ’distance dilate’, ’distance contour’, ’covers’, ’fits’<br />

º Min (input control) ................................................number (Htuple .) double / long<br />

Lower border of feature.<br />

Default Value : 50.0<br />

Value Suggestions : Min ¾0.0, 1.0, 5.0, 10.0, 20.0, 30.0, 50.0, 60.0, 70.0, 80.0, 90.0, 95.0, 99.0, 100.0,<br />

200.0, 400.0<br />

Typical Range of Values : 0.0 Min<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 5.0<br />

º Max (input control) ................................................number (Htuple .) double / long<br />

Upper border of the feature.<br />

Default Value : 100.0<br />

Value Suggestions : Max ¾0.0, 10.0, 20.0, 30.0, 50.0, 60.0, 70.0, 80.0, 90.0, 95.0, 99.0, 100.0, 200.0, 300.0,<br />

400.0<br />

Typical Range of Values : 0.0 Max<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 5.0<br />

Example<br />

regiongrowing(Image,&Seg,3,3,5.0,0);<br />

gen_circle(&C,100.0,100.0,MinRadius);<br />

select_shape_proto(Seg,C,"fits",0.0,0.0);<br />

<strong>HALCON</strong> 6.0


504 CHAPTER 9. REGIONS<br />

Result<br />

The operator (T )select shape proto returns the value H MSG TRUE if the input is not empty.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )select shape proto is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

connection, draw region, (T )gen circle, (T )gen rectangle1, (T )gen rectangle2,<br />

(T )gen ellipse<br />

Possible Successor Functions<br />

select gray, shape trans, reduce domain, count obj<br />

(T )select shape<br />

Alternatives<br />

See Also<br />

opening, erosion1, distance rr min dil, distance rr min<br />

Region processing<br />

Module<br />

select shape std ( Hobject Regions, Hobject *SelectedRegions,<br />

const char *Shape, double Percent )<br />

Select regions of a given shape.<br />

The operator select shape std compares the shape of the given regions with default shapes. If the region has<br />

a similar shape it is adopted into the output. Possible values for Shape are:<br />

’max area’ The largest region is selected.<br />

’rectangle1’ The surrounding rectangle parallel to the coordinate axes is determined via the operator<br />

(T )smallest rectangle1. If the area difference in percent is larger than Percent the region is<br />

adopted.<br />

’rectangle1’ The smallest surrounding rectangle with any orientation is determined via the operator<br />

(T )smallest rectangle2. If the area difference in percent is larger than Percent the region is<br />

adopted.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Input regions to be selected.<br />

º SelectedRegions (output object) .......................................region(-array) Hobject *<br />

Regions with desired shape.<br />

º Shape (input control) ..........................................................string const char *<br />

Shape features to be checked.<br />

Default Value : ’max area’<br />

Value List : Shape ¾’max area’, ’rectangle1’, ’rectangle2’<br />

º Percent (input control) ..............................................................real double<br />

Similarity measure.<br />

Default Value : 70.0<br />

Value Suggestions : Percent ¾10.0, 30.0, 50.0, 60.0, 70.0, 80.0, 90.0, 95.0, 100.0<br />

Typical Range of Values : 0.0 Percent 100.0 (lin)<br />

Minimal Value Step : 0.1<br />

Recommended Value Step : 10.0<br />

Parallelization Information<br />

select shape std is reentrant and processed without parallelization.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 505<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, (T )smallest rectangle1,<br />

(T )smallest rectangle2<br />

Alternatives<br />

intersection, complement, (T )area center<br />

See Also<br />

(T )smallest rectangle1, (T )smallest rectangle2<br />

Region processing<br />

Module<br />

smallest circle ( Hobject Regions, double *Row, double *Column,<br />

double *Radius )<br />

T smallest circle ( Hobject Regions, Htuple *Row, Htuple *Column,<br />

Htuple *Radius )<br />

Smallest surrounding circle of a region.<br />

The operator (T )smallest circle determines the smallest surrounding circle of a region, i.e. the circle<br />

with the smallest area of all circles containing the region. For this circle the center (Row,Column) and the radius<br />

(Radius) are calculated. The procedure is applied when, for example, the location and size of circular objects<br />

(e.g. coins) which, however, are not homogeneous inside or have broken edges due to bad segmentation, has<br />

to be determined. The output of the procedure is selected in such a way that it can be used as input for the<br />

<strong>HALCON</strong>procedures disp circle and (T )gen circle.<br />

If several regions are passed in Regions corresponding tuples are returned as output parameter. In case of empty<br />

region all parameters have the value 0.0 if no other behavior was set (see set system).<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be examined.<br />

º Row (output control) .......................................circle.center.y(-array) (Htuple .) double *<br />

Line index of the center.<br />

º Column (output control) ...................................circle.center.x(-array) (Htuple .) double *<br />

Column index of the center.<br />

º Radius (output control) ....................................circle.radius(-array) (Htuple .) double *<br />

Radius of the surrounding circle.<br />

Assertion : Radius 0<br />

Example<br />

read_image(&Image,"fabrik");<br />

open_window(0,0,-1,-1,0,"visible","",&WindowHandle);<br />

regiongrowing(Image,&Seg,5,5,6.0,100);<br />

select_shape(Seg,&H,"area","and",100.0,2000.0);<br />

T_smallest_circle(H,&Row,&Column,&Radius);<br />

T_gen_circle(&Circles,Row,Column,Radius);<br />

set_draw(WindowHandle,"margin");<br />

disp_region(Circles,WindowHandle);<br />

Complexity<br />

If is the area of the region and Æ is the number of supporting points of the convex hull, the mean runtime<br />

complexity is Ç´Ô<br />

· Æ ¿ µ.<br />

Result<br />

The operator (T )smallest circle returns the value H MSG TRUE if the input is not empty. The<br />

behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

<strong>HALCON</strong> 6.0


506 CHAPTER 9. REGIONS<br />

Parallelization Information<br />

(T )smallest circle is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, (T )runlength features<br />

(T )gen circle, disp circle<br />

Possible Successor Functions<br />

Alternatives<br />

(T )elliptic axis, (T )smallest rectangle1, (T )smallest rectangle2<br />

See Also<br />

set shape, (T )select shape, (T )inner circle<br />

Region processing<br />

Module<br />

smallest rectangle1 ( Hobject Regions, long *Row1, long *Column1,<br />

long *Row2, long *Column2 )<br />

T smallest rectangle1 ( Hobject Regions, Htuple *Row1, Htuple *Column1,<br />

Htuple *Row2, Htuple *Column2 )<br />

Surrounding rectangle parallel to the coordinate axes.<br />

The operator (T )smallest rectangle1 calculates the surrounding rectangle of all input regions (parallel<br />

to the coordinate axes). The surrounding rectangle is described by the coordinates of the corner pixels<br />

(Row1,Column1,Row2,Column2)<br />

If more than one region is passed in Regions, the results are stored in tuples, the index of a value in the tuple<br />

corresponding to the index of a region in the input. In case of empty region all parameters have the value 0 if no<br />

other behavior was set (see set system).<br />

Attention<br />

In case of empty region the result of Row1,Column1, Row2 and Column2 (all are 0) can lead to confusion.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be examined.<br />

º Row1 (output control) ....................................rectangle.origin.y(-array) (Htuple .) long *<br />

Line index of upper left corner point.<br />

º Column1 (output control) ................................rectangle.origin.x(-array) (Htuple .) long *<br />

Column index of upper left corner point.<br />

º Row2 (output control) ....................................rectangle.corner.y(-array) (Htuple .) long *<br />

Line index of lower right corner point.<br />

º Column2 (output control) ................................rectangle.corner.x(-array) (Htuple .) long *<br />

Column index of lower right corner point.<br />

Complexity<br />

If is the area of the region the mean runtime complexity is Ç´×ÕÖØ´ µµ.<br />

Result<br />

The operator (T )smallest rectangle1 returns the value H MSG TRUE if the input is not empty.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )smallest rectangle1 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, (T )runlength features<br />

Possible Successor Functions<br />

disp rectangle1, (T )gen rectangle1<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 507<br />

Alternatives<br />

(T )smallest rectangle2, (T )area center<br />

(T )select shape<br />

Region processing<br />

See Also<br />

Module<br />

smallest rectangle2 ( Hobject Regions, double *Row, double *Column,<br />

double *Phi, double *Length1, double *Length2 )<br />

T smallest rectangle2 ( Hobject Regions, Htuple *Row, Htuple *Column,<br />

Htuple *Phi, Htuple *Length1, Htuple *Length2 )<br />

Smallest surrounding rectangle with any orientation.<br />

The operator (T )smallest rectangle2 determines the smallest surrounding rectangle of a region, i.e. the<br />

rectangle with the smallest area of all rectangles containing the region. For this rectangle the center, the inclination<br />

and the two radii are calculated.<br />

The procedure is applied when, for example, the location of a scenery of several regions (e.g. printed<br />

text on a rectangular paper or in rectangular print (justified lines)) must be found. The parameters of<br />

(T )smallest rectangle2 are chosen in such a way that they can be used directly as input for the <strong>HALCON</strong>procedures<br />

disp rectangle2 and (T )gen rectangle2.<br />

If more than one region is passed in Regions the results are stored in tuples, the index of a value in the tuple<br />

corresponding to the index of a region in the input. In case of empty region all parameters have the value 0.0 if no<br />

other behavior was set (see set system).<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions to be examined.<br />

º Row (output control) ..................................rectangle2.center.y(-array) (Htuple .) double *<br />

Line index of the center.<br />

º Column (output control) ..............................rectangle2.center.x(-array) (Htuple .) double *<br />

Column index of the center.<br />

º Phi (output control) .................................rectangle2.angle.rad(-array) (Htuple .) double *<br />

Orientation of the surrounding rectangle (arc measure)<br />

Assertion : ´´ pi2µ Phiµ ´Phi ´pi2µµ<br />

º Length1 (output control) ..............................rectangle2.hwidth(-array) (Htuple .) double *<br />

First radius (half length) of the surrounding rectangle.<br />

Assertion : Length1 0.0<br />

º Length2 (output control) .............................rectangle2.hheight(-array) (Htuple .) double *<br />

Second radius (half width) of the surrounding rectangle.<br />

Assertion : ´Length2 0.0µ ´Length2 Length1µ<br />

Example<br />

#include<br />

#include<br />

<br />

"HalconCpp.h"<br />

int main (int argc, char *argv[])<br />

{<br />

Tuple row, col, phi, len1, len2;<br />

HImage img (argv[1]);<br />

HWindow w;<br />

img.Display (w);<br />

<strong>HALCON</strong> 6.0


508 CHAPTER 9. REGIONS<br />

HRegionArray reg = img.Regiongrowing (5, 5, 6.0, 100);<br />

HRegionArray seg = reg.SelectShape ("area", "and", 100.0, 1000.0);<br />

row = seg.SmallestRectangle2 (&col, &phi, &len1, &len2);<br />

HRegionArray rect = HRegionArray::GenRectangle2 (row, col, phi, len1, len2);<br />

w.SetDraw ("margin");<br />

w.SetColor ("green"); reg.Display (w);<br />

w.SetColor ("blue"); seg.Display (w);<br />

w.SetColor ("red"); rect.Display (w);<br />

w.Click ();<br />

}<br />

return(0);<br />

Complexity<br />

If is the area of the region and Æ is the number of supporting points of the convex hull, the runtime complexity<br />

is Ç´Ô<br />

· Æ ¾ µ.<br />

Result<br />

The operator (T )smallest rectangle2 returns the value H MSG TRUE if the input is not empty.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,). The behavior in case of empty region (the region is the empty set) is<br />

set via set system(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )smallest rectangle2 is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection, (T )runlength features<br />

Possible Successor Functions<br />

disp rectangle2, (T )gen rectangle2<br />

Alternatives<br />

(T )elliptic axis, (T )smallest rectangle1<br />

(T )smallest circle, set shape<br />

Region processing<br />

See Also<br />

Module<br />

T spatial relation ( Hobject Regions1, Hobject Regions2,<br />

Htuple Percent, Htuple *RegionIndex1, Htuple *RegionIndex2,<br />

Htuple *Relation1, Htuple *Relation2 )<br />

Pose relation of regions with regard to the coordinate axes.<br />

The operator T spatial relation selects regions located by Percent percent “left”, “right”, “above” or<br />

“below” other regions. Regions1 and Regions2 contain the regions to be compared. Regions1 can have<br />

three states:<br />

¯ Regions1 is empty:<br />

In this case all regions in Regions2 are permutatively checked for neighborhood.<br />

¯ Regions1 consists of one region:<br />

The regions of Regions1 are compared to all regions in Regions2.<br />

¯ Regions1 consists of the same number of regions as Regions2:<br />

Regions1 and Regions2 are checked for a neighboring relation.<br />

The percentage Percent is interpreted in such a way that the area of the second region has to be located really<br />

left/right or above/below the region margins of the first region by at least Percent percent. The indices of<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.4. FEATURES 509<br />

the regions that fulfill at least one of these conditions are then located at the n-th position in the output parameters<br />

RegionIndex1 and RegionIndex2. Additionally the output parameters Relation1 and Relation2<br />

contain at the n-th position the type of relation of the region pair (RegionIndex1[n], RegionIndex2[n]),<br />

i.e. region with index RegionIndex2[n] has the relation Relation1[n] and Relation2[n] with region with<br />

index RegionIndex1[n].<br />

Possible values for Relation1 and Relation2 are:<br />

Relation1: ’left’, ’right’ or ”<br />

Relation2: ’above’, ’below’ or ”<br />

In RegionIndex1 and RegionIndex2 the indices of the regions in the tuples of the input regions (Regions1<br />

or Regions2), respectively, are entered as image identifiers. Access to chosen regions via the index can be<br />

obtained by the operator copy obj.<br />

Parameter<br />

º Regions1 (input object) ...................................................region(-array) Hobject<br />

Starting regions.<br />

º Regions2 (input object) ...................................................region(-array) Hobject<br />

Comparative regions.<br />

º Percent (input control) .....................................................integer Htuple . long<br />

Percentage of the area of the comparative region which must be located left/right or above/below the region<br />

margins of the starting region.<br />

Default Value : 50<br />

Value Suggestions : Percent ¾0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100<br />

Typical Range of Values : 0 Percent 100 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : ´0 Percentµ ´Percent 100µ<br />

º RegionIndex1 (output control) ......................................integer-array Htuple . long *<br />

Indices of the regions in the tuple of the input regions which fulfill the pose relation.<br />

º RegionIndex2 (output control) ......................................integer-array Htuple . long *<br />

Indices of the regions in the tuple of the input regions which fulfill the pose relation.<br />

º Relation1 (output control) ............................................string-array Htuple . char *<br />

Horizontal pose relation in which RegionIndex2[n] stands with RegionIndex1[n].<br />

º Relation2 (output control) ............................................string-array Htuple . char *<br />

Vertical pose relation in which RegionIndex2[n] stands with RegionIndex1[n].<br />

Result<br />

The operator T spatial relation returns the value H MSG TRUE if Regions2 is not empty and Percent<br />

is correctly choosen. The behavior in case of empty parameter Regions2 (no input regions available) is set via<br />

the operator set system(’no object result’,). The behavior in case of empty region (the<br />

region is the empty set) is set via set system(’empty region result’,). If necessary an<br />

exception handling is raised.<br />

Parallelization Information<br />

T spatial relation is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

(T )area center, intersection<br />

Alternatives<br />

See Also<br />

T select region spatial, T find neighbors, copy obj, obj to integer<br />

Region processing<br />

Module<br />

test region point ( Hobject Regions, long Row, long Column )<br />

Test if the region consists of the given point.<br />

<strong>HALCON</strong> 6.0


510 CHAPTER 9. REGIONS<br />

test region point tests if at least one input region of Regions consists of the test point (Row,Column).<br />

Attention<br />

In case of empty input (= no region) and set system(’no object result’,’true’) FALSE is returned<br />

(no region contains the pixel).<br />

The test pixel is not contained in an empty region (no pixel of the region corresponds to the pixel). If all regions<br />

are empty FALSE is also returned, i.e. an empty region behaves as if it did not exist.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Region(s) to be examined.<br />

º Row (input control) ...................................................................point.y long<br />

Line index of the test pixel.<br />

Default Value : 100<br />

Typical Range of Values : 0 Row 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Column (input control) ...............................................................point.x long<br />

Column index of the test pixel.<br />

Default Value : 100<br />

Typical Range of Values : 0 Column 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

If is the area of one region and Æ is the number of regions, the runtime complexity is Ç´ÐÒ´Ô<br />

µ £ Æ µ.<br />

Result<br />

The operator test region point returns the value H MSG TRUE if a region contains the test pixel. If this<br />

is not the case test region point returns H MSG FALSE. The behavior in case of empty input (no input<br />

regions available) is set via the operator set system(’no object result’,). If necessary an<br />

exception handling is raised.<br />

Parallelization Information<br />

test region point is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

Alternatives<br />

union1, intersection, (T )area center<br />

select region point<br />

bool<br />

Region processing<br />

See Also<br />

Return Value<br />

Module<br />

9.5 Sets<br />

complement ( Hobject Region, Hobject *RegionComplement )<br />

Return the complement of a region.<br />

complement determines the complement of the input region(s).<br />

If the system flag ’clip region’ is ’false’ (see set system) the complement is done virtually by setting the<br />

complement flag of Region to TRUE. For succeeding operations the de Morgan laws are applied while calculating<br />

results.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.5. SETS 511<br />

If the system flag ’clip region’ is ’true’ the difference of the largest image processed so far (see reset obj db)<br />

and the input region is returned.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Input region(s).<br />

º RegionComplement (output object) .....................................region(-array) Hobject *<br />

Complemented regions.<br />

Parameter Number : RegionComplement Region<br />

Result<br />

complement always returns the value H MSG TRUE. The behavior in case of empty input (no regions given)<br />

can be set via set system(’no object result’,) and the behavior in case of an empty input<br />

region via set system(’empty region result’,). If necessary, an exception handling is<br />

raised.<br />

Parallelization Information<br />

complement is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring, class ndim norm<br />

(T )select shape<br />

Possible Successor Functions<br />

See Also<br />

difference, union1, union2, intersection, reset obj db, set system<br />

Region processing<br />

Module<br />

difference ( Hobject Region, Hobject Sub, Hobject *RegionDifference )<br />

Calculate the difference of two regions.<br />

difference calculates the set-theoretic difference of two regions:<br />

(Regions in Region) (Regions in Sub)<br />

The resulting region is defined as the input region (Region) with all points from Sub removed. The following<br />

two special regions can also be used as input:<br />

’full’ i.e., the full region (FULL REGION in <strong>HALCON</strong>/C) or<br />

’empty’ i.e., the empty region (EMPTY REGION in <strong>HALCON</strong>/C).<br />

Attention<br />

Empty regions are valid for both parameters. On output, empty regions may resultṪhe value of the system flag<br />

’store empty region’ determines the behavior in this case.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be processed.<br />

º Sub (input object) ..........................................................region(-array) Hobject<br />

The union of these regions is subtracted from Region.<br />

º RegionDifference (output object) .....................................region(-array) Hobject *<br />

Resulting region.<br />

Example<br />

/* provides the region X without the points in Y */<br />

difference(X,Y,&RegionDifference);<br />

/* provides the region. */<br />

difference(Region,EMPTY_REGION,&RegionDifference);<br />

<strong>HALCON</strong> 6.0


512 CHAPTER 9. REGIONS<br />

Complexity<br />

Let Æ be the number of regions, ½ be their average area, and ¾ be the total area of all regions in Sub. Then the<br />

runtime complexity is Ç´ ½ £ ÐÓ´ ½ µ·Æ £ ´Ô<br />

½ · Ô<br />

¾ µµ.<br />

Result<br />

difference always returns the value H MSG TRUE. The behavior in case of empty input (no regions given)<br />

can be set via set system(’no object result’,) and the behavior in case of an empty input<br />

region via set system(’empty region result’,). If necessary, an exception handling is<br />

raised.<br />

Parallelization Information<br />

difference is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring, class ndim norm<br />

(T )select shape, disp region<br />

Possible Successor Functions<br />

See Also<br />

intersection, union1, union2, complement<br />

Region processing<br />

Module<br />

intersection ( Hobject Region1, Hobject Region2,<br />

Hobject *RegionIntersection )<br />

Calculate the intersection of two regions.<br />

intersection calculates the intersection of the regions in Region1 with the regions in Region2. Each<br />

region in Region1 is intersected with all regions in Region2. The order of regions in RegionIntersection<br />

is identical to the order of regions in Region1.<br />

Attention<br />

Empty input regions are permitted. Because empty result regions are possible, the system flag<br />

’store empty region’ should be set appropriately.<br />

Parameter<br />

º Region1 (input object) .....................................................region(-array) Hobject<br />

Regions to be intersected with all regions in Region2.<br />

º Region2 (input object) .....................................................region(-array) Hobject<br />

Regions with which Region1 is intersected.<br />

º RegionIntersection (output object) ...................................region(-array) Hobject *<br />

Result of the intersection.<br />

Parameter Number : RegionIntersection Region1<br />

Complexity<br />

Let Æ be the number of regions in Region1, ½ be their average area, and ¾ be the total area of all regions in<br />

Region2. Then the runtime complexity is Ç´ ½ ÐÓ ´ ½ µ·Æ £ ´Ô<br />

½ · Ô<br />

¾ µµ.<br />

Result<br />

intersection always returns H MSG TRUE. The behavior in case of empty input (no regions given) can be<br />

set via set system(’no object result’,) and the behavior in case of an empty input region<br />

via set system(’empty region result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

intersection is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring<br />

(T )select shape, disp region<br />

union1, union2, complement<br />

Possible Successor Functions<br />

See Also<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.5. SETS 513<br />

Region processing<br />

Module<br />

union1 ( Hobject Region, Hobject *RegionUnion )<br />

Return the union of all input regions.<br />

union1 computes the union of all input regions and returns the result in RegionUnion.<br />

Parameter<br />

º Region (input object) .......................................................region-array Hobject<br />

Regions of which the union is to be computed.<br />

º RegionUnion (output object) ...................................................region Hobject *<br />

Union of all input regions.<br />

Parameter Number : RegionUnion Region<br />

Example<br />

/* Union of segmentation results: */<br />

threshold(Image,&Seg1,128.0,255.0);<br />

dyn_threshold(Image,Mean,&Seg2,5.0,"light");<br />

concat_obj(Seg1,Seg2,&H);<br />

union1(H,&Seg);<br />

Complexity<br />

Let be the sum of all areas of the input regions. Then the runtime complexity is Ç´ÐÓ´Ô<br />

µ £<br />

Ô<br />

µ.<br />

Result<br />

union1 always returns H MSG TRUE. The behavior in case of empty input (no regions given) can be set via<br />

set system(’no object result’,) and the behavior in case of an empty input region via<br />

set system(’empty region result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

union1 is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring<br />

(T )select shape, disp region<br />

union2<br />

intersection, complement<br />

Region processing<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

union2 ( Hobject Region1, Hobject Region2, Hobject *RegionUnion )<br />

Return the union of two regions.<br />

union2 computes the union of the region in Region1 with all regions in Region2. This means that union2<br />

is not commutative!<br />

Parameter<br />

º Region1 (input object) .....................................................region(-array) Hobject<br />

Region for which the union with all regions in Region2 is to be computed.<br />

º Region2 (input object) .....................................................region(-array) Hobject<br />

Regions which should be added to Region1.<br />

<strong>HALCON</strong> 6.0


514 CHAPTER 9. REGIONS<br />

º RegionUnion (output object) ............................................region(-array) Hobject *<br />

Resulting regions.<br />

Parameter Number : RegionUnion Region1<br />

Complexity<br />

Let be the sum of all areas of the input regions. Then the runtime complexity is Ç´ÐÓ´Ô<br />

µ £<br />

Ô<br />

µ.<br />

Result<br />

union2 always returns H MSG TRUE. The behavior in case of empty input (no regions given) can be set via<br />

set system(’no object result’,) and the behavior in case of an empty input region via<br />

set system(’empty region result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

union2 is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring<br />

(T )select shape, disp region<br />

union1<br />

intersection, complement<br />

Region processing<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

9.6 Transformation<br />

background seg ( Hobject Foreground, Hobject *BackgroundRegions )<br />

Determine the connected components of the background of given regions.<br />

background seg determines connected components of the background of the foreground regions given in<br />

Foreground. This operator is normally used after an edge operator in order to determine the regions enclosed<br />

by the extracted edges. The connected components are determined using 4-connectivity.<br />

Parameter<br />

º Foreground (input object) .................................................region(-array) Hobject<br />

Input regions.<br />

º BackgroundRegions (output object) ......................................region-array Hobject *<br />

Connected components of the background.<br />

Example<br />

/* Segmentation with edge filter: */<br />

read_image(&Image,"fabrik") ;<br />

sobel_dir(Image,&Sobel,&Dir,"sum_sqrt",3) ;<br />

threshold(Sobel,&Edges,20,255) ;<br />

skeleton(Edges,&Margins) ;<br />

background_seg(Margins,&Regions) ;<br />

Complexity<br />

Let be the area of the background, À and Ï be the height and width of the image, and Æ be the number of<br />

resulting regions. Then the runtime complexity is Ç´À ·<br />

Ô<br />

£<br />

Ô<br />

Ƶ.<br />

Result<br />

background seg always returns the value H MSG TRUE. The behavior in case of empty input (no regions<br />

given) can be set via set system(’no object result’,) and the behavior in case of an empty<br />

input region via set system(’empty region result’,). If necessary, an exception handling<br />

is raised.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.6. TRANSFORMATION 515<br />

Parallelization Information<br />

background seg is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring, class ndim norm<br />

(T )select shape<br />

complement, connection<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

threshold, hysteresis threshold, skeleton, expand region, set system, sobel amp,<br />

edges image, roberts, bandpass image<br />

Region processing<br />

Module<br />

clip region ( Hobject Region, Hobject *RegionClipped, long Row1,<br />

long Column1, long Row2, long Column2 )<br />

Clip a region to a rectangle.<br />

clip region clips the input regions to the rectangle given by the four control parameters. clip region is<br />

more efficient than calling intersection with a rectangle generated by (T )gen rectangle1.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Region to be clipped.<br />

º RegionClipped (output object) ..........................................region(-array) Hobject *<br />

Clipped regions.<br />

º Row1 (input control) ........................................................rectangle.origin.y long<br />

Row coordinate of the upper left corner of the rectangle.<br />

Default Value : 0<br />

Value Suggestions : Row1 ¾0, 128, 200, 256<br />

Typical Range of Values : ½ Row1 ½(lin)<br />

º Column1 (input control) ....................................................rectangle.origin.x long<br />

Column coordinate of the upper left corner of the rectangle.<br />

Default Value : 0<br />

Value Suggestions : Column1 ¾0, 128, 200, 256<br />

Typical Range of Values : ½ Column1 ½(lin)<br />

º Row2 (input control) .......................................................rectangle.corner.y long<br />

Row coordinate of the lower right corner of the rectangle.<br />

Default Value : 256<br />

Value Suggestions : Row2 ¾128, 200, 256, 512<br />

Typical Range of Values : 0 Row2 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Column2 (input control) ...................................................rectangle.corner.x long<br />

Column coordinate of the lower right corner of the rectangle.<br />

Default Value : 256<br />

Value Suggestions : Column2 ¾128, 200, 256, 512<br />

Typical Range of Values : 0 Column2 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Result<br />

clip region returns H MSG TRUE if all parameters are correct. The behavior in case of empty input (no<br />

regions given) can be set via set system(’no object result’,) and the behavior in case of<br />

an empty input region via set system(’empty region result’,). If necessary, an exception<br />

handling is raised.<br />

<strong>HALCON</strong> 6.0


516 CHAPTER 9. REGIONS<br />

Parallelization Information<br />

clip region is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring<br />

(T )select shape, disp region<br />

Possible Successor Functions<br />

Alternatives<br />

intersection, (T )gen rectangle1, clip region rel<br />

Region processing<br />

Module<br />

clip region rel ( Hobject Region, Hobject *RegionClipped, long Top,<br />

long Bottom, long Left, long Right )<br />

Clip a region relative to its size.<br />

clip region rel clips a region to a rectangle lying within the region. The size of the rectangle is determined<br />

by the enclosing rectangle of the region, which is reduced by the values given in the four control parameters. All<br />

four parameters must contain numbers larger or equal to zero, and determine by which amount the rectangle is<br />

reduced at the top (Top), at the bottom (Bottom), at the left (Left), and at the right (Right). If all parameters<br />

are set to zero, the region remains unchanged.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be clipped.<br />

º RegionClipped (output object) ..........................................region(-array) Hobject *<br />

Clipped regions.<br />

º Top (input control) ...................................................................integer long<br />

Number of rows clipped at the top.<br />

Default Value : 1<br />

Value Suggestions : Top ¾0, 1, 2, 3, 4, 5, 7, 10, 20, 30, 50<br />

Typical Range of Values : 0 Top (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Bottom (input control) ...............................................................integer long<br />

Number of rows clipped at the bottom.<br />

Default Value : 1<br />

Value Suggestions : Bottom ¾0, 1, 2, 3, 4, 5, 7, 10, 20, 30, 50<br />

Typical Range of Values : 0 Bottom (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Left (input control) .................................................................integer long<br />

Number of columns clipped at the left.<br />

Default Value : 1<br />

Value Suggestions : Left ¾0, 1, 2, 3, 4, 5, 7, 10, 20, 30, 50<br />

Typical Range of Values : 0 Left (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Right (input control) ................................................................integer long<br />

Number of columns clipped at the right.<br />

Default Value : 1<br />

Value Suggestions : Right ¾0, 1, 2, 3, 4, 5, 7, 10, 20, 30, 50<br />

Typical Range of Values : 0 Right (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.6. TRANSFORMATION 517<br />

Result<br />

clip region rel returns H MSG TRUE if all parameters are correct. The behavior in case of empty input (no<br />

regions given) can be set via set system(’no object result’,) and the behavior in case of<br />

an empty input region via set system(’empty region result’,). If necessary, an exception<br />

handling is raised.<br />

Parallelization Information<br />

clip region rel is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring<br />

(T )select shape, disp region<br />

Possible Successor Functions<br />

Alternatives<br />

(T )smallest rectangle1, intersection, (T )gen rectangle1, clip region<br />

Region processing<br />

Module<br />

connection ( Hobject Region, Hobject *ConnectedRegions )<br />

Compute connected components of a region.<br />

connection determines the connected components of the input regions given in Region. The neighborhood<br />

used for this can be set via set system(’neighborhood’,) The default is 8-neighborhood, which<br />

is useful for determining the connected components of the foreground. The inverse operator of connection is<br />

union1.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Input region.<br />

º ConnectedRegions (output object) .......................................region-array Hobject *<br />

Connected components.<br />

Example<br />

read_image(&Image,"affe");<br />

set_colored(WindowHandle,12);<br />

threshold(Image,&Light,150.0,255.0);<br />

count_obj(Light,&Number1);<br />

printf("Nummber of regions after threshold = %d\n",Number1);<br />

disp_region(Light,WindowHandle);<br />

connection(Light,&Many);<br />

count_obj(Many,&Number2);<br />

printf("Nummber of regions after threshold = %d\n",Number2);<br />

disp_region(Many,WindowHandle);<br />

Complexity<br />

Let be the areaÔ of theÔinput region and Æ be the number of generated connected components. Then the runtime<br />

complexity is Ç´ £ Æ µ.<br />

Result<br />

connection always returns the value H MSG TRUE. The behavior in case of empty input (no regions given)<br />

can be set via set system(’no object result’,) and the behavior in case of an empty input<br />

region via set system(’empty region result’,). If necessary, an exception handling is<br />

raised.<br />

Parallelization Information<br />

connection is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

auto threshold, threshold, dyn threshold, erosion1<br />

<strong>HALCON</strong> 6.0


518 CHAPTER 9. REGIONS<br />

Possible Successor Functions<br />

(T )select shape, select gray, shape trans, set colored, dilation1, count obj,<br />

reduce domain, add channels<br />

background seg<br />

set system, union1<br />

Region processing<br />

Alternatives<br />

See Also<br />

Module<br />

crop domain rel ( Hobject Image, Hobject *ImagePart, long Top,<br />

long Bottom, long Left, long Right )<br />

Cut out an image area relative to the domain.<br />

crop domain rel cuts a rectangular area from the input images. The area is determined by the surrounding<br />

rectangle of the domain of the input image. The rectangle can be influenced by the control parameters to modify<br />

at the top (Top), at the bottom (Bottom), at the left (Left), and at the right (Right). Positive values results in<br />

a smaller, negative values in a larger size. If all parameters are set to zero, the region remains unchanged. The new<br />

image matrix has the size of a rectangle.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject<br />

Input image.<br />

º ImagePart (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject *<br />

Image area.<br />

º Top (input control) ...................................................................integer long<br />

Number of rows clipped at the top.<br />

Default Value : -1<br />

Value Suggestions : Top ¾-20, -10, -5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 10, 20<br />

º Bottom (input control) ...............................................................integer long<br />

Number of rows clipped at the bottom.<br />

Default Value : -1<br />

Value Suggestions : Bottom ¾-20, -10, -5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 10, 20<br />

º Left (input control) .................................................................integer long<br />

Number of columns clipped at the left.<br />

Default Value : -1<br />

Value Suggestions : Left ¾-20, -10, -5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 10, 20<br />

º Right (input control) ................................................................integer long<br />

Number of columns clipped at the right.<br />

Default Value : -1<br />

Value Suggestions : Right ¾-20, -10, -5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 10, 20<br />

Result<br />

crop domain rel returns H MSG TRUE if all parameters are correct. The behavior in case of empty input (no<br />

regions given) can be set via set system(’no object result’,) and the behavior in case of<br />

an empty input region via set system(’empty region result’,). If necessary, an exception<br />

handling is raised.<br />

Parallelization Information<br />

crop domain rel is reentrant and automatically parallelized (on tuple level, channel level).<br />

Possible Predecessor Functions<br />

reduce domain, threshold, connection, regiongrowing, pouring<br />

crop domain, crop rectangle1<br />

Alternatives<br />

See Also<br />

(T )smallest rectangle1, intersection, (T )gen rectangle1, clip region<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.6. TRANSFORMATION 519<br />

Image / region / XLD management<br />

Module<br />

distance transform ( Hobject Region, Hobject *DistanceImage,<br />

const char *Metric, const char *Foreground, long Width, long Height )<br />

Compute the distance transformation of a region.<br />

distance transform computes for every point of the input region Region (or its complement, respectively)<br />

the distance of the point to the border of the region. The parameter Foreground determines whether the distances<br />

are calculated for all points within the region (Foreground = ’true’) or for all points outside the region<br />

(Foreground = ’false’). The distance is computed for every point of the output image DistanceImage,<br />

which has the specified dimensions Width and Height. The input region is always clipped to the extent of<br />

the output image. If it is important that the distances within the entire region should be computed, the region<br />

should be moved (see move region) so that it has only positive coordinates and the width and height of the<br />

output image should be large enough to contain the region. The extent of the input region can be obtained with<br />

(T )smallest rectangle1.<br />

The parameter Metric determines which metric is used for the calculation of the distances. If Metric = ’cityblock’,<br />

the distance is calculated from the shortest path from the point to the border of the region, where only<br />

horizontal and vertical “movements” are allowed. They are weighted with a distance of 1. If Metric = ’chessboard’,<br />

the distance is calculated from the shortest path to the border, where horizontal, vertical, and diagonal<br />

“movements” are allowed. They are weighted with a distance of 1. If Metric = ’octagonal’, a combination of<br />

these approaches is used, which leads to diagonal paths getting a higher weight. If Metric = ’chamfer-3-4’,<br />

horizontal and vertical movements are weighted with a weight of 3, while diagonal movements are weighted with<br />

a weight of 4. To normalize the distances, the resulting distance image is divided by 3. Since this normalization<br />

step takes some time, and one usually is interested in the relative distances of the points, the normalization can<br />

be suppressed with Metric = ’chamfer-3-4-unnormalized’. Finally, if Metric = ’euclidean’, the computed<br />

distance is approximately Euclidean.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Region for which the distance to the border is computed.<br />

º DistanceImage (output object) ...........................................image Hobject * :int4<br />

Image containing the distance information.<br />

º Metric (input control) .........................................................string const char *<br />

Type of metric to be used for the distance transformation.<br />

Default Value : ”city-block”<br />

Value List : Metric ¾”city-block”, ”chessboard”, ”octagonal”, ”chamfer-3-4”,<br />

”chamfer-3-4-unnormalized”, ”euclidean”<br />

º Foreground (input control) ...................................................string const char *<br />

Compute the distance for pixels inside (true) or outside (false) the input region.<br />

Default Value : ’true’<br />

Value List : Foreground ¾’true’, ’false’<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the output image.<br />

Default Value : 640<br />

Value Suggestions : Width ¾160, 192, 320, 384, 640, 768<br />

Typical Range of Values : 1 Width<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the output image.<br />

Default Value : 480<br />

Value Suggestions : Height ¾120, 144, 240, 288, 480, 576<br />

Typical Range of Values : 1 Height<br />

Example<br />

/* Step towards extracting the medial axis of a shape: */<br />

gen_rectangle1 (Rectangle1, 0, 0, 200, 400)<br />

<strong>HALCON</strong> 6.0


520 CHAPTER 9. REGIONS<br />

gen_rectangle1 (Rectangle2, 200, 0, 400, 200)<br />

union2 (Rectangle1, Rectangle2, Shape)<br />

distance_transform (Shape, DistanceImage, ’chessboard’, ’true’, 640, 480)<br />

The runtime complexity is Ç´ÏØ £ Àص.<br />

Complexity<br />

Result<br />

distance transform returns H MSG H MSG TRUE if all parameters are correct.<br />

Parallelization Information<br />

distance transform is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, dyn threshold, regiongrowing<br />

threshold<br />

skeleton<br />

Possible Successor Functions<br />

See Also<br />

Bibliography<br />

P. Soille: “Morphological Image Analysis, Principles and Applications”; Springer Verlag Berlin Heidelberg New<br />

York, 1999.<br />

G. Borgefors: “Distance Transformations in Arbitrary Dimensions”; Computer Vision, Graphics, and Image Processing,<br />

Vol. 27, pages 321–345, 1984.<br />

P.E. Danielsson: “Euclidean Distance Mapping”; Computer Graphics and Image Processing, Vol. 14, pages 227–<br />

248, 1980.<br />

Module<br />

Region processing<br />

eliminate runs ( Hobject Region, Hobject *RegionClipped,<br />

long ElimShorter, long ElimLonger )<br />

Eliminate runs of a given length.<br />

eliminate runs eliminates all runs of the run length encoding of the input regions which are shorter than<br />

ElimShorter or longer as ElimLonger.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Region to be clipped.<br />

º RegionClipped (output object) ..........................................region(-array) Hobject *<br />

Clipped regions.<br />

º ElimShorter (input control) ........................................................integer long<br />

All runs which are shorter are eliminated.<br />

Default Value : 3<br />

Value Suggestions : ElimShorter ¾2, 3, 4, 5, 6, 8, 10, 12, 15<br />

Typical Range of Values : 1 ElimShorter 500 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º ElimLonger (input control) .........................................................integer long<br />

All runs which are longer are eliminated.<br />

Default Value : 1000<br />

Value Suggestions : ElimLonger ¾50, 100, 200, 500, 1000, 2000<br />

Typical Range of Values : 1 ElimLonger 10000 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.6. TRANSFORMATION 521<br />

Result<br />

eliminate runs returns H MSG TRUE if all parameters are correct. The behavior in case of empty input (no<br />

regions given) can be set via set system(’no object result’,) and the behavior in case of<br />

an empty input region via set system(’empty region result’,). If necessary, an exception<br />

handling is raised.<br />

Parallelization Information<br />

eliminate runs is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring<br />

Possible Successor Functions<br />

erosion1, dilation1, disp region<br />

shape trans<br />

Region processing<br />

Alternatives<br />

Module<br />

expand region ( Hobject Regions, Hobject ForbiddenArea,<br />

Hobject *RegionExpanded, long Iterations, const char *Mode )<br />

Fill gaps between regions or split overlapping regions.<br />

expand region closes gaps between the input regions, which resulted from the suppression of small regions in<br />

a segmentation operator, for example, (mode ’image’), or to separate overlapping regions (mode ’region’). Both<br />

uses result from the expansion of regions. The operator works by adding or removing a one pixel wide “strip” to a<br />

region.<br />

The expansion takes place only in regions, which are designated as not “forbidden” (parameter<br />

ForbiddenArea). The number of iterations is determined by the parameter Iterations. By passing ’maximal’,<br />

expand region iterates until convergence, i.e., until no more changes occur. By passing 0 for this parameter,<br />

all non-overlapping regions are returned. The two modes of operation (’image’ and ’region’) are different in<br />

the following ways:<br />

’image’ The input regions are expanded iteratively until they touch another region or the image border. Because<br />

expand region processes all regions simultaneously, gaps between regions are distributed evenly to all<br />

regions. Overlapping regions are split by distributing the area of overlap evenly to both regions.<br />

’region’ No expansion of the input regions is performed. Instead, only overlapping regions are split by distributing<br />

the area of overlap evenly to the respective regions. Because the intersection with the original region is<br />

computed after the shrinking operation gaps in the output regions may result, i.e., the segmentation is not<br />

complete. This can be prevented by calling expand region a second time with the complement of the<br />

original regions as “forbidden area.”<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions for which the gaps are to be closed, or which are to be separated.<br />

º ForbiddenArea (input object) ...................................................region Hobject<br />

Regions in which no expasion takes place.<br />

º RegionExpanded (output object) ........................................region(-array) Hobject *<br />

Expanded or separated regions.<br />

º Iterations (input control) ............................................integer long / const char *<br />

Number of iterations.<br />

Default Value : ’maximal’<br />

Value Suggestions : Iterations ¾’maximal’, 0, 1, 2, 3, 5, 7, 10, 15, 20, 30, 50, 70, 100, 200<br />

Typical Range of Values : 0 Iterations 1000 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

<strong>HALCON</strong> 6.0


522 CHAPTER 9. REGIONS<br />

º Mode (input control) ............................................................string const char *<br />

Expansion mode.<br />

Default Value : ’image’<br />

Value List : Mode ¾’image’, ’region’<br />

Example<br />

read_image(&Image,"fabrik");<br />

threshold(Image,&Light,100.0,255.0);<br />

disp_region(Light,WindowHandle);<br />

connection(Light,&Seg);<br />

expand_region(Seg,EMPTY_REGION,&Exp1,"maximal","image");<br />

set_colored(WindowHandle,12);<br />

set_draw(WindowHandle,"margin");<br />

disp_region(Exp1,WindowHandle);<br />

Result<br />

expand region always returns the value H MSG TRUE. The behavior in case of empty input (no regions given)<br />

can be set via set system(’no object result’,), the behavior in case of an empty input region<br />

via set system(’empty region result’,), and the behavior in case of an empty result<br />

region via set system(’store empty region’,). If necessary, an exception handling<br />

is raised.<br />

Parallelization Information<br />

expand region is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

pouring, threshold, dyn threshold, regiongrowing<br />

dilation1<br />

expand gray, interjacent, skeleton<br />

Region processing<br />

Alternatives<br />

See Also<br />

Module<br />

fill up ( Hobject Region, Hobject *RegionFillUp )<br />

Fill up holes in regions.<br />

fill up fills up holes in regions. The number of regions remains unchanged. The neighborhood type is set via<br />

set system(’neighborhood’,) (default: 8-neighborhood).<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Input regions containing holes.<br />

º RegionFillUp (output object) ...........................................region(-array) Hobject *<br />

Regions without holes.<br />

Result<br />

fill up returns H MSG TRUE if all parameters are correct. The behavior in case of empty input (no regions<br />

given) can be set via set system(’no object result’,) and the behavior in case of an empty<br />

input region via set system(’empty region result’,). If necessary, an exception handling<br />

is raised.<br />

Parallelization Information<br />

fill up is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring<br />

(T )select shape, disp region<br />

Possible Successor Functions<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.6. TRANSFORMATION 523<br />

fill up shape<br />

boundary<br />

Region processing<br />

Alternatives<br />

See Also<br />

Module<br />

fill up shape ( Hobject Region, Hobject *RegionFillUp,<br />

const char *Feature, double Min, double Max )<br />

Fill up holes in regions having given shape features.<br />

fill up shape fills up those holes in the input region Region having given shape features. The parameter<br />

Feature determines the shape feature to be used, while Min and Max determine the range the shape feature has<br />

to lie in in order for the hole to be filled up.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Input region(s).<br />

º RegionFillUp (output object) ...........................................region(-array) Hobject *<br />

Output region(s) with filled holes.<br />

º Feature (input control) .......................................................string const char *<br />

Shape feature used.<br />

Default Value : ’area’<br />

Value List : Feature ¾’area’, ’compactness’, ’convexity’, ’anisometry’, ’phi’, ’ra’, ’rb’, ’inner circle’,<br />

’outer circle’<br />

º Min (input control) ..........................................................number double / long<br />

Minimum value for Feature.<br />

Default Value : 1.0<br />

Value Suggestions : Min ¾0.0, 1.0, 10.0, 50.0, 100.0, 500.0, 1000.0, 10000.0<br />

Typical Range of Values : 0.0 Min<br />

º Max (input control) ..........................................................number double / long<br />

Maximum value for Feature.<br />

Default Value : 100.0<br />

Value Suggestions : Max ¾10.0, 50.0, 100.0, 500.0, 1000.0, 10000.0, 100000.0<br />

Typical Range of Values : 0.0 Max<br />

Example<br />

read_image(&Image,"affe");<br />

threshold(Image,&Seg,120.0,255.0);<br />

fill_up_shape(Seg,&Filled,"area",0.0,200.0);<br />

Result<br />

fill up shape returns H MSG TRUE if all parameters are correct. The behavior in case of empty input (no<br />

regions given) can be set via set system(’no object result’,) and the behavior in case of<br />

an empty input region via set system(’empty region result’,). If necessary, an exception<br />

handling is raised.<br />

Parallelization Information<br />

fill up shape is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring<br />

(T )select shape, disp region<br />

fill up<br />

Possible Successor Functions<br />

Alternatives<br />

<strong>HALCON</strong> 6.0


524 CHAPTER 9. REGIONS<br />

See Also<br />

(T )select shape, connection, (T )area center<br />

Region processing<br />

Module<br />

hamming change region ( Hobject InputRegion, Hobject *OutputRegion,<br />

long Width, long Height, long Distance )<br />

Generate a region having a given Hamming distance.<br />

hamming change region changes the region in the left upper part of the image given by Width and Height<br />

such that the resulting regions have a Hamming distance of Distance to the input regions. This is done by<br />

adding or removing Distance points from the input region.<br />

Attention<br />

If Width and Height are chosen too large the resulting region requires a lot of memory.<br />

Parameter<br />

º InputRegion (input object) ...............................................region(-array) Hobject<br />

Region to be modified.<br />

º OutputRegion (output object) ...........................................region(-array) Hobject *<br />

Regions having the required Hamming distance.<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the region to be changed.<br />

Default Value : 100<br />

Value Suggestions : Width ¾64, 128, 256, 512<br />

Typical Range of Values : 1 Width 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Width 0<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the region to be changed.<br />

Default Value : 100<br />

Value Suggestions : Height ¾64, 128, 256, 512<br />

Typical Range of Values : 1 Height 512 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Height 0<br />

º Distance (input control) ............................................................integer long<br />

Hamming distance between the old and new regions.<br />

Default Value : 1000<br />

Value Suggestions : Distance ¾100, 500, 1000, 5000, 10000<br />

Typical Range of Values : 0 Distance 10000 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : ´Distance 0µ ´Distance ´Width ¡ Heightµµ<br />

Complexity<br />

Memory requirement of the generated region (worst case): Ç´¾ £ ÏØ £ Àص.<br />

Result<br />

hamming change region returns H MSG TRUE if all parameters are correct. The behavior in case of empty<br />

input (no regions given) can be set via set system(’no object result’,). If necessary, an<br />

exception handling is raised.<br />

Parallelization Information<br />

hamming change region is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

connection, regiongrowing, pouring, class ndim norm<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.6. TRANSFORMATION 525<br />

(T )select shape<br />

(T )hamming distance<br />

Region processing<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

interjacent ( Hobject Region, Hobject *RegionInterjacent,<br />

const char *Mode )<br />

Partition the image plane using given regions.<br />

interjacent partitions the image plane using the regions given in Region. The result is a region containing<br />

the extracted separating lines. The following modes of operation can be used:<br />

’medial axis’ This mode is used for regions that do not touch or overlap. The operator will find separating lines<br />

between the regions which partition the background evenly between the input regions. This corresponds to<br />

the following calls:<br />

complement(’full’,Region,Tmp) skeleton(Tmp,Result)<br />

’border’ If the input regions do not touch or overlap this mode is equivalent to boundary(Region,Result),<br />

i.e., it replaces each region by its boundary. If regions are touching they are aggregated into one region. The<br />

corresponding output region then contains the boundary of the aggregated region, as well as the one pixel<br />

wide separating line between the original regions. This corresponds to the following calls:<br />

boundary(Region,Tmp1,’inner’) union1(Tmp1,Tmp2)<br />

skeleton(Tmp2,Result)<br />

’mixed’ In this mode the operator behaves like the mode ’medial axis’ for non-overlapping regions. If regions<br />

touch or overlap, again separating lines between the input regions are generated on output, but this time<br />

including the “touching line” between regions, i.e., touching regions are separated by a line in the output<br />

region. This corresponds to the following calls:<br />

erosion1(Region,Mask,Tmp1,1) union1(Tmp1,Tmp2)<br />

complement(full,Tmp2,Tmp3) skeleton(Tmp3,Result)<br />

where Mask denotes the following “cross mask”:<br />

¢<br />

¢ ¢ ¢<br />

¢<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions for which the separating lines are to be determined.<br />

º RegionInterjacent (output object) ...........................................region Hobject *<br />

Output region containing the separating lines.<br />

º Mode (input control) ............................................................string const char *<br />

Mode of operation.<br />

Default Value : ’mixed’<br />

Value List : Mode ¾’medial axis’, ’border’, ’mixed’<br />

Example<br />

read_image(&Image,"wald1_rot") ;<br />

mean(Image,&Mean,31,31) ;<br />

dyn_threshold(Mean,&Seg,20) ;<br />

interjacent(Seg,&Graph,"medial_axis") ;<br />

disp_region(Graph,WindowHandle) ;<br />

<strong>HALCON</strong> 6.0


526 CHAPTER 9. REGIONS<br />

Result<br />

interjacent always returns the value H MSG TRUE. The behavior in case of empty input (no regions given)<br />

can be set via set system(’no object result’,), the behavior in case of an empty input region<br />

via set system(’empty region result’,), and the behavior in case of an empty result<br />

region via set system(’store empty region’,). If necessary, an exception handling<br />

is raised.<br />

Parallelization Information<br />

interjacent is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring<br />

(T )select shape, disp region<br />

Possible Successor Functions<br />

See Also<br />

expand region, junctions skeleton, boundary<br />

Region processing<br />

Module<br />

junctions skeleton ( Hobject Region, Hobject *EndPoints,<br />

Hobject *JuncPoints )<br />

Find junctions and end points in a skeleton.<br />

junctions skeleton detects junctions and end points in a skeleton (see skeleton). The junctions in the<br />

input region Region are output as a region in JuncPoints, while the end points are output as a region in<br />

EndPoints.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Input skeletons.<br />

º EndPoints (output object) ...............................................region(-array) Hobject *<br />

Extracted end points.<br />

Parameter Number : EndPoints Region<br />

º JuncPoints (output object) ..............................................region(-array) Hobject *<br />

Extracted junctions.<br />

Parameter Number : JuncPoints Region<br />

Example<br />

/* non-connected branches of a skeleton */<br />

skeleton(Region,&Skeleton) ;<br />

junctions_skeleton(Skeleton,&EPoints,&JPoints) ;<br />

difference(S,JPoints,&Rows) ;<br />

connection(Rows,&Parts) ;<br />

Complexity<br />

Let be the area of the input region. Then the runtime complexity is Ç´ µ.<br />

Result<br />

junctions skeleton always returns the value H MSG TRUE. The behavior in case of empty input (no regions<br />

given) can be set via set system(’no object result’,), the behavior in case of an<br />

empty input region via set system(’empty region result’,), and the behavior in case of<br />

an empty result region via set system(’store empty region’,). If necessary, an exception<br />

handling is raised.<br />

Parallelization Information<br />

junctions skeleton is reentrant and automatically parallelized (on tuple level).<br />

skeleton<br />

Possible Predecessor Functions<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.6. TRANSFORMATION 527<br />

Possible Successor Functions<br />

(T )area center, connection, T get region points, difference<br />

pruning, split skeleton region<br />

Region processing<br />

See Also<br />

Module<br />

merge regions line scan ( Hobject CurrRegions, Hobject PrevRegions,<br />

Hobject *CurrMergedRegions, Hobject *PrevMergedRegions, long ImageHeight,<br />

const char *MergeBorder, long MaxImagesRegion )<br />

Merge regions from line scan images.<br />

The operator merge regions line scan connects adjacent regions, which were segmentated from adjacent<br />

images with the height ImageHeight. This operator was especially designed to process regions that were extracted<br />

from images grabbed by a line scan camera. CurrRegions contains the regions from the current image<br />

and PrevRegions the regions from the previous one.<br />

With the help of the parameter MergeBorder two cases can be distinguished: If the top (first) line of the current<br />

image touches the bottom (last) line of the previous image, MergeBorder must be set to ’top’, otherwise set<br />

MergeBorder to ’bottom’.<br />

If the operator merge regions line scan is used recursivly, the parameter MaxImagesRegion determines<br />

the maximum number of images which are covered by a merged region. All older region parts are removed.<br />

The operator merge regions line scan returns two region arrays. PrevMergedRegions contains all<br />

those regions from the previous input regions PrevRegions, which could not be merged with a current<br />

region. CurrMergedRegions collects all current regions together with the merged parts from the previous<br />

images. Merged regions will exceed the original image, because the previous regions are moved upward<br />

(MergeBorder=’top’) ordownward(MergeBorder=’bottom’) according to the image height. For this the<br />

system parameter ’clip region’ (see also set system) will internaly be set to ’false’.<br />

Parameter<br />

º CurrRegions (input object) ...............................................region(-array) Hobject<br />

Current input regions.<br />

º PrevRegions (input object) ...............................................region(-array) Hobject<br />

Merged regions from the previous iteration.<br />

º CurrMergedRegions (output object) ....................................region(-array) Hobject *<br />

Current regions, merged with old ones where applicable.<br />

º PrevMergedRegions (output object) ....................................region(-array) Hobject *<br />

Regions from the previous iteration which could not be merged with the current ones.<br />

º ImageHeight (input control) ........................................................integer long<br />

Height of the line scan images.<br />

Default Value : 512<br />

Value List : ImageHeight ¾240, 480, 512<br />

º MergeBorder (input control) ..................................................string const char *<br />

Image line of the current image, which touches the previous image.<br />

Default Value : ”top”<br />

Value List : MergeBorder ¾”top”, ”bottom”<br />

º MaxImagesRegion (input control) ..................................................integer long<br />

Maximum number of images for a single region.<br />

Default Value : 3<br />

Value Suggestions : MaxImagesRegion ¾1, 2, 3, 4, 5<br />

Result<br />

The operator merge regions line scan returns the value H MSG TRUE if the given parameters are correct.<br />

Otherwise, an exception will be raised.<br />

Parallelization Information<br />

merge regions line scan is reentrant and processed without parallelization.<br />

<strong>HALCON</strong> 6.0


528 CHAPTER 9. REGIONS<br />

Region processing<br />

Module<br />

partition dynamic ( Hobject Region, Hobject *Partitioned,<br />

double Distance, double Percent )<br />

Partition a region horizontally into rectangles.<br />

partition dynamic partitions the input region into rectangles having an average width of Distance. The<br />

region is not split exactly into Ò parts, but rather starting from the calculated splitting point positions having a<br />

minimum number of set pixels in the vertical directions are extracted. The search area is at most plus/minus the<br />

width of a rectangle. If Percent is passed as 100, this search area is used fully. If it is passed as 0, no search is<br />

done.<br />

If the region is smaller than the given size its output remains unchanged. A partition is only done if the size of the<br />

region is at least 1.5 times the size of the rectangle given by the parameters.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Region to be partitioned.<br />

º Partitioned (output object) ..............................................region-array Hobject *<br />

Partitioned region.<br />

º Distance (input control) .............................................................real double<br />

Width of the individual rectangles.<br />

º Percent (input control) ..............................................................real double<br />

Maximum shift of the partition point.<br />

Default Value : 20<br />

Value Suggestions : Percent ¾0, 10, 20, 30, 40, 50, 70, 90, 100<br />

Typical Range of Values : 0 Percent 100<br />

Result<br />

partition dynamic returns H MSG TRUE if all parameters are correct. The behavior in case of empty input<br />

(no regions given) can be set via set system(’no object result’,), the behavior in case of<br />

an empty input region via set system(’empty region result’,), and the behavior in case<br />

of an empty result region via set system(’store empty region’,). If necessary, an<br />

exception handling is raised.<br />

Parallelization Information<br />

partition dynamic is reentrant and automatically parallelized (on tuple level).<br />

threshold, connection<br />

partition rectangle<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

intersection, (T )smallest rectangle1, shape trans, clip region<br />

Region processing<br />

Module<br />

partition rectangle ( Hobject Region, Hobject *Partitioned,<br />

double Width, double Height )<br />

Partition a region into rectangles of equal size.<br />

partition rectangle partitions the input region into rectangles having an extent of Width times Height.<br />

The region is always split into rectangles of equal size. Therefore, Width and Height are adapted to the actual<br />

size of the region. If the region is smaller than the given size its output remains unchanged. A partition is only<br />

done if the size of the region is at least 1.5 times the size of the rectangle given by the paramters.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.6. TRANSFORMATION 529<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Region to be partitioned.<br />

º Partitioned (output object) ............................................region(-array) Hobject *<br />

Partitioned region.<br />

º Width (input control) .................................................................real double<br />

Width of the individual rectangles.<br />

º Height (input control) ...............................................................real double<br />

Height of the individual rectangles.<br />

Result<br />

partition rectangle returns H MSG TRUE if all parameters are correct. The behavior in case of empty input<br />

(no regions given) can be set via set system(’no object result’,), the behavior in case<br />

of an empty input region via set system(’empty region result’,), and the behavior in<br />

case of an empty result region via set system(’store empty region’,). If necessary,<br />

an exception handling is raised.<br />

Parallelization Information<br />

partition rectangle is reentrant and automatically parallelized (on tuple level).<br />

threshold, connection<br />

partition dynamic<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

intersection, (T )smallest rectangle1, shape trans, clip region<br />

Region processing<br />

Module<br />

rank region ( Hobject Region, Hobject *RegionCount, long Width,<br />

long Height, long Number )<br />

Rank operator for regions.<br />

rank region calculates the binary rank operator. A filter mask of size Height x Width) isused. Inthe<br />

process, for each point in the region the number of points of Region lying within the filter mask are counted. If<br />

this number is greater or equal to Number, the current point is added to the output region. If<br />

is chosen, the median operator is obtained.<br />

ÀØ £ ÏØ<br />

ÆÙÑÖ <br />

¾<br />

Attention<br />

For Height and Width only odd values 3 are valid. If invalid parameters are chosen they are converted<br />

automatically (without raising an exception handling) to the next larger even values.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Region(s) to be transformed.<br />

º RegionCount (output object) ............................................region(-array) Hobject *<br />

Resulting region(s).<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the filter mask.<br />

Default Value : 15<br />

Value Suggestions : Width ¾3, 5, 7, 9, 11, 13, 15, 17, 19, 21<br />

Typical Range of Values : 3 Width 511 (lin)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : ´Width 3µ odd´Widthµ<br />

<strong>HALCON</strong> 6.0


530 CHAPTER 9. REGIONS<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the filter mask.<br />

Default Value : 15<br />

Value Suggestions : Height ¾3, 5, 7, 9, 11, 13, 15, 17, 19, 21<br />

Typical Range of Values : 3 Height 511 (lin)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : ´Height 3µ odd´Heightµ<br />

º Number (input control) ...............................................................integer long<br />

Minimum number of points lying within the filter mask.<br />

Default Value : 70<br />

Value Suggestions : Number ¾5, 10, 20, 40, 60, 80, 90, 120, 150, 200<br />

Typical Range of Values : 1 Number 1000 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : Number 0<br />

read_image(&Image,"affe") ;<br />

mean_image(Image,&Mean,5,5) ;<br />

dyn_threshold(Mean,&Points,25) ;<br />

rank_region(Points,Textur,15,15,30) ;<br />

gen_circle(&Mask,10,10,3) ;<br />

opening1(Textur,Mask,&Seg) ;<br />

Example<br />

Complexity<br />

Let be the area of the input region. Then the runtime complexity is Ç´ £ µ.<br />

Result<br />

rank region returns H MSG TRUE if all parameters are correct. The behavior in case of empty input (no<br />

regions given) can be set via set system(’no object result’,) and the behavior in case of<br />

an empty input region via set system(’empty region result’,). If necessary, an exception<br />

handling is raised.<br />

Parallelization Information<br />

rank region is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

threshold, connection, regiongrowing, pouring, class ndim norm<br />

(T )select shape, disp region<br />

closing rectangle1, expand region<br />

rank image, mean image<br />

Region processing<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

remove noise region ( Hobject InputRegion, Hobject *OutputRegion,<br />

const char *Type )<br />

Remove noise from a region.<br />

remove noise region removes noise from a region. In mode ’n 4’, a structuring element consisting of the<br />

four neighbors of a point is generated. A dilation with this structuring element is performed, and the intersection<br />

of the result and the input region is calculated. Thus all pixels having no 4-connected neighbor are removed.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.6. TRANSFORMATION 531<br />

Parameter<br />

º InputRegion (input object) ...............................................region(-array) Hobject<br />

Regions to be modified.<br />

º OutputRegion (output object) ...........................................region(-array) Hobject *<br />

Less noisy regions.<br />

º Type (input control) ............................................................string const char *<br />

Mode of noise removal.<br />

Default Value : ’n 4’<br />

Value List : Type ¾’n 4’, ’n 8’, ’n 48’<br />

Complexity<br />

Let be the area of the input region. Then the runtime complexity is Ç´Ô<br />

£ µ.<br />

Result<br />

remove noise region returns H MSG TRUE if all parameters are correct. The behavior in case of empty<br />

input (no regions given) can be set via set system(’no object result’,). If necessary, an<br />

exception handling is raised.<br />

Parallelization Information<br />

remove noise region is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

connection, regiongrowing, pouring, class ndim norm<br />

(T )select shape<br />

Possible Successor Functions<br />

See Also<br />

dilation1, intersection, (T )gen region points<br />

Region processing<br />

Module<br />

shape trans ( Hobject Region, Hobject *RegionTrans, const char *Type )<br />

Transform the shape of a region.<br />

shape trans transforms the shape of the input regions depending on the parameter Type:<br />

’convex’ Convex hull.<br />

’ellipse’ Ellipse with the same moments and area as the input region.<br />

’outer circle’ Smallest enclosing circle.<br />

’inner circle’ Largest circle fitting into the region.<br />

’rectangle1’ Smallest enclosing rectangle parallel to the coordinate axes.<br />

’rectangle2’ Smallest enclosing rectangle.<br />

’inner center’ The point on the skeleton of the input region having the smallest distance to the center of gravity<br />

of the input region.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be transformed.<br />

º RegionTrans (output object) ............................................region(-array) Hobject *<br />

Transformed regions.<br />

º Type (input control) ............................................................string const char *<br />

Type of transformation.<br />

Default Value : ’convex’<br />

Value List : Type ¾’convex’, ’ellipse’, ’outer circle’, ’inner circle’, ’rectangle1’, ’rectangle2’,<br />

’inner center’<br />

<strong>HALCON</strong> 6.0


532 CHAPTER 9. REGIONS<br />

Complexity<br />

Let be the area of the input region. Then the runtime complexity is Ç´ µ.<br />

Result<br />

shape trans returns H MSG TRUE if all parameters are correct. The behavior in case of empty input (no<br />

regions given) can be set via set system(’no object result’,). If necessary, an exception<br />

handling is raised.<br />

Parallelization Information<br />

shape trans is reentrant and automatically parallelized (on tuple level).<br />

connection, regiongrowing<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

disp region, regiongrowing mean, (T )area center<br />

See Also<br />

(T )convexity, (T )elliptic axis, (T )area center, (T )smallest rectangle1,<br />

(T )smallest rectangle2, set shape, (T )select shape, (T )inner circle<br />

Region processing<br />

Module<br />

skeleton ( Hobject Region, Hobject *Skeleton )<br />

Compute the skeleton of a region.<br />

skeleton computes the skeleton of the input regions.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Region to be thinned.<br />

º Skeleton (output object) ................................................region(-array) Hobject *<br />

Resulting skeleton.<br />

Parameter Number : Skeleton Region<br />

Complexity<br />

Let be the area of the enclosing rectangle of the input region. Then the runtime complexity is Ç´ µ (per region).<br />

Result<br />

skeleton returns H MSG TRUE if all parameters are correct. The behavior in case of empty input (no regions<br />

given) can be set via set system(’no object result’,) and the behavior in case of an empty<br />

input region via set system(’empty region result’,). If necessary, an exception handling<br />

is raised.<br />

Parallelization Information<br />

skeleton is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

sobel amp, edges image, bandpass image, threshold, hysteresis threshold<br />

junctions skeleton, pruning<br />

morph skeleton, thinning<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

gray skeleton, sobel amp, edges image, roberts, bandpass image, threshold<br />

Bibliography<br />

Eckardt, U. “Verd”unnung mit Perfekten Punkten”, Proceedings 10. DAGM-Symposium, IFB 180, Zurich, 1988<br />

Region processing<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.6. TRANSFORMATION 533<br />

sort region ( Hobject Regions, Hobject *SortedRegions,<br />

const char *SortMode, const char *Order, const char *RowOrCol )<br />

Sorting of regions with respect to their relative position.<br />

The operator sort region sorts the regions with respect to their relative position. All sorting methods with the<br />

exception of ’character’ use one point of the region. With the help of the parameter RowOrCol = ’row’ these<br />

points will be sorted according to their row and then according to their columnḂy using ’column’, thecolumn<br />

value will be used first. The following values are available for the parameter SortMode:<br />

’character’ The regions will be treated like characters in a row and will be sorted according to their order in the<br />

line: If two regions overlap horizontally, they will be sorted with respect to their column values, otherwise<br />

they will be sorted with regard to their row values.<br />

’first point’ The point with the lowest column value in the first row of the region.<br />

’last point’ The point with the highest column value in the last row of the region.<br />

’upper left’ Upper left corner of the surrounding rectangle.<br />

’upper right’ Upper right corner of the surrounding rectangle.<br />

’lower left’ Lower left corner of the surrounding rectangle.<br />

’lower right’ Lower right corner of the surrounding rectangle.<br />

The parameter Order determines whether the sorting order is increasing or decreasing: using ’true’ the order will<br />

be increasing, using ’false’ the order will be decreasing.<br />

Parameter<br />

º Regions (input object) ......................................................region-array Hobject<br />

Regions to be sorted.<br />

º SortedRegions (output object) ...........................................region-array Hobject *<br />

Sorted regions.<br />

º SortMode (input control) ......................................................string const char *<br />

Kind of sorting.<br />

Default Value : ’first point’<br />

Value List : SortMode ¾’character’, ’first point’, ’last point’, ’upper left’, ’lower left’, ’upper right’,<br />

’lower right’<br />

º Order (input control) ..........................................................string const char *<br />

Increasing or decreasing sorting order.<br />

Default Value : ’true’<br />

Value List : Order ¾’true’, ’false’<br />

º RowOrCol (input control) ......................................................string const char *<br />

Sorting first with respect to row, then to column.<br />

Default Value : ’row’<br />

Value List : RowOrCol ¾’row’, ’column’<br />

Result<br />

If the parameters are correct, the operator sort region returns the value H MSG TRUE. Otherwise an exception<br />

will be raised.<br />

Parallelization Information<br />

sort region is reentrant and processed without parallelization.<br />

do ocr multi, do ocr single<br />

Region processing<br />

Possible Successor Functions<br />

Module<br />

T split skeleton lines ( Hobject SkeletonRegion, Htuple MaxDistance,<br />

Htuple *BeginRow, Htuple *BeginCol, Htuple *EndRow, Htuple *EndCol )<br />

Split lines represented by one pixel wide, non-branching lines.<br />

<strong>HALCON</strong> 6.0


534 CHAPTER 9. REGIONS<br />

T split skeleton lines splits lines represented by one pixel wide, non-branching regions into shorter lines<br />

based on their curvature. A line is split if the maximum distance of a point on the line to the line segment<br />

connecting its end points is larger than MaxDistance (split & merge algorithm). The start and end points of<br />

the approximating line segments are returned in BeginRow, BeginCol, EndRow,andEndCol.<br />

Attention<br />

The input regions must represent non-branching lines, that is single branches of the skeleton.<br />

Parameter<br />

º SkeletonRegion (input object) .............................................region-array Hobject<br />

Input lines (represented by 1 pixel wide, non-branching regions).<br />

º MaxDistance (input control) ................................................integer Htuple . long<br />

Maximum distance of the line points to the line segment connecting both end points.<br />

Default Value : 3<br />

Value Suggestions : MaxDistance ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10<br />

Typical Range of Values : 1 MaxDistance 500 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º BeginRow (output control) .......................................line.begin.y-array Htuple . long *<br />

Row coordinates of the start points of the output lines.<br />

º BeginCol (output control) .......................................line.begin.x-array Htuple . long *<br />

Column coordinates of the start points of the output lines.<br />

º EndRow (output control) ............................................line.end.y-array Htuple . long *<br />

Row coordinates of the end points of the output lines.<br />

º EndCol (output control) ............................................line.end.x-array Htuple . long *<br />

Column coordinates of the end points of the output lines.<br />

Example<br />

read_image(&Image,"fabrik");<br />

edges_image (Image, &ImaAmp, &ImaDir, "lanser2", 0.5, "nms", 8, 16);<br />

threshold (ImaAmp, &RawEdges, 8, 255);<br />

skeleton (RawEdges, &Skeleton);<br />

junctions_skeleton (Skeleton, &EndPoints, &JuncPoints);<br />

difference (Skeleton, JuncPoints, &SkelWithoutJunc);<br />

connection (SkelWithoutJunc, &SingleBranches);<br />

select_shape (SingleBranches, &SelectedBranches, "area", "and", 16, 99999);<br />

split_skeleton_lines (SelectedBranches, 3, &BeginRow, &BeginCol, &EndRow,<br />

&EndCol);<br />

Result<br />

T split skeleton lines always returns the value H MSG TRUE. The behavior in case of empty input<br />

(no regions given) can be set via set system(’no object result’,), the behavior in case of<br />

an empty input region via set system(’empty region result’,), and the behavior in case<br />

of an empty result region via set system(’store empty region’,). If necessary, an<br />

exception handling is raised.<br />

Parallelization Information<br />

T split skeleton lines is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

connection, (T )select shape, skeleton, junctions skeleton, difference<br />

Possible Successor Functions<br />

select lines, partition lines, disp line<br />

See Also<br />

split skeleton region, detect edge segments<br />

Region processing<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


9.6. TRANSFORMATION 535<br />

split skeleton region ( Hobject SkeletonRegion, Hobject *RegionLines,<br />

long MaxDistance )<br />

Split lines represented by one pixel wide, non-branching regions.<br />

split skeleton region splits lines represented by one pixel wide, non-branching regions into shorter lines<br />

based on their curvature. A line is split if the maximum distance of a point on the line to the line segment connecting<br />

its end points is larger than MaxDistance (split & merge algorithm). However, not the approximating lines are<br />

returned, but rather the original lines split into several output regions.<br />

Attention<br />

The input regions must represent non-branching lines, that is single branches of the skeleton.<br />

Parameter<br />

º SkeletonRegion (input object) ...........................................region(-array) Hobject<br />

Input lines (represented by 1 pixel wide, non-branching regions).<br />

º RegionLines (output object) ..............................................region-array Hobject *<br />

Split lines.<br />

º MaxDistance (input control) ........................................................integer long<br />

Maximum distance of the line points to the line segment connecting both end points.<br />

Default Value : 3<br />

Value Suggestions : MaxDistance ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10<br />

Typical Range of Values : 1 MaxDistance 500 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Example<br />

read_image(&Image,"fabrik");<br />

edges_image (Image, &ImaAmp, &ImaDir, "lanser2", 0.5, "nms", 8, 16);<br />

threshold (ImaAmp, &RawEdges, 8, 255);<br />

skeleton (RawEdges, &Skeleton);<br />

junctions_skeleton (Skeleton, &EndPoints, &JuncPoints);<br />

difference (Skeleton, JuncPoints, &SkelWithoutJunc);<br />

connection (SkelWithoutJunc, &SingleBranches);<br />

select_shape (SingleBranches, &SelectedBranches, "area", "and", 16, 99999);<br />

split_skeleton_region (SelectedBranches, Lines, 3);<br />

Result<br />

split skeleton region always returns the value H MSG TRUE. The behavior in case of empty input (no<br />

regions given) can be set via set system(’no object result’,), the behavior in case of an<br />

empty input region via set system(’empty region result’,), and the behavior in case of<br />

an empty result region via set system(’store empty region’,). If necessary, an exception<br />

handling is raised.<br />

Parallelization Information<br />

split skeleton region is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

connection, (T )select shape, skeleton, junctions skeleton, difference<br />

Possible Successor Functions<br />

count obj, (T )select shape, select obj, (T )area center, (T )elliptic axis,<br />

(T )smallest rectangle2, T get region polygon, T get region contour<br />

See Also<br />

T split skeleton lines, T get region polygon, gen polygons xld<br />

Region processing<br />

Module<br />

<strong>HALCON</strong> 6.0


536 CHAPTER 9. REGIONS<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Chapter 10<br />

Segmentation<br />

auto threshold ( Hobject Image, Hobject *Regions, double Sigma )<br />

Segment an image using thresholds determined from its histogram.<br />

auto threshold segments a single-channel image using multiple thresholding. First the relative histogram of<br />

the gray values is determined. Then relevant minima are extracted from the histogram, which are used successively<br />

as parameters for a thresholding operation. The thresholds used are 0, 255, and all minima extracted from the<br />

histogram (after the histogram has been smoothed). For each gray value interval one region is generated. Thus,<br />

the number of regions is the number of minima + 1. The larger the value of Sigma is chosen, the less regions<br />

will be extracted. This operator is particularly suited if the regions to be extracted exhibit similar gray values<br />

(homogeneous regions).<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Image to be segmented.<br />

º Regions (output object) ...................................................region-array Hobject *<br />

Regions with gray values within the automatically determined intervals.<br />

º Sigma (input control) .......................................................number double / long<br />

Sigma for the Gaussian smoothing of the histogram.<br />

Default Value : 2.0<br />

Value Suggestions : Sigma ¾0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0<br />

Typical Range of Values : 0.0 Sigma 100.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.3<br />

Restriction : Sigma 0.0<br />

Example<br />

read_image(&Image,"fabrik");<br />

median_image(Image,&Median,"circle",3);<br />

auto_threshold(Median,&Seg,2.0);<br />

set_colored(WindowHandle,12);<br />

disp_region(Seg,WindowHandle);<br />

connection(Seg,&Connected);<br />

disp_region(Connected,WindowHandle);<br />

Parallelization Information<br />

auto threshold is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

anisotrope diff, median image, illuminate<br />

Possible Successor Functions<br />

connection, select shape, select gray<br />

537


538 CHAPTER 10. SEGMENTATION<br />

Alternatives<br />

gray histo, smooth funct 1d gauss, (T )threshold<br />

Region processing<br />

Module<br />

bin threshold ( Hobject Image, Hobject *Region )<br />

Segment a black-and-white image using an automatically determined threshold.<br />

bin threshold segments a single-channel gray value image using an automatically determined threshold. First<br />

the relative histogram of the gray values is determined. Then relevant minima are extracted from the histogram,<br />

which are used as parameters for a thresholding operation. In order to reduce the number of minima, the histogram<br />

is smoothed with a Gaussian, as in auto threshold. The mask size is enlarged until there is only one minimum<br />

in the smoothed histogram. The selected region contains the pixels with gray values from 0 to the minimum. This<br />

operator is particularly suited for the segmentation of dark characters on a light paper.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Image to be segmented.<br />

º Region (output object) ...................................................region(-array) Hobject *<br />

Dark regions of the image.<br />

read_image(&Image,"letters");<br />

bin_threshold(Image,&Seg);<br />

set_colored(WindowHandle,6);<br />

disp_region(Seg,WindowHandle);<br />

set_shape(WindowHandle,"rectangle1");<br />

connection(Seg,&Connected);<br />

disp_region(Connected,WindowHandle);<br />

Example<br />

Parallelization Information<br />

bin threshold is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

anisotrope diff, median image, illuminate<br />

Possible Successor Functions<br />

connection, select shape, select gray<br />

Alternatives<br />

auto threshold, gray histo, smooth funct 1d gauss, (T )threshold<br />

Region processing<br />

Module<br />

char threshold ( Hobject Image, Hobject HistoRegion,<br />

Hobject *Characters, double Sigma, double Percent, long *Threshold )<br />

T char threshold ( Hobject Image, Hobject HistoRegion,<br />

Hobject *Characters, Htuple Sigma, Htuple Percent, Htuple *Threshold )<br />

Perform a threshold segmentation for extracting characters.<br />

(T )char threshold segments a single-channel image using an automatically determined threshold. It is<br />

assumed that the background of the image is bright and the foreground (the characters) are dark. First a histogram<br />

of the gray values in the image Image is computed in the points given by the region HistoRegion. Then the<br />

maximum in the histogram is computed (most frequently ocuring gray value = bright paper). Finally, the first<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


539<br />

gray value to the “left” of the maximum is located, which is at least Percent less frequently occuring than the<br />

maximum. In addition a Gaussian smoothing can be applied to suppress gaps in the histogram.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Image to be segmented.<br />

º HistoRegion (input object) ......................................................region Hobject<br />

Region in which the histogram is computed.<br />

º Characters (output object) ..............................................region(-array) Hobject *<br />

Dark regions (characters).<br />

º Sigma (input control) ....................................................number (Htuple .) double<br />

Sigma for the Gaussian smoothing of the histogram.<br />

Default Value : 2.0<br />

Value Suggestions : Sigma ¾0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0<br />

Typical Range of Values : 0.0 Sigma 50.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.2<br />

º Percent (input control) ...........................................number (Htuple .) double / long<br />

Percentage for the gray value difference.<br />

Default Value : 95<br />

Value Suggestions : Percent ¾90, 92, 95, 96, 97, 98, 99, 99.5, 100<br />

Typical Range of Values : 0.0 Percent 100.0 (lin)<br />

Minimal Value Step : 0.1<br />

Recommended Value Step : 0.5<br />

º Threshold (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Calculated threshold.<br />

Example<br />

read_image(&Image,"letters");<br />

char_threshold(Median,&Seg,0.0,5.0,&Threshold);<br />

set_colored(WindowHandle,12);<br />

disp_region(Seg,WindowHandle);<br />

set_shape(WindowHandle,"rectangle1");<br />

connection(Seg,&Connected);<br />

disp_region(Connected,WindowHandle);<br />

Parallelization Information<br />

(T )char threshold is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

anisotrope diff, median image, illuminate<br />

Possible Successor Functions<br />

connection, select shape, select gray<br />

Alternatives<br />

bin threshold, auto threshold, gray histo, smooth funct 1d gauss, (T )threshold<br />

Region processing<br />

Module<br />

check difference ( Hobject Image, Hobject Pattern, Hobject *Selected,<br />

const char *Mode, long DiffLowerBound, long DiffUpperBound,<br />

long GrayOffset, long AddRow, long AddCol )<br />

Compare two images pixel by pixel.<br />

check difference selects from the input image Image those pixels ( Ó ÁÑ ), whose<br />

gray value difference to the corresponding pixels in Pattern is inside (outside) of the interval<br />

<strong>HALCON</strong> 6.0


540 CHAPTER 10. SEGMENTATION<br />

ÄÓÛÖÓÙÒ ÄÓÛÖÓÙÒ℄. The pixels of Pattern are translated by ´ÊÓÛ Óе with respect<br />

to Image. Let Ô be the gray value from Pattern translated by ´ÊÓÛ Óе w.r.t. Ó .<br />

If the selected mode Mode is ’diff inside’, a pixel Ó is selected if<br />

Ó Ô ÖÝÇ×Ø ÄÓÛÖÓÙÒ and<br />

Ó Ô ÖÝÇ×Ø ÍÔÔÖÓÙÒ<br />

If the mode is set to ’diff outside’, a pixel Ó is selected if<br />

Ó Ô ÖÝÇ×Ø ÄÓÛÖÓÙÒ or<br />

Ó Ô ÖÝÇ×Ø ÍÔÔÖÓÙÒ<br />

This test is performed for all points of the domain (region) of Image, intersected with the domain of the translated<br />

Pattern. All points fulfilling the above condition are aggregated in the output region. The two images may be<br />

of different size. Typically, Pattern is smaller than Image.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Image to be examined.<br />

º Pattern (input object) ...............................................image(-array) Hobject : byte<br />

Comparison image.<br />

º Selected (output object) ................................................region(-array) Hobject *<br />

Points in which the two images are similar/different.<br />

º Mode (input control) ............................................................string const char *<br />

Mode: return similar or different pixels.<br />

Default Value : ’diff outside’<br />

Value Suggestions : Mode ¾’diff inside’, ’diff outside’<br />

º DiffLowerBound (input control) ...................................................number long<br />

Lower bound of the tolerated gray value difference.<br />

Default Value : -5<br />

Value Suggestions : DiffLowerBound ¾0, -1, -2, -3, -5, -7, -10, -12, -15, -17, -20, -25, -30<br />

Typical Range of Values : -255 DiffLowerBound 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

Restriction : ´-255 DiffLowerBoundµ ´DiffLowerBound 255µ<br />

º DiffUpperBound (input control) ...................................................number long<br />

Upper bound of the tolerated gray value difference.<br />

Default Value : 5<br />

Value Suggestions : DiffUpperBound ¾0, 1, 2, 3, 5, 7, 10, 12, 15, 17, 20, 25, 30<br />

Typical Range of Values : -255 DiffUpperBound 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

Restriction : ´-255 DiffUpperBoundµ ´DiffUpperBound 255µ<br />

º GrayOffset (input control) .........................................................number long<br />

Offset gray value subtracted from Image.<br />

Default Value : 0<br />

Value Suggestions : GrayOffset ¾-30, -25, -20, -17, -15, -12, -10, -7, -5, -3, -2, -1, 0, 1, 2, 3, 5, 7, 10,<br />

12, 15, 17, 20, 25, 30<br />

Typical Range of Values : -255 GrayOffset 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

Restriction : ´-255 GrayOffsetµ ´GrayOffset 255µ<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


541<br />

º AddRow (input control) ...............................................................point.y long<br />

Row coordinate, by which Pattern is translated.<br />

Default Value : 0<br />

Value Suggestions : AddRow ¾-200, -100, -20, -10, 0, 10, 20, 100, 200<br />

Typical Range of Values : -32000 AddRow 32000 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º AddCol (input control) ...............................................................point.x long<br />

Column coordinate, by which Pattern is translated.<br />

Default Value : 0<br />

Value Suggestions : AddCol ¾-200, -100, -20, -10, 0, 10, 20, 100, 200<br />

Typical Range of Values : -32000 AddCol 32000 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Complexity<br />

Let be the number of valid pixels. Then the runtime complexity is Ç´ µ.<br />

Result<br />

check difference returns H MSG TRUE if all parameters are correct. The behavior with respect to<br />

the input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

check difference is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

connection, select shape, reduce domain, select gray, rank region, dilation1,<br />

opening<br />

Alternatives<br />

sub image, dyn threshold<br />

Region processing<br />

Module<br />

class 2dim sup ( Hobject ImageCol, Hobject ImageRow,<br />

Hobject FeatureSpace, Hobject *RegionClass2Dim )<br />

Segment an image using two-dimensional pixel classification.<br />

class 2dim sup classifies the points in two-channel images using a two-dimensional feature space. For each<br />

point, two gray values (one from each image) are used as features. The feature space is represented by the input<br />

region. The classification is done as follows:<br />

A point from the input region of an image is accepted if the point ´ Ð µ, which is determined by the respective<br />

gray values, is contained in the region FeatureSpace. Ð is here a gray value from the image ImageRow, while<br />

is the corresponding gray value from ImageCol.<br />

Let È be a point with the coordinates È ´Ä µ, Ð be the gray value at position ´Ä µ in the image ImageRow,<br />

and be the gray value at position ´Ä µ in the image ImageCol. Then the point È is aggregated into the output<br />

region if<br />

´ Ð µ ¾ ØÙÖËÔ<br />

Ð is interpreted as row coordinate and as colum coordinate.<br />

For the generation of FeatureSpace,seehisto 2dim. The feature space can be modified by applying region<br />

transformation operators, such as rank region, dilation1, shape trans, elliptic axis, etc., before<br />

calling class 2dim sup.<br />

The parameters ImageCol and ImageRow must contain an equal number of images with the same respective<br />

size. The image points are taken from the intersection of the domains of both images (see reduce domain).<br />

<strong>HALCON</strong> 6.0


542 CHAPTER 10. SEGMENTATION<br />

Parameter<br />

º ImageCol (input object) .......................image(-array) Hobject : byte / int1 / cyclic / direction<br />

Input image (first channel).<br />

º ImageRow (input object) ..............................................image(-array) Hobject : byte<br />

Input image (second channel).<br />

º FeatureSpace (input object) ..............................................region(-array) Hobject<br />

Region defining the feature space.<br />

º RegionClass2Dim (output object) .......................................region(-array) Hobject *<br />

Classified regions.<br />

Example<br />

read_image(&Image,"combine");<br />

open_window(0,0,-1,-1,0,"visible","",&WindowHandle);<br />

disp_image(Image,WindowHandle);<br />

fwrite_string("draw region of interest with the mouse");<br />

fnew_line();<br />

set_color(WindowHandle,"green");<br />

draw_region(&Testreg,draw_region);<br />

/* Texture transformation for 2-dimensional charachteristic */<br />

texture_laws(Image,&T1,"el",2,5);<br />

mean_image(T1,&M1,21,21);<br />

clear_obj(T1);<br />

texture_laws(M1,&T2,"es,",2,5);<br />

mean_image(T2,&M2,21,21);<br />

clear_obj(T2);<br />

/* 2-dimensinal histogram of the test region */<br />

histo_2dim(Testreg,M1,M2,&Histo);<br />

/* All points occuring at least once */<br />

threshold(Histo,&FeatureSpace,1.0,100000.0);<br />

set_draw(WindowHandle,"fill");<br />

set_color(WindowHandle,"red");<br />

disp_region(FeatureSpace,WindowHandle);<br />

fwrite_string("Characteristics area in red");<br />

fnew_line();<br />

/* Segmentation */<br />

class_2dim_sup(M1,M2,FeatureSpace,&RegionClass2Dim);<br />

set_color(WindowHandle,"blue");<br />

disp_region(RegionClass2Dim,WindowHandle);<br />

fwrite_string("Result of classification in blue");<br />

fnew_line();<br />

Complexity<br />

Let be the area of the input region. Then the runtime complexity is Ç´¾ ¾ · µ.<br />

Result<br />

class 2dim sup always returns H MSG TRUE. The behavior with respect to the input images and output<br />

regions can be determined by setting the values of the flags ’no object result’, ’empty region result’, and<br />

’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

class 2dim sup is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

histo 2dim, (T )threshold, draw region, dilation1, opening, shape trans<br />

Possible Successor Functions<br />

connection, select shape, select gray<br />

Alternatives<br />

(T )class ndim norm, class ndim box, (T )threshold, histo 2dim<br />

Region processing<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


543<br />

class 2dim unsup ( Hobject Image1, Hobject Image2, Hobject *Classes,<br />

long Threshold, long NumClasses )<br />

Segment two images by clustering.<br />

class 2dim unsup performs a classification with two single-channel images. First a two-dimensional histogram<br />

of the two images is computed (histo 2dim). In this histogram the first maximum is extracted; it serves<br />

as the first cluster center. The histogram is computed with the intersection of the domains of both images (see<br />

reduce domain). After this, all pixels in the images, which are at most Threshold pixels from the cluster<br />

center in the maximum norm, are determined. These pixels form one output region. Next, the pixels thus classified<br />

are deleted from the histogram so that they are not taken into account for the next class. In this modified histogram<br />

again the maximum is extracted; it again serves as a cluster center. The above steps are repeated NumClasses<br />

times; thus, NumClasses output regions result. Only pixels defined in both images are returned.<br />

Both input images must have the same size.<br />

Attention<br />

Parameter<br />

º Image1 (input object) .......................................................image Hobject : byte<br />

First input image.<br />

º Image2 (input object) .......................................................image Hobject : byte<br />

Second input image.<br />

º Classes (output object) ...................................................region-array Hobject *<br />

Segmentation result.<br />

º Threshold (input control) ...........................................................integer long<br />

Threshold (maximum distance to the cluster’s center).<br />

Default Value : 15<br />

Value Suggestions : Threshold ¾0, 2, 5, 8, 12, 17, 20, 30, 50, 70<br />

º NumClasses (input control) .........................................................integer long<br />

Number of classes (cluster centers).<br />

Default Value : 5<br />

Value Suggestions : NumClasses ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 20, 30, 40, 50<br />

Example<br />

read_image(&ColorImage,"patras");<br />

decompose3(ColorImage,&Red,&Green,&Blue);<br />

class_2dim_unsup(Red,Green,&Seg,15,5);<br />

set_colored(WindowHandle,12);<br />

disp_region(Seg,WindowHandle);<br />

Result<br />

class 2dim unsup returns H MSG TRUE if all parameters are correct. The behavior with respect to<br />

the input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

class 2dim unsup is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

decompose2, decompose3, median image, anisotrope diff, reduce domain<br />

Possible Successor Functions<br />

select shape, select gray, connection<br />

Alternatives<br />

(T )threshold, histo 2dim, class 2dim sup, (T )class ndim norm, class ndim box<br />

Region processing<br />

Module<br />

<strong>HALCON</strong> 6.0


544 CHAPTER 10. SEGMENTATION<br />

class ndim box ( Hobject MultiChannelImage, Hobject *Regions,<br />

long ClassifHandle )<br />

Classify pixels using hyper-cuboids.<br />

class ndim box classifies the pixels of the multi-channel image given in MultiChannelImage. Todoso,<br />

the classificator ClassifHandle created with create class box is used. The classificator can be trained<br />

using class ndim box or as described with create class box. More information on the structure of the<br />

classificator can be found also under that operator.<br />

MultiChannelImage is a multi channel image. Its pixel values are used for the classification.<br />

Parameter<br />

º MultiChannelImage (input object) multichannel-image(-array) Hobject : byte / int1 / int2 / int4 / real<br />

/ direction / cyclic<br />

Multi-channel input image.<br />

º Regions (output object) ...................................................region-array Hobject *<br />

Segmentation result.<br />

º ClassifHandle (input control) ...................................................class box long<br />

Classificator’s handle number.<br />

Example<br />

read_image(&Image,"meer");<br />

disp_image(Image,WindowHandle);<br />

set_color(WindowHandle,"green");<br />

fwrite_string("Draw the foreground");<br />

fnew_line();<br />

draw_region(&Reg1,WindowHandle);<br />

reduce_domain(Image,Reg1,&Foreground);<br />

set_color(WindowHandle,"red");<br />

fwrite_string("Draw background");<br />

fnew_line();<br />

draw_region(&Reg2,WindowHandle);<br />

reduce_domain(Image,Reg2,&Background);<br />

fwrite_string("Start to learn");<br />

fnew_line();<br />

create_classif(&ClassifHandle);<br />

class_ndim_box(Foreground,Background,Image,ClassifHandle);<br />

fwrite_string("start classification");<br />

fnew_line();<br />

class_ndim_box(Image,&Res,ClassifHandle);<br />

set_draw(WindowHandle,"fill");<br />

disp_region(Res,WindowHandle);<br />

free_classif(ClassifHandle);<br />

Complexity<br />

Let Æ be the number of hyper-cuboids and be the area of the input region. Then the runtime complexity is<br />

Ç´Æ £ µ.<br />

Result<br />

class ndim box returns H MSG TRUE if all parameters are correct. The behavior with respect to the<br />

input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

class ndim box is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

create class box, T learn class box, median image, compose2, compose3, compose4<br />

(T )class ndim norm, class 2dim sup<br />

Alternatives<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


545<br />

See Also<br />

class ndim box, descript class box, create class box<br />

Region processing<br />

Module<br />

class ndim norm ( Hobject MultiChannelImage, Hobject *Regions,<br />

const char *Metric, const char *SingleMultiple, double Radius,<br />

double Center )<br />

T class ndim norm ( Hobject MultiChannelImage, Hobject *Regions,<br />

Htuple Metric, Htuple SingleMultiple, Htuple Radius, Htuple Center )<br />

Classify pixels using hyper-spheres or hyper-cubes.<br />

(T )class ndim norm classifies the pixels of the multi-channel image given in MultiChannelImage. The<br />

result is returned in Regions as one region per classification object. The metric used (’euclid’ or ’maximum’)<br />

is determined by Metric. This paramter must be set to the same value used in T learn ndim norm. The<br />

parameter is used to determine whether one region (’single’) or multiple regions (’multiple’) have to be generated<br />

for each cluster. Radius determines the radii or half edge length of the clusters, respectively. Center determines<br />

their centers.<br />

Parameter<br />

º MultiChannelImage (input object) multichannel-image(-array) Hobject : byte / int1 / int2 / int4 / real<br />

Multi-channel input image.<br />

º Regions (output object) ...................................................region-array Hobject *<br />

Segmentation result.<br />

º Metric (input control) ...............................................string (Htuple .) const char *<br />

Metrictobeused.<br />

Default Value : ’euclid’<br />

Value List : Metric ¾’euclid’, ’maximum’<br />

º SingleMultiple (input control) ....................................string (Htuple .) const char *<br />

Return one region or one region for each cluster.<br />

Default Value : ’single’<br />

Value List : SingleMultiple ¾’single’, ’multiple’<br />

º Radius (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Cluster radii or half edge lengths (returned by T learn ndim norm).<br />

º Center (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Coordinates of the cluster centers (returned by T learn ndim norm).<br />

Example<br />

read_image(&Image,"meer:);<br />

open_window(0,0,-1,-1,0,"visible","",&WindowHandle);<br />

disp_image(Image,WindowHandle);<br />

fwrite_string("draw region of interest with the mouse");<br />

fnew_line();<br />

set_color(WindowHandle,"green");<br />

draw_region(&Testreg,draw_region);<br />

/* Texture transformation for 3-dimensional charachteristic */<br />

texture_laws(Image,&T1,"el",2,5);<br />

mean_image(T1,&M1,21,21);<br />

texture_laws(Image,&T2,"es",2,5);<br />

mean_image(T2,&M2,21,21);<br />

texture_laws(Image,&T3,"le",2,5);<br />

mean_image(T3,&M3,21,21);<br />

compose3(M1,M2,M3,&M);<br />

/* Cluster for 3-dimensional characteristic area determine training area */<br />

create_tuple(&Metric,1);<br />

<strong>HALCON</strong> 6.0


546 CHAPTER 10. SEGMENTATION<br />

set_s(Metric,"euclid",0);<br />

create_tuple(&Radius,1);<br />

set_d(Radius,20.0,0);<br />

create_tuple(&MinNumber,1);<br />

set_i(MinNumber,5,0);<br />

T_learn_ndim_norm(Testobj,EMPTY_REGION,&M,"euclid",Radius,MinNumber,<br />

&Radius,&Center,_t);<br />

/* Segmentation */<br />

create_tuple(&RegionMode,1);<br />

set_s(RegionMode,"multiple",0);<br />

class_ndim_norm(M,&Regions,Metric,RegionMode,Radius,Center);<br />

set_colored(WindowHandle,12);<br />

disp_region(Regions,WindowHandle);<br />

fwrite_string("Result of classification;");<br />

fwrite_string("Each cluster in another color.");<br />

fnew_line();<br />

Complexity<br />

Let Æ be the number of clusters and be the area of the input region. Then the runtime complexity is Ç´Æ £ µ.<br />

Result<br />

(T )class ndim norm returns H MSG TRUE if all parameters are correct. The behavior with respect to<br />

the input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

(T )class ndim norm is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

T learn ndim norm, compose2, compose3, compose4<br />

Possible Successor Functions<br />

connection, select shape, reduce domain, select gray<br />

class ndim box, class 2dim sup<br />

disp circle, disp rectangle1<br />

Region processing<br />

Alternatives<br />

See Also<br />

Module<br />

T detect edge segments ( Hobject Image, Htuple SobelSize,<br />

Htuple MinAmplitude, Htuple MaxDistance, Htuple MinLength,<br />

Htuple *BeginRow, Htuple *BeginCol, Htuple *EndRow, Htuple *EndCol )<br />

Detect straight edge segments.<br />

T detect edge segments detects straight edge segments in the gray image Image. The extracted edge segments<br />

are returned as line segments with start point (BeginRow,BeginCol) and end point (EndRow,EndCol).<br />

Edge detection is based on the Sobel filter, using ’sum abs’ as parameter and SobelSize as the filter mask size<br />

(see sobel amp). Only pixels with a filter response larger than MinAmplitude are used as candidates for edge<br />

points. These thresholded edge points are thinned and split into straight segments. Due to technical reasons, edge<br />

points in which several edges meet are lost. Therefore, T detect edge segments usually does not return<br />

closed object contours. The parameter MaxDistance controls the maximum allowed distance of an edge point<br />

to its approximating line. For efficiency reasons, the sum of the absolute values of the coordinate differences is<br />

used instead of the Euclidean distance. MinLength controls the minimum length of the line segments. Lines<br />

shorter than MinLength are not returned.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


547<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .(multichannel-)image(-array) Hobject : byte<br />

Input image.<br />

º SobelSize (input control) ...................................................integer Htuple . long<br />

Mask size of the Sobel operator.<br />

Default Value : 5<br />

Value List : SobelSize ¾3, 5, 7, 9, 11, 13<br />

º MinAmplitude (input control) ..............................................integer Htuple . long<br />

Minimum edge strength.<br />

Default Value : 32<br />

Value Suggestions : MinAmplitude ¾10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 80, 90, 100, 110<br />

Typical Range of Values : 1 MinAmplitude 255<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : MinAmplitude 0<br />

º MaxDistance (input control) ................................................integer Htuple . long<br />

Maximum distance of the approximating line to its original edge.<br />

Default Value : 3<br />

Value Suggestions : MaxDistance ¾2, 3, 4, 5, 6, 7, 8<br />

Typical Range of Values : 1 MaxDistance 30<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : MaxDistance 0<br />

º MinLength (input control) ...................................................integer Htuple . long<br />

Minimum lenght of to resulting line segments.<br />

Default Value : 10<br />

Value Suggestions : MinLength ¾3, 5, 7, 9, 11, 13, 16, 20<br />

Typical Range of Values : 1 MinLength 500<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : MinLength 0<br />

º BeginRow (output control) .......................................line.begin.y-array Htuple . long *<br />

Row coordinate of the line segments’ start points.<br />

º BeginCol (output control) .......................................line.begin.x-array Htuple . long *<br />

Column coordinate of the line segments’ start points.<br />

º EndRow (output control) ............................................line.end.y-array Htuple . long *<br />

Row coordinate of the line segments’ end points.<br />

º EndCol (output control) ............................................line.end.x-array Htuple . long *<br />

Column coordinate of the line segments’ end points.<br />

Example<br />

Htuple<br />

Htuple<br />

SobelSize,MinAmplitude,MaxDistance,MinLength;<br />

RowBegin,ColBegin,RowEnd,ColEnd;<br />

create_tuple(&SobelSize,1);<br />

set_i(SobelSize,5,0);<br />

create_tuple(&MinAmplitude,1);<br />

set_i(MinAmplitude,32,0);<br />

create_tuple(&MaxDistance,1);<br />

set_i(MaxDistance,3,0);<br />

create_tuple(&MinLength,1);<br />

set_i(MinLength,10,0);<br />

T_detect_edge_segments(Image,SobelSize,MinAmplitude,MaxDistance,MinLength,<br />

&RowBegin,&ColBegin,&RowEnd,&ColEnd);<br />

Result<br />

T detect edge segments returns H MSG TRUE if all parameters are correct. If the input is empty the<br />

<strong>HALCON</strong> 6.0


548 CHAPTER 10. SEGMENTATION<br />

behaviour can be set via set system(’no object result’,). If necessary, an exception handling<br />

is raised.<br />

Parallelization Information<br />

T detect edge segments is reentrant and automatically parallelized (on tuple level, channel level).<br />

sigma image, median image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

select lines, partition lines, select lines longest, line position,<br />

line orientation<br />

Alternatives<br />

sobel amp, (T )threshold, skeleton<br />

Image filters<br />

Module<br />

dual threshold ( Hobject Image, Hobject *RegionCrossings, long MinSize,<br />

double MinGray, double Threshold )<br />

Threshold operator for signed images.<br />

dual threshold segments the input image into a region with gray values Threshold (“positive” regions)<br />

and a region with gray values -Threshold (“negative” regions). “Positive” or “negative” regions having a size<br />

of less than MinSize are suppressed, as well as regions whose maximum gray value is less than MinGray in<br />

absolute value.<br />

The segmentation performed is not complete, i.e., the “positive” and “negative” regions together do not necessarily<br />

cover the entire image: Areas with a gray value between ÌÖ×ÓÐ and Threshold, ÅÒÖÝ and<br />

MinGray respectively, are not taken into account.<br />

dual threshold is usually called after applying a Laplace operator (laplace, derivate gauss or<br />

diff of gauss) or the difference of two images (sub image)toanimage.<br />

The zero crossings of a Laplace image correspond to edges in an image, and are the separating regions of the<br />

“positive” and “negative” regions in the Laplace image. They can be determined by calling dual threshold<br />

with Threshold = 1. The parameter MinGray controls the noise invariance, while MinSize controls the<br />

resolution of the edge detection.<br />

Using byte images only the positive part of the operator is applied. Therefore dual threshold behaves like a<br />

standard threshold operator ((T )threshold) with successive connection and select gray.<br />

Parameter<br />

º Image (input object) ..................................image(-array) Hobject : byte / int2 / int4 / real<br />

Input Laplace image.<br />

º RegionCrossings (output object) ........................................region-array Hobject *<br />

“Positive” and “negative” regions.<br />

º MinSize (input control) .............................................................integer long<br />

Regions smaller than MinSize are suppressed.<br />

Default Value : 20<br />

Value Suggestions : MinSize ¾0, 10, 20, 50, 100, 200, 500, 1000<br />

Typical Range of Values : 0 MinSize 10000 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º MinGray (input control) ..............................................................real double<br />

Regions whose maximum absolute gray value is smaller than MinGray are suppressed.<br />

Default Value : 5.0<br />

Value Suggestions : MinGray ¾1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 9.0, 11.0, 15.0, 20.0<br />

Typical Range of Values : 0.001 MinGray 10000.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : MinGray 0<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


549<br />

º Threshold (input control) ...........................................................real double<br />

Regions which have a gray value larger than Threshold (or smaller than -Threshold) are suppressed.<br />

Default Value : 2.0<br />

Value Suggestions : Threshold ¾1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 9.0, 11.0, 15.0, 20.0<br />

Typical Range of Values : 0.001 Threshold 10000.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : ´Threshold 1µ ´Threshold MinGrayµ<br />

Example<br />

/* Edge detection with the Laplace operator (and edge thinning) */<br />

diff_of_gauss(Image,&Laplace,2.0,1.6) ;<br />

/* finde "‘positive"’ und "‘negative"’ Bildbereiche: */<br />

dual_threshold(Laplace,&Region,20,2,1) ;<br />

/*The zero runnings are the complement to these image section: */<br />

complement("full",Region,Nulldurchgaenge) ;<br />

Result<br />

dual threshold returns H MSG TRUE if all parameters are correct. The behavior with respect to the<br />

input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

dual threshold is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

min max gray, sobel amp, gauss image, reduce domain, diff of gauss, sub image,<br />

derivate gauss<br />

Possible Successor Functions<br />

connection, dilation1, erosion1, opening, closing, rank region, shape trans, skeleton<br />

Alternatives<br />

(T )threshold, connection, select shape, select gray, dyn threshold,<br />

check difference<br />

See Also<br />

laplace, diff of gauss, expand region<br />

Region processing<br />

Module<br />

dyn threshold ( Hobject OrigImage, Hobject ThresholdImage,<br />

Hobject *RegionDynThresh, double Offset, const char *LightDark )<br />

Segment an image using a local threshold.<br />

dyn threshold selects from the input image those regions in which the pixels fulfill a threshold condition. Let<br />

Ó ÇÖÁÑ ,and Ñ ÌÖ×ÓÐÁÑ . Then the condition for LightDark = ’light’ is:<br />

For LightDark = ’dark’ the condition is:<br />

Ó Ñ · Ç×Ø<br />

Ó Ñ Ç×Ø<br />

For LightDark = ’equal’ it is:<br />

Ñ Ç×Ø Ó Ñ · Ç×Ø<br />

Finally, for LightDark = ’not equal’ it is:<br />

Ñ<br />

Ç×Ø Ó Ó Ñ · Ç×Ø<br />

<strong>HALCON</strong> 6.0


550 CHAPTER 10. SEGMENTATION<br />

This means that all points in OrigImage whose gray value is larger then or equal to the gray value in<br />

ThresholdImage plus an offset are aggregated into the resulting region.<br />

Typically, the threshold images are smoothed versions of the original image (e.g., by applying mean image,<br />

gauss image, etc.). Then the effect of dyn threshold is similar to applying (T )threshold to a<br />

highpass-filtered version of the original image (see highpass image).<br />

With dyn threshold contours of an object can be extracted, where the objects’ size (diameter) is determined<br />

by the mask size of the lowpass filter and the amplitude of the objects’ edges:<br />

The larger the mask size is chosen, the larger the found regions get. As a rule of thumb, the mask size should be<br />

about twice the diameter of the objects to be extracted. It is important not to set the parameter Offset to zero<br />

because in this case too many small regions will be found (noise). Values between 5 and 40 are a sensible choice.<br />

The larger Offset is chosen, the smaller the extracted regions get.<br />

All points of the input image fulfilling the above condition are stored jointly in one region. If necessary, the<br />

connected components can be obtained by calling connection.<br />

Attention<br />

If Offset is chosen from ½ to ½ usually a very noisy region is generated, requiring large storage. If Offset<br />

is chosen too large ( 60, say) it may happen that no points fulfill the threshold condition (i.e., an empty region is<br />

returned). If Offset is chosen too small ( -60, say) it may happen that all points fulfill the threshold condition<br />

(i.e., a full region is returned).<br />

Parameter<br />

º OrigImage (input object) ............................image(-array) Hobject : byte / int2 / int4 / real<br />

Image to be segmented.<br />

º ThresholdImage (input object) ......................image(-array) Hobject : byte / int2 / int4 / real<br />

Image containing the local thresholds.<br />

º RegionDynThresh (output object) .......................................region(-array) Hobject *<br />

Segmented regions.<br />

º Offset (input control) .....................................................number double / long<br />

Offset added to ThresholdImage.<br />

Default Value : 5.0<br />

Value Suggestions : Offset ¾1.0, 3.0, 5.0, 7.0, 10.0, 20.0, 30.0<br />

Typical Range of Values : -255.0 Offset 255.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 5<br />

Restriction : ´-255 Offsetµ ´Offset 255µ<br />

º LightDark (input control) .....................................................string const char *<br />

Extract light, dark or similar areas?<br />

Default Value : ’light’<br />

Value List : LightDark ¾’dark’, ’light’, ’equal’, ’not equal’<br />

Example<br />

/* Looking for regions with the diameter D */<br />

mean_image(Image,&Mean,D*2+1,D*2+1);<br />

dyn_threshold(Image,Mean,&Seg,5.0,"light");<br />

connection(Seg,&Region);<br />

Complexity<br />

Let be the area of the input region. Then the runtime complexity is Ç´ µ.<br />

Result<br />

dyn threshold returns H MSG TRUE if all parameters are correct. The behavior with respect to the<br />

input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

dyn threshold is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

mean image, smooth image, gauss image<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


551<br />

Possible Successor Functions<br />

connection, select shape, reduce domain, select gray, rank region, dilation1,<br />

opening<br />

Alternatives<br />

check difference, highpass image, sub image, (T )threshold<br />

See Also<br />

mean image, smooth image, gauss image, connection, rank region, dilation1<br />

Region processing<br />

Module<br />

expand gray ( Hobject Regions, Hobject Image, Hobject ForbiddenArea,<br />

Hobject *RegionExpand, const char *Iterations, const char *Mode,<br />

long Threshold )<br />

T expand gray ( Hobject Regions, Hobject Image, Hobject ForbiddenArea,<br />

Hobject *RegionExpand, Htuple Iterations, Htuple Mode, Htuple Threshold )<br />

Fill gaps between regions (depending on gray value or color) or split overlapping regions.<br />

(T )expand gray closes gaps between the input regions, which resulted from the suppression of small regions<br />

in a segmentation operator, (mode ’image’), for example, or separates overlapping regions ’region’). Both uses<br />

result from the expansion of regions. The operator works by adding a one pixel wide “strip” to a region, in which<br />

the gray values or color are different from the gray values or color of neighboring pixles on the region’s border<br />

by at most Threshold (in each channel). For images of type ’cyclic’ (e.g., direction images), also points with a<br />

gray value difference of at least ¾ ÌÖ×ÓÐ are added to the output region.<br />

The expansion takes place only in regions, which are designated as not “forbidden” (parameter<br />

ForbiddenArea). The number of iterations is determined by the parameter Iterations. By passing ’maximal’,<br />

(T )expand gray iterates until convergence, i.e., until no more changes occur. By passing 0 for this<br />

parameter, all non-overlapping regions are returned. The two modes of operation (’image’ and ’region’) are different<br />

in the following ways:<br />

’image’ The input regions are expanded iteratively until they touch another region or the image border, or the<br />

expansion stops because of too high gray value differences. Because (T )expand gray processes all<br />

regions simultaneously, gaps between regions are distributed evenly to all regions with a similar gray value.<br />

Overlapping regions are split by distributing the area of overlap evenly to both regions.<br />

’region’ No expansion of the input regions is performed. Instead, only overlapping regions are split by distributing<br />

the area of overlap evenly to regions having a matching gray value or color.<br />

Attention<br />

Because regions are only expanded into areas having a matching gray value or color, usually gaps will remain<br />

between the output regions, i.e., the segmentation is not complete.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions for which the gaps are to be closed, or which are to be separated.<br />

º Image (input object) ..............................................................image Hobject<br />

Image (possibly multi-channel) for gray value or color comparison.<br />

º ForbiddenArea (input object) ...................................................region Hobject<br />

Regions in which no expansion takes place.<br />

º RegionExpand (output object) ...........................................region(-array) Hobject *<br />

Expanded or separated regions.<br />

º Iterations (input control) ....................................string (Htuple .) const char * / long<br />

Number of iterations.<br />

Default Value : ’maximal’<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ’maximal’<br />

Typical Range of Values : 1 Iterations 500 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

<strong>HALCON</strong> 6.0


552 CHAPTER 10. SEGMENTATION<br />

º Mode (input control) ..................................................string (Htuple .) const char *<br />

Expansion mode.<br />

Default Value : ’image’<br />

Value List : Mode ¾’image’, ’region’<br />

º Threshold (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Maximum difference between the gray value or color at the region’s border and a candidate for expansion.<br />

Default Value : 32<br />

Value Suggestions : Threshold ¾5, 10, 15, 20, 25, 30, 40, 50<br />

Typical Range of Values : 1 Threshold 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

Example<br />

read_image(&Image,"fabrik");<br />

disp_image(Image,WindowHandle);<br />

regiongrowing(Image,&RawSegments,3,3,6.0,100);<br />

set_colored(WindowHandle,12);<br />

disp_region(RawSegments,WindowHandle);<br />

expand_gray(RawSegments,Image,EMPTY_REGION,&Segments,"maximal","image",24);<br />

clear_window(WindowHandle);<br />

disp_region(Segments,WindowHandle)<br />

Result<br />

(T )expand gray always returns the value H MSG TRUE. The behavior in case of empty input (no regions<br />

given) can be set via set system(’no object result’,), the behavior in case of an empty input<br />

region via set system(’empty region result’,), and the behavior in case of an empty<br />

result region via set system(’store empty region’,). If necessary, an exception handling<br />

is raised.<br />

Parallelization Information<br />

(T )expand gray is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

connection, regiongrowing, pouring, (T )class ndim norm<br />

select shape<br />

(T )expand gray ref, expand region<br />

Region processing<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

expand gray ref ( Hobject Regions, Hobject Image, Hobject ForbiddenArea,<br />

Hobject *RegionExpand, const char *Iterations, const char *Mode,<br />

long RefGray, long Threshold )<br />

T expand gray ref ( Hobject Regions, Hobject Image,<br />

Hobject ForbiddenArea, Hobject *RegionExpand, Htuple Iterations,<br />

Htuple Mode, Htuple RefGray, Htuple Threshold )<br />

Fill gaps between regions (depending on gray value or color) or split overlapping regions.<br />

(T )expand gray ref closes gaps between the input regions, which resulted from the suppression of small<br />

regions in a segmentation operator, (mode ’image’), for example, or separates overlapping regions ’region’). Both<br />

uses result from the expansion of regions. The operator works by adding a one pixel wide “strip” to a region, in<br />

which the gray values or color are different from a reference gray value or color by at most Threshold (in each<br />

channel). For images of type ’cyclic’ (e.g., direction images), also points with a gray value difference of at least<br />

¾ ÌÖ×ÓÐ are added to the output region.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


553<br />

The expansion takes place only in regions, which are designated as not “forbidden” (parameter<br />

ForbiddenArea). The number of iterations is determined by the parameter Iterations. By passing ’maximal’,<br />

(T )expand gray ref iterates until convergence, i.e., until no more changes occur. By passing 0 for<br />

this parameter, all non-overlapping regions are returned. The two modes of operation (’image’ and ’region’) are<br />

different in the following ways:<br />

’image’ The input regions are expanded iteratively until they touch another region or the image border, or the<br />

expansion stops because of too high gray value differences. Because (T )expand gray ref processes all<br />

regions simultaneously, gaps between regions are distributed evenly to all regions with a similar gray value.<br />

Overlapping regions are split by distributing the area of overlap evenly to both regions.<br />

’region’ No expansion of the input regions is performed. Instead, only overlapping regions are split by distributing<br />

the area of overlap evenly to regions having a matching gray value or color.<br />

Attention<br />

Because regions are only expanded into areas having a matching gray value or color, usually gaps will remain<br />

between the output regions, i.e., the segmentation is not complete.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Regions for which the gaps are to be closed, or which are to be separated.<br />

º Image (input object) ..............................................................image Hobject<br />

Image (possibly multi-channel) for gray value or color comparison.<br />

º ForbiddenArea (input object) ...................................................region Hobject<br />

Regions in which no expansion takes place.<br />

º RegionExpand (output object) ...........................................region(-array) Hobject *<br />

Expanded or separated regions.<br />

º Iterations (input control) ....................................string (Htuple .) const char * / long<br />

Number of iterations.<br />

Default Value : ’maximal’<br />

Value Suggestions : Iterations ¾’maximal’, 1, 2, 3, 4, 5, 7, 10, 15, 20, 30, 50, 70, 100, 150, 200, 300,<br />

500<br />

Typical Range of Values : 1 Iterations 500 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Mode (input control) ..................................................string (Htuple .) const char *<br />

Expansion mode.<br />

Default Value : ’image’<br />

Value List : Mode ¾’image’, ’region’<br />

º RefGray (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

<strong>Reference</strong> gray value or color for comparison.<br />

Default Value : 128<br />

Value Suggestions : RefGray ¾1, 10, 20, 50, 100, 128, 200, 255<br />

Typical Range of Values : 1 RefGray 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Threshold (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Maximum difference between the reference gray value or color and a candidate for expansion.<br />

Default Value : 32<br />

Value Suggestions : Threshold ¾4, 10, 15, 20, 25, 30, 40<br />

Typical Range of Values : 1 Threshold 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

Example<br />

read_image(&Image,"fabrik");<br />

disp_image(Image,WindowHandle);<br />

regiongrowing(Image,&RawSegments,3,3,6.0,100);<br />

set_colored(WindowHandle,12);<br />

<strong>HALCON</strong> 6.0


554 CHAPTER 10. SEGMENTATION<br />

disp_region(RawSegments,WindowHandle);<br />

T_intensity(RawSegments,Image,&Mean,_t);<br />

set_i(Thresh,24,0);<br />

set_s(Iter,"maximal",0);<br />

set_s(Mode,"image",0);<br />

T_expand_gray_ref(RawSegments,Image,EMPTY_REGION,&Segments,Iter,Mode,<br />

Mean,Thresh);<br />

clear_window(WindowHandle);<br />

disp_region(Segments,WindowHandle);<br />

Result<br />

(T )expand gray ref always returns the value H MSG TRUE. The behavior in case of empty input (no regions<br />

given) can be set via set system(’no object result’,), the behavior in case of an<br />

empty input region via set system(’empty region result’,), and the behavior in case of<br />

an empty result region via set system(’store empty region’,). If necessary, an exception<br />

handling is raised.<br />

Parallelization Information<br />

(T )expand gray ref is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

connection, regiongrowing, pouring, (T )class ndim norm<br />

select shape<br />

(T )expand gray, expand region<br />

Region processing<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

expand line ( Hobject Image, Hobject *RegionExpand, long Index,<br />

const char *ExpandType, const char *RowColumn, double Threshold )<br />

Expand a region starting at a given line.<br />

expand line generates a region by expansion, starting at a given line (row or column).<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Image to be segmented.<br />

º RegionExpand (output object) ...........................................region(-array) Hobject *<br />

Extracted segments.<br />

º Index (input control) ................................................................integer long<br />

Row or column index.<br />

Default Value : 256<br />

Value Suggestions : Index ¾16, 64, 128, 200, 256, 300, 400, 511<br />

Restriction : Index 0<br />

º ExpandType (input control) ...................................................string const char *<br />

Stopping criterion.<br />

Default Value : ’gradient’<br />

Value List : ExpandType ¾’gradient’, ’mean’<br />

º RowColumn (input control) .....................................................string const char *<br />

Segmentation mode (row or column).<br />

Default Value : ’row’<br />

Value List : RowColumn ¾’row’, ’column’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


555<br />

º Threshold (input control) .................................................number double / long<br />

Threshold for the expansion.<br />

Default Value : 3.0<br />

Value Suggestions : Threshold ¾0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 13.0, 17.0, 20.0, 30.0<br />

Typical Range of Values : 1.0 Threshold 255.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 1.0<br />

Restriction : ´Threshold 0.0µ ´Threshold 255.0µ<br />

Example<br />

read_image(&Image,"fabrik");<br />

gauss_image(Image,&Gauss,5);<br />

expand_line(Gauss,&Reg,100,"mean","row",5.0);<br />

set_colored(WindowHandle,12);<br />

disp_region(Maxima,WindowHandle);<br />

Parallelization Information<br />

expand line is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

gauss image, smooth image, anisotrope diff, median image, affine trans image,<br />

rotate image<br />

Possible Successor Functions<br />

intersection, opening, closing<br />

Alternatives<br />

(T )regiongrowing mean, (T )expand gray, (T )expand gray ref<br />

Region processing<br />

Module<br />

fast threshold ( Hobject Image, Hobject *Region, double MinGray,<br />

double MaxGray, long MinHeight )<br />

Fast selection of grayvalues within a given gray intervall.<br />

fast threshold selects the pixels from the input image whose gray values fulfill the following condition:<br />

ÅÒÖÝ ÅÜÖÝ <br />

To reduce procesing time, the selection is done in two steps: At first all pixels along rows with distances<br />

MinHeight are processed. In the next step the neighborhood (size MinHeight ¢ MinHeight) ofallpreviously<br />

selected points are processed.<br />

Parameter<br />

º Image (input object) .................................image(-array) Hobject : byte / direction / cyclic<br />

Image to be thresholded.<br />

º Region (output object) ...................................................region(-array) Hobject *<br />

Regions with gray values lying in the specified interval.<br />

º MinGray (input control) ....................................................number double / long<br />

Lower threshold for the gray values.<br />

Default Value : 128<br />

Value Suggestions : MinGray ¾0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0<br />

Typical Range of Values : 0.0 MinGray 255.0 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5.0<br />

<strong>HALCON</strong> 6.0


556 CHAPTER 10. SEGMENTATION<br />

º MaxGray (input control) ....................................................number double / long<br />

Upper threshold for the gray values.<br />

Default Value : 255.0<br />

Value Suggestions : MaxGray ¾0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0<br />

Typical Range of Values : 0.0 MaxGray 255.0 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5.0<br />

º MinHeight (input control) ..........................................................number long<br />

Minimum height of objects to be extracted.<br />

Default Value : 20<br />

Value Suggestions : MinHeight ¾5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 100<br />

Typical Range of Values : 2 MinHeight 200 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 2<br />

Complexity<br />

Let be the area of the ouput region and Ø the height of Image. Then the runtime complexity is Ç´ ·<br />

ØÅÒÀص.<br />

Result<br />

fast threshold returns H MSG TRUE if all parameters are correct. The behavior with respect to the<br />

input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

fast threshold is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

T histo to thresh, min max gray, sobel amp, gauss image, reduce domain,<br />

fill interlace<br />

Possible Successor Functions<br />

connection, dilation1, erosion1, opening, closing, rank region, shape trans, skeleton<br />

(T )threshold<br />

Alternatives<br />

See Also<br />

class 2dim sup, hysteresis threshold, dyn threshold<br />

Region processing<br />

Module<br />

T histo to thresh ( Htuple Histogramm, Htuple Sigma, Htuple *MinThresh,<br />

Htuple *MaxThresh )<br />

Determine gray value thresholds from a histogram.<br />

T histo to thresh determines gray value thresholds from a histogram for a segmentation of an image using<br />

(T )threshold. The thresholds returned are 0, 255, and all minima extracted from the histogram. Before the<br />

thresholds are determined the histogram is smoothed with a Gaussian.<br />

Parameter<br />

º Histogramm (input control) ................................histogram-array Htuple . long / double<br />

Gray value histogram.<br />

º Sigma (input control) .....................................................number Htuple . double<br />

Sigma for the Gaussian smoothing of the histogram.<br />

Default Value : 2.0<br />

Value Suggestions : Sigma ¾0.5, 1.0, 2.0, 3.0, 4.0, 5.0<br />

Typical Range of Values : 0.1 Sigma 30.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.2<br />

º MinThresh (output control) ..........................................integer-array Htuple . long *<br />

Minimum thresholds.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


557<br />

º MaxThresh (output control) ..........................................integer-array Htuple . long *<br />

Maximum thresholds.<br />

Example<br />

read_image(&Image,"fabrik");<br />

T_histo(Image,Image,&HistoAbs,&HistoRel);<br />

create_tuple(&Sigma,1);<br />

set_d(Sigma,3.0,0);<br />

T_histo_to_thresh(HistoAbs,Sigma,&MinThresh,&MaxThresh);<br />

T_threshold(Image,&Seg,MinThresh,MaxThresh);<br />

connection(Seg,&Connected);<br />

Parallelization Information<br />

T histo to thresh is reentrant and processed without parallelization.<br />

gray histo<br />

(T )threshold<br />

auto threshold<br />

Region processing<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

Module<br />

hysteresis threshold ( Hobject Image, Hobject *RegionHysteresis,<br />

long Low, long High, long MaxLength )<br />

Perform a hysteresis threshold operation on an image.<br />

hysteresis threshold performs a hysteresis threshold operation (due to Canny) on an image. All points<br />

in the input image Image having a gray value larger than or equal to High are immediately accepted (“secure”<br />

points). Conversely, all points with gray values less than Low are immediately rejected. “Potential” points with<br />

gray values between both thresholds are accepted if they are connected to “secure” points by a path of “potential”<br />

points having a length of at most MaxLength points. This means that “secure” points influence their surroundings<br />

(hysteresis). The gray values of the input images remain unchanged. Only the regions of the image may get smaller.<br />

Parameter<br />

º Image (input object) ..................................................image(-array) Hobject : byte<br />

Image to be segmented.<br />

º RegionHysteresis (output object) .....................................region(-array) Hobject *<br />

Segmentation result.<br />

º Low (input control) ...................................................................integer long<br />

Lower threshold for the gray values.<br />

Default Value : 30<br />

Value Suggestions : Low ¾5, 10, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100<br />

Typical Range of Values : 0 Low 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

Restriction : ´0 Lowµ ´Low 255µ<br />

º High (input control) .................................................................integer long<br />

Lower threshold for the gray values.<br />

Default Value : 60<br />

Value Suggestions : High ¾5, 10, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130<br />

Typical Range of Values : 0 High 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

Restriction : ´´0 Highµ ´High 255µµ ´High Lowµ<br />

<strong>HALCON</strong> 6.0


558 CHAPTER 10. SEGMENTATION<br />

º MaxLength (input control) ...........................................................integer long<br />

Maximum length of a path of “potential” points to reach a “secure” point.<br />

Default Value : 10<br />

Value Suggestions : MaxLength ¾1, 2, 3, 5, 7, 10, 12, 14, 17, 20, 25, 30, 35, 40, 50<br />

Typical Range of Values : 1 MaxLength 1000 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

Restriction : MaxLength 1<br />

Result<br />

hysteresis threshold returns H MSG TRUE if all parameters are correct. The behavior with respect to<br />

the input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

hysteresis threshold is reentrant and automatically parallelized (on tuple level).<br />

Alternatives<br />

dyn threshold, (T )threshold, class 2dim sup<br />

See Also<br />

edges image, sobel amp, background seg<br />

Bibliography<br />

J. Canny, ”‘Finding Edges and Lines in Images”’; Report, AI-TR-720, M.I.T. Artificial Intelligence Lab., Cambridge,<br />

MA, 1983.<br />

Module<br />

Region processing<br />

learn ndim box ( Hobject Foreground, Hobject Background,<br />

Hobject MultiChannelImage, long ClassifHandle )<br />

Train the current classificator using a multi-channel image.<br />

learn ndim box trains the classificator ClassifHandle with the gray values of MultiChannelImage<br />

using the points in Foreground as training sample. The points in Background are to be rejected by the<br />

classificator. The classificator trained thus can be used in learn ndim box to segment multi-channel images.<br />

Foreground are the points that have to be found, Background contains the points which shall not be found.<br />

Each pixel is trained once during the training process. For points in Foreground the class “0” is used, while<br />

for Background “1” is used. Pixels are trained by alternating points from Foreground with points from<br />

Background. If one region is smaller than the other, pixels are taken cyclically from the smaller region until the<br />

larger region is exhausted. learn ndim box later accepts only points which can be classified into class “0”.<br />

Attention<br />

All channels must be of the same type and have the same size.<br />

Parameter<br />

º Foreground (input object) .................................................region(-array) Hobject<br />

Foreground pixels to be trained.<br />

º Background (input object) .................................................region(-array) Hobject<br />

Background pixels to be trained (rejection class).<br />

º MultiChannelImage (input object) multichannel-image(-array) Hobject : byte / int1 / int2 / int4 / real<br />

/ direction / cyclic<br />

Multi-channel training image.<br />

º ClassifHandle (input control) ...................................................class box long<br />

Classificator’s handle number.<br />

Complexity<br />

Let Æ be the number of generated hyper-cuboids and be the area of the input region. Then the runtime complexity<br />

is Ç´Æ £ µ.<br />

Result<br />

class ndim box returns H MSG TRUE if all parameters are correct and there is an active classificator. The<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


559<br />

behavior with respect to the input images can be determined by setting the values of the flags ’no object result’<br />

and ’empty region result’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

learn ndim box is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

create class box, draw region<br />

Possible Successor Functions<br />

class ndim box, descript class box<br />

T learn class box<br />

Region processing<br />

Alternatives<br />

Module<br />

T learn ndim norm ( Hobject Foreground, Hobject Background,<br />

Hobject Image, Htuple Metric, Htuple Distance, Htuple MinNumberPercent,<br />

Htuple *Radius, Htuple *Center, Htuple *Quality )<br />

Construct clusters for (T )class ndim norm.<br />

T learn ndim norm generates classification clusters from the region Foreground and the corresponding<br />

gray values in the multi-channel image Image, which can be used in (T )class ndim norm. Background<br />

determines a class of pixels not to be found in (T )class ndim norm. This parameter may be empty (empty<br />

tuple).<br />

The parameter Distance determines the maximum distance Radius of the clusters. It describes the minimum<br />

distance between two cluster centers. If the parameter Distance is small the (small) hyper-cubes or hyperspheres<br />

can approximate the feature space well. Simultaneously the runtime during classification increases.<br />

The ratio of the number of pixels in a cluster to the total number of pixels (in percent) must be larger than the<br />

value of MinNumberPercent, otherwise the cluster is not returned. MinNumberPercent serves to eliminate<br />

outliers in the training set. If it is chosen too large many clusters are suppressed.<br />

Two different clustering procedures can be selected: The minimum distance algorithm (n-dimensional hyperspheres)<br />

and the maximum algorithm (n-dimensional hyper-cubes) for describing the pixels of the image to classify<br />

in the n-dimensional histogram (parameter Metric). The Euclidian metric usually yields the better results, but<br />

takes longer to compute. The parameter Quality returns the quality of the clustering. It is a measure of overlap<br />

between the rejection class and the classificator classes. Values larger than 0 denote the corresponding ratio of<br />

overlap. If no rejection region is given, its value is set to 1. The regions in Background do not influence on the<br />

clusteringṪhey are merely used to check the results that can be expected.<br />

Parameter<br />

º Foreground (input object) .................................................region(-array) Hobject<br />

Foreground pixels to be trained.<br />

º Background (input object) .................................................region(-array) Hobject<br />

Background pixels to be trained (rejection class).<br />

º Image (input object) .............................image(-array) Hobject : byte / int1 / int2 / int4 / real<br />

Multi-channel training image.<br />

º Metric (input control) .................................................string Htuple . const char *<br />

Metrictobeused.<br />

Default Value : ’euclid’<br />

Value List : Metric ¾’euclid’, ’maximum’<br />

º Distance (input control) ...........................................number Htuple . double / long<br />

Maximum cluster radius.<br />

Default Value : 10.0<br />

Value Suggestions : Distance ¾1.0, 2.0, 3.0, 4.0, 6.0, 8.0, 10.0, 13.0, 17.0, 24.0, 30.0, 40.0<br />

Typical Range of Values : 0.0 Distance 511.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 1.0<br />

Restriction : Radius 0.0<br />

<strong>HALCON</strong> 6.0


560 CHAPTER 10. SEGMENTATION<br />

º MinNumberPercent (input control) ................................number Htuple . double / long<br />

The ratio of the number of pixels in a cluster to the total number of pixels (in percent) must be larger than<br />

MinNumberPercent (otherwise the cluster is not output).<br />

Default Value : 0.01<br />

Value Suggestions : MinNumberPercent ¾0.001, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0<br />

Typical Range of Values : 0.0 MinNumberPercent 100.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : ´0 MinNumberPercentµ ´MinNumberPercent 100µ<br />

º Radius (output control) ...............................................real-array Htuple . double *<br />

Cluster radii of half edge lengths.<br />

º Center (output control) ...............................................real-array Htuple . double *<br />

Coordinates of all cluster centers.<br />

º Quality (output control) ...................................................real Htuple . double *<br />

Overlap of the rejection class with the classified objects (1: no overlapping).<br />

Assertion : ´0 Qualityµ ´Quality 1µ<br />

Result<br />

T learn ndim norm returns H MSG TRUE if all parameters are correct. The behavior with respect to the<br />

input images can be determined by setting the values of the flags ’no object result’ and ’empty region result’<br />

with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

T learn ndim norm is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

min max gray, sobel amp, gauss image, reduce domain, diff of gauss<br />

Possible Successor Functions<br />

(T )class ndim norm, connection, dilation1, erosion1, opening, closing, rank region,<br />

shape trans, skeleton<br />

See Also<br />

(T )class ndim norm, class ndim box, histo 2dim<br />

Bibliography<br />

P. Haber”acker, ”‘Digitale Bildverarbeitung”’; Hanser-Studienb”ucher, M”unchen, Wien, 1987<br />

Region processing<br />

Module<br />

local max ( Hobject Image, Hobject *LocalMaxima )<br />

Detect all local maxima in an image.<br />

local max extracts all points in an image having a gray value larger than the gray value of all its neighbors. The<br />

neighborhood used can be set by set system(’neighborhood’,).<br />

Parameter<br />

º Image (input object) .............................image(-array) Hobject : byte / int1 / int2 / int4 / real<br />

Image to be processed.<br />

º LocalMaxima (output object) ............................................region(-array) Hobject *<br />

Extracted local maxima as regions.<br />

Parameter Number : LocalMaxima Image<br />

Example<br />

read_image(&Image,"fabrik");<br />

corner_responce(Image,&CornerResp,5,0.04);<br />

local_max(CornerResp,&Maxima);<br />

set_colored(WindowHandle,12);<br />

disp_region(Maxima,WindowHandle);<br />

T_get_region_points(Maxima,&Row,&Col);<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


561<br />

Parallelization Information<br />

local max is reentrant and automatically parallelized (on tuple level).<br />

gauss image, smooth image<br />

get region points, connection<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

gray skeleton, nonmax suppression amp, plateaus, plateaus center<br />

See Also<br />

monotony, topographic sketch, corner response, texture laws<br />

Region processing<br />

Module<br />

nonmax suppression amp ( Hobject ImgAmp, Hobject *ImageResult,<br />

const char *Mode )<br />

Suppress non-maximum points on an edge.<br />

nonmax suppression amp suppresses in the regions of the image ImgAmp all points whose gray values are<br />

not local (directed) maxima. In contrast to nonmax suppression dir, a direction image is not needed. Two<br />

modes of operation can be selected:<br />

’hvnms’ A point is labeled as a local maximum if its gray value is larger than or equal to the gray values within<br />

a seach space of ¦ 5 pixels, either horizontally or vertically. Non-maximum points are removed from the<br />

region, gray values remain unchanged.<br />

’loc max’ A point is labeled as a local maximum if its gray value is larger than or equal to the gray values of its<br />

eight neighbors.<br />

Parameter<br />

º ImgAmp (input object) ................................................image(-array) Hobject : byte<br />

Amplitude (gradient magnitude) image.<br />

º ImageResult (output object) ......................................image(-array) Hobject * : byte<br />

Image with thinned edge regions.<br />

º Mode (input control) ............................................................string const char *<br />

Select horizontal/vertical or undirected NMS.<br />

Default Value : ’hvnms’<br />

Value List : Mode ¾’hvnms’, ’loc max’<br />

Result<br />

nonmax suppression amp returns H MSG TRUE if all parameters are correct. The behavior with respect<br />

to the input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

nonmax suppression amp is reentrant and automatically parallelized (on tuple level, channel level).<br />

sobel amp<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

(T )threshold, hysteresis threshold<br />

Alternatives<br />

gray skeleton, local max, gray dilation rect<br />

skeleton<br />

See Also<br />

Bibliography<br />

S.Lanser: ”‘Detektion von Stufenkanten mittels rekursiver Filter nach Deriche”’; Diplomarbeit; Technische Universit”at<br />

M”unchen, Institut f”ur Informatik, Lehrstuhl Prof. Radig; 1991.<br />

<strong>HALCON</strong> 6.0


562 CHAPTER 10. SEGMENTATION<br />

J.Canny: ”‘Finding Edges and Rows in Images”’; Report, AI-TR-720; M.I.T. Artificial Intelligence Lab., Cambridge,<br />

MA; 1983.<br />

Module<br />

Region processing<br />

nonmax suppression dir ( Hobject ImgAmp, Hobject ImgDir,<br />

Hobject *ImageResult, const char *Mode )<br />

Suppress non-maximum points on an edge.<br />

nonmax suppression dir suppresses in the regions of the image ImgAmp all points whose gray values<br />

are not local (directed) maxima. ImgDir is a direction image giving the direction perpendicular for the local<br />

maximum (Unit: 2 degrees, i.e., 50 degrees are coded as 25 in the image). Such images are returned, for example,<br />

by edges image. Two modes of operation can be selected:<br />

’nms’ Each point in the image is tested whether its gray value is a local maximum perpendicular to its direction.<br />

In this mode only the two neighbors closest to the given direction are examined. If one of the two gray values<br />

is greater than the gray of the point to be tested, it is suppressed (i.e., removed from the input regionṪhe<br />

corresponding gray value remains unchanged).<br />

’inms’ Like ’nms’Ḣowever, the two gray values for the test are obtained by interpolation from four adjacent<br />

points.<br />

Parameter<br />

º ImgAmp (input object) ......................................................image(-array) Hobject<br />

Amplitude (gradient magnitude) image.<br />

º ImgDir (input object) ......................................................image(-array) Hobject<br />

Direction image.<br />

º ImageResult (output object) .............................................image(-array) Hobject *<br />

Image with thinned edge regions.<br />

º Mode (input control) ............................................................string const char *<br />

Select non-maximum-suppression or interpolating NMS.<br />

Default Value : ’nms’<br />

Value List : Mode ¾’nms’, ’inms’<br />

Result<br />

nonmax suppression dir returns H MSG TRUE if all parameters are correct. The behavior with respect<br />

to the input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

nonmax suppression dir is reentrant and automatically parallelized (on tuple level, channel level).<br />

edges image, sobel dir<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

(T )threshold, hysteresis threshold<br />

Alternatives<br />

nonmax suppression amp, gray skeleton, gray dilation rect<br />

skeleton<br />

See Also<br />

Bibliography<br />

S.Lanser: ”‘Detektion von Stufenkanten mittels rekursiver Filter nach Deriche”’; Diplomarbeit; Technische Universit”at<br />

M”unchen, Institut f”ur Informatik, Lehrstuhl Prof. Radig; 1991.<br />

J.Canny: ”‘Finding Edges and Rows in Images”’; Report, AI-TR-720; M.I.T. Artificial Intelligence Lab., Cambridge;<br />

1983.<br />

Module<br />

Region processing<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


563<br />

plateaus ( Hobject Image, Hobject *Plateaus )<br />

Detect all gray value plateaus.<br />

plateaus extracts all points with a gray value greater or equal to the gray value of its neighbors (8-connectivity).<br />

Each maximum is returned as a separate region.<br />

Parameter<br />

º Image (input object) .............................image(-array) Hobject : byte / int1 / int2 / int4 / real<br />

Image to be processed.<br />

º Plateaus (output object) ..................................................region-array Hobject *<br />

Extracted plateaus as regions (one region for each plateau).<br />

Example<br />

read_image(&Image,"fabrik");<br />

corner_responce(Image,&CornerResp,5,0.04);<br />

plateaus(CornerResp,&Maxima);<br />

set_colored(WindowHandle,12);<br />

disp_region(Maxima,WindowHandle);<br />

T_area_center(Maxima,_,&Row,&Col);<br />

Parallelization Information<br />

plateaus is reentrant and automatically parallelized (on tuple level).<br />

gauss image, smooth image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

area center, get region points, select shape<br />

Alternatives<br />

plateaus center, gray skeleton, nonmax suppression amp, local max<br />

See Also<br />

monotony, topographic sketch, corner response, texture laws<br />

Region processing<br />

Module<br />

plateaus center ( Hobject Image, Hobject *Plateaus )<br />

Detect the centers of all gray value plateaus.<br />

plateaus center extracts all points with a gray value greater or equal to the gray value of its neighbors (8-<br />

connectivity). If more than one of these points are connected (plateau), their center of gravity is returned. Each<br />

maximum is returned as a separate region.<br />

Parameter<br />

º Image (input object) .............................image(-array) Hobject : byte / int1 / int2 / int4 / real<br />

Image to be processed.<br />

º Plateaus (output object) ..................................................region-array Hobject *<br />

Centers of gravity of the extracted plateaus as regions (one region for each plateau).<br />

Example<br />

read_image(&Image,"fabrik");<br />

corner_responce(Image,&CornerResp,5,0.04);<br />

plateaus_center(CornerResp,&Maxima);<br />

set_colored(WindowHandle,12);<br />

disp_region(Maxima,WindowHandle);<br />

T_area_center(Maxima,_,&Row,&Col);<br />

<strong>HALCON</strong> 6.0


564 CHAPTER 10. SEGMENTATION<br />

Parallelization Information<br />

plateaus center is reentrant and automatically parallelized (on tuple level).<br />

gauss image, smooth image<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

area center, get region points, select shape<br />

Alternatives<br />

plateaus, gray skeleton, nonmax suppression amp, local max<br />

See Also<br />

monotony, topographic sketch, corner response, texture laws<br />

Region processing<br />

Module<br />

pouring ( Hobject Image, Hobject *Regions, const char *Mode,<br />

long MinGray, long MaxGray )<br />

Segment an image by “pouring water” over it.<br />

pouring regards the input image as a “mountain range.” Larger gray values correspond to mountain peaks, while<br />

smaller gray values correspond to valley bottoms. pouring segments the input image in several steps. First the<br />

local maxima are extracted, i.e., pixels which either alone or in the form of an extended plateau have larger gray<br />

values than their immediate neighbors (in 4-connectivity). In the next step, the maxima thus found are the starting<br />

points for an expansion until “valley bottoms” are reached. The expansion is done as long as there are chains of<br />

pixels in which the gray value gets smaller (like water running downhill from the maxima in all directions). Again,<br />

4-connectivity is used, but with a weaker condition (smaller or equal). This means that points at valley bottoms<br />

may belong to more than one maximum. These areas are at first not assigned to a region, but rather are split among<br />

all competing segments in the last step. The split is done by a uniform expansion of all involved segments, until all<br />

ambiguous pixels were assigned. The parameter Mode determines which steps are executed. The following values<br />

are possible:<br />

’all’ This is the normal mode of operation. All steps of the segmentation are performed. The regions are assigned<br />

to maxima, and overlapping regions are split.<br />

’maxima’ The segmentation only extracts the local maxima of the input image. No corresponding regions are<br />

extracted.<br />

’regions’ The segmentation extracts the local maxima of the input image and the corresponding regions, which<br />

are uniquely determined. Areas which could be assigned to more than one maximum are not split.<br />

In order to prevent the algorithm from splitting a uniform background, which is different from the rest of the<br />

image, the parameters MinGray and MaxGray determine gray value thresholds for regions in the image which<br />

should be regarded as background. All parts of the image having a gray value smaller than MinGray or larger<br />

than MaxGray are disregarded for the extraction of the maxima as well as for the assignment of regions. For<br />

a complete segmentation of the image, MinGray = 0 und MaxGray = 255 should be selected. In any case,<br />

MinGray MaxGray must be observed.<br />

Parameter<br />

º Image (input object) .........................................................image Hobject : byte<br />

Image to be segmented.<br />

º Regions (output object) ...................................................region-array Hobject *<br />

Segmentation result.<br />

º Mode (input control) ............................................................string const char *<br />

Mode of operation.<br />

Default Value : ’all’<br />

Value List : Mode ¾’all’, ’maxima’, ’regions’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


565<br />

º MinGray (input control) .............................................................integer long<br />

All gray values smaller than this threshold are disregarded.<br />

Default Value : 0<br />

Value Suggestions : MinGray ¾0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110<br />

Typical Range of Values : 0 MinGray 256 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : MinGray 0<br />

º MaxGray (input control) .............................................................integer long<br />

All gray values larger than this threshold are disregarded.<br />

Default Value : 255<br />

Value Suggestions : MaxGray ¾100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240,<br />

250, 255<br />

Typical Range of Values : 0 MaxGray 256 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

Restriction : ´MaxGray 255µ ´MaxGray MinGrayµ<br />

Example<br />

/* Segmentation of a filtered image */<br />

read_image(&Image,"br2");<br />

mean_image(Image,&Mean,11,11);<br />

pouring(Mean,&Seg,"all",0,255);<br />

disp_image(Mean,WindowHandle);<br />

set_colored(WindowHandle,12);<br />

disp_region(Seg,WindowHandle);<br />

/* Segmentation of an image with masking of a dark backround */<br />

read_image(&Image,"hand");<br />

mean_image(Image,&Mean,15,15);<br />

pouring(Mean,&Seg,"all",40,255);<br />

disp_image(Mean,WindowHandle);<br />

set_colored(WindowHandle,12);<br />

disp_region(Seg,WindowHandle);<br />

/* Segmentation of a 2D-histogram */<br />

read_image(&Image,"affe");<br />

texture_laws(Image,&Texture,"el",2,5);<br />

disp_image(Image,WindowHandle);<br />

draw_region(&Region,draw_region);<br />

reduce_domain(Texture,Region,&Testreg);<br />

histo_2dim(Testreg,Texture,Region,&Histo);<br />

pouring(Histo,Seg,"all",0,255);<br />

Complexity<br />

Let Æ be the number of pixels in the input image and Å be the number of found segments, where the enclosing<br />

rectangle of the segment contains Ñ pixels. Furthermore, let à be the number of chords in segment . Then the<br />

runtime complexity is<br />

Ç´¿ £ Æ · ×ÙÑ Å ´¿ £ Ñ µ·×ÙÑ Å ´Ã µµ <br />

Result<br />

pouring usually returns the value H MSG TRUE. If necessary, an exception is raised.<br />

Parallelization Information<br />

pouring is processed under mutual exclusion against itself and without parallelization.<br />

gauss image, smooth image<br />

Possible Predecessor Functions<br />

<strong>HALCON</strong> 6.0


566 CHAPTER 10. SEGMENTATION<br />

watersheds, local max<br />

Alternatives<br />

See Also<br />

histo 2dim, expand region, (T )expand gray, (T )expand gray ref<br />

Region processing<br />

Module<br />

regiongrowing ( Hobject Image, Hobject *Regions, long Row, long Column,<br />

double Tolerance, long MinSize )<br />

Segment an image using regiongrowing.<br />

regiongrowing segments images into regions of the same intensity — rastered into rectangles of size Row ¢<br />

Column. In order to decide whether two adjacent rectangles belong to the same region only the gray value of their<br />

center points is used. If the gray value difference is less then or equal to Tolerance the rectangles are merged<br />

into one region.<br />

If ½ und ¾ are two gray values to be examined, they are merged into the same region if:<br />

½ ¾ ÌÓÐÖÒ<br />

For images of type ’cyclic’, the following formulas are used:<br />

´ ½ ¾ ÌÓÐÖÒµ ´ ½ ¾ ½¾µ<br />

´¾ ½ ¾ ÌÓÐÖÒµ ´ ½ ¾ ½¾µ<br />

For rectangles larger than one pixel, ususally the images should be smoothed with a lowpass filter with a size of<br />

at least Row ¢ Column before calling regiongrowing (so that the gray values at the centers of the regtangles<br />

are “representative” for the whole rectangle). If the image contains little noise and the rectangles are small, the<br />

smoothing can be omitted in many cases. This, of course, makes the whole procedure faster.<br />

The resulting regions are collections of rectangles of the chosen size Row ¢ Column . Only regions containing at<br />

least MinSize points are returned.<br />

Regiongrowing is a very fast operation, and thus suited for time-critical applications.<br />

Attention<br />

Column and Row are automatically converted to odd values if necessary.<br />

Parameter<br />

º Image (input object) .....................image(-array) Hobject : byte / int1 / int2 / int4 / cyclic / real<br />

Image to be segmented.<br />

º Regions (output object) ...................................................region-array Hobject *<br />

Extracted segments.<br />

º Row (input control) ..................................................................extent.y long<br />

Vertical distance between tested pixels (height of the raster).<br />

Default Value : 3<br />

Value Suggestions : Row ¾1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21<br />

Typical Range of Values : 1 Row 99 (lin)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : ´Row 1µ odd´Rowµ<br />

º Column (input control) ..............................................................extent.x long<br />

Horizontal distance between tested pixels (height of the raster).<br />

Default Value : 3<br />

Value Suggestions : Column ¾1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21<br />

Typical Range of Values : 1 Column 99 (lin)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 2<br />

Restriction : ´Column 1µ odd´Columnµ<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


567<br />

º Tolerance (input control) .................................................number double / long<br />

Points with a gray value difference less then or equal to tolerance are accumulated into the same object.<br />

Default Value : 6.0<br />

Value Suggestions : Tolerance ¾1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 14.0, 18.0, 25.0<br />

Typical Range of Values : 1.0 Tolerance 127.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 1.0<br />

Restriction : ´0 Toleranceµ ´Tolerance 127µ<br />

º MinSize (input control) .............................................................integer long<br />

Minimum size of the output regions.<br />

Default Value : 100<br />

Value Suggestions : MinSize ¾1, 5, 10, 20, 50, 100, 200, 500, 1000<br />

Typical Range of Values : 1 MinSize 1000 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

Restriction : MinSize 1<br />

Example<br />

read_image(&Image,"fabrik");<br />

mean_image(Image,&Mean,Row,Column);<br />

regiongrowing(Mean,&Result,Row,Column,6,100);<br />

Complexity<br />

Let Æ be the number of found regions and Å the number of points in one of these regions. Then the runtime<br />

complexity is Ç´Æ £ ÐÓ´Å µ £ Å µ.<br />

Result<br />

regiongrowing returns H MSG TRUE if all parameters are correct. The behavior with respect to the<br />

input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

regiongrowing is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

mean image, gauss image, smooth image, median image, anisotrope diff<br />

Possible Successor Functions<br />

select shape, reduce domain, select gray<br />

Alternatives<br />

regiongrowing n, (T )regiongrowing mean, label to region<br />

Region processing<br />

Module<br />

regiongrowing mean ( Hobject Image, Hobject *Regions, long StartRows,<br />

long StartColumns, double Tolerance, long MinSize )<br />

T regiongrowing mean ( Hobject Image, Hobject *Regions,<br />

Htuple StartRows, Htuple StartColumns, Htuple Tolerance, Htuple MinSize )<br />

Regiongrowing using mean gray values.<br />

(T )regiongrowing mean performs a regiongrowing using mean gray values of a region, starting from points<br />

given by StartRows and StartColumns. At any point in the process the mean gray value of the current region<br />

is calculated. Gray values at the boundary of the region are added to the region if they differ from the current mean<br />

by less than Tolerance. Regions smaller than MinSize are suppressed.<br />

If no starting points are given (empty tuples), the expansion process starts at the upper leftmost point, and is<br />

continued with the first unprocessed point after a region has been created.<br />

<strong>HALCON</strong> 6.0


568 CHAPTER 10. SEGMENTATION<br />

Parameter<br />

º Image (input object) ............................................image(-array) Hobject : byte / int4<br />

Image to be segmented.<br />

º Regions (output object) ...................................................region-array Hobject *<br />

Extracted segments.<br />

º StartRows (input control) ..........................................point.y(-array) (Htuple .) long<br />

Row coordinates of the starting points.<br />

Default Value : ’[]’<br />

Typical Range of Values : 0 StartRows 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º StartColumns (input control) ......................................point.x(-array) (Htuple .) long<br />

Column coordinates of the starting points.<br />

Default Value : ’[]’<br />

Typical Range of Values : 0 StartColumns 511 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Tolerance (input control) ..............................................number (Htuple .) double<br />

Maximum deviation from the mean.<br />

Default Value : 5.0<br />

Value Suggestions : Tolerance ¾0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 15.0, 17.0,<br />

20.0, 25.0, 30.0, 40.0<br />

Typical Range of Values : 0.1 Tolerance 100.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 1.0<br />

Restriction : Tolerance 0.0<br />

º MinSize (input control) ....................................................integer (Htuple .) long<br />

Minimum size of a region.<br />

Default Value : 100<br />

Value Suggestions : MinSize ¾0, 10, 30, 50, 100, 500, 1000, 2000<br />

Typical Range of Values : 0 MinSize 50000 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 100<br />

Restriction : MinSize 0<br />

Result<br />

(T )regiongrowing mean returns H MSG TRUE if all parameters are correct. The behavior with respect<br />

to the input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

(T )regiongrowing mean is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

gauss image, sigma image, anisotrope diff, median image<br />

Possible Successor Functions<br />

select shape, reduce domain, opening, expand region<br />

regiongrowing, regiongrowing n<br />

Region processing<br />

Alternatives<br />

Module<br />

regiongrowing n ( Hobject MultiChannelImage, Hobject *Regions,<br />

const char *Metric, double MinTolerance, double MaxTolerance,<br />

long MinSize )<br />

Regiongrowing for multi-channel images.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


569<br />

regiongrowing n performs a multi-channel regiongrowing. The Ò channels give rise to an n-dimensional<br />

feature vector. Neighboring points are aggregated into the same region if the difference of their feature vectors<br />

with respect to the given metric lies in the interval [MinTolerance, MaxTolerance]. Only 4-connected<br />

neighbors are examined. The following metrics can be used:<br />

Let denote the gray value in the feature vector at point of the image, and likewise be the gray value<br />

in the feature vector at point a neighboring point . Let´µ be the gray value with index . Furthermore, let<br />

ÅÒÌ denote MinTolerance and ÅÜÌ denote MaxTolerance.<br />

’1-norm’: Sum of absolute values<br />

’2-norm’: Euclidian distance<br />

’3-norm’: p - Norm with p = 3<br />

’4-norm’: p - Norm with p = 4<br />

’n-norm’: Minkowski distance<br />

’max-diff’: Supremum distance<br />

’min-diff’: Infimum distance<br />

ÅÒÌ ½ Ò<br />

<br />

ÅÜÌ<br />

ÅÒÌ <br />

ÖÈ<br />

´ µ ¾<br />

Ò<br />

ÅÒÌ ¿ ÖÈ<br />

´ µ ¿<br />

Ò<br />

ÅÒÌ ÖÈ<br />

´ µ <br />

Ò<br />

ÅÒÌ Ò ÖÈ<br />

´ µ Ò<br />

Ò<br />

ÅÜÌ<br />

ÅÜÌ<br />

ÅÜÌ<br />

ÅÜÌ<br />

ÅÒÌ ÑÜ ÅÜÌ<br />

ÅÒÌ ÑÒ ÅÜÌ<br />

’variance’: Variance of gray value differences<br />

ÅÒÌ ÎÖ´ µ ÅÜÌ<br />

’dot-product’: Dot product<br />

’correlation’: Correlation<br />

ÅÒÌ ½ Ò<br />

ÎÖ ½ Ò<br />

Õ<br />

´ µ ÅÜÌ<br />

Ñ ½ Ò<br />

<br />

<br />

Õ<br />

´ Ñ µ ¾<br />

ÎÖ ½ Ò<br />

Ñ ½ Ò<br />

<br />

<br />

Õ<br />

´ Ñ µ ¾<br />

ÅÒÌ ½ Ò ¾ ´ Ñ µ´ Ñ µ<br />

´ÎÖ ÎÖ µ<br />

ÅÜÌ<br />

’mean-diff’: Difference of arithmetic means<br />

½ Ò<br />

<br />

<br />

½ Ò<br />

<br />

<br />

ÅÒÌ <br />

ÅÜÌ<br />

<strong>HALCON</strong> 6.0


570 CHAPTER 10. SEGMENTATION<br />

’mean-ratio’: Ratio of arithmetic means<br />

½ Ò<br />

<br />

<br />

’length-diff’: Difference of the vector lengths<br />

’length-ratio’: Ratio of the vector lengths<br />

ÅÒÌ ÑÒ<br />

ÅÒÌ <br />

ÅÒÌ ÑÒ<br />

½ Ò<br />

<br />

<br />

<br />

<br />

<br />

ÖÈ <br />

¾<br />

<br />

Ò<br />

<br />

ÖÈ <br />

¾<br />

<br />

Ò<br />

<br />

ÖÈ <br />

¾<br />

<br />

Ò<br />

ÖÈ <br />

¾<br />

<br />

Ò<br />

<br />

<br />

<br />

ÅÜÌ<br />

ÅÜÌ<br />

ÅÜÌ<br />

’n-norm-ratio’: Ratio of the vector lengths w.r.t the p-norm with Ô Ò<br />

ÅÒÌ ÑÒ<br />

’gray-max-diff’: Difference of the maximum gray values<br />

Ò ÖÈ <br />

Ò<br />

<br />

Ò<br />

ÖÈ<br />

Ò <br />

Ò<br />

<br />

Ò<br />

<br />

<br />

<br />

ÑÜ <br />

ÑÜ <br />

ÅÒÌ <br />

’gray-max-ratio’: Ratio of the maximum gray values<br />

ÅÒÌ ÑÒ<br />

’gray-min-diff’: Difference of the minimum gray values<br />

ÅÜÌ<br />

ÅÜÌ<br />

ÑÜ <br />

ÑÜ <br />

<br />

<br />

ÑÒ <br />

ÑÒ <br />

ÅÒÌ <br />

ÅÜÌ<br />

ÅÜÌ<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


571<br />

’gray-min-ratio’: Ratio of the minimum gray values<br />

ÅÒÌ ÑÒ<br />

ÑÒ <br />

ÑÒ <br />

<br />

<br />

ÅÜÌ<br />

’variance-diff’: Difference of the variances over all gray values (channels)<br />

ÅÒÌ ÎÖ´ µ ÎÖ´ µÅÜÌ<br />

’variance-ratio’: Ratio of the variances over all gray values (channels)<br />

ÅÒÌ ÎÖ´ µ<br />

ÎÖ´ µ ÅÜÌ<br />

’mean-abs-diff’: Difference of the sum of absolute values over all gray values (channels)<br />

<br />

<br />

<br />

<br />

<br />

<br />

´µ ´µ<br />

´µ<br />

´µ<br />

<br />

ÅÒÌ <br />

Anzahl der Summen ÅÜÌ<br />

’mean-abs-ratio’: Ratio of the sum of absolute values over all gray values (channels)<br />

<br />

<br />

<br />

<br />

<br />

<br />

ÅÒÌ ÑÒ<br />

´µ ´µ<br />

´µ<br />

<br />

<br />

´µ<br />

ÅÜÌ<br />

’max-abs-diff’: Difference of the maximum distance of the components<br />

ÑÜ ´µ ´µ<br />

ÑÜ ´µ ´µ<br />

ÅÒÌ <br />

ÅÜÌ<br />

’max-abs-ratio’: Ratio of the maximum distance of the components<br />

ÑÜ ´µ ´µ<br />

ÑÜ ´µ ´µ<br />

ÅÒÌ ÑÒ<br />

<br />

<br />

ÅÜÌ<br />

’min-abs-diff’: Difference of the minimum distance of the components<br />

ÑÒ ´µ ´µ <br />

ÑÒ ´µ ´µ <br />

ÅÒÌ <br />

ÅÜÌ<br />

<strong>HALCON</strong> 6.0


572 CHAPTER 10. SEGMENTATION<br />

’min-abs-ratio’: Ratio of the minimum distance of the components<br />

ÑÒ ´µ ´µ <br />

ÑÒ ´µ ´µ <br />

ÅÒÌ ÑÒ<br />

’plane’: The following has to hold for all ½ , ¾ ¾ ½Ò℄:<br />

Regions with less than MinSize are suppressed.<br />

<br />

<br />

ÅÜÌ<br />

´ ½ µ ´ ¾ µ µ ´ ½ µ ´ ¾ µ<br />

´ ½ µ ´ ¾ µ µ ´ ½ µ ´ ¾ µ<br />

Parameter<br />

º MultiChannelImage (input object) .................................image(-array) Hobject : byte<br />

Multi-channel image to be segmented.<br />

º Regions (output object) ...................................................region-array Hobject *<br />

Segmented regions.<br />

º Metric (input control) .........................................................string const char *<br />

Metric for the distance of the feature vectors.<br />

Default Value : ’2-norm’<br />

Value List : Metric ¾’1-norm’, ’2-norm’, ’3-norm’, ’4-norm’, ’n-norm’, ’max-diff’, ’min-diff’,<br />

’variance’, ’dot-product’, ’correlation’, ’mean-diff’, ’mean-ratio’, ’length-diff’, ’length-ratio’, ’n-norm-ratio’,<br />

’gray-max-diff’, ’gray-max-ratio’, ’gray-min-diff’, ’gray-min-ratio’, ’variance-diff’, ’variance-ratio’,<br />

’mean-abs-diff’, ’mean-abs-ratio’, ’max-abs-diff’, ’max-abs-ratio’, ’min-abs-diff’, ’min-abs-ratio’, ’plane’<br />

º MinTolerance (input control) .............................................number double / long<br />

Lower threshold for the features’ distance.<br />

Default Value : 0.0<br />

Value Suggestions : MinTolerance ¾0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 14.0, 16.0,<br />

18.0, 20.0, 25.0, 30.0<br />

Typical Range of Values : 0.0 MinTolerance 255.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 1.0<br />

º MaxTolerance (input control) .............................................number double / long<br />

Upper threshold for the features’ distance.<br />

Default Value : 20.0<br />

Value Suggestions : MaxTolerance ¾0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 14.0, 16.0,<br />

18.0, 20.0, 25.0, 30.0<br />

Typical Range of Values : 0.0 MaxTolerance 255.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 1.0<br />

º MinSize (input control) .............................................................integer long<br />

Minimum size of the output regions.<br />

Default Value : 30<br />

Value Suggestions : MinSize ¾1, 10, 25, 50, 100, 200, 500, 1000<br />

Typical Range of Values : 1 MinSize 10000 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

Result<br />

regiongrowing n returns H MSG TRUE if all parameters are correct. The behavior with respect to the<br />

input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

regiongrowing n is reentrant and automatically parallelized (on tuple level).<br />

compose2, compose3<br />

Possible Predecessor Functions<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


573<br />

Alternatives<br />

class 2dim sup, (T )class ndim norm, class ndim box<br />

regiongrowing<br />

Region processing<br />

See Also<br />

Module<br />

threshold ( Hobject Image, Hobject *Region, double MinGray,<br />

double MaxGray )<br />

T threshold ( Hobject Image, Hobject *Region, Htuple MinGray,<br />

Htuple MaxGray )<br />

Select gray values lying within an interval.<br />

(T )threshold selects the pixels from the input image whose gray values fulfill the following condition:<br />

ÅÒÖÝ ÅÜÖÝ <br />

All points of an image fulfilling the condition are returned as one region. If more than one gray value interval is<br />

passed (tuples for MinGray and MaxGray), one separate region is returned for each interval.<br />

Parameter<br />

º Image (input object) .................image(-array) Hobject : byte / direction / cyclic / int2 / int4 / real<br />

Image to be thresholded.<br />

º Region (output object) ...................................................region(-array) Hobject *<br />

Regions with gray values lying in the specified interval.<br />

º MinGray (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double / long<br />

Lower threshold for the gray values.<br />

Default Value : 128.0<br />

Value Suggestions : MinGray ¾0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0<br />

Typical Range of Values : 0.0 MinGray 255.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 5.0<br />

º MaxGray (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double / long<br />

Upper threshold for the gray values.<br />

Default Value : 255.0<br />

Value Suggestions : MaxGray ¾0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0<br />

Typical Range of Values : 0.0 MaxGray 255.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 5.0<br />

Restriction : MaxGray MinGray<br />

Example<br />

read_image(&Image,"fabrik");<br />

sobel_amp(Image,&EdgeAmp,"sum_abs",3);<br />

threshold(EdgeAmp,&Seg,50.0,255.0);<br />

skeleton(Seg,&Rand);<br />

connection(Rand,&Lines);<br />

select_shape(Lines,&Edges,"area","and",10.0,1000000.0);<br />

Complexity<br />

Let be the area of the input region. Then the runtime complexity is Ç´ µ.<br />

Result<br />

(T )threshold returns H MSG TRUE if all parameters are correct. The behavior with respect to the<br />

input images and output regions can be determined by setting the values of the flags ’no object result’,<br />

’empty region result’,and’store empty region’ with set system. If necessary, an exception is raised.<br />

<strong>HALCON</strong> 6.0


574 CHAPTER 10. SEGMENTATION<br />

Parallelization Information<br />

(T )threshold is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

T histo to thresh, min max gray, sobel amp, gauss image, reduce domain,<br />

fill interlace<br />

Possible Successor Functions<br />

connection, dilation1, erosion1, opening, closing, rank region, shape trans, skeleton<br />

Alternatives<br />

class 2dim sup, hysteresis threshold, dyn threshold<br />

See Also<br />

dual threshold, zero crossing, background seg, regiongrowing<br />

Region processing<br />

Module<br />

threshold sub pix ( Hobject Image, Hobject *Border, double Threshold )<br />

Extract level crossings from an image with subpixel accuracy.<br />

threshold sub pix extracts the level crossings at the level Threshold of the input image Image with<br />

subpixel accuracy. The extracted level crossings are returned as XLD-contours in Border. In contrast to the<br />

operator (T )threshold, threshold sub pix does not return regions, but the lines which separate regions<br />

with a gray value less than Threshold from regions with a gray value greater than Threshold.<br />

For the extraction, the input image is regarded as a surface, in which the gray values are interpolated bilinearly<br />

between the centers of the individual pixels. Consistent with the surface thus defined, level crossing lines are<br />

extracted for each pixel and linked into topologically sound contours. This means that the level crossing contours<br />

are correctly split at junction points. If the image contains extended areas of constant gray value Threshold,<br />

only the border of such areas is returned as level crossings.<br />

Parameter<br />

º Image (input object) ......................singlechannel-image Hobject : byte / int1 / int2 / int4 / real<br />

Input image.<br />

º Border (output object) ...................................................xld cont-array Hobject *<br />

Extracted level crossings.<br />

º Threshold (input control) .................................................number double / long<br />

Threshold for the level crossings.<br />

Default Value : 128<br />

Value Suggestions : Threshold ¾0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0<br />

Example<br />

/* Detection zero crossings of the Laplacian-of-Gaussian of aerial image */<br />

read_image(&Image,"fabrik");<br />

threshold_sub_pix(Laplace,&Border,35);<br />

disp_xld(Border,WindowHandle);<br />

Result<br />

threshold sub pix usually returns the value H MSG TRUE. If necessary, an exception is raised.<br />

Parallelization Information<br />

threshold sub pix is reentrant and processed without parallelization.<br />

(T )threshold<br />

zero crossing sub pix<br />

Sub-pixel operators<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


575<br />

watersheds ( Hobject GrayImage, Hobject *Basins, Hobject *Watersheds )<br />

Extract watersheds and basins from an image.<br />

watersheds segments an image based on the topology of the gray values. The image is interpreted as a “mountain<br />

range.” Higher gray values correspond to “mountains,” while lower gray values correspond to “valleys.” In the<br />

resulting mountain range watersheds are extracted. These correspond to the bright ridges between dark basins. On<br />

output, the parameter Basins contains these basins, while Watersheds contains the watersheds, which are at<br />

least one pixel wide (points on the ridge which form a plateau). Watersheds always is a single region per input<br />

image, while Basins contains a separate region for each basin. It is advisable to apply a smoothing operator (e.g.,<br />

gauss image) to the input image before calling watersheds in order to reduce the number of output regions.<br />

Attention<br />

If the image contains many fine structures or is noisy, many output regions result, and thus the runtime increases<br />

considerably.<br />

Parameter<br />

º GrayImage (input object) ............................................image(-array) Hobject : byte<br />

Images to be segmented.<br />

º Basins (output object) .....................................................region-array Hobject *<br />

Segments found (dark basins).<br />

º Watersheds (output object) ..............................................region(-array) Hobject *<br />

Watersheds between the basins.<br />

Example<br />

read_image(&Cells,"meningg5");<br />

gauss_image(Cells,&CellsGauss,9);<br />

invert_image(CellsGauss,&CellsInvert);<br />

watersheds(CellsInvert,&Bassins,&Watersheds);<br />

set_colored(WindowHandle,12);<br />

disp_region(Bassins,WindowHandle);<br />

Result<br />

watersheds always returns H MSG TRUE. The behavior with respect to the input images and output regions<br />

can be determined by setting the values of the flags ’no object result’, ’empty region result’, and<br />

’store empty region’ with set system. If necessary, an exception is raised.<br />

Parallelization Information<br />

watersheds is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

gauss image, smooth image, invert image<br />

Possible Successor Functions<br />

expand region, select shape, reduce domain, opening<br />

pouring<br />

Region processing<br />

Alternatives<br />

Module<br />

zero crossing ( Hobject Image, Hobject *RegionCrossing )<br />

Detect zero crossings in an image.<br />

zero crossing returns the zero crossings of the input image as a region. A pixel is accepted as a zero crossing<br />

if its gray value (in Image) is zero, or if at least one of its 4-connected neighbors has a different sign.<br />

This operator is intended to be used after edge operators returning the second derivative of the image (e.g.,<br />

laplace of gauss), which were possibly followed by a smoothing operator. In this case, the zero crossings<br />

are (candidates for) edges.<br />

<strong>HALCON</strong> 6.0


576 CHAPTER 10. SEGMENTATION<br />

Parameter<br />

º Image (input object) ........................................image(-array) Hobject : int2 / int4 / real<br />

Input image.<br />

º RegionCrossing (output object) ........................................region(-array) Hobject *<br />

Zero crossings (as region).<br />

Result<br />

zero crossing usually returns the value H MSG TRUE. If necessary, an exception is raised.<br />

Parallelization Information<br />

zero crossing is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

laplace, laplace of gauss, derivate gauss<br />

Possible Successor Functions<br />

connection, skeleton, boundary, select shape, fill up<br />

(T )threshold, dual threshold<br />

Region processing<br />

Alternatives<br />

Module<br />

zero crossing sub pix ( Hobject Image, Hobject *ZeroCrossings )<br />

Extract zero crossings from an image with subpixel accuracy.<br />

zero crossing sub pix extracts the zero crossings of the input image Image with subpixel accuracy. The<br />

extracted zero crossings are returned as XLD-contours in ZeroCrossings. Thus, zero crossing sub pix<br />

can be used as a sub-pixel precise edge extractor if the input image is a Laplace-filtered image (see laplace,<br />

laplace of gauss, derivate gauss).<br />

For the extraction, the input image is regarded as a surface, in which the gray values are interpolated bilinearly<br />

between the centers of the individual pixels. Consistent with the surface thus defined, zero crossing lines are<br />

extracted for each pixel and linked into topologically sound contours. This means that the zero crossing contours<br />

are correctly split at junction points. If the image contains extended areas of constant gray value 0, only the border<br />

of such areas is returned as zero crossings.<br />

Parameter<br />

º Image (input object) ............................singlechannel-image Hobject : int1 / int2 / int4 / real<br />

Input image.<br />

º ZeroCrossings (output object) .........................................xld cont-array Hobject *<br />

Extracted zero crossings.<br />

Example<br />

/* Detection zero crossings of the Laplacian-of-Gaussian of aerial image */<br />

read_image(&Image,"mreut");<br />

derivate_gauss(Image,&Laplace,3,"laplace");<br />

zero_crossing_sub_pix(Laplace,&ZeroCrossings);<br />

disp_xld(ZeroCrossings,WindowHandle);<br />

/* Detection of edges, i.e, zero crossings of the Laplacian-of-Gaussian<br />

that have a large gradient magnitude, in an aerial image */<br />

read_image(&Image,"mreut");<br />

Sigma = 1.5;<br />

/* Compensate the threshold for the fact that derivate_gauss(...,’gradient’)<br />

calculates a Gaussian-smoothed gradient, in which the edge amplitudes<br />

are too small because of the Gaussian smoothing, to correspond to a true<br />

edge amplitude of 20. */<br />

Threshold = 20/(Sigma*sqrt(2*PI));<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


577<br />

derivate_gauss(Image,&Gradient,Sigma,"gradient");<br />

threshold(Gradient,&Region,Threshold,255);<br />

reduce_domain(Image,Region,&ImageReduced);<br />

derivate_gauss(ImageReduced,&Laplace,Sigma,"laplace");<br />

zero_crossing_sub_pix(Laplace,&Edges);<br />

disp_xld(Edges,WindowHandle);<br />

Result<br />

zero crossing sub pix usually returns the value H MSG TRUE. If necessary, an exception is raised.<br />

Parallelization Information<br />

zero crossing sub pix is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

laplace, laplace of gauss, diff of gauss, derivate gauss<br />

zero crossing<br />

Sub-pixel operators<br />

Alternatives<br />

Module<br />

<strong>HALCON</strong> 6.0


578 CHAPTER 10. SEGMENTATION<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Chapter 11<br />

System<br />

11.1 Database<br />

count relation ( const char *RelationName, long *NumOfTuples )<br />

Number of entries in the <strong>HALCON</strong> database.<br />

The operator count relation counts the number of entries in one of the four relations of the <strong>HALCON</strong><br />

database. The <strong>HALCON</strong> database is organized as follows:<br />

There are two basic relations for ÖÓÒ Ø and Ñ ÑØÖ×. The <strong>HALCON</strong> objects ÖÓÒ and Ñ<br />

are constructed from elements from these two relations: a region consists of a pointer to a tuplet in the region-data<br />

relation. An image consists also of a pointer to a tuplet in the region-data relation (like a region) and additionally<br />

of one or more pointers to tuplets in the matrix relation. If there is more than one matrix pointer, the image is called<br />

a ÑÙÐØ ÒÒÐ Ñ.<br />

Both regions and images are called ÓØ×. A region can be considered as the special case of an iconic object<br />

having no image matrixes. For reasons of an efficient memory managment, the tuplets of the region-data relation<br />

and the image-matrix relation ÛÐÐ Ù× Ý ÖÒØ ÓØ× ØÓØÖ. Therefore there may be for example<br />

more images than image matrices. Only the two lowlevel relations are of relevance to the memory consumption.<br />

Image objects (regions as well as images) consist only of references on region and matrix data and therefore only<br />

need a couple of bytes of memory.<br />

Possible values for RelationName:<br />

’image’: Image matrices. One matrix may also be the component of more than one image (no redundant storage).<br />

’region’: Regions (the full and the empty region are always available). One region may of course also be the<br />

component of more than one image object (no redundant storage).<br />

’XLD’: eXtended Line Description: Contours, Polygons, paralles, lines, etc. XLD data types don’t have gray<br />

values and are stored with subpixel accuracy.<br />

’object’: Iconic objects. Composed of a region (called region) and optionally image matrices (called image).<br />

’tuple’: In the compact mode, tuplets of iconic objects are stored as a surrogate in this relation. Instead of working<br />

with the individual object keys, only this tuplet key is used. It depends on the host language, whether the<br />

objects are passed individually (Prolog and C++) or as tuplets (C, Smalltalk, Lisp, OPS-5).<br />

Certain database objects will be created already by the operator reset obj db and therefore have to be available<br />

all the time (the undefined gray value component, the objects ’full’ (FULL REGION in <strong>HALCON</strong>/C) and<br />

’empty’ (EMPTY REGION in <strong>HALCON</strong>/C) as well as the herein included empty and full region). By calling<br />

get channel info, the operator therefore appears correspondingly also as ’creator’ of the full and empty region.<br />

The procedure can be used for example to check the completeness of the clear obj operation.<br />

579


580 CHAPTER 11. SYSTEM<br />

Parameter<br />

º RelationName (input control) .................................................string const char *<br />

Relation of interest of the <strong>HALCON</strong> database.<br />

Default Value : ’object’<br />

Value List : RelationName ¾’image’, ’region’, ’XLD’, ’object’, ’tuple’<br />

º NumOfTuples (output control) .....................................................integer long *<br />

Number of tuplets in the relation.<br />

Example<br />

reset_obj_db(512,512,3) ;<br />

count_relation("image",&I1) ;<br />

count_relation("region",&R1) ;<br />

count_relation("XLD",&X1) ;<br />

count_relation("object",&O1) ;<br />

count_relation("tuple",&T1) ;<br />

read_image(&X,"monkey") ;<br />

count_relation("image",&I2) ;<br />

count_relation("region",&R2) ;<br />

count_relation("XLD",&X2) ;<br />

count_relation("object",&O2) ;<br />

count_relation("tuple",&T2) ;<br />

/*<br />

Result: I1 = 1 (undefined image)<br />

R1 = 2 (full and empty region)<br />

X1 = 0 (no XLD data)<br />

O1 = 2 (full and empty objects)<br />

T1 = 0 (always 0 in the normal mode)<br />

*/<br />

I2 = 2 (additionally the image ’monkey’)<br />

R2 = 2 (read_image uses the full region)<br />

X2 = 0 (no XLD data)<br />

O2 = 3 (additionally the image object X)<br />

T2 = 0.<br />

Result<br />

If the parameter is correct, the operator count relation returns the value H MSG TRUE. Otherwise an exception<br />

is raised.<br />

Parallelization Information<br />

count relation is reentrant and processed without parallelization.<br />

reset obj db<br />

clear obj<br />

System<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

T get modules ( Htuple *UsedModules, Htuple *ModuleKey )<br />

Query of used modules and the module key.<br />

T get modules returns the module numbers of all operators used up to this point. Each operator belongs to<br />

one module (maximum 32). Each module has a name, which is returned in UsedModules. Based on the used<br />

modules, a key is generated that is needed for the licence manager. T get modules is normally called at the end<br />

of a programm to check the used modules.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.1. DATABASE 581<br />

Parameter<br />

º UsedModules (output control) .........................................string-array Htuple . char *<br />

Names of used modules.<br />

º ModuleKey (output control) ................................................integer Htuple . long *<br />

Key for licence manager.<br />

Parallelization Information<br />

T get modules is reentrant and processed without parallelization.<br />

Operators not requiring licensing<br />

Module<br />

reset obj db ( long DefaultImageWidth, long DefaultImageHeight,<br />

long DefaultChannels )<br />

Initialization of the <strong>HALCON</strong> system.<br />

The operator reset obj db initializes the <strong>HALCON</strong> system. With this procedure the four relations (grayvalue<br />

data, region data, iconic objects and object tuplets) which are necessary for image processing with <strong>HALCON</strong> will<br />

be installed (see also count relation). In case the relations already exist, all tuplets in the relations will be<br />

deallocated!<br />

The parameters DefaultImageWidth and DefaultImageHeight provide the initial values for the global<br />

maximum image size. If the first created object is an image, (e.g. read image), the set values will be overruled<br />

in Standard-<strong>HALCON</strong> by the size of this picture. Instead of this, in Parallel <strong>HALCON</strong> the set values will only be<br />

changed, if they are smaller than the size of the created object. If on the other hand the first object to be created<br />

is a region, both in Standard- and in Parallel <strong>HALCON</strong> the values will only be adjusted in case the new image is<br />

larger than the set values. This is not only the case for the first image which is created or read: the global image<br />

size will always be enlarged, if larger images are created.<br />

The global image size is of consequence for the opening of windows (open window) and the clipping of<br />

regions. Whenever the clip mode is activated, regions will be clipped according to the global image size<br />

((T )set system(’clip region’,’true’)). This can lead to problems if images of various sizes are<br />

used. In this case only the fact that a region is smaller or of the same size as the largest image can be guaranteed.<br />

The parameter DefaultChannels returns the most frequent number of channels of an image object. This value<br />

can be set to 0 if for the most part regions are used. If more channels than those having been set at the initialization<br />

are necessary for one image, the number will be enlarged dynamically for this image. If less channels than those<br />

having been set at the initialization are necessary for the image, the superfluous channels will be set as undefined.<br />

For the user this will seem as if they were non existent, however, memory is allocated unnecessarily.<br />

The parameter values can be queried using the operator (T )get system.<br />

Attention<br />

If the operator reset obj db is not called at the beginning of a <strong>HALCON</strong> session, <strong>HALCON</strong> will be initialized<br />

automatically by the operator reset obj db(128,128,0). In case the operator reset obj db is called<br />

again, all image objects in the database will be deallocated.<br />

Parameter<br />

º DefaultImageWidth (input control) ................................................integer long<br />

Default image width (in pixels).<br />

Default Value : 128<br />

Value Suggestions : DefaultImageWidth ¾64, 128, 256, 512, 525, 1024<br />

º DefaultImageHeight (input control) ..............................................integer long<br />

Default image height (in pixels).<br />

Default Value : 128<br />

Value Suggestions : DefaultImageHeight ¾64, 128, 256, 512, 768, 1024<br />

º DefaultChannels (input control) ..................................................integer long<br />

Usual number of channels by which the system constant ’max channels’ is limited.<br />

Default Value : 0<br />

Value Suggestions : DefaultChannels ¾0, 1, 2, 3, 4, 5, 6, 7<br />

<strong>HALCON</strong> 6.0


582 CHAPTER 11. SYSTEM<br />

Result<br />

The operator reset obj db returns the value H MSG TRUE if the parameter values are correct. Otherwise an<br />

exception will be raised.<br />

Parallelization Information<br />

reset obj db is reentrant and processed without parallelization.<br />

get channel info, count relation<br />

Operators not requiring licensing<br />

See Also<br />

Module<br />

11.2 Error-Handling<br />

T get check ( Htuple *Check )<br />

State of the <strong>HALCON</strong> control modes.<br />

Executing the operator T get check the user can inquire what kind of control modes are currently activated and<br />

which are not. Check gives the tuplet containing the names of the control modes (see also (T )set check)<br />

which are preceded by a tilde (˜, e.g. ’˜data’), if the corresponding control is deactivated.<br />

Parameter<br />

º Check (output control) .................................................string-array Htuple . char *<br />

Tuplet of the currently activated control modes.<br />

Result<br />

T get check always returns the value H MSG TRUE.<br />

Parallelization Information<br />

T get check is reentrant and processed without parallelization.<br />

(T )set check<br />

(T )set check<br />

System<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

get error text ( long ErrorNumber, char *ErrorText )<br />

Inquiry after the error text of a <strong>HALCON</strong> error number.<br />

The operator get error text returns the error text for the corresponding <strong>HALCON</strong> error number. This is<br />

indeed the same text which will be given during an exception. The operator get error text is especially useful<br />

if the error treatment is programmed by the users themselves (see also (T )set check(’˜give error’:)).<br />

Attention<br />

Unknown error numbers will trigger a standard message.<br />

Parameter<br />

º ErrorNumber (input control) ........................................................integer long<br />

Number of the <strong>HALCON</strong> error.<br />

Restriction : ´1 ErrorNumberµ ´ErrorNumber 36000µ<br />

º ErrorText (output control) .........................................................string char *<br />

Corresponding error text.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.2. ERROR-HANDLING 583<br />

Example<br />

Herror<br />

char<br />

err;<br />

message[MAX_STRING];<br />

set_check("˜give_error");<br />

err = send_region(region,socket_id);<br />

set_check("give_error");<br />

if (err != MESS_TRUE) {<br />

get_error_text((long)err,message);<br />

fprintf(stderr,"my error message: %s\n",message);<br />

exit(1);<br />

}<br />

Result<br />

The operator get error text always returns the value H MSG TRUE.<br />

Parallelization Information<br />

get error text is reentrant and processed without parallelization.<br />

(T )set check<br />

(T )set check<br />

System<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

get spy ( const char *Class, char *Value )<br />

Current configuration of the <strong>HALCON</strong> debugging-tool.<br />

The operator get spy returns the current configuration of spy, the <strong>HALCON</strong> debugging tool. The available<br />

control modes (possible choices for Class) as well as the corresponding tuning possibilities (possible values for<br />

Value) can be called up by using the operator T query spy. You will find a more detailed description under<br />

set spy.<br />

Parameter<br />

º Class (input control) ..........................................................string const char *<br />

Control mode<br />

Default Value : ’mode’<br />

Value List : Class ¾’mode’, ’procedure’, ’input control’, ’output control’, ’parameter values’,<br />

’input gray window’, ’output gray window’, ’input region window’, ’db’, ’output region window’, ’halt’,<br />

’timeout’, ’button window’, ’button window’, ’button click’, ’button notify’, ’log file’, ’error’, ’internal’<br />

º Value (output control) .............................................string char * / long * / double *<br />

State of the control mode.<br />

Result<br />

The operator get spy returns the value H MSG TRUE if the parameter Class is correct. Otherwise an exception<br />

is raised.<br />

Parallelization Information<br />

get spy is reentrant and processed without parallelization.<br />

reset obj db<br />

set spy, T query spy<br />

System<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


584 CHAPTER 11. SYSTEM<br />

T query spy ( Htuple *Classes, Htuple *Values )<br />

Inquiring for possible settings of the <strong>HALCON</strong> debugging tool.<br />

The operator T query spy returns all possible settings of spy, the <strong>HALCON</strong> debugging tool, i.e. all the available<br />

control modes (Classes) as well as the corresponding possible ways of setting (Values). For a more detailed<br />

description of spy see operator set spy.<br />

Attention<br />

The values of Values cannot be used as direct input for set spy, as they are transmitted as a symbolic constant.<br />

Parameter<br />

º Classes (output control) ..............................................string-array Htuple . char *<br />

Available control modes (see also set spy).<br />

º Values (output control) ................................................string-array Htuple . char *<br />

Corresponding state of the control modes.<br />

Result<br />

query spy always returns the value H MSG TRUE.<br />

Parallelization Information<br />

T query spy is reentrant, local, and processed without parallelization.<br />

reset obj db<br />

set spy, get spy<br />

System<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

set check ( const char *Check )<br />

T set check ( Htuple Check )<br />

Activating and deactivating of <strong>HALCON</strong> control modes.<br />

With the help of the operator (T )set check different control modes of the <strong>HALCON</strong> system can be activated<br />

or deactivated. If a certain control mode is activated, parameters etc. will be checked at runtime. Whenever an<br />

inconsistency is hereby detected, the program will be interrupted by an exception.<br />

It is recommendable to activate the control modes during the development of a program and to deactivate them<br />

only after a successfully concluded testrun. For if the control mode is deactivated and an error occurs, the system<br />

may react in an unpredictable way.<br />

The <strong>HALCON</strong> system provides various possible control modes which can be activated and deactivated independently.<br />

By calling the operator (T )set check with the name (Check) of the desired control mode, this control<br />

mode is activated; the control mode is deactivated by passing its name prefixed with a tilde (˜, z.B. ’˜data’).<br />

Available control modes:<br />

’color’: If this control mode is activated, only colors may be used which are supported by the display for the<br />

currently active window. Otherwise an error message is displayed.<br />

In case of deactivated control mode and non existent colors, the nearest color is used (see also set color,<br />

set gray, set rgb).<br />

’text’: If this control mode is activated, it will check the coordinates during the setting of the text cursor as well<br />

as during the display of strings (write string) to the effect whether a part of a sign would lie outside the<br />

windowframe (a fact which is not forbidden in principle by the system).<br />

If the control mode is deactivaed, the text will be clipped at the windowframe.<br />

’parameter’: (For <strong>HALCON</strong>/PRO only)<br />

If this control mode is activated, output parameter may not be instantiated by calling a procedure.<br />

Otherwise a normal unification mechanism is used.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.2. ERROR-HANDLING 585<br />

’data’: (For program development)<br />

Checks the consistency of image objects (regions and grayvalue components.<br />

’interface’: If this control mode is activated, the interface between the host language and the <strong>HALCON</strong> procedures<br />

will be checked in course (e.g. typifying and counting of the values).<br />

’database’: This is a consistency check of the database (e.g. checks whether an object which shall be canceled<br />

does indeed exist or not.)<br />

’give error’: Determines whether errors shall trigger exceptions or not. If this control modes is deactivated,<br />

the application program must provide a suitable error treatment itself. Please note that errors which are<br />

not reported usually lead to undefined output parameters which may cause an unpredictable reaction of the<br />

program.<br />

’father’: If this control mode is activated by calling the operator open window, <strong>HALCON</strong> allows only the usage<br />

of the number of another <strong>HALCON</strong> window as the ”‘father”’ of the new window; otherwise it allows also<br />

other X Window IDs.<br />

’region’: For program development)<br />

Checks the consistency of chords (this may lead to a notable speed reduction of routines).<br />

’clear’: Normally, if a list of objects shall be canceled by using clear obj, an exception will be raised, in case<br />

individual objects do not or no longer exist. If the ’clear’ mode is activated, such objects will be ignored.<br />

’all’: Activates all control modes.<br />

’none’: Deactivates all control modes.<br />

’default’: Original setting.<br />

Parameter<br />

º Check (input control) ..........................................string(-array) (Htuple .) const char *<br />

Desired control mode.<br />

Default Value : ’default’<br />

Value List : Check ¾’color’, ’text’, ’database’, ’data’, ’interface’, ’give error’, ’father’, ’region’, ’clear’,<br />

’all’, ’none’, ’default’<br />

Result<br />

The operator (T )set check returns the value H MSG TRUE, if the parameters are correct. Otherwise an<br />

exception will be raised.<br />

Parallelization Information<br />

(T )set check is reentrant and processed without parallelization.<br />

See Also<br />

T get check, set color, set rgb, set hsi, write string<br />

System<br />

Module<br />

set spy ( const char *Class, const char *Value )<br />

Control of the <strong>HALCON</strong> Debugging Tools.<br />

The operator set spy is the <strong>HALCON</strong> debugging tool. This tool allows the flexible control of the input and<br />

output data of <strong>HALCON</strong>-operators - in graphical as well as in textual form. The datacontrol is activated by using<br />

set spy(’mode’,’on’),<br />

and deactivated by using<br />

set spy(’mode’,’off’).<br />

The debugging tool can further be activated with the help of the environment variable <strong>HALCON</strong>SPY. The definition<br />

of this variable corresponds to calling up ’mode’ and ’on’.<br />

The following control modes can be tuned (in any desired combination of course) with the help of Class/Value:<br />

Class Meaning / Value<br />

<strong>HALCON</strong> 6.0


586 CHAPTER 11. SYSTEM<br />

’operator’ When a routine is called, its name and the names of its parameters will be given (in TRIAS notation).<br />

Value: ’on’ or ’off’<br />

default: ’off’<br />

’input control’ When a routine is called, the names and values of the input control parameters will be given.<br />

Value: ’on’ or ’off’<br />

default: ’off’<br />

’output control’ When a routine is called, the names and values of the output control parameters are given.<br />

Value: ’on’ or ’off’<br />

default: ’off’<br />

’parameter values’ Additional information on ’input control’ and ’output control’: indicates how many values<br />

per parameter shall be displayed at most (maximum tuplet length of the output).<br />

Value: tuplet length (integer)<br />

default: 4<br />

’db’ Information concerning the 4 relations in the <strong>HALCON</strong>-database. This is especially valuable in looking for<br />

forgotten clear obj.<br />

Value: ’on’ or ’off’<br />

default: ’off’<br />

’input gray window’ Any reading access of the gray-value component of an (input) image object will cause the<br />

gray-value component to be shown in the indicated window (Window-ID; ’none’ will deactivate this control<br />

).<br />

Value: Window-ID (integer) or ’none’<br />

default: ’none’<br />

’output gray window’ As soon as the gray-value component of an (output) image object is set, spy will show<br />

this gray-value component in the indicated window (Window-ID; ’none’ will deactivate this control).<br />

Value: Window-ID (integer) or ’none’<br />

default: ’none’<br />

’input region window’ Any reading access of the region of an (input) iconic object will cause this region to be<br />

shown in the indicated (Window-ID; ’none’ will deactivate this control ).<br />

Value: Window-ID (integer) or ’none’<br />

default: ’none’<br />

’output region window’ As soon as the region of an (output) iconic object is set, spy will show this region in the<br />

indicated window (Window-ID; ’none’ will deactivate this control ).<br />

Value: Window-ID (integer) or ’none’<br />

default: ’none’<br />

’time’ Processing time of the operator<br />

Value: ’on’ or ’off’<br />

default: ’off’<br />

’halt’ Determines whether there is a halt after every individual action (’multiple’) or only at the end of each operator<br />

(’single’). The parameter is only effective if the halt has been activated by ’timeout’ or ’button window’.<br />

Value: ’single’ or ’multiple’<br />

default: ’multiple’<br />

’timeout’ After every output there will be a halt of the indicated number of seconds.<br />

Value: seconds (real)<br />

default 0.0<br />

’button window’ Alternative to ’timeout’: after every output spy waits until the cursor indicates (’button click’ =<br />

’false’) or clicks into (’button click’ = ’true’) the indicated window. (Window-ID; ’none’ will deactivate this<br />

control ).<br />

Value: Window-ID (integer) or ’none’<br />

default: ’none’<br />

’button click’ Additional option for ’button window’: determines whether or not a mouse-click has to be waited<br />

for after an output.<br />

Value: ’on’ or ’off’<br />

default: ’off’<br />

’button notify’ If ’button notify’ is activated, spy generates a beep after every output. This is useful in combination<br />

with ’button window’.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.3. INFORMATION 587<br />

Value: ’on’ or ’off’<br />

default: ’off’<br />

’log file’ Spy can hereby divert the text output into a file having been opened with open file.<br />

Value: a file handle (see open file)<br />

’error’ If ’error’ is activated and an internal error occurs, spy will show the internal procedures (file/line) concerned.<br />

Value: ’on’ or ’off’<br />

default: ’off’<br />

’internal’ If ’internal’ is activated, spy will display the internal procedures and their parameters (file/line) while<br />

an <strong>HALCON</strong>-operator is processed.<br />

Value: ’on’ or ’off’<br />

default: ’off’<br />

Parameter<br />

º Class (input control) ..........................................................string const char *<br />

Control mode<br />

Default Value : ’mode’<br />

Value List : Class ¾’mode’, ’operator’, ’input control’, ’output control’, ’parameter values’,<br />

’input gray window’, ’db’, ’time’, ’output gray window’, ’output region window’, ’input region window’,<br />

’halt’, ’timeout’, ’button window’, ’button click’, ’button notify’, ’log file’, ’error’, ’internal’<br />

º Value (input control) ............................................string const char * / long / double<br />

State of the control mode to be set.<br />

Default Value : ’on’<br />

Value Suggestions : Value ¾’on’, ’off’, 1, 2, 3, 4, 5, 10, 50, 0.0, 1.0, 2.0, 5.0, 10.0<br />

Example<br />

/* init spy: Setting of the wished control modi */<br />

set_spy("mode","on");<br />

set_spy("operator","on");<br />

set_spy("input_control","on");<br />

set_spy("output_control","on");<br />

/* calling of program section, that will be examined */<br />

set_spy("mode","off");<br />

Result<br />

The operator set spy returns the value H MSG TRUE if the parameters are correct. Otherwise an exception is<br />

raised.<br />

Parallelization Information<br />

set spy is reentrant, local, and processed without parallelization.<br />

reset obj db<br />

get spy, T query spy<br />

System<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

11.3 Information<br />

disp info ( const char *ProcName, const char *Machine,<br />

const char *DispProgram, const char *Extension )<br />

Display the manual information of a procedure on the screen.<br />

The operator disp info together with the previewer DispProgram shows the manual entry of the indicated<br />

procedure on the screen. The individual files (Name: .Extension) are located in the <strong>HALCON</strong>-Directory<br />

<strong>HALCON</strong> 6.0


588 CHAPTER 11. SYSTEM<br />

”‘doc/ps/reference/LANGUAGE/*”’, whereby the value for LANGUAGE will be determined by the currently<br />

used host language. The directory can also be generated with the help of the operator (T )set system<br />

(’reference dir’,’Pfad’).<br />

Parameter<br />

º ProcName (input control)..................................................proc name const char *<br />

Name of the seeked procedure.<br />

Default Value : ’read image’<br />

º Machine (input control) .......................................................string const char *<br />

Name of the computer to which the data shall be transmitted or empty string.<br />

Default Value : ”<br />

º DispProgram (input control) ..................................................string const char *<br />

Name of the program which shall display the help text.<br />

Default Value : ’ghostview’<br />

Value Suggestions : DispProgram ¾’gs’, ’ghostview’<br />

º Extension (input control) .....................................................string const char *<br />

Extension of the helpfile.<br />

Default Value : ’ps’<br />

Result<br />

If the parameter values are correct and the file and the program are available, the operator disp info returns the<br />

value H MSG TRUE. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

disp info is reentrant and processed without parallelization.<br />

open window<br />

Image / region / XLD management<br />

See Also<br />

Module<br />

T get chapter info ( Htuple Chapter, Htuple *Info )<br />

Get information concerning the chapters on procedures.<br />

The operator T get chapter info gives information concerning the chapters on procedures. If instead of<br />

Chapter the empty string is transmitted, the routine will provide in Info the names of all chapters. If on the<br />

other hand a certain chapter or a chapter and its subchapter(s) are indicated (by a tuple of names), the corresponding<br />

subchapters or - in case there are no further subchapters - the names of the corresponding procedures will be given.<br />

The organization of the chapters on procedures is the same as the organization of chapters and subchapters in the<br />

<strong>HALCON</strong>-manual. Please note: The chapters on procedures respectively the subchapters concerning an individual<br />

procedure can be called by using the operator T get operator info(,’chapter’,Info).<br />

The Online-texts will be taken from the files english.hlp, english.sta, english.num and english.idx, which will be<br />

searched by <strong>HALCON</strong> in the currently used directory or the directory ’help dir’ (see also (T )get system and<br />

(T )set system).<br />

Parameter<br />

º Chapter (input control).........................................string(-array) Htuple . const char *<br />

Procedure class or subclass of interest.<br />

Default Value : ”<br />

º Info (output control) ..................................................string-array Htuple . char *<br />

Procedure classes (Chapter = ”) or procedure subclasses respectively procedures.<br />

Result<br />

If the parameter values are correct and the helpfile is available, the operator T get chapter info returns the<br />

value H MSG TRUE. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T get chapter info is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

(T )get system, (T )set system<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.3. INFORMATION 589<br />

See Also<br />

T get operator info, (T )get system, (T )set system<br />

Image / region / XLD management<br />

Module<br />

T get keywords ( Htuple ProcName, Htuple *Keywords )<br />

Get keywords which are assigned to procedures.<br />

The operator T get keywords returns all the keywords in the online-texts corresponding to those procedures<br />

which have the indicated substring ProcName in their name. If instead of ProcName the empty string is transmitted,<br />

the operator T get keywords returns all keywords. The keywords of an individual procedure can also be<br />

called by using the operator T get operator info. The online-texts will be taken from the files english.hlp,<br />

english.sta, english.num, english.key and english.idx, which are searched by <strong>HALCON</strong> in the currently used<br />

directory and in the directory ’help dir’ (see also (T )get system and (T )set system).<br />

Parameter<br />

º ProcName (input control) .........................................proc name Htuple . const char *<br />

Substring in the names of those procedures for which keywords are needed.<br />

Default Value : ’get keywords’<br />

º Keywords (output control) .............................................string-array Htuple . char *<br />

Keywords for the procedures.<br />

Result<br />

The operator T get keywords returns the value H MSG TRUE if the parameters are correct and the helpfiles<br />

are available. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T get keywords is processed completely exclusively without parallelization.<br />

T get chapter info<br />

T get operator info<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

T get operator name, T search operator, T get param info<br />

Image / region / XLD management<br />

Module<br />

T get operator info ( Htuple ProcName, Htuple Slot,<br />

Htuple *Information )<br />

Get information concerning a <strong>HALCON</strong>-procedure.<br />

With the help of the operator T get operator info the online-texts concerning a certain procedure can be<br />

called (see also T get operator name). The form of information available for all procedures (Slot) can be<br />

called using the operator T query operator info. For the time being the following slots are available:<br />

’short’: Short description of the procedure.<br />

’abstract’: Description of the procedure.<br />

’procedure class’: Name(s) of the chapter(s) in the procedure hierarchy (chapter, subchapter in the <strong>HALCON</strong><br />

manual).<br />

’functionality’: Functionality is equivalent to the object class to which the procedure can be assigned.<br />

’keywords’: Keywords of the procedure (optional).<br />

’example’: Example for the use of the procedure (optional). The operator ’example.LANGUAGE’ (LANGUAGE<br />

¾c,c++,smalltalk,trias) calls up examples for a certain language if available. If the language is not indicated<br />

or if no example is available in this language, the TRIAS-example will be returned.<br />

<strong>HALCON</strong> 6.0


590 CHAPTER 11. SYSTEM<br />

’complexity’: Complexity of the procedure (optional).<br />

’effect’: Not in use so far.<br />

’alternatives’: Alternative procedures (optional).<br />

’see also’: Procedures containing further information (optional).<br />

’predecessor’: Possible and sensible predecessor<br />

’successor’: Possible and sensible successor<br />

’result state’: Return value of the procedure (TRUE, FALSE, FAIL, VOID or EXCEPTION).<br />

’attention’: Restrictions and advice concering the correct use of the procedure (optional).<br />

’parameter’: Names of the parameter of the procedure (see also T get param info).<br />

’references’: Literary references (optional).<br />

’module’: The module to which the operator is assigned.<br />

’html path’: The directory where the HTML documentation of the operator resides.<br />

’parameter relations’: Assurances concerning the parameters (optional).<br />

The texts will be taken from the files english.hlp, english.sta, english.key, english.num und english.idx which will<br />

be searched by <strong>HALCON</strong> in the currently used directory or in the directory ’help dir’ (respectively ’user help dir’)<br />

(see also (T )get system and (T )set system). By adding ’.latex’ after the slotname, the text of slots<br />

containing textual information can be made available in L A TEX notation.<br />

Parameter<br />

º ProcName (input control) .........................................proc name Htuple . const char *<br />

Name of the procedure on which more information is needed.<br />

Default Value : ’get operator info’<br />

º Slot (input control) ....................................................string Htuple . const char *<br />

Desired information.<br />

Default Value : ’abstract’<br />

Value List : Slot ¾’short’, ’abstract’, ’procedure class’, ’functionality’, ’effect’, ’complexity’,<br />

’predecessor’, ’successor’, ’alternatives’, ’see also’, ’keywords’, ’example’, ’attention’, ’result state’,<br />

’return value’, ’references’, ’sourcefiles’, ’deffile’, ’module’, ’html path’<br />

º Information (output control) .........................................string-array Htuple . char *<br />

Information (empty if no information is available)<br />

Result<br />

The operator T get operator info returns the value H MSG TRUE if the parameters are correct and the<br />

helpfiles are availabe. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T get operator info is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

T get keywords, T search operator, T get operator name, T query operator info,<br />

T query param info, T get param info<br />

Possible Successor Functions<br />

T get param names, get param num, T get param types<br />

T get param names<br />

Alternatives<br />

See Also<br />

T query operator info, T get param info, T get operator name, get param num,<br />

T get param types<br />

Module<br />

Image / region / XLD management<br />

T get operator name ( Htuple Pattern, Htuple *ProcNames )<br />

Get procedures with the given string as a substring of their name.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.3. INFORMATION 591<br />

The operator T get operator name takes a string (Pattern) as input and searches all <strong>HALCON</strong>-procedures<br />

having this string as a substring in their name. If an empty string is entered, the names of all procedures available<br />

will be returned.<br />

Parameter<br />

º Pattern (input control) ...............................................string Htuple . const char *<br />

Substring of the seeked names (empty all names).<br />

Default Value : ’info’<br />

º ProcNames (output control) ............................................string-array Htuple . char *<br />

Detected procedure names.<br />

Result<br />

The operator T get operator name returns the value H MSG TRUE if the helpfiles are available. Otherwise<br />

an exception handling is raised.<br />

Parallelization Information<br />

T get operator name is reentrant, local, and processed without parallelization.<br />

Possible Successor Functions<br />

T get operator info, T get param names, get param num, T get param types<br />

T search operator<br />

Alternatives<br />

See Also<br />

T get operator info, T get param names, get param num, T get param types<br />

Image / region / XLD management<br />

Module<br />

T get param info ( Htuple ProcName, Htuple ParamName, Htuple Slot,<br />

Htuple *Information )<br />

Get information concerning the procedure parameters.<br />

The operator T get param info is used for calling up the online-texts assigned to a parameter of an indicated<br />

procedure. The form of information available for each parameter (Slot), can be called up by using the operator<br />

T query param info. At the moment the following slots are available:<br />

’description’: Description of the parameter.<br />

’description.latex’: Description of the parameter in L A TEX notation.<br />

’parameter class’: Parameter classes: ’input object’, ’output object’, ’input control’ oder ’output control’.<br />

’type list’: Permitted type(s) of data for parameter values (for control parameters only). Value: ’real’, ’integer’<br />

oder ’string’.<br />

’default type’: Default-type for parameter values (for control parameters only). This type of parameter is the one<br />

<strong>HALCON</strong>/C uses in the ”‘simple mode”’. If ’none’ is indicated, the ”‘tuple mode”’ must be used. Value:<br />

’real’, ’integer’, ’string’ oder ’none’.<br />

’sem type’: Semantic type of the parameter. This is important to allow the assignment of the parameters to object<br />

classes in object-oriented languages (C++, Smalltalk). If more than one parameter belongs semantically to<br />

one type, this fact is indicated as well. So far the the following objects are supported:<br />

object, image, region, xld,<br />

xld cont, xld para, xld poly, xld ext para, xld mod para,<br />

integer, real, number, string,<br />

channel, grayval, window,<br />

histogram, distribution,<br />

point(.x, .y), extent(.x, .y),<br />

angle(.rad oder .deg),<br />

circle(.center.x, .center.y, .radius),<br />

arc(.center.x, .center.y, .angle.rad, .begin.x, .begin.y),<br />

ellipse(.center.x, .center.y, .angle.rad, .radius1, .radius2),<br />

line(.begin.x, .begin.y, .end.x, .end.y)<br />

<strong>HALCON</strong> 6.0


592 CHAPTER 11. SYSTEM<br />

rectangle(.origin.x, .origin.y, .corner.x, .corner.y<br />

bzw. .extent.x, .extent.y),<br />

polygon(.x, .y), contour(.x, .y),<br />

coordinates(.x, .y), chord(.x1, .x2, .y),<br />

chain(.begin.x, .begin.y, .code).<br />

’default value’: Default-value for the parameter (for input-control parameters only). It is the question of mere<br />

information only (the parameter value must be transmitted explicitly, even if the default-value is used). This<br />

entry serves only as a notice, a point of departure for own experiments. The values have been selected so that<br />

they normally do not cause any errors but generate something that makes sense.<br />

’multi value’: ’true’, if more than one value is permitted in this parameter position, otherwise ’false’.<br />

’multichannel’: ’true’, in case the input image object may be multichannel.<br />

’mixed type’: For control parameters exclusively and only if value tuples (’multivalue’-’true’) and various types<br />

of data are permitted for the parameter values (’type list’ having more than one value). In this case Slot<br />

indicates, whether values of various types may be mixed in one tuple (’true’ or ’false’).<br />

’values’: Selection of values (optional).<br />

’value list’: In case a parameter can take only a limited number of values, this fact will be indicated explicitly<br />

(optional).<br />

’valuemin’: Minimum value of a value interval.<br />

’valuemax’: Maximum value of a value interval.<br />

’valuefunction’: Function discribing the course of the values for a series of tests (lin, log, quadr, ...).<br />

’steprec’: Recommended step width for the parameter values in a series of tests.<br />

’steprec’: Minimum step width of the parameter values in a series of tests.<br />

’valuenumber’: Expression describing the number of parameters as such or in relation to other parameters.<br />

’assertion’: Expression describing the parameter values as such or in relation to other parameters.<br />

The online-texts will be taken from the files english.hlp, english.sta, english.key, english.num and english.idx<br />

which will be searched by <strong>HALCON</strong> in the currently used directory or the directory ’help dir’ (see also<br />

(T )get system and (T )set system).<br />

Parameter<br />

º ProcName (input control) .........................................proc name Htuple . const char *<br />

Name of the procedure on whose parameter more information is needed.<br />

Default Value : ’get param info’<br />

º ParamName (input control) .............................................string Htuple . const char *<br />

Name of the parameter on which more information is needed.<br />

Default Value : ’Slot’<br />

º Slot (input control) ....................................................string Htuple . const char *<br />

Desired information.<br />

Default Value : ’description’<br />

Value List : Slot ¾’description’, ’type list’, ’default type’, ’sem type’, ’default value’, ’values’,<br />

’value list’, ’valuemin’, ’valuemax’, ’valuefunction’, ’valuenumber’, ’assertion’, ’steprec’, ’stepmin’,<br />

’mixed type’, ’multivalue’, ’multichannel’<br />

º Information (output control) .........................................string-array Htuple . char *<br />

Information (empty in case there is no information available).<br />

Result<br />

The operator T get param info returns the value H MSG TRUE if the parameters are correct and the helpfiles<br />

are available. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T get param info is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

T get keywords, T search operator<br />

Alternatives<br />

T get param names, get param num, T get param types<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.3. INFORMATION 593<br />

See Also<br />

T query param info, T get operator info, T get operator name<br />

Image / region / XLD management<br />

Module<br />

T get param names ( Htuple ProcName, Htuple *InpObjPar,<br />

Htuple *OutpObjPar, Htuple *InpCtrlPar, Htuple *OutpCtrlPar )<br />

Get the names of the parameters of a <strong>HALCON</strong>-procedure.<br />

For the <strong>HALCON</strong>-procedure indicated in ProcName the operator T get param names returns the names of<br />

the input objects, the output objects, of the input control parameters and the output control parameters.<br />

Parameter<br />

º ProcName (input control) .........................................proc name Htuple . const char *<br />

Name of the procedure.<br />

Default Value : ’get param names’<br />

º InpObjPar (output control) ............................................string-array Htuple . char *<br />

Names of the input objects.<br />

º OutpObjPar (output control) ..........................................string-array Htuple . char *<br />

Names of the output objects.<br />

º InpCtrlPar (output control) ..........................................string-array Htuple . char *<br />

Names of the input control parameters.<br />

º OutpCtrlPar (output control) .........................................string-array Htuple . char *<br />

Names of the output control parameters.<br />

Result<br />

The operator T get param names returns the value H MSG TRUE if the name of the procedure exists and the<br />

helpfiles are available. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T get param names is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T get keywords, T search operator, T get operator name, T get operator info<br />

Possible Successor Functions<br />

get param num, T get param types<br />

Alternatives<br />

T get operator info, T get param info<br />

See Also<br />

get param num, T get param types, T get operator name<br />

Image / region / XLD management<br />

Module<br />

get param num ( const char *ProcName, char *CName, long *InpObjPar,<br />

long *OutpObjPar, long *InpCtrlPar, long *OutpCtrlPar, char *Type )<br />

Get number of the different parameter classes of a <strong>HALCON</strong>-procedure.<br />

The operator get param num returns the number of the input and output object parameters, as well as the input<br />

and output control parameters for the indicated <strong>HALCON</strong>-procedure. Further, you will receive the name of the<br />

C-function (CName) called by the procedure. The output parameter Type indicates, whether the procedure is a<br />

system procedure or an user procedure.<br />

<strong>HALCON</strong> 6.0


594 CHAPTER 11. SYSTEM<br />

Parameter<br />

º ProcName (input control)..................................................proc name const char *<br />

Name of the procedure.<br />

Default Value : ’get param num’<br />

º CName (output control) ..............................................................string char *<br />

Name of the called C-function.<br />

º InpObjPar (output control) ........................................................integer long *<br />

Number of the input object parameters.<br />

º OutpObjPar (output control) ......................................................integer long *<br />

Number of the output object parameters.<br />

º InpCtrlPar (output control) ......................................................integer long *<br />

Number of the input control parameters.<br />

º OutpCtrlPar (output control) .....................................................integer long *<br />

Number of the output control parameters.<br />

º Type (output control) ................................................................string char *<br />

System procedure or user procedure.<br />

Value Suggestions : Type ¾’system’, ’user’<br />

Result<br />

The operator get param num returns the value H MSG TRUE if the name of the procedure exists. Otherwise<br />

an exception handling is raised.<br />

Parallelization Information<br />

get param num is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T get keywords, T search operator, T get operator name, T get operator info<br />

T get param types<br />

Possible Successor Functions<br />

Alternatives<br />

T get operator info, T get param info<br />

See Also<br />

T get param names, T get param types, T get operator name<br />

Image / region / XLD management<br />

Module<br />

T get param types ( Htuple ProcName, Htuple *InpCtrlParType,<br />

Htuple *OutpCtrlParType )<br />

Get default data type for the control parameters of a <strong>HALCON</strong>-procedure.<br />

The operator T get param types returns the default data type for each input and output control parameter.<br />

The default type of a parameter is the type used in ”‘simple mode”’ in <strong>HALCON</strong>/C. This concerns parameters<br />

which allow more than one type as for example write string. Hereby the types of input parameters are<br />

combined in the variable InpCtrlParType, whereas the types of output parameters are combined in the variable<br />

OutpCtrlParType. The following types are possible:<br />

’integer’: an integer.<br />

’integer tuple’: an integer or a tuple of integers.<br />

’real’: a floating point number.<br />

’real tuple’: a floating point number or a tuple of floating point numbers.<br />

’string’: a string.<br />

’string tuple’: a string or a tuple of strings.<br />

’no default’: individual value of which the type cannot be determined.<br />

’no default tuple’: individual value or tuple of values of which the type cannot be determined.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.3. INFORMATION 595<br />

’default’: individual value of unknown type, whereby the systems assumes it to be an ’integer’.<br />

Parameter<br />

º ProcName (input control) .........................................proc name Htuple . const char *<br />

Name of the procedure.<br />

Default Value : ’get param types’<br />

º InpCtrlParType (output control) .....................................string-array Htuple . char *<br />

Default type of the input control parameters.<br />

º OutpCtrlParType (output control) ...................................string-array Htuple . char *<br />

Default type of the output control parameters.<br />

Result<br />

The operator T get param types returns the value H MSG TRUE if the indicated procedure name exists.<br />

Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T get param types is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T get keywords, T search operator, T get operator name, T get operator info<br />

T get param info<br />

Alternatives<br />

See Also<br />

T get param names, get param num, T get operator info, T get operator name<br />

Image / region / XLD management<br />

Module<br />

T query operator info ( Htuple *Slots )<br />

Query slots concerning information with relation to the operator T get operator info.<br />

The operator T query operator info returns the names of those online texts (Slots) which are available<br />

online for each procedure. The information itself can be called up using<br />

T get operator info(,).<br />

Parameter<br />

º Slots (output control) .................................................string-array Htuple . char *<br />

Slotnames of the operator T get operator info.<br />

Result<br />

The operator T query operator info always returns the value H MSG TRUE.<br />

Parallelization Information<br />

T query operator info is local and processed completely exclusively without parallelization.<br />

T get operator info<br />

T get operator info<br />

Image / region / XLD management<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

T query param info ( Htuple *Slots )<br />

Query slots of the online-information concerning the operator T get param info.<br />

The operator T query param info returns the names of those pieces of information (Slots) which are available<br />

online for each parameter (online texts). The online texts themselves can be called up using<br />

T get param info(,,).<br />

<strong>HALCON</strong> 6.0


596 CHAPTER 11. SYSTEM<br />

Parameter<br />

º Slots (output control) .................................................string-array Htuple . char *<br />

Slotnames for the operator T get param info.<br />

Result<br />

T query param info always returns the value H MSG TRUE.<br />

Parallelization Information<br />

T query param info is reentrant, local, and processed without parallelization.<br />

T get param info<br />

T get param info<br />

Image / region / XLD management<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

T search operator ( Htuple Keyword, Htuple *ProcNames )<br />

Search names of all procedures assigned to one keyword.<br />

The operator T search operator returns the names of all procedures whose online-texts include the keyword<br />

Keyword (see also T get operator info). All available keywords are called by using the operator<br />

T get keywords(’’ ). The online-texts are taken from the files english.hlp, english.sta, english.key,<br />

english.num and Halcon.idx, which are searched by <strong>HALCON</strong> in the currently used directory or the<br />

directory ’help dir’ (see also (T )get system and (T )get system).<br />

Parameter<br />

º Keyword (input control) ...............................................string Htuple . const char *<br />

Keyword for which corresponding procedures are searched.<br />

Default Value : ’Information’<br />

º ProcNames (output control) ............................................string-array Htuple . char *<br />

Procedures whose slot ’keyword’ contains the keyword.<br />

Result<br />

The operator T search operator returns the value H MSG TRUE if the parameters are correct and the helpfiles<br />

are available. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T search operator is processed completely exclusively without parallelization.<br />

T get keywords<br />

Possible Predecessor Functions<br />

See Also<br />

T get keywords, T get operator info, T get param info<br />

Image / region / XLD management<br />

Module<br />

11.4 Operating-System<br />

count seconds ( double *Seconds )<br />

Elapsed processing time since the last call of count seconds.<br />

The operator count seconds helps to measure the runtime. The first call of the procedure normally returns a<br />

zero. Each further call returns the processing time which has elapsed in the meantime in seconds. The C-function<br />

”‘clock’” is used for the measurement.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.4. OPERATING-SYSTEM 597<br />

Attention<br />

The time measurement is not exact and depends on the load of the computer.<br />

Parameter<br />

º Seconds (output control) ...........................................................real double *<br />

Processtime since the program start.<br />

Example<br />

count_seconds(&Start);<br />

/* aktion to be measured */<br />

count_seconds(&End);<br />

printf("RunTime = %g\n",End-Start);<br />

Result<br />

The operator count seconds always returns the value H MSG TRUE.<br />

Parallelization Information<br />

count seconds is reentrant and processed without parallelization.<br />

System<br />

Module<br />

system call ( const char *Command )<br />

Executes a system command.<br />

The operator system call executes the system command specified by the string pointed to by Command (Cprocedure<br />

”‘system”’). If the string is empty, an interactive shell will be started (’csh -i’).<br />

Parameter<br />

º Command (input control) .......................................................string const char *<br />

Command to be called by the system.<br />

Default Value : ’ls’<br />

Result<br />

If the entered operator can be executed by the system, the operator system call returns the value<br />

H MSG TRUE. Otherwise an exception will be raised.<br />

Parallelization Information<br />

system call is reentrant and processed without parallelization.<br />

count seconds<br />

wait seconds, count seconds<br />

System<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

wait seconds ( double Seconds )<br />

Delaying the execution of the program.<br />

The operator wait seconds delays the execution by the number of seconds indicated in Seconds.<br />

Parameter<br />

º Seconds (input control) ..............................................................real double<br />

Number of seconds by which the execution of the program will be delayed.<br />

Default Value : 10<br />

Restriction : Seconds 0<br />

<strong>HALCON</strong> 6.0


598 CHAPTER 11. SYSTEM<br />

Result<br />

The operator wait seconds always returns the value H MSG TRUE.<br />

Parallelization Information<br />

wait seconds is reentrant and processed without parallelization.<br />

system call<br />

system call, count seconds<br />

System<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

11.5 Parallelization<br />

check par hw potential ( long AllInpPars )<br />

Check hardware regarding its potential for parallel processing.<br />

check par hw potential is necessary for an efficient automatic parallelization, which is used by <strong>HALCON</strong><br />

to better utilize multiprocessor hardware in order to speed up the processing of operators. As the parallelization<br />

of operators is done automatically, there is no need for the user to explicitely prepare or change programs for<br />

their parallelization. Thus, all <strong>HALCON</strong>-based programs can be used unchanged on multiprocessor hardware and<br />

nevertheless utilize the potential of parallel hardware. check par hw potential checks a given hardware<br />

with respect to a parallel processing of <strong>HALCON</strong> operators. At this, it examines every operator, which can be<br />

sped up in principle by an automatic parallelization. Each examined operator is processed several times - both<br />

sequentially and in parallel - with a changing set of input parameter values/images. The latter helps to evaluate<br />

dependencies between an operator’s input parameter characteristics (e.g. the size of an input image) and the<br />

efficiency of its parallel processing. At this, AllInpPars is used in the following way: In the normal case,<br />

i.e. if AllInpPars contains the default value 0 (“false”), only those input parameters are examined which are<br />

supposed to show influence on the processing time. Other parameters are not examined so that the whole process is<br />

sped up. However, in some rare cases, the internal implementation of a <strong>HALCON</strong> operator might change from one<br />

<strong>HALCON</strong> release to another. Then, a parameter which did not show any direct influence on the processing time in<br />

former releases, may now show such an influence. In this case it is necessary to set AllInpPars to 1 (“true”) in<br />

order to force the examination of all input parameters. If this happens, the <strong>HALCON</strong> release notes will most likely<br />

contain an appropriate note about this fact. Overall, check par hw potential performs several test loops and<br />

collects a lot of hardware-specific informations, which enable <strong>HALCON</strong> to optimize the automatic parallelization<br />

for a given hardware. The hardware information is stored so that it can be used again in future <strong>HALCON</strong> sessions.<br />

Thus, it is sufficient, to start check par hw potential once on each multiprocessor machine that is used for<br />

parallel processing. Of course, it should be started again, if the hardware of the machine changes, for example,<br />

by installing a new cpu, or if the operating system of the machine changes, or if the machine gets a new host<br />

name. The latter is necessary, because <strong>HALCON</strong> identifies the machine-specific parallelization information by<br />

the machine’s host name. If the same multiprocessor machine is used with different operating systems, such<br />

as Windows and Linux, it is necessary to start check par hw potential once for each operating system<br />

in order to correctly measure the rather strong influence of the operating system on the potential of exploiting<br />

multiprocessor hardware. Under Windows, <strong>HALCON</strong> stores the parallelization knowledge, which belongs to a<br />

specific machine, in the machine’s registry. At this, it uses a machine-specific registry key, which can be used by<br />

different users simultaneously. In the normal case, this key can be written or changed by any user under Windows<br />

NT. However, under Windows 2000 the key may only be changed by users with administrator privileges or by<br />

users which at least belong to the “power user” group. For all other users check par hw potential shows<br />

no effect (but does not return an error). Under Linux/UNIX the parallelization information is stored in a file in the<br />

<strong>HALCON</strong> installation directory ($<strong>HALCON</strong>ROOT). Again this means that check par hw potential must<br />

be called by users with the appropriate privileges, here by users which have write access to the <strong>HALCON</strong> directory.<br />

If <strong>HALCON</strong> is used within a network under Linux/UNIX, the denoted file contains the information about every<br />

computer in the network for which the hardware check has been successfully completed.<br />

Attention<br />

During its test loops check par hw potential has to start every examined operator several times. Thus,<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.5. PARALLELIZATION 599<br />

the processing of check par hw potential can take rather a long time. check par hw potential<br />

bases on the automatic parallelization of operators which is exclusively supported by Parallel <strong>HALCON</strong>. Thus,<br />

check par hw potential always returns an appropriate error, if it used with a non-parallel <strong>HALCON</strong> version.<br />

check par hw potential must be called by users with the appropriate privileges for storing the parallelization<br />

information permanently (see the operator’s description above for more details about this subject).<br />

Parameter<br />

º AllInpPars (input control) .........................................................integer long<br />

Check every input parameter?<br />

Default Value : 0<br />

Value List : AllInpPars ¾0, 1<br />

Result<br />

check par hw potential returns H MSG TRUE if all parameters are correct.<br />

Parallelization Information<br />

check par hw potential is local and processed completely exclusively without parallelization.<br />

store par knowledge<br />

Possible Successor Functions<br />

See Also<br />

store par knowledge, load par knowledge<br />

System<br />

Module<br />

load par knowledge ( const char *FileName )<br />

Load knowledge about automatic parallelization from file.<br />

load par knowledge supports the automatic parallelization of <strong>HALCON</strong> operators, which is used to better utilize<br />

multiprocessor hardware in order to speed up the processing of operators. To parallelize the processing of operators<br />

automatically <strong>HALCON</strong> needs some specific knowledge about the used hardware. This hardware-specific<br />

knowledge can be obtained by using the operator check par hw potential. In the normal case, <strong>HALCON</strong><br />

stores this knowledge in a specific file in the <strong>HALCON</strong> installation directory (Linux/UNIX) or within the “registry”<br />

(Windows). This enables <strong>HALCON</strong> to use the knowledge again later on. With load par knowledge<br />

it is possible to load this knowledge explicitely from an ASCII file. At this, FileName denotes the name of<br />

this file (incl. path and file extension). The file must conform to a specific syntax and must have been stored<br />

beforehand by using store par knowledge. While reading the file load par knowledge checks whether<br />

its content was written for the currently used computer and whether the contained parallelization information regards<br />

the currently used <strong>HALCON</strong> version (and revision). If this is the case, load par knowledge adopts the<br />

information so that it will also be used with further <strong>HALCON</strong> sessions. Otherwise, the information is ignored and<br />

load par knowledge returns an appropriate error message.<br />

Parameter<br />

º FileName (input control) .............................................filename.named const char *<br />

Name of parallelization knowledge file.<br />

Default Value : ”<br />

Result<br />

load par knowledge returns H MSG TRUE if all parameters are correct.<br />

Parallelization Information<br />

load par knowledge is local and processed completely exclusively without parallelization.<br />

store par knowledge<br />

Possible Predecessor Functions<br />

See Also<br />

store par knowledge, check par hw potential<br />

System<br />

Module<br />

<strong>HALCON</strong> 6.0


600 CHAPTER 11. SYSTEM<br />

store par knowledge ( const char *FileName )<br />

Store knowledge about automatic parallelization in file.<br />

store par knowledge supports the automatic parallelization of <strong>HALCON</strong> operators, which is used to better<br />

utilize multiprocessor hardware in order to speed up the processing of operators. To parallelize the processing<br />

of operators automatically <strong>HALCON</strong> needs some specific knowledge about the used hardware. This hardwarespecific<br />

knowledge can be obtained by calling the operator check par hw potential. There, <strong>HALCON</strong><br />

stores the knowledge in a specific file in the <strong>HALCON</strong> installation directory (Linux/UNIX) or within the “registry”<br />

(Windows). This enables <strong>HALCON</strong> to use the knowledge again later on. With store par knowledge it is<br />

possible to store this knowledge explicitely as an ASCII file. At this, FileName denotes the name of this file (incl.<br />

path and file extension). The stored knowledge can be read again later on by using load par knowledge.<br />

Parameter<br />

º FileName (input control) .............................................filename.named const char *<br />

Name of parallelization knowledge file.<br />

Default Value : ”<br />

Result<br />

store par knowledge returns H MSG TRUE if all parameters are correct.<br />

Parallelization Information<br />

store par knowledge is local and processed completely exclusively without parallelization.<br />

check par hw potential<br />

load par knowledge<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

load par knowledge, check par hw potential<br />

System<br />

Module<br />

11.6 Parameters<br />

get system ( const char *Query, long *Information )<br />

T get system ( Htuple Query, Htuple *Information )<br />

Information concerning the currently used <strong>HALCON</strong> system parameter.<br />

The operator (T )get system returns information concerning the currently activated <strong>HALCON</strong> system parameters.<br />

Some of these parameters can be changed dynamically by using the operator (T )set system. They<br />

are marked by a + in the list below. By passing the string ’?’ as the parameter Query, the names of all system<br />

parameters are provided with Information.<br />

The following system parameters can be queried:<br />

Versions<br />

’version’: <strong>HALCON</strong> version number, e.g.: 6.0<br />

’last update’: Date of creation of the <strong>HALCON</strong> library<br />

’revision’: Revision number of the <strong>HALCON</strong> library, e.g.: 1<br />

Upper Limits<br />

’max contour length’: Maximum number of contour respectively polygone control points of a region.<br />

’max images’: Maximum total of images.<br />

’max channels’: Maximum number of channels of an image.<br />

’max obj per par’: Maximum number of image objects which may be used during one call up per parameter<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.6. PARAMETERS 601<br />

’max inp obj par’: Maximum number of input parameters.<br />

’max outp obj par’: Maximum number of output parameters.<br />

’max inp ctrl par’: Maximum number of input control parameters.<br />

’max outp ctrl par’: Maximum number of output control parameters.<br />

’max window’: Maximum number of windows.<br />

’max window types’: Maximum number of window systems.<br />

’max proc’: Maximum number of <strong>HALCON</strong> procedures (system defined + user defined).<br />

Graphic<br />

+’flush graphic’: Determines, whether the flush operation is called or not after each <strong>HALCON</strong> procedure.<br />

+’int2 bits’: Number of significant bits of int2 images. This number is used when scaling the gray values.<br />

If the values is -1 the gray values will be automatically scaled (default).<br />

+’int zooming’: Determines if the zooming of images is done with integer arithmetic or with floating point<br />

arithmetic.<br />

+’draw mode’: (no description available)<br />

+’ignore colormap’: (no description available)<br />

+’backing store’: Storage of the window contents in case of overlaps.<br />

+’icon name’: (no description available)<br />

+’window name’: (no description available)<br />

+’default font’: Name of the font to set at opening the window.<br />

+’single lut’: (no description available)<br />

+’update lut’: (no description available)<br />

+’x package’: Number of bytes which are sent to the X server during each transfer of data.<br />

+’num gray 4’: Number of colors reserved under X Xindows concerning the output of graylevels<br />

(disp channel) on a machine with 4 bitplanes (16 colors).<br />

+’num gray 6’: Number of colors reserved under X Window concerning the output of graylevels<br />

(disp channel) on a machine with 6 bitplanes (64 colors).<br />

+’num gray 8’: Number of colors reserved under X Window concerning the output of graylevels<br />

(disp channel) on a machine with 8 bitplanes (256 colors).<br />

+’num gray percentage’: <strong>HALCON</strong> reserves a certain amount of the available colors under X Window<br />

for the representation of graylevels (disp image). This shall interfere with other X applications<br />

as little as possible. However, if <strong>HALCON</strong> does not succeed in reserving a miminum percentage of<br />

’num gray percentage’ of the necessary colors on the X server, a certain amount of the lookup-table will<br />

be claimed for the <strong>HALCON</strong> graylevels regardless of the consequences for other applications.<br />

This may result in undesired shifts of color when switching between <strong>HALCON</strong> windows and windows<br />

of other applications, or if (outside <strong>HALCON</strong>) a window-dump is generated. The number of the real<br />

graylevels to be reserved depends on the number of available bitplanes on the outputmachine (see also<br />

’num gray *’. Naturally no colors will be reserved on monochrome machines - the graylevels will<br />

instead be dithered when displayed. If graylevel displays are used, only different shades of gray will be<br />

applied (’black’, ’white’, ’gray’, etc.). Machines with 2 or 3 bitplanes will be considered monochrome<br />

machines, machines with 5 (7) bitplanes like machines with 4 (6) bitplanes, and machines having more<br />

than 8 bitplanes like machines with 8 bitplanes. A special case are machines providing a 24 bit display<br />

(true color machines). Naturally no colors are reserved for the display of graylevels in this case.<br />

Note: Before the first window on a machine with x bitplanes is opened, num gray x indicates the number<br />

of colors which have to be reserved for the display of graylevels, afterwards, however, it will indicate<br />

the number of colors which actually have been reserved.<br />

+’num graphic percentage’: (no description available)<br />

+’num graphic 2’: Number of the <strong>HALCON</strong> graphic colors reserved under X Window (for disp region<br />

etc.) on a machine with 2 bitplanes (4 colors).<br />

+’num graphic 4’: Number of the <strong>HALCON</strong> graphic colors reserved under X Window (for disp region<br />

etc.) on a machine with 4 bitplanes (16 colors).<br />

+’num graphic 6’: Number of the <strong>HALCON</strong> graphic colors reserved under X Window (for disp region<br />

etc.) on a machine with 6 bitplanes (64 colors).<br />

+’num graphic 8’: Number of the <strong>HALCON</strong> graphic colors reserved under X Window (for disp region<br />

etc.) on a machine with 8 bitplanes (256 colors).<br />

<strong>HALCON</strong> 6.0


602 CHAPTER 11. SYSTEM<br />

Image Processing<br />

+’neighborhood’: Using the 4 or 8 neighborhood.<br />

+’only lines’: (no description available)<br />

+’init new image’: Initialization of images before applying grayvalue transformations.<br />

+’no object result’: Behavior for an empty object lists.<br />

+’empty region result’: Reaction of procedures concerning input objects with empty regions which<br />

actually are not useful for such objects (e.g. certain region features, segmentation, etc.). Possible return<br />

values:<br />

’true’: the error will be ignored if possible<br />

’false’: the procedure returns FALSE<br />

’fail’: the procedure returns FAIL<br />

’void’: the procedure returns VOID<br />

’exception’: an exception is raised<br />

+’store empty region’: Storing of objects with empty regions.<br />

+’clip region’: Clipping of output regions so that they fit the global image size.<br />

’width’: Global maximum image width - in Standard-<strong>HALCON</strong> this value contains the maximum image<br />

width of all <strong>HALCON</strong> image objects which are currently stored in memory. In Parallel <strong>HALCON</strong><br />

this value contains the maximum image width of all <strong>HALCON</strong> image objects which are or were in<br />

memory since the start of the current <strong>HALCON</strong> session (this also includes objects which may be deleted<br />

meanwhile).<br />

’height’: Global maximum image height - in Standard-<strong>HALCON</strong> this value contains the maximum image<br />

height of all <strong>HALCON</strong> image objects which are currently stored in memory. In Parallel <strong>HALCON</strong><br />

this value contains the maximum image height of all <strong>HALCON</strong> image objects which are or were in<br />

memory since the start of the current <strong>HALCON</strong> session (this also includes objects which may be deleted<br />

meanwhile).<br />

’obj images’: Current number of grayvalue components per image object.<br />

+’current runlength number’: Currently used number of chords which can be used for the encoding of<br />

regions.<br />

Parallelization<br />

+’parallelize operators’: Determines whether Parallel <strong>HALCON</strong> uses an automatic parallelization to speed<br />

up the processing of operators on multiprocessor machines.<br />

+’reentrant’: Denotes whether Parallel <strong>HALCON</strong> currently supports reentrancy (default case), or whether<br />

this feature has been switched off. Reentrancy is necessary for the automatic parallelization of Parallel<br />

<strong>HALCON</strong> and for calling and processing multiple <strong>HALCON</strong> operators in parallel within multithreaded<br />

applications.<br />

’processor num’: Returns the number of processors which Parallel <strong>HALCON</strong> has found on the hardware it<br />

is running on. This also indicates the number of processors which is used by Parallel <strong>HALCON</strong> for the<br />

automatic parallelization of operators.<br />

File<br />

+’flush file’: Buffering of file output.<br />

Directories<br />

+’image dir’: Path which will searched for the image file after the default directory (see also:<br />

read image).<br />

+’lut dir’: Path for the default directory for color tables (see also: set lut).<br />

+’reference dir’: Path for the default directory concerning the postscript <strong>HALCON</strong> documentation.<br />

+’help dir’: Path for the default help directory for the online help files:<br />

german,english.hlp,sta,idx,num,key.<br />

Other<br />

+’do low error’: Flag, if low level error should be printed.<br />

’num proc’: Total number of the available <strong>HALCON</strong> procedures (’num sys proc’ + ’num user proc’).<br />

’num sys proc’: Number of the system procedures (supported procedures).<br />

’num user proc’: Number of the user defined procedures (see also ’Extension Packages’ manual).<br />

’byte order’: Byte order of the processor (’msb first’ or ’lsb first’).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.6. PARAMETERS 603<br />

’operating system’: Name of the operating system of the computer on which the <strong>HALCON</strong>process is being<br />

executed.<br />

’operating system version’: Version number of the operating system of the computer on which the HAL-<br />

CON process is being executed.<br />

+’alloctmp single block’: Flag for kind of temporary memory management.<br />

’temp mem’: Amount of temporary memory used by the last operator. This feature is only supported by<br />

Standard-<strong>HALCON</strong>. Instead of this, Parallel <strong>HALCON</strong> returns the amount of temporary memory used<br />

by (T )get system itself.<br />

+’language’: Language used for error messages (’english’ or ’german’).<br />

Parameter<br />

º Query (input control) ..........................................string(-array) (Htuple .) const char *<br />

Desired system parameter.<br />

Default Value : ’width’<br />

Value List : Query ¾”?”, ’version’, ’last update’, ’revision’, ’max images’, ’max channels’,<br />

’max obj per par’, ’max inp obj par’, ’max outp obj par’, ’max inp ctrl par’, ’max outp ctrl par’,<br />

’max window’, ’max window types’, ’max proc’, ’flush graphic’, ’int2 bits’, ’int zooming’, ’draw mode’,<br />

’ignore colormap’, ’backing store’, ’icon name’, ’window name’, ’default font’, ’single lut’, ’update lut’,<br />

’x package’, ’num gray 4’, ’num gray 6’, ’num gray 8’, ’num gray percentage’, ’num graphic 2’,<br />

’num graphic 4’, ’num graphic 6’, ’num graphic 8’, ’num graphic percentage’, ’neighborhood’,<br />

’only lines’, ’init new image’, ’no object result’, ’empty region result’, ’store empty region’, ’clip region’,<br />

’width’, ’height’, ’obj images’, ’current runlength number’, ’flush file’, ’image dir’, ’lut dir’, ’reference dir’,<br />

’help dir’, ’num proc’, ’num sys proc’, ’num user proc’, ’temp mem’, ’alloctmp single block’,<br />

’do low error’, ’reentrant’, ’parallelize operators’, ’processor num’, ’byte order’, ’operating system’,<br />

’operating system version’, ’language’<br />

º Information (output control) . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long * / double * / char *<br />

Current value of the system parameter.<br />

Result<br />

The operator (T )get system returns the value H MSG TRUE if the parameters are correct. Otherwise an<br />

exception is raised.<br />

Parallelization Information<br />

(T )get system is local and processed completely exclusively without parallelization.<br />

reset obj db<br />

(T )set system<br />

(T )set system<br />

System<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

set system ( const char *Systemparameter, const char *Value )<br />

T set system ( Htuple Systemparameter, Htuple Value )<br />

Setting of <strong>HALCON</strong> system parameters.<br />

The operator (T )set system allows to change different system parameters with relation to the runlength.<br />

Available system parameters:<br />

’neighborhood’: This parameter is used with all procedures which examine neighborhood relations:<br />

connection, get region contour, get region chain, get region polygon,<br />

get region thickness, boundary, paint region, disp region, fill up, contlength,<br />

shape histo all.<br />

<strong>HALCON</strong> 6.0


604 CHAPTER 11. SYSTEM<br />

Value: 4or8<br />

default: 8<br />

’default font’: Whenever a window is opened, a font will be set for the text output, whereby the ’default font’<br />

will be used. If the preset font cannot be found, another fontname can be set before opening the window.<br />

Value: Filename of the fonts<br />

default: fixed<br />

’single lut’: (no description available) default: ’false’<br />

’update lut’ Determines whether the <strong>HALCON</strong> color tables are adapted according to their environment or not.<br />

Value: ’true’ or ’false’<br />

default: ’false’<br />

’image dir’: Image files (e.g. read image and read sequence) will be looked for in the currently used<br />

directory and in ’image dir’ (if no absolute paths are indicated). More than one directory name can be<br />

indicated (searchpaths), seperated by semicolons (Windows NT) or colons (Unix). The path can also be<br />

determined using the environment variable <strong>HALCON</strong>IMAGES.<br />

Value: Name of the filepath<br />

default: ’$<strong>HALCON</strong>ROOT/images’ bzw. ’%<strong>HALCON</strong>ROOT%/images’<br />

’lut dir’: Color tables (set lut) which are realized as an ASCII-file will be looked for in the currently used<br />

directory and in ’lut dir’ (if no absolute paths are indicated). If <strong>HALCON</strong>ROOT is set, <strong>HALCON</strong> will search<br />

the color tables in the sub-directory ”‘lut”’.<br />

Value: Name of the filepath<br />

default: ’$<strong>HALCON</strong>ROOT/lut’ bzw. ’%<strong>HALCON</strong>ROOT%/lut’<br />

’reference dir’: The HTML and postscript sources of the <strong>HALCON</strong> documentation (especially the <strong>HALCON</strong><br />

manual itself) will be looked for in the currently used directory or in ’reference dir’. This system parameter<br />

is necessary for example using the operator disp info. This parameter can also be set by the environment<br />

variable <strong>HALCON</strong>ROOT before initializing <strong>HALCON</strong>. In this case the variable must indicate the directory<br />

above the help directories (that is the <strong>HALCON</strong>-Homedirectory): e.g.: ’/usr/local/halcon’<br />

Value: Name of the filepath<br />

default: ’$<strong>HALCON</strong>ROOT/doc/ps/reference/c’ bzw. ’%<strong>HALCON</strong>ROOT%/doc/ps/reference/c’<br />

’help dir’: The online text files german or english.hlp, .sta, .key .num and .idx will be looked for in the currently<br />

used directory or in ’help dir’. This system parameter is necessary for instance using the operators<br />

T get operator info and T get param info. This parameter can also be set by the environment<br />

variable <strong>HALCON</strong>ROOT before initializing <strong>HALCON</strong>. In this case the variable must indicate the directory<br />

above the helpdirectories (that is the <strong>HALCON</strong>-Homedirectory): e.g.: ’/usr/local/halcon’<br />

Value: Name of the filepath<br />

default: ’$<strong>HALCON</strong>ROOT/help’ bzw. ’%<strong>HALCON</strong>ROOT%/help’<br />

’only lines’: (no description available) default: ’true’<br />

’init new image’: Determines whether new images shall be set to 0 before using filters. This is not necessary if<br />

always the whole image is filtered of if the data of not filtered image areas are unimportant.<br />

Value: ’true’ or ’false’<br />

default: ’true’<br />

’no object result’: Determines how operations processing iconic objects shall react if the object tuplet is empty<br />

(= no objects). Available values for Value:<br />

’true’: the error will be ignored<br />

’false’: the procedure returns FALSE<br />

’fail’: the procedure returns FAIL<br />

’void’: the procedure returns VOID<br />

’exception’: an exception is raised<br />

default: ’true’<br />

’empty region result’: Controls the reaction of procedures concerning input objects with empty regions which<br />

actually are not useful for such objects (e.g. certain region features, segmentation, etc.). Available values for<br />

Value:<br />

’true’: the error will be ignored if possible<br />

’false’: the procedure returns FALSE<br />

’fail’: the procedure returns FAIL<br />

’void’: the procedure returns VOID<br />

’exception’: an exception is raised<br />

default: ’true’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.6. PARAMETERS 605<br />

’store empty region’: Quite a number of operations will lead to the creation of objects with an empty region (=<br />

no image points) (e.g. intersection,threshold, etc.). This parameter determines whether the object<br />

with an empty region will be returned as a result (’true’) or whether it will be ignored (’false’) that is no result<br />

will be returned.<br />

Value: ’true’ or ’false’<br />

default: ’true’<br />

’backing store’: Determines whether the window content will be refreshed in case of overlapping of the windows.<br />

Some implementations of X Window are faulty; in order to avoid these errors, the storing of contents<br />

can be deactivated. It may be recommendable in some cases to deactivate the security mechanism, if e.g.<br />

performance / memory is what matters.<br />

Value: true or false<br />

default: true<br />

’flush graphic’: After each <strong>HALCON</strong> procedure which creates a graphic output, a flush operation will be executed<br />

in order to display the data immediately on screen. This is not necessary with all programs (e.g. if<br />

everything is done with the help of the mouse). In this case ’flush graphic’ can be set to ’false’ to improve<br />

the runlength.<br />

Value: ’true’ or ’false’<br />

default: ’true’<br />

’flush file’: This parameter determines whether the output into a file (also to the terminal) shall be buffered or<br />

not. If the output is to be buffered, in general the data will be displayed on the terminal only after entering<br />

the operator fnew line.<br />

Value: ’true’ or ’false’<br />

default: ’true’<br />

’x package’: The output of image data via the network may cause errors owing to the heavy load on the computer<br />

or on the network. In order to avoid this, the data are transmitted in small packages. If the computer is used<br />

locally, these units can be enlarged at will. This can lead to a notably improved output performance.<br />

Value: package size (in bytes)<br />

default: 20480<br />

’int2 bits’: Number of significant bits of int2 images. This number is used when scaling the gray values. If the<br />

values is -1 the gray values will be automatically scaled (default).<br />

Value: -1 or 9..15<br />

default: -1<br />

’num gray 4’: Number of colors to be reserved under X Window to allow the output of graylevels disp channel<br />

on a machine with 4 bitplanes (16 colors).<br />

Attention! This value may only be changed before the first window has been opened on the machine.<br />

Value: 2-12<br />

default: 8<br />

’num gray 6’: Number of colors to be reserved under X Window to allow the output of graylevels disp channel<br />

on a machine with 6 bitplanes (64 colors).<br />

Attention! This value may only be changed before the first window has been opened on the machine.<br />

Value: 2-62<br />

default: 50<br />

’num gray 8’: Number of colors to be reserved under X Window to allow the output of graylevels disp channel<br />

on a machine with 8 bitplanes (256 colors).<br />

Attention! This value may only be changed before the first window has been opened on the machine.<br />

Value: 2 - 254<br />

default: 140<br />

’num gray percentage’: Under X Window <strong>HALCON</strong> reserves a part of the available colors for the representation<br />

of gray values (disp channel). This shall interfere with other X applications as little as possible.<br />

However, if <strong>HALCON</strong> does not succeed in reserving a miminum percentage of ’num gray percentage’ of<br />

the necessary colors on the X server, a certain amount of the lookup table will be claimed for the <strong>HALCON</strong><br />

graylevels regardless of the consequences. This may result in undesired shifts of color when switching between<br />

<strong>HALCON</strong> windows and windows of other applications, or (outside <strong>HALCON</strong>) if a window-dump is<br />

generated. The number of the real graylevels to be reserved depends on the number of available bitplanes on<br />

the outputmachine (see also ’num gray *’. Naturally no colors will be reserved on monochrome machines -<br />

the graylevels will instead be dithered when displayed. If graylevel-displays are used, only different shades<br />

<strong>HALCON</strong> 6.0


606 CHAPTER 11. SYSTEM<br />

of gray will be applied (’black’, ’white’, ’gray’, etc.). Machines with 2 or 3 bitplanes will be considered<br />

monochrome machines, machines with 5 (7) bitplanes like machines with 4 (6) bitplanes, and machines having<br />

more than 8 bitplanes like machines with 8 bitplanes. A special case are machines providing a 24 bit<br />

display (true color machines). Naturally no colors are reserved for the display of graylevels in this case.<br />

Note: This value may only be changed before the first window has been opened on the machine. For before<br />

opening the first window on a machine with x bitplanes, num gray x indicates the number of colors which<br />

have to be reserved for the display of graylevels, afterwards, however, it will indicate the number of colors<br />

which actually have been reserved.<br />

Value: 0 - 100<br />

default: 30<br />

’num graphic percentage’: (no description available) default: 60<br />

’draw mode’: (no description available) default: ’complement’<br />

’int zooming’: (no description available) default: ’true’<br />

’ignore colormap’: (no description available) default: ’false’<br />

’icon name’: (no description available) default: ’default’<br />

’num graphic 2’: Number of the graphic colors to be reserved by <strong>HALCON</strong> under X Window (concerning the<br />

operators disp region etc.) on a machine with 2 bitplanes (4 colors).<br />

Attention: This value may only be changed before the first window has been opened on the machine.<br />

Value: 0-2<br />

default: 2<br />

’num graphic 4’: Number of the graphic colors to be reserved by <strong>HALCON</strong> under X Window (concerning the<br />

operators disp region etc.) on a machine with 4 bitplanes (16 colors).<br />

Attention: This value may only be changed before the first window has been opened on the machine.<br />

Value: 0-14<br />

default: 5<br />

’num graphic 6’: Number of the graphic colors to be reserved by <strong>HALCON</strong> under X Window (concerning the<br />

operators disp region etc.) on a machine with 6 bitplanes (64 colors).<br />

Attention: This value may only be changed before the first window has been opened on the machine.<br />

Value: 0-62<br />

default: 10<br />

’num graphic 8’: Number of the graphic colors to be reserved by <strong>HALCON</strong> under X Window (concerning the<br />

operators disp region etc.) on a machine with 8 bitplanes (256 colors).<br />

Attention: This value may only be changed before the first window has been opened on the machine.<br />

Value: 0-64<br />

default: 20<br />

’graphic colors’ <strong>HALCON</strong> reserves the first num graphic x colors form this list of color names as graphic colors.<br />

As a default <strong>HALCON</strong> uses this same list which is also returned by using query all colors. However,<br />

the list can be changed individually: hereby a tuplet of color names will be returned as value. It is recommendable<br />

that such a tuplet always includes the colors ’black’ and ’white’, and optionally also ’red’, ’green’<br />

and ’blue’. If ’default’ is set as Value, <strong>HALCON</strong> returns to the initial setting. Note: On graylevel machines<br />

not the first x colors will be reserved, but the first x shades of gray from the list.<br />

Attention: This value may only be changed before the first window has been opened on the machine.<br />

Value: Tuplets of X Window color names<br />

default: see also query all colors<br />

’current runlength number’: Regions will be stored internally in a certain runlengthcode. This parameter can<br />

determine the maximum number of chords which may be used for representing a region. Please note that<br />

some procedures raise the number on their own if necessary.<br />

The value can be enlarged as well as reduced.<br />

Value: maximum number of chords<br />

default: 50000<br />

’clip region’: Determines whether the regions of iconic objects of the <strong>HALCON</strong> database will be clipped to<br />

the currently used image size or not. This is the case for example in procedures like gen circle,<br />

gen rectangle1 or dilation1.<br />

See also: reset obj db<br />

Value: ’true’ or ’false’<br />

default: ’true’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.6. PARAMETERS 607<br />

’do low error’ Determines whether the <strong>HALCON</strong> should print low level error or not.<br />

Value: ’true’ or ’false’<br />

default: ’false’<br />

’reentrant’ Determines whether <strong>HALCON</strong> must be reentrant for being used within a parallel programming environment<br />

(e.g. a multithreaded application). This parameter is only of importance for Parallel <strong>HALCON</strong>,<br />

which can process several operators concurrently. Thus, the parameter is ignored by the sequentially working<br />

<strong>HALCON</strong>-Version. If it is set to ’true’, Parallel <strong>HALCON</strong> internally uses synchronization mechanisms to<br />

protect shared data objects from concurrent accesses. Though this is inevitable with any effectively parallel<br />

working application, it may cause undesired overhead, if used within an application which works purely<br />

sequentially. The latter case can be signalled by setting ’reentrant’ to ’false’. This switches off all internal<br />

synchronization mechanisms and thus reduces overhead. Of course, Parallel <strong>HALCON</strong> then is no longer<br />

thread-safe, which causes another side-effect: Parallel <strong>HALCON</strong> will then no longer use the internal parallelization<br />

of operators, because this needs reentrancy. Setting ’reentrant’ to ’true’ resets Parallel <strong>HALCON</strong><br />

to its default state, i.e. it is reentrant (and thread-safe) and it uses the automatic parallelization to speed up<br />

the processing of operators on multiprocessor machines.<br />

Value: ’true’ or ’false’<br />

default: Parallel <strong>HALCON</strong>: ’true’, otherwise: ’false’<br />

’parallelize operators’ Determines whether Parallel <strong>HALCON</strong> uses an automatic parallelization to speed up the<br />

processing of operators on multiprocessor machines. This feature can be switched off by setting ’parallelize<br />

operators’ to ’false’. Even then Parallel <strong>HALCON</strong> will remain reentrant (and thread-safe), unless the<br />

parameter ’reentrant’ is changed via (T )set system accordingly. Changing ’parallelize operators’ can<br />

be helpful, for example, if <strong>HALCON</strong>-operators are called by a multithreaded application, which also does<br />

the scheduling and load-balancing of operators and data by itself. Then it may be undesired that <strong>HALCON</strong><br />

performs additional parallelization steps, which may disturb the application’s scheduling and load-balancing<br />

concepts. The parameter ’parallelize operators’ is only supported by Parallel <strong>HALCON</strong> and thus ignored by<br />

the sequentially working <strong>HALCON</strong>-Version.<br />

Value: ’true’ or ’false’<br />

default: Parallel <strong>HALCON</strong>: ’true’, otherwise: ’false’<br />

’alloctmp single block’ Kind of temporary memory management. Value: ’true’ or ’false’<br />

default: ’false’<br />

’language’ Language used for error messages. Value: ’english’ or ’german’. default: ’ english’<br />

Parameter<br />

º Systemparameter (input control) ............................string(-array) (Htuple .) const char *<br />

Name of the system parameter to be changed.<br />

Default Value : ’image dir’<br />

Value List : Systemparameter ¾’neighborhood’, ’default font’, ’single lut’, ’update lut’, ’image dir’,<br />

’lut dir’, ’reference dir’, ’help dir’, ’only lines’, ’init new image’, ’no object result’, ’empty region result’,<br />

’store empty region’, ’backing store’, ’flush graphic’, ’flush file’, ’x package’, ’int2 bits’, ’icon name’,<br />

’num gray 4’, ’num gray 6’, ’num gray 8’, ’num gray percentage’, ’num graphic 2’, ’num graphic 4’,<br />

’num graphic 6’, ’num graphic 8’, ’num graphic percentage’, ’draw mode’, ’int zooming’,<br />

’ignore colormap’, ’graphic colors’, ’current runlength number’, ’clip region’, ’update lut’, ’do low error’,<br />

’reentrant’, ’parallelize operators’, ’alloctmp single block’, ’language’<br />

º Value (input control) ............................string(-array) (Htuple .) const char * / long / double<br />

New value of the system parameter.<br />

Default Value : ’true’<br />

Value Suggestions : Value ¾’true’, ’false’, 0, 4, 8, 100, 140, 255<br />

Result<br />

The operator (T )set system returns the value H MSG TRUE if the parameters are correct. Otherwise an<br />

exception will be raised.<br />

Parallelization Information<br />

(T )set system is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

reset obj db, (T )get system, (T )set check<br />

(T )get system, (T )set check<br />

See Also<br />

<strong>HALCON</strong> 6.0


608 CHAPTER 11. SYSTEM<br />

System<br />

Module<br />

11.7 Serial<br />

clear serial ( long SerialHandle, const char *Channel )<br />

Clear the buffer of a serial connection.<br />

clear serial discards data written to the serial device referred to by SerialHandle, but not transmitted<br />

(Channel = ’output’), or data received, but not read (Channel = ’input’), or performs both these operations at<br />

once (Channel = ’in out’).<br />

Parameter<br />

º SerialHandle (input control) .....................................................serial id long<br />

Serial interface handle.<br />

º Channel (input control) .......................................................string const char *<br />

Buffer to be cleared.<br />

Default Value : ’input’<br />

Value List : Channel ¾’input’, ’output’, ’in out’<br />

Result<br />

If the parameters are correct and the buffers of the serial device could be cleared, the operator clear serial<br />

returns the value H MSG TRUE. Otherwise an exception is raised.<br />

Parallelization Information<br />

clear serial is reentrant and processed without parallelization.<br />

open serial<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

(T )read serial, (T )write serial<br />

(T )read serial<br />

System<br />

See Also<br />

Module<br />

close all serials ( )<br />

Close all serial devices.<br />

close all serials closes all serial devices that have been opened with open serial.<br />

Result<br />

close all serials returns always H MSG TRUE.<br />

Parallelization Information<br />

close all serials is reentrant and processed without parallelization.<br />

open serial<br />

close serial<br />

open serial, close file<br />

System<br />

Possible Predecessor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.7. SERIAL 609<br />

close serial ( long SerialHandle )<br />

Close a serial device.<br />

close serial closes a serial device that was opened with open serial.<br />

Parameter<br />

º SerialHandle (input control) .....................................................serial id long<br />

Serial interface handle.<br />

Result<br />

If the parameters are correct and the device could be closed, the operator close serial returns the value<br />

H MSG TRUE. Otherwise an exception is raised.<br />

Parallelization Information<br />

close serial is reentrant and processed without parallelization.<br />

open serial<br />

open serial, close file<br />

System<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

get serial param ( long SerialHandle, long *BaudRate, long *DataBits,<br />

char *FlowControl, char *Parity, long *StopBits, long *TotalTimeOut,<br />

long *InterCharTimeOut )<br />

Get the parameters of a serial device.<br />

get serial param returns the current parameter settings of the serial device passed in SerialHandle. For<br />

a description of the parameters of a serial device, see set serial param.<br />

Parameter<br />

º SerialHandle (input control) .....................................................serial id long<br />

Serial interface handle.<br />

º BaudRate (output control) .........................................................integer long *<br />

Speed of the serial interface.<br />

º DataBits (output control) .........................................................integer long *<br />

Number of data bits of the serial interface.<br />

º FlowControl (output control) ......................................................string char *<br />

Type of flow control of the serial interface.<br />

º Parity (output control) .............................................................string char *<br />

Parity of the serial interface.<br />

º StopBits (output control) .........................................................integer long *<br />

Number of stop bits of the serial interface.<br />

º TotalTimeOut (output control) ....................................................integer long *<br />

Total timeout of the serial interface in ms.<br />

º InterCharTimeOut (output control) ..............................................integer long *<br />

Inter-character timeout of the serial interface in ms.<br />

Result<br />

If the parameters are correct and the parameters of the device could be read, the operator get serial param<br />

returns the value H MSG TRUE. Otherwise an exception is raised.<br />

Parallelization Information<br />

get serial param is reentrant and processed without parallelization.<br />

open serial<br />

Possible Predecessor Functions<br />

<strong>HALCON</strong> 6.0


610 CHAPTER 11. SYSTEM<br />

Possible Successor Functions<br />

get serial param, (T )read serial, (T )write serial<br />

set serial param<br />

System<br />

See Also<br />

Module<br />

open serial ( const char *PortName, long *SerialHandle )<br />

Open a serial device.<br />

open serial opens a serial device. The name of the device is determined by the parameter PortName and is<br />

operating system specific. On Windows NT machines, ’COM1’-’COM4’ is typically used, while on Unix systems<br />

the serial devices usually are named ’/dev/tty*’. The parameters of the serial device, e.g., its speed or number of<br />

data bits, are set to the system default values for the respective device after the device has been opened. They can<br />

be set or changed by calling set serial param.<br />

Parameter<br />

º PortName (input control) .............................................filename.named const char *<br />

Name of the serial port.<br />

Default Value : ”COM1”<br />

Value Suggestions : PortName ¾”COM1”, ”COM2”, ”COM3”, ”COM4”, ”/dev/ttya”, ”/dev/ttyb”,<br />

”/dev/tty00”, ”/dev/tty01”, ”/dev/ttyd1”, ”/dev/ttyd2”, ”/dev/cua0”, ”/dev/cua1”<br />

º SerialHandle (output control) ..................................................serial id long *<br />

Serial interface handle.<br />

Result<br />

If the parameters are correct and the device could be opened, the operator open serial returns the value<br />

H MSG TRUE. Otherwise an exception is raised.<br />

Parallelization Information<br />

open serial is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

set serial param, (T )read serial, (T )write serial, close serial<br />

See Also<br />

set serial param, get serial param, open file<br />

System<br />

Module<br />

read serial ( long SerialHandle, long NumCharacters, long *Data )<br />

T read serial ( Htuple SerialHandle, Htuple NumCharacters,<br />

Htuple *Data )<br />

Read from a serial device.<br />

(T )read serial tries to read NumCharacters from the serial device given in SerialHandle. The read<br />

characters are returned in Data as a tuple of integers. This allows to read NUL characters, which would otherwise<br />

be interpreted as the end of a string. If the timeout of the serial device has been set to a value greater than 0 with<br />

set serial param, (T )read serial waits at most as long for the arrival of the first character as indicated<br />

by the timeout. Otherwise, the operator returns immediately. In any case, the number of characters available at<br />

the time of return are passed back to the caller, i.e., fewer characters than requested can be returned. This can be<br />

checked by the length of the tuple Data.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.7. SERIAL 611<br />

Parameter<br />

º SerialHandle (input control) ............................................serial id (Htuple .) long<br />

Serial interface handle.<br />

º NumCharacters (input control) ............................................integer (Htuple .) long<br />

Number of characters to read.<br />

Default Value : 1<br />

Value Suggestions : NumCharacters ¾1, 2, 3, 4, 5, 10, 20, 40, 100<br />

º Data (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Read characters (as tuple of integers).<br />

Result<br />

If the parameters are correct and the read from the device was successful, the operator (T )read serial returns<br />

the value H MSG TRUE. Otherwise an exception is raised.<br />

Parallelization Information<br />

(T )read serial is reentrant and processed without parallelization.<br />

open serial<br />

(T )write serial<br />

System<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

set serial param ( long SerialHandle, long BaudRate, long DataBits,<br />

const char *FlowControl, const char *Parity, long StopBits,<br />

long TotalTimeOut, long InterCharTimeOut )<br />

Set the parameters of a serial device.<br />

set serial param can be used to set the parameters of a serial device. The parameter BaudRate determines<br />

the input and output speed of the device. It should be noted that not all devices support all possible speeds. The<br />

number of sent and received data bits is set with DataBits. The parameter FlowControl determines if and<br />

what kind of data flow control should be used. In the latter case, a choice between software control (’xon xoff’)<br />

and hardware control (’cts rts’, ’dtr dsr’) can be made. If and what kind of parity check of the transmitted<br />

data should be performed can be determined by Parity. The number of stop bits sent is set with StopBits.<br />

Finally, two timeout for reading from the serial device can be set. The parameter TotalTimeOut determines<br />

the maximum time, which may pass in (T )read serial until the first character arrives, independent of the<br />

actual number of characters requested. The parameter InterCharTimeOut determines the time which may<br />

pass between the reading of individual characters, if multiple characters are requested with (T )read serial.<br />

If one of the timeouts is set to -1, a read waits an arbitrary amount of time for the arrival of characters. Thus, on<br />

Windows NT systems, a total timeout of ÌÓØÐÌÑÇÙØ · ÒÁÒØÖÖÌÑÇÙØ results if Ò characters are to be<br />

read. On Unix systems, only one of the two timeouts can be set. Thus, if both timeouts are passed larger than -1,<br />

only the total timeout is used. The unit of both timeouts is milliseconds. For each parameter, the current values<br />

can be left in effect by passing ’unchanged’.<br />

Parameter<br />

º SerialHandle (input control) .....................................................serial id long<br />

Serial interface handle.<br />

º BaudRate (input control) ...............................................integer long / const char *<br />

Speed of the serial interface.<br />

Default Value : ’unchanged’<br />

Value List : BaudRate ¾50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,<br />

38400, 57600, 76800, 115200, 153600, 230400, 307200, 460800, ’unchanged’<br />

º DataBits (input control) ...............................................integer long / const char *<br />

Number of data bits of the serial interface.<br />

Default Value : ’unchanged’<br />

Value List : DataBits ¾5, 6, 7, 8, ’unchanged’<br />

<strong>HALCON</strong> 6.0


612 CHAPTER 11. SYSTEM<br />

º FlowControl (input control) ..................................................string const char *<br />

Type of flow control of the serial interface.<br />

Default Value : ’unchanged’<br />

Value List : FlowControl ¾’none’, ’xon xoff’, ’cts rts’, ’dtr dsr’, ’unchanged’<br />

º Parity (input control) .........................................................string const char *<br />

Parity of the serial interface.<br />

Default Value : ’unchanged’<br />

Value List : Parity ¾’none’, ’odd’, ’even’, ’unchanged’<br />

º StopBits (input control) ...............................................integer long / const char *<br />

Number of stop bits of the serial interface.<br />

Default Value : ’unchanged’<br />

Value List : StopBits ¾1, 2, ’unchanged’<br />

º TotalTimeOut (input control) .........................................integer long / const char *<br />

Total timeout of the serial interface in ms.<br />

Default Value : ’unchanged’<br />

Value Suggestions : TotalTimeOut ¾-1, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000,<br />

’unchanged’<br />

º InterCharTimeOut (input control) ....................................integer long / const char *<br />

Inter-character timeout of the serial interface in ms.<br />

Default Value : ’unchanged’<br />

Value Suggestions : InterCharTimeOut ¾-1, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000,<br />

’unchanged’<br />

Result<br />

If the parameters are correct and the parameters of the device could be set, the operator set serial param<br />

returns the value H MSG TRUE. Otherwise an exception is raised.<br />

Parallelization Information<br />

set serial param is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

open serial, get serial param<br />

Possible Successor Functions<br />

(T )read serial, (T )write serial<br />

get serial param<br />

System<br />

See Also<br />

Module<br />

write serial ( long SerialHandle, long Data )<br />

T write serial ( Htuple SerialHandle, Htuple Data )<br />

Write to a serial connection.<br />

(T )write serial writes the characters given in Data to the serial device given by SerialHandle. The<br />

data to be written is passed as a tuple of integers. This allows to write NUL characters, which would otherwise<br />

be interpreted as the end of a string. (T )write serial always waits until all data has been transmitted, i.e., a<br />

timout for writing cannot be set.<br />

Parameter<br />

º SerialHandle (input control) ............................................serial id (Htuple .) long<br />

Serial interface handle.<br />

º Data (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Characters to write (as tuple of integers).<br />

Result<br />

If the parameters are correct and the write to the device was successful, the operator (T )write serial returns<br />

the value H MSG TRUE. Otherwise an exception is raised.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.8. SOCKETS 613<br />

Parallelization Information<br />

(T )write serial is reentrant and processed without parallelization.<br />

open serial<br />

(T )read serial<br />

System<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

11.8 Sockets<br />

close socket ( long Socket )<br />

Close a socket.<br />

close socket closes a socket that was previously opened with open socket accept,<br />

open socket connect, or socket accept connect. For a detailed example, see<br />

open socket accept.<br />

Parameter<br />

º Socket (input control) .............................................................socket id long<br />

Socket number.<br />

Parallelization Information<br />

close socket is reentrant and processed without parallelization.<br />

See Also<br />

open socket accept, open socket connect, socket accept connect<br />

System<br />

Module<br />

get next socket data type ( long Socket, char *DataType )<br />

Determine the <strong>HALCON</strong> data type of the next socket data.<br />

get next socket data type returns the data type of the next data that are present on the socket Socket<br />

and returns it in DataType. The possible values for DataType are:<br />

’no data’: No data are present.<br />

’no halcon data’: Some data are present, but they are not <strong>HALCON</strong> data.<br />

’tuple’: Thenextdataisatuple.<br />

’region’: The next data is a region object.<br />

’image’: The next data is an image object.<br />

’xld cont’: The next data is an XLD contour.<br />

’xld poly’: The next data is an XLD polygon.<br />

’xld para’: The next data is an XLD parallel.<br />

’xld mod para’: The next data is a modified XLD parallel.<br />

’xld ext para’: The next data is an extended XLD parallel.<br />

<strong>HALCON</strong> 6.0


614 CHAPTER 11. SYSTEM<br />

Parameter<br />

º Socket (input control) .............................................................socket id long<br />

Socket number.<br />

º DataType (output control) ..........................................................string char *<br />

Data type of next <strong>HALCON</strong> data.<br />

Parallelization Information<br />

get next socket data type is reentrant and processed without parallelization.<br />

See Also<br />

send image, receive image, send region, receive region, send tuple, receive tuple<br />

System<br />

Module<br />

open socket accept ( long Port, long *AcceptingSocket )<br />

Open a socket that accepts connection requests.<br />

open socket accept opens a socket that accepts incoming connection requests by other <strong>HALCON</strong> processes.<br />

This operator is the necessary first step in the establishment of a communication channel between two <strong>HALCON</strong><br />

processes. The socket listens for incoming connection requests on the port number given by Port. The accepting<br />

socket is returned in AcceptingSocket. open socket accept returns immediately without waiting for<br />

a request from another process, done by calling open socket connect in the other process. This allows<br />

multiple other processes to connect to the particular <strong>HALCON</strong> process that calls open socket accept. To<br />

accept an incoming connection request, socket accept connect must be called after another process has<br />

called open socket connect.<br />

Parameter<br />

º Port (input control) .................................................................integer long<br />

Port number.<br />

Default Value : 3000<br />

Typical Range of Values : 1024 Port 65535<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º AcceptingSocket (output control) .............................................socket id long *<br />

Socket number.<br />

Example<br />

/* Process 1 */<br />

dev_set_colored (12)<br />

open_socket_accept (3000, AcceptingSocket)<br />

/* Busy wait for an incoming connection */<br />

dev_error_var (Error, 1)<br />

dev_set_check (’˜give_error’)<br />

OpenStatus := 5<br />

while (OpenStatus # 2)<br />

socket_accept_connect (AcceptingSocket, ’false’, Socket)<br />

OpenStatus := Error<br />

wait_seconds (0.2)<br />

endwhile<br />

dev_set_check (’give_error’)<br />

/* Connection established */<br />

receive_image (Image, Socket)<br />

threshold (Image, Region, 0, 63)<br />

send_region (Region, Socket)<br />

receive_region (ConnectedRegions, Socket)<br />

area_center (ConnectedRegions, Area, Row, Column)<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.8. SOCKETS 615<br />

send_tuple (Socket, Area)<br />

send_tuple (Socket, Row)<br />

send_tuple (Socket, Column)<br />

close_socket (Socket)<br />

close_socket (AcceptingSocket)<br />

/* Process 2 */<br />

dev_set_colored (12)<br />

open_socket_connect (’localhost’, 3000, Socket)<br />

read_image (Image, ’fabrik’)<br />

send_image (Image, Socket)<br />

receive_region (Region, Socket)<br />

connection (Region, ConnectedRegions)<br />

send_region (ConnectedRegions, Socket)<br />

receive_tuple (Socket, Area)<br />

receive_tuple (Socket, Row)<br />

receive_tuple (Socket, Column)<br />

close_socket (Socket)<br />

Parallelization Information<br />

open socket accept is reentrant and processed without parallelization.<br />

socket accept connect<br />

Possible Successor Functions<br />

See Also<br />

open socket connect, close socket, send image, receive image, send region,<br />

receive region, send tuple, receive tuple<br />

System<br />

Module<br />

open socket connect ( const char *HostName, long Port, long *Socket )<br />

Open a socket to an existing socket.<br />

open socket connect opens a connection to an accepting socket on the computer HostName, which listens<br />

on port Port. The listening socket in the other <strong>HALCON</strong> process must have been created earlier with the operator<br />

open socket accept. The socket thus created is returned in Socket. To establish the connection, the<br />

<strong>HALCON</strong> process, in which the accepting socket resides, must call socket accept connect. For a detailed<br />

example, see open socket accept.<br />

Parameter<br />

º HostName (input control) ......................................................string const char *<br />

Hostname of the computer to connect to.<br />

Default Value : ’localhost’<br />

º Port (input control) .................................................................integer long<br />

Port number.<br />

Default Value : 3000<br />

Typical Range of Values : 1024 Port 65535<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

º Socket (output control) ..........................................................socket id long *<br />

Socket number.<br />

Parallelization Information<br />

open socket connect is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

send image, receive image, send region, receive region, send tuple, receive tuple<br />

<strong>HALCON</strong> 6.0


616 CHAPTER 11. SYSTEM<br />

See Also<br />

open socket accept, socket accept connect, close socket<br />

System<br />

Module<br />

receive image ( Hobject *Image, long Socket )<br />

Receive an image over a socket connection.<br />

receive image reads an image object that was sent over the socket connection determined by Socket by<br />

another <strong>HALCON</strong> process using the operator send image. If no image has been sent, the <strong>HALCON</strong> process<br />

calling receive image blocks until enough data arrives. For a detailed example, see open socket accept.<br />

Parameter<br />

º Image (output object) .....................................................image(-array) Hobject *<br />

Received image.<br />

º Socket (input control) .............................................................socket id long<br />

Socket number.<br />

Parallelization Information<br />

receive image is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

open socket connect, socket accept connect<br />

See Also<br />

send image, send region, receive region, send tuple, receive tuple,<br />

get next socket data type<br />

Module<br />

System<br />

receive region ( Hobject *Region, long Socket )<br />

Receive regions over a socket connection.<br />

receive region reads a region object that was sent over the socket connection determined by Socket<br />

by another <strong>HALCON</strong> process using the operator send region. If no regions have been sent, the HAL-<br />

CON process calling receive region blocks until enough data arrives. For a detailed example, see<br />

open socket accept.<br />

Parameter<br />

º Region (output object) ...................................................region(-array) Hobject *<br />

Received regions.<br />

º Socket (input control) .............................................................socket id long<br />

Socket number.<br />

Parallelization Information<br />

receive region is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

open socket connect, socket accept connect<br />

See Also<br />

send region, send image, receive image, send tuple, receive tuple,<br />

get next socket data type<br />

Module<br />

System<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.8. SOCKETS 617<br />

receive tuple ( long Socket, char *Tuple )<br />

Receive a tuple over a socket connection.<br />

receive tuple reads a tuple that was sent over the socket connection determined by Socket by another<br />

<strong>HALCON</strong> process using the operator send tuple. If no tuple has been sent, the <strong>HALCON</strong> process calling<br />

receive tuple blocks until enough data arrives. For a detailed example, see open socket accept.<br />

Parameter<br />

º Socket (input control) .............................................................socket id long<br />

Socket number.<br />

º Tuple (output control) ..............................................................string char *<br />

Received tuple.<br />

Parallelization Information<br />

receive tuple is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

open socket connect, socket accept connect<br />

See Also<br />

send tuple, send image, receive image, send region, receive region,<br />

get next socket data type<br />

Module<br />

System<br />

receive xld ( Hobject *XLD, long Socket )<br />

Receive an XLD object over a socket connection.<br />

receive xld reads an XLD object that was sent over the socket connection determined by Socket by another<br />

<strong>HALCON</strong> process using the operator send xld. If no XLD object has been sent, the <strong>HALCON</strong> process calling<br />

receive xld blocks until enough data arrives. For a detailed example, see send xld.<br />

Parameter<br />

º XLD (output object) ..........................................................xld(-array) Hobject *<br />

Received XLD object.<br />

º Socket (input control) .............................................................socket id long<br />

Socket number.<br />

Parallelization Information<br />

receive xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

open socket connect, socket accept connect<br />

See Also<br />

send xld, send image, receive image, send region, receive region, send tuple,<br />

receive tuple, get next socket data type<br />

System<br />

Module<br />

send image ( Hobject Image, long Socket )<br />

Send an image over a socket connection.<br />

send image sends an image object over the socket connection determined by Socket. The receiving HAL-<br />

CON process must call receive image to read the image from the socket. For a detailed example, see<br />

open socket accept.<br />

<strong>HALCON</strong> 6.0


618 CHAPTER 11. SYSTEM<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Image to be sent.<br />

º Socket (input control) .............................................................socket id long<br />

Socket number.<br />

Parallelization Information<br />

send image is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

open socket connect, socket accept connect<br />

See Also<br />

receive image, send region, receive region, send tuple, receive tuple,<br />

get next socket data type<br />

Module<br />

System<br />

send region ( Hobject Region, long Socket )<br />

Send regions over a socket connection.<br />

send region sends a region object over the socket connection determined by Socket. The receiving HAL-<br />

CON process must call receive region to read the regions from the socket. For a detailed example, see<br />

open socket accept.<br />

Parameter<br />

º Region (input object) ......................................................region(-array) Hobject<br />

Regions to be sent.<br />

º Socket (input control) .............................................................socket id long<br />

Socket number.<br />

Parallelization Information<br />

send region is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

open socket connect, socket accept connect<br />

See Also<br />

receive region, send image, receive image, send tuple, receive tuple,<br />

get next socket data type<br />

Module<br />

System<br />

send tuple ( long Socket, const char *Tuple )<br />

Send a tuple over a socket connection.<br />

send tuple sends a tuple over the socket connection determined by Socket. The receiving HAL-<br />

CON process must call receive tuple to read the tuple from the socket. For a detailed example, see<br />

open socket accept.<br />

Parameter<br />

º Socket (input control) .............................................................socket id long<br />

Socket number.<br />

º Tuple (input control) ..........................................................string const char *<br />

Tupletobesent.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


11.8. SOCKETS 619<br />

Parallelization Information<br />

send tuple is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

open socket connect, socket accept connect<br />

See Also<br />

receive tuple, send image, receive image, send region, receive region,<br />

get next socket data type<br />

Module<br />

System<br />

send xld ( Hobject XLD, long Socket )<br />

Send an XLD object over a socket connection.<br />

send xld sends an XLD object over the socket connection determined by Socket. The receiving <strong>HALCON</strong><br />

process must call receive xld to read the XLD object from the socket.<br />

Parameter<br />

º XLD (input object) .............................................................xld(-array) Hobject<br />

XLD object to be sent.<br />

º Socket (input control) .............................................................socket id long<br />

Socket number.<br />

Example<br />

/* Process 1 */<br />

dev_set_colored (12)<br />

open_socket_accept (3000, AcceptingSocket)<br />

socket_accept_connect (AcceptingSocket, ’true’, Socket)<br />

receive_image (Image, Socket)<br />

edges_sub_pix (Image, Edges, ’canny’, 1.5, 20, 40)<br />

send_xld (Edges, Socket)<br />

receive_xld (Polygons, Socket)<br />

split_contours_xld (Polygons, Contours, ’polygon’, 1, 5)<br />

gen_parallels_xld (Polygons, Parallels, 10, 30, 0.15, ’true’)<br />

send_xld (Parallels, Socket)<br />

receive_xld (ModParallels, Socket)<br />

receive_xld (ExtParallels, Socket)<br />

stop ()<br />

close_socket (Socket)<br />

close_socket (AcceptingSocket)<br />

/* Process 2 */<br />

dev_set_colored (12)<br />

open_socket_connect (’localhost’, 3000, Socket)<br />

read_image (Image, ’mreut’)<br />

send_image (Image, Socket)<br />

receive_xld (Edges, Socket)<br />

gen_polygons_xld (Edges, Polygons, ’ramer’, 2)<br />

send_xld (Polygons, Socket)<br />

split_contours_xld (Polygons, Contours, ’polygon’, 1, 5)<br />

receive_xld (Parallels, Socket)<br />

mod_parallels_xld (Parallels, Image, ModParallels, ExtParallels,<br />

0.4, 160, 220, 10)<br />

send_xld (ModParallels, Socket)<br />

send_xld (ExtParallels, Socket)<br />

stop ()<br />

close_socket (Socket)<br />

<strong>HALCON</strong> 6.0


620 CHAPTER 11. SYSTEM<br />

Parallelization Information<br />

send xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

open socket connect, socket accept connect<br />

See Also<br />

receive xld, send image, receive image, send region, receive region, send tuple,<br />

receive tuple, get next socket data type<br />

System<br />

Module<br />

socket accept connect ( long AcceptingSocket, const char *Wait,<br />

long *Socket )<br />

Accept a connection request on a listening socket.<br />

socket accept connect accepts an incoming connection request, generated by open socket connect<br />

in another <strong>HALCON</strong> process, on the listening socket AcceptingSocket. The listening socket must have been<br />

created earlier with open socket accept. IfWait=’true’, socket accept connect waits until a connection<br />

request from another <strong>HALCON</strong> process arrives. If Wait=’false’, socket accept connect returns<br />

with the error FAIL, if currently there are no connection requests from other <strong>HALCON</strong> processes. The result of<br />

socket accept connect is another socket Socket, which is used for a two-way communication with another<br />

<strong>HALCON</strong> process. After this connection has been established, data can be exchanged between the two processes<br />

by calling the appropriate send or receive operators. For a detailed example, see open socket accept.<br />

Parameter<br />

º AcceptingSocket (input control) ................................................socket id long<br />

Socket number of the accepting socket.<br />

º Wait (input control) ............................................................string const char *<br />

Should the operator wait until a connection request arrives?<br />

Value List : Wait ¾’true’, ’false’<br />

º Socket (output control) ..........................................................socket id long *<br />

Socket number.<br />

Parallelization Information<br />

socket accept connect is reentrant and processed without parallelization.<br />

open socket accept<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

send image, receive image, send region, receive region, send tuple, receive tuple<br />

open socket connect, close socket<br />

System<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Chapter 12<br />

Tools<br />

12.1 Affine-Transformations<br />

T affine trans point 2d ( Htuple HomMat2D, Htuple Px, Htuple Py,<br />

Htuple *Qx, Htuple *Qy )<br />

Apply a homogeneous 2D transformation matrix to points.<br />

T affine trans point 2d calculates the result of applying the affine transformation, given by the homogeneous<br />

2D transformation matrix HomMat2D, to the input points (Px,Py). The resulting points are returned in<br />

(Qx,Qy).<br />

If the coordinates (Px,Py) are image coordinates, it should be noted that the components of the homogeneous<br />

transformation matrix are to be interpreted as follows: the row coordinate of the image corresponds to the Ü coordinate<br />

of the matrix, while the column coordinate of the image corresponds to the Ý coordinate of the matrix. This<br />

is necessary to obtain a right-handed coordinate system, which is assumed for the homogeneous transformation<br />

matrices, also for the image. In particular, by doing so roatations are performed in the correct direction. Note that<br />

the (Ü,Ý) order of the matrices quite naturally corresponds to the usual (row,column) order for coordinates in the<br />

image.<br />

Parameter<br />

º HomMat2D (input control) ...........................................affine2d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 6<br />

º Px (input control) .............................................point.x(-array) Htuple . double / long<br />

Input point (x coordinate).<br />

Default Value : 64<br />

Value Suggestions : Px ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Px 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Py (input control) .............................................point.y(-array) Htuple . double / long<br />

Input point (y coordinate).<br />

Default Value : 64<br />

Value Suggestions : Py ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Py 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Qx (output control) ................................................point.x(-array) Htuple . double *<br />

Output point (x coordinate).<br />

º Qy (output control) ................................................point.y(-array) Htuple . double *<br />

Output point (y coordinate).<br />

Result<br />

T affine trans point 2d always returns H MSG TRUE.<br />

621


622 CHAPTER 12. TOOLS<br />

Parallelization Information<br />

T affine trans point 2d is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate, T hom mat2d slant<br />

Possible Successor Functions<br />

T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate, T hom mat2d slant<br />

Basic operators<br />

Module<br />

T affine trans point 3d ( Htuple HomMat3D, Htuple Px, Htuple Py,<br />

Htuple Pz, Htuple *Qx, Htuple *Qy, Htuple *Qz )<br />

Apply a homogeneous 3D transformation matrix to points.<br />

T affine trans point 3d calculates the result of applying the affine transformation, given by the homogeneous<br />

3D transformation matrix HomMat3D, to the input points (Px,Py ,Pz). The resulting points are returned in<br />

(Qx, Qy,Qz).<br />

T affine trans point 3d is used to transform a 3D point (Px, Py, Pz) into a new coordinate system. The<br />

necessary translation and rotation is given by the 4x3 transformation matrix HomMat3D. The values are given as<br />

a tupel in the following order: The first three values of each row describe the three rows of the rotation matrix Ê<br />

and the last values of each row describe the translation Ì . During the transformation the 3D point is first rotated<br />

and subsequently translated:<br />

¼<br />

Ü ¾<br />

Ý ¾<br />

Þ ¾<br />

½ ¼<br />

Ê¡ Ü ½<br />

Ý ½<br />

Þ ½<br />

Parameter<br />

½<br />

· Ì<br />

º HomMat3D (input control) ...........................................affine3d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 12<br />

º Px (input control) ..........................................point3d.x(-array) Htuple . double / long<br />

Input point (x coordinate).<br />

Default Value : 64<br />

Value Suggestions : Px ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Px 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Py (input control) ..........................................point3d.y(-array) Htuple . double / long<br />

Input point (y coordinate).<br />

Default Value : 64<br />

Value Suggestions : Py ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Py 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Pz (input control) ..........................................point3d.z(-array) Htuple . double / long<br />

Input point (z coordinate).<br />

Default Value : 64<br />

Value Suggestions : Pz ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Pz 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Qx (output control) ..............................................point3d.x(-array) Htuple . double *<br />

Output point (x coordinate).<br />

º Qy (output control) ..............................................point3d.y(-array) Htuple . double *<br />

Output point (y coordinate).<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.1. AFFINE-TRANSFORMATIONS 623<br />

º Qz (output control) ..............................................point3d.z(-array) Htuple . double *<br />

Output point (z coordinate).<br />

Result<br />

T affine trans point 3d always returns H MSG TRUE.<br />

Parallelization Information<br />

T affine trans point 3d is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T hom mat3d translate, T hom mat3d scale, T hom mat3d rotate, T pose to hom mat3d<br />

Possible Successor Functions<br />

T hom mat3d translate, T hom mat3d scale, T hom mat3d rotate, T project 3d point<br />

Basic operators<br />

Module<br />

T dvf to hom mat2d ( Hobject VectorField, Htuple *HomMat2D )<br />

Approximate an affine map from a displacement vector field.<br />

T dvf to hom mat2d approximates an affine map from the displacement vector field VectorField. The<br />

affine map is returned in HomMat2D.<br />

If the displacement vector field has been computed from the original image Á orig and the second image Áres,<br />

the internally stored transformation matrix (see affine trans image) contains a map that describes how to<br />

transform the first image Á orig to the second image Áres.<br />

Parameter<br />

º VectorField (input object) ....................................singlechannel-image Hobject : dvf<br />

Input image.<br />

º HomMat2D (output control) ........................................affine2d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 6<br />

Parallelization Information<br />

T dvf to hom mat2d is reentrant and processed without parallelization.<br />

optical flow match<br />

affine trans image<br />

T vector to hom mat2d<br />

Basic operators<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

Module<br />

T hom mat2d compose ( Htuple HomMat2DSecond, Htuple HomMat2DFirst,<br />

Htuple *HomMat2DCompose )<br />

Compose two homogeneous 2D transformation matrices.<br />

T hom mat2d compose composes a new 2D transformation matrix from the two input matrices. The transformation<br />

given by HomMat2DFirst is applied first, followed by the transformation given by HomMat2DSecond,<br />

i.e., with HomMat2DFirst = À ½ , HomMat2DSecond = À ¾ ,andHomMat2DCompose = À is:<br />

À À ¾ ¡À ½<br />

<strong>HALCON</strong> 6.0


624 CHAPTER 12. TOOLS<br />

Parameter<br />

º HomMat2DSecond (input control) ...................................affine2d-array Htuple . double<br />

Second input transformation matrix.<br />

Parameter Number : 6<br />

º HomMat2DFirst (input control) ....................................affine2d-array Htuple . double<br />

First input transformation matrix.<br />

Parameter Number : 6<br />

º HomMat2DCompose (output control) ...............................affine2d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 6<br />

Result<br />

T hom mat2d compose always returns H MSG TRUE.<br />

Parallelization Information<br />

T hom mat2d compose is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T hom mat2d identity, T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate,<br />

T hom mat2d slant<br />

Possible Successor Functions<br />

T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate, T hom mat2d slant<br />

Basic operators<br />

Module<br />

T hom mat2d identity ( Htuple *HomMat2DIdentity )<br />

Generate the homogeneous transformation matrix of the identical 2D transformation.<br />

T hom mat2d identity generates the homogeneous ¾ ¢ ¿ transformation matrix HomMat2DIdentity describing<br />

the identical 2D transformation.<br />

Parameter<br />

º HomMat2DIdentity (output control) .............................affine2d-array Htuple . double *<br />

Transformation matrix.<br />

Parameter Number : 6<br />

Result<br />

T hom mat2d identity always returns H MSG TRUE.<br />

Parallelization Information<br />

T hom mat2d identity is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate, T hom mat2d slant<br />

Basic operators<br />

Module<br />

T hom mat2d invert ( Htuple HomMat2D, Htuple *HomMat2DInvert )<br />

Invert a homogeneous 2D transformation matrix.<br />

T hom mat2d invert inverts the homogeneous 2D transformation matrix given by HomMat2D. The resulting<br />

matrix is returned in HomMat2DInvert.<br />

Parameter<br />

º HomMat2D (input control) ...........................................affine2d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 6<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.1. AFFINE-TRANSFORMATIONS 625<br />

º HomMat2DInvert (output control) ................................affine2d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 6<br />

Result<br />

T hom mat2d invert returns H MSG TRUE if the input matrix is invertible.<br />

Parallelization Information<br />

T hom mat2d invert is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate, T hom mat2d slant<br />

Possible Successor Functions<br />

T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate, T hom mat2d slant<br />

Basic operators<br />

Module<br />

T hom mat2d rotate ( Htuple HomMat2D, Htuple Phi, Htuple Px, Htuple Py,<br />

Htuple *HomMat2DRotate )<br />

Add a rotation to a homogeneous 2D transformation matrix.<br />

T hom mat2d rotate adds a rotation by the angle Phi to a homogeneous 2D transformation matrix<br />

HomMat2D. The point (Px,Py) is the fixed point of the transformation. The resulting matrix is returned in<br />

HomMat2DRotate.<br />

Parameter<br />

º HomMat2D (input control) ...........................................affine2d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 6<br />

º Phi (input control) ................................................angle.rad Htuple . double / long<br />

Rotation angle.<br />

Default Value : 0.78<br />

Value Suggestions : Phi ¾0.1, 0.2, 0.3, 0.4, 0.78, 1.57, 3.14<br />

Typical Range of Values : 0 Phi 6.28318530718<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

º Px (input control) ...................................................point.x Htuple . double / long<br />

Fixed point of the transformation (x coordinate).<br />

Default Value : 0<br />

Value Suggestions : Px ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Px 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Py (input control) ...................................................point.y Htuple . double / long<br />

Fixed point of the transformation (y coordinate).<br />

Default Value : 0<br />

Value Suggestions : Py ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Py 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º HomMat2DRotate (output control) ................................affine2d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 6<br />

Result<br />

T hom mat2d rotate always returns H MSG TRUE.<br />

Parallelization Information<br />

T hom mat2d rotate is reentrant and processed without parallelization.<br />

<strong>HALCON</strong> 6.0


626 CHAPTER 12. TOOLS<br />

Possible Predecessor Functions<br />

T hom mat2d identity, T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate,<br />

T hom mat2d slant<br />

Possible Successor Functions<br />

T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate, T hom mat2d slant<br />

Basic operators<br />

Module<br />

T hom mat2d scale ( Htuple HomMat2D, Htuple Sx, Htuple Sy, Htuple Px,<br />

Htuple Py, Htuple *HomMat2DScale )<br />

Add a scaling to a homogeneous 2D transformation matrix.<br />

T hom mat2d scale adds a scaling by the scale factors Sx and Sy to a homogeneous 2D transformation matrix<br />

HomMat2D. The point (Px,Py) is the fixed point of the transformation. The resulting matrix is returned in<br />

HomMat2DScale.<br />

Parameter<br />

º HomMat2D (input control) ...........................................affine2d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 6<br />

º Sx (input control) ...................................................number Htuple . double / long<br />

Scale factor along the x-axis.<br />

Default Value : 2<br />

Value Suggestions : Sx ¾0.125, 0.25, 0.5, 1, 2, 4, 8, 16<br />

Typical Range of Values : 0 Sx 1024<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.125<br />

Restriction : Sx 0<br />

º Sy (input control) ...................................................number Htuple . double / long<br />

Scale factor along the y-axis.<br />

Default Value : 2<br />

Value Suggestions : Sy ¾0.125, 0.25, 0.5, 1, 2, 4, 8, 16<br />

Typical Range of Values : 0 Sy 1024<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.125<br />

Restriction : Sy 0<br />

º Px (input control) ...................................................point.x Htuple . double / long<br />

Fixed point of the transformation (x coordinate).<br />

Default Value : 0<br />

Value Suggestions : Px ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Px 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Py (input control) ...................................................point.y Htuple . double / long<br />

Fixed point of the transformation (y coordinate).<br />

Default Value : 0<br />

Value Suggestions : Py ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Py 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º HomMat2DScale (output control) ..................................affine2d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 6<br />

Result<br />

T hom mat2d scale returns H MSG TRUE if both scale factors are not 0.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.1. AFFINE-TRANSFORMATIONS 627<br />

Parallelization Information<br />

T hom mat2d scale is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T hom mat2d identity, T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate,<br />

T hom mat2d slant<br />

Possible Successor Functions<br />

T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate, T hom mat2d slant<br />

Basic operators<br />

Module<br />

T hom mat2d slant ( Htuple HomMat2D, Htuple Theta, Htuple Axis,<br />

Htuple Px, Htuple Py, Htuple *HomMat2DSlant )<br />

Add a slant to a homogeneous 2D transformation matrix.<br />

T hom mat2d slant adds a slant by the angle Theta to a homogeneous 2D transformation matrix HomMat2D.<br />

A slant is an affine transformation in which one coordinate axis remains fixed, while the other coordinate axis is<br />

rotated counterclockwise by an angle Theta. The parameter Axis determines which coordinate axis is slanted.<br />

For Axis = ’x’, the x-axis is slanted, while for Axis = ’y’ the y-axis is slanted. The point (Px,Py) isthefixed<br />

point of the transformation. The resulting matrix is returned in HomMat2DSlant.<br />

Parameter<br />

º HomMat2D (input control) ...........................................affine2d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 6<br />

º Theta (input control) .............................................angle.rad Htuple . double / long<br />

Slant angle.<br />

Default Value : 0.78<br />

Value Suggestions : Theta ¾0.1, 0.2, 0.3, 0.4, 0.78, 1.57, 3.14<br />

Typical Range of Values : 0 Theta 6.28318530718<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

º Axis (input control) ....................................................string Htuple . const char *<br />

Coordinate axis that is slanted.<br />

Default Value : ’x’<br />

Value List : Axis ¾’x’, ’y’<br />

º Px (input control) ...................................................point.x Htuple . double / long<br />

Fixed point of the transformation (x coordinate).<br />

Default Value : 0<br />

Value Suggestions : Px ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Px 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Py (input control) ...................................................point.y Htuple . double / long<br />

Fixed point of the transformation (y coordinate).<br />

Default Value : 0<br />

Value Suggestions : Py ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Py 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º HomMat2DSlant (output control) ..................................affine2d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 6<br />

Result<br />

T hom mat2d slant always returns H MSG TRUE.<br />

Parallelization Information<br />

T hom mat2d slant is reentrant and processed without parallelization.<br />

<strong>HALCON</strong> 6.0


628 CHAPTER 12. TOOLS<br />

Possible Predecessor Functions<br />

T hom mat2d identity, T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate,<br />

T hom mat2d slant<br />

Possible Successor Functions<br />

T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate, T hom mat2d slant<br />

Basic operators<br />

Module<br />

T hom mat2d to affine par ( Htuple HomMat2D, Htuple *Sx, Htuple *Sy,<br />

Htuple *Phi, Htuple *Theta, Htuple *Tx, Htuple *Ty )<br />

Compute the affine transformation parameters from a homogeneous 2D transformation matrix.<br />

T hom mat2d to affine par computes the affine transformation parameters corresponding to the homogeneous<br />

2D transformation matrix HomMat2D. The parameters Sx and Sy determine how the transformation scales<br />

the original x- and y-axes, respectively. The two scaling factors are always positive. The angle Theta determines<br />

how the transformed coordinate axes deviate from orthogonality. For Theta = 0, the two coordinate axes are<br />

orthogonal. If ÌØ ¾ the transformation contains a reflection. The angle Phi determines the rotation of<br />

the transformed x-axis with respect to the original x-axis. The parameters Tx and Ty determine the translation of<br />

the two coordinate systems. The Matrix HomMat2D can be constructed from the six transformation parameters by<br />

the following operator sequence:<br />

hom\_mat2d\_identity (HomMat2DIdentity)<br />

hom\_mat2d\_scale (HomMat2DIdentity, Sx, Sy, 0, 0, HomMat2DScale)<br />

hom\_mat2d\_slant (HomMat2DScale, Theta, ’y’, 0, 0, HomMat2DSlant)<br />

hom\_mat2d\_rotate (HomMat2DSlant, Phi, 0, 0, HomMat2DRotate)<br />

hom\_mat2d\_translate (HomMat2DRotate, Tx, Ty, HomMat2D)<br />

Parameter<br />

º HomMat2D (input control) ...........................................affine2d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 6<br />

º Sx (output control) ..........................................................real Htuple . double *<br />

Scaling factor along the x direction.<br />

º Sy (output control) ..........................................................real Htuple . double *<br />

Scaling factor along the y direction.<br />

º Phi (output control) ....................................................angle.rad Htuple . double *<br />

Rotation angle.<br />

º Theta (output control) .................................................angle.rad Htuple . double *<br />

Slant angle.<br />

º Tx (output control) .......................................................point.x Htuple . double *<br />

Translation along the x direction.<br />

º Ty (output control) .......................................................point.y Htuple . double *<br />

Translation along the y direction.<br />

Result<br />

If the matrix HomMat2D is non-degenerate, T hom mat2d to affine par returns H MSG TRUE. Otherwise,<br />

an exception is raised.<br />

Parallelization Information<br />

T hom mat2d to affine par is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T vector to hom mat2d, T vector to rigid, T vector to similarity<br />

Possible Successor Functions<br />

T hom mat2d identity, T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate,<br />

T hom mat2d slant<br />

Module<br />

Basic operators<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.1. AFFINE-TRANSFORMATIONS 629<br />

T hom mat2d translate ( Htuple HomMat2D, Htuple Tx, Htuple Ty,<br />

Htuple *HomMat2DTranslate )<br />

Add a translation to a homogeneous 2D transformation matrix.<br />

T hom mat2d translate adds a translation by the vector (Tx,Ty) to a homogeneous 2D transformation matrix<br />

HomMat2D. The resulting matrix is returned in HomMat2DTranslate.<br />

Parameter<br />

º HomMat2D (input control) ...........................................affine2d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 6<br />

º Tx (input control) ...................................................point.x Htuple . double / long<br />

Translation along the x-axis.<br />

Default Value : 64<br />

Value Suggestions : Tx ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Tx 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Ty (input control) ...................................................point.y Htuple . double / long<br />

Translation along the y-axis.<br />

Default Value : 64<br />

Value Suggestions : Ty ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Ty 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º HomMat2DTranslate (output control) ............................affine2d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 6<br />

Result<br />

T hom mat2d identity always returns H MSG TRUE.<br />

Parallelization Information<br />

T hom mat2d translate is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T hom mat2d identity, T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate,<br />

T hom mat2d slant<br />

Possible Successor Functions<br />

T hom mat2d translate, T hom mat2d scale, T hom mat2d rotate, T hom mat2d slant<br />

Basic operators<br />

Module<br />

T hom mat3d compose ( Htuple HomMat3DSecond, Htuple HomMat3DFirst,<br />

Htuple *HomMat3DCompose )<br />

Compose two homogeneous 3D transformation matrices.<br />

T hom mat3d compose composes a new 3D transformation matrix from the two input matrices. The transformation<br />

given by HomMat3DFirst is applied first, followed by the transformation given by HomMat3DSecond,<br />

i.e., with HomMat3DFirst = À ½ , HomMat3DSecond = À ¾ ,andHomMat3DCompose = À is:<br />

À À ¾ ¡À ½<br />

A homogeneous 4x3 transformation matrix describes the transformation of a 3D point from the source coordinate<br />

system into the destination coordinate system. In this sight the following holds are usable:<br />

<strong>HALCON</strong> 6.0


630 CHAPTER 12. TOOLS<br />

with:<br />

¼<br />

Ü ¿<br />

Ý ¿<br />

Þ ¿<br />

½<br />

À ¡<br />

À ¾ ¡<br />

¼<br />

Ü ½<br />

Ý ½<br />

¼<br />

Þ ½<br />

Ü ¾<br />

Ý ¾<br />

Þ ¾<br />

½<br />

À¾ ¡À ½ ¡<br />

½<br />

<br />

¼<br />

Ü ½<br />

Ý ½<br />

Þ ½<br />

½<br />

<br />

therefore:<br />

¼<br />

Ü ¾<br />

Ý ¾<br />

Þ ¾<br />

½<br />

À½ ¡<br />

¼<br />

Ü ½<br />

Ý ½<br />

Þ ½<br />

½<br />

ʽ ¡<br />

¼<br />

Ü ½<br />

Ý ½<br />

Þ ½<br />

½<br />

· ̽<br />

with:<br />

¼<br />

Ü ¿<br />

Ý ¿<br />

Þ ¿<br />

½<br />

ʾ ¡<br />

¼<br />

Ü ¾<br />

Ý ¾<br />

Ê ¾ ¡Ê ½ ¡<br />

Þ ¾<br />

¼<br />

½<br />

¼<br />

· ̾ Ê ¾ ¡ ʽ ¡<br />

Ü ½<br />

Ý ½<br />

Þ ½<br />

½<br />

¼<br />

Ü ½<br />

Ý ½<br />

Þ ½<br />

· ʾ ¡Ì ½ · Ì ¾ Ê ¡<br />

½ ½<br />

· ̽<br />

¼<br />

Ü ½<br />

Ý ½<br />

Þ ½<br />

· ̾<br />

½<br />

· Ì<br />

Rotation:<br />

Ê Ê ¾ ¡Ê ¾<br />

Translation: Ì Ê ¾ ¡Ì ½ · Ì ¾<br />

Parameter<br />

º HomMat3DSecond (input control) ...................................affine3d-array Htuple . double<br />

Second input transformation matrix.<br />

Parameter Number : 12<br />

º HomMat3DFirst (input control) ....................................affine3d-array Htuple . double<br />

First input transformation matrix.<br />

Parameter Number : 12<br />

º HomMat3DCompose (output control) ...............................affine3d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 12<br />

Example<br />

HTuple Pose, HomTransMat1, HomTransMat2, HomTransMatMult ;<br />

// read camera pose<br />

::read_pose("campose.dat",&CamPose);<br />

// transform pose to transformation matrix<br />

::pose_to_hom_mat3d(CamPose,&HomTransMat1);<br />

// multiply transformation matrices<br />

::hom_mat3d_compose(HomTransMat2, HomTransMat1, &HomTransMatMult);<br />

Result<br />

T hom mat3d compose always returns H MSG TRUE.<br />

Parallelization Information<br />

T hom mat3d compose is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T hom mat3d identity, T hom mat3d translate, T hom mat3d scale, T hom mat3d rotate,<br />

T pose to hom mat3d<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.1. AFFINE-TRANSFORMATIONS 631<br />

Possible Successor Functions<br />

T hom mat3d translate, T hom mat3d scale, T hom mat3d rotate<br />

See Also<br />

T affine trans point 3d, T hom mat3d identity, T hom mat3d rotate,<br />

T hom mat3d translate, T pose to hom mat3d, T hom mat3d to pose<br />

Basic operators<br />

Module<br />

T hom mat3d identity ( Htuple *HomMat3DIdentity )<br />

Generate the homogeneous transformation matrix of the identical 3D transformation.<br />

T hom mat3d identity generates the homogeneous ¿ ¢ transformation matrix HomMat3DIdentity describing<br />

the identical 3D transformation.<br />

Parameter<br />

º HomMat3DIdentity (output control) .............................affine3d-array Htuple . double *<br />

Transformation matrix.<br />

Parameter Number : 12<br />

Result<br />

T hom mat3d identity always returns H MSG TRUE.<br />

Parallelization Information<br />

T hom mat3d identity is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

T hom mat3d translate, T hom mat3d scale, T hom mat3d rotate<br />

T pose to hom mat3d<br />

Basic operators<br />

Alternatives<br />

Module<br />

T hom mat3d invert ( Htuple HomMat3D, Htuple *HomMat3DInvert )<br />

Invert a homogeneous 3D transformation matrix.<br />

T hom mat3d invert inverts the homogeneous 3D transformation matrix given by HomMat3D. The resulting<br />

matrix is returned in HomMat3DInvert.<br />

A homogeneous 4x3 transformation matrix describes the transformation of a 3D point from the source coordinate<br />

system into the destination coordinate system. In this sight the inverted transformation matrix HomMat3DInvert<br />

describes the transformation from the original destination coordinate system to the original source coordinate<br />

system. The transformation of a 3D point (given in the source coordinate system) into a destination coordinate<br />

system is given by a rotation Ê and a translation Ì (see T affine trans point 3d). Thus, the following<br />

holds:<br />

¼<br />

Ü ¾<br />

Ý ¾<br />

¼<br />

Ü ½<br />

Ý ½<br />

Þ ½<br />

Þ ¾<br />

½<br />

½<br />

ÊÓÖ ¡<br />

ÊÓÖ ½ ¡<br />

¼<br />

Ü ½<br />

Ý ½<br />

¼<br />

Þ ½<br />

Ü ¾<br />

Ý ¾<br />

Þ ¾<br />

½<br />

· ÌÓÖ<br />

½<br />

Ì ÓÖ<br />

with Ê ÒÚ Ê ÓÖ ½ and Ì ÒÚ Ì ÓÖ :<br />

<strong>HALCON</strong> 6.0


632 CHAPTER 12. TOOLS<br />

¼<br />

Ü ½<br />

Ý ½<br />

Þ ½<br />

½<br />

ÊÒÚ ¡<br />

¼<br />

Ü ¾<br />

Ý ¾<br />

Þ ¾<br />

Parameter<br />

½<br />

· ÌÒÚ<br />

º HomMat3D (input control) ...........................................affine3d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 12<br />

º HomMat3DInvert (output control) ................................affine3d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 12<br />

Example<br />

HTuple CamPose, HomTransMat, HomTransMatInv;<br />

// read camera pose<br />

::read_pose("campose.dat",&CamPose);<br />

// transform pose to transformation matrix<br />

pose_to_hom_mat3d(CamPose,&HomTransMat);<br />

// invert transformation matrix<br />

::hom_mat3d_invert(HomTransMat,&HomTransMatInv);<br />

Result<br />

T hom mat3d invert returns H MSG TRUE if the input matrix is invertible.<br />

Parallelization Information<br />

T hom mat3d invert is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T hom mat3d translate, T hom mat3d scale, T hom mat3d rotate, T pose to hom mat3d<br />

Possible Successor Functions<br />

T hom mat3d translate, T hom mat3d scale, T hom mat3d rotate, T hom mat3d to pose<br />

See Also<br />

T affine trans point 3d, T hom mat3d identity, T hom mat3d rotate,<br />

T hom mat3d translate, T pose to hom mat3d, T hom mat3d to pose, T hom mat3d compose<br />

Basic operators<br />

Module<br />

T hom mat3d rotate ( Htuple HomMat3D, Htuple Phi, Htuple Axis,<br />

Htuple Px, Htuple Py, Htuple Pz, Htuple *HomMat3DRotate )<br />

Add a rotation to a homogeneous 3D transformation matrix.<br />

T hom mat3d rotate adds a rotation around the Axis-axis by the angle Phi to a homogeneous 3D transformation<br />

matrix HomMat3D. The point (Px,Py,Pz) is the fixed point of the transformation. The resulting matrix is<br />

returned in HomMat3DRotate.<br />

The homogeneous 4x3 transformation matrix HomMat3D describes the transformation of a 3D point from the<br />

source coordinate system into the destination coordinate system (Without Attention to the fixed point).<br />

T hom mat3d rotate is used to generate a new 4x3 transformation matrix HomMat3DRotate by rotating the<br />

Axis-axis of HomMat3D by the angle Phi (in mathematical positive direction).<br />

If you want to rotate the source coordinate system, you have to invert the transformation matrix using<br />

T hom mat3d invert, rotate it using T hom mat3d rotate, and invert it back again.<br />

The transformation of a 3D point (given in the source coordinate system) into a destination coordinate system ist<br />

given by a rotation Ê and a translation Ì (see T affine trans point 3d). Thus, the following holds:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.1. AFFINE-TRANSFORMATIONS 633<br />

¼<br />

Ü ¾<br />

Ý ¾<br />

Þ ¾<br />

½<br />

ÊÖÓØ ¡<br />

¼<br />

Ü ½<br />

Ý ½<br />

Þ ½<br />

´Ê ¡Ê ÓÖ µ ¡<br />

½<br />

· ÌÖÓØ<br />

¼<br />

Ü ¾<br />

Ý ¾<br />

Þ ¾<br />

½<br />

· ÌÓÖ<br />

with<br />

Ê Ü ¼<br />

½ ¼ ¼<br />

¼ Ó× ×Ò <br />

¼ ×Ò Ó× <br />

½<br />

<br />

¼<br />

Ê<br />

Ý <br />

<br />

Ó× ¼ ×Ò <br />

¼ ½ ¼<br />

×Ò ¼ Ó× <br />

½<br />

<br />

Ê<br />

Þ<br />

<br />

¼<br />

<br />

Ó× ×Ò ¼<br />

×Ò Ó× ¼<br />

¼ ¼ ½<br />

½<br />

<br />

Parameter<br />

º HomMat3D (input control) ...........................................affine3d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 12<br />

º Phi (input control) ................................................angle.rad Htuple . double / long<br />

Rotation angle.<br />

Default Value : 0.78<br />

Value Suggestions : Phi ¾0.1, 0.2, 0.3, 0.4, 0.78, 1.57, 3.14<br />

Typical Range of Values : 0 Phi 6.28318530718<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

º Axis (input control) ....................................................string Htuple . const char *<br />

Axis, to be rotated around.<br />

Default Value : ”x”<br />

Value Suggestions : Axis ¾”x”, ”y”, ”z”<br />

º Px (input control) .................................................point3d.x Htuple . double / long<br />

Fixed point of the transformation (x coordinate).<br />

Default Value : 0<br />

Value Suggestions : Px ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Px 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Py (input control) .................................................point3d.y Htuple . double / long<br />

Fixed point of the transformation (y coordinate).<br />

Default Value : 0<br />

Value Suggestions : Py ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Py 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Pz (input control) .................................................point3d.z Htuple . double / long<br />

Fixed point of the transformation (z coordinate).<br />

Default Value : 0<br />

Value Suggestions : Pz ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Pz 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º HomMat3DRotate (output control) ................................affine3d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 12<br />

Example<br />

HTuple CamPose, HomTransMat, HomTransMatRot;<br />

<strong>HALCON</strong> 6.0


634 CHAPTER 12. TOOLS<br />

HTuple HomTransMatInv, HomTransMatRot2, HomTransMat2;<br />

// read camera pose<br />

::read_pose("campose.dat",&CamPose);<br />

// transform pose to transformation matrix<br />

::pose_to_hom_mat3d(CamPose,&HomTransMat);<br />

// rotate destination coordinate system around x-axis by 10 degree<br />

::hom_mat3d_rotate(HomTransMat,10,"x",0,0,0,&HomTransMatRot);<br />

// rotate source coordinate system around y-axis by 270 degree<br />

::hom_mat3d_invert(HomTransMat,&HomTransMatInv);<br />

::hom_mat3d_rotate(HomTransMatInv,270,"y",0,0,0,&HomTransMatRot2);<br />

::hom_mat3d_invert(HomTransMatRot2,&HomTransMat2);<br />

Result<br />

T hom mat3d rotate always returns H MSG TRUE.<br />

Parallelization Information<br />

T hom mat3d rotate is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T hom mat3d identity, T hom mat3d translate, T hom mat3d scale, T hom mat3d rotate<br />

Possible Successor Functions<br />

T hom mat3d translate, T hom mat3d scale, T hom mat3d rotate<br />

See Also<br />

T hom mat3d invert, T hom mat3d identity, T hom mat3d rotate, T hom mat3d translate,<br />

T pose to hom mat3d, T hom mat3d to pose, T hom mat3d compose<br />

Basic operators<br />

Module<br />

T hom mat3d scale ( Htuple HomMat3D, Htuple Sx, Htuple Sy, Htuple Sz,<br />

Htuple Px, Htuple Py, Htuple Pz, Htuple *HomMat3DScale )<br />

Add a scaling to a homogeneous 3D transformation matrix.<br />

T hom mat3d scale adds a scaling by the scale factors Sx and Sy to a homogeneous 3D transformation matrix<br />

HomMat3D. The point (Px,Py,Pz) is the fixed point of the transformation. The resulting matrix is returned in<br />

HomMat3DScale.<br />

Parameter<br />

º HomMat3D (input control) ...........................................affine3d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 12<br />

º Sx (input control) ...................................................number Htuple . double / long<br />

Scale factor along the x-axis.<br />

Default Value : 2<br />

Value Suggestions : Sx ¾0.125, 0.25, 0.5, 1, 2, 4, 8, 112<br />

Typical Range of Values : 0 Sx 1024<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.125<br />

Restriction : Sx 0<br />

º Sy (input control) ...................................................number Htuple . double / long<br />

Scale factor along the y-axis.<br />

Default Value : 2<br />

Value Suggestions : Sy ¾0.125, 0.25, 0.5, 1, 2, 4, 8, 112<br />

Typical Range of Values : 0 Sy 1024<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.125<br />

Restriction : Sy 0<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.1. AFFINE-TRANSFORMATIONS 635<br />

º Sz (input control) ...................................................number Htuple . double / long<br />

Scale factor along the z-axis.<br />

Default Value : 2<br />

Value Suggestions : Sz ¾0.125, 0.25, 0.5, 1, 2, 4, 8, 112<br />

Typical Range of Values : 0 Sz 1024<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.125<br />

Restriction : Sz 0<br />

º Px (input control) .................................................point3d.x Htuple . double / long<br />

Fixed point of the transformation (x coordinate).<br />

Default Value : 0<br />

Value Suggestions : Px ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Px 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Py (input control) .................................................point3d.y Htuple . double / long<br />

Fixed point of the transformation (y coordinate).<br />

Default Value : 0<br />

Value Suggestions : Py ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Py 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Pz (input control) .................................................point3d.z Htuple . double / long<br />

Fixed point of the transformation (z coordinate).<br />

Default Value : 0<br />

Value Suggestions : Pz ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Pz 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º HomMat3DScale (output control) ..................................affine3d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 12<br />

Result<br />

T hom mat3d scale returns H MSG TRUE if all three scale factors are not 0.<br />

Parallelization Information<br />

T hom mat3d scale is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T hom mat3d identity, T hom mat3d translate, T hom mat3d scale, T hom mat3d rotate<br />

Possible Successor Functions<br />

T hom mat3d translate, T hom mat3d scale, T hom mat3d rotate<br />

Basic operators<br />

Module<br />

T hom mat3d translate ( Htuple HomMat3D, Htuple Tx, Htuple Ty,<br />

Htuple Tz, Htuple *HomMat3DTranslate )<br />

Add a translation to a homogeneous 3D transformation matrix.<br />

T hom mat3d translate adds a translation by the vector (Tx,Ty,Tz) to a homogeneous 3D transformation<br />

matrix HomMat3D. The resulting matrix is returned in HomMat3DTranslate.<br />

The homogeneous 4x3 transformation matrix HomMat3D describes the transformation of a 3D point from the<br />

source coordinate system into the destination coordinate system. In this sight T hom mat3d translate is<br />

used to generate a new 4x3 transformation matrix HomMat3DTranslate by translating the origin of HomMat3D<br />

along the negative Axis by the amount (in meter) of the according to the vector (Tx,Ty,Tz).<br />

If you want to translate the source coordinate system, you have to invert the transformation matrix using<br />

T hom mat3d invert, translate it using T hom mat3d translate, and invert it back again.<br />

<strong>HALCON</strong> 6.0


636 CHAPTER 12. TOOLS<br />

The transformation of a 3D point (given in the source coordinate system) into a destination coordinate system ist<br />

given by a rotation Ê and a translation Ì (see T affine trans point 3d). Thus, the following holds:<br />

¼<br />

Ü ¾<br />

Ý ¾<br />

Þ ¾<br />

½<br />

ÊØÖÒ× ¡<br />

Ê ÓÖ ¡<br />

¼<br />

¼<br />

Ü ½<br />

Ý ½<br />

Ü ¾<br />

Ý ¾<br />

Þ ¾<br />

Þ ½<br />

½<br />

· ÌØÖÒ×<br />

½<br />

·´ÌÓÖ · Ì Æ µ<br />

with<br />

Ì Æ <br />

¼<br />

Ø Ü<br />

Ø Ý<br />

Ø Þ<br />

Parameter<br />

º HomMat3D (input control) ...........................................affine3d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 12<br />

º Tx (input control) .................................................point3d.x Htuple . double / long<br />

Translation along the x-axis.<br />

Default Value : 64<br />

Value Suggestions : Tx ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Tx 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Ty (input control) .................................................point3d.y Htuple . double / long<br />

Translation along the y-axis.<br />

Default Value : 64<br />

Value Suggestions : Ty ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Ty 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º Tz (input control) .................................................point3d.z Htuple . double / long<br />

Translation along the z-axis.<br />

Default Value : 64<br />

Value Suggestions : Tz ¾0, 16, 32, 64, 128, 256, 512, 1024<br />

Typical Range of Values : 0 Tz 1024<br />

Minimal Value Step : 1<br />

Recommended Value Step : 10<br />

º HomMat3DTranslate (output control) ............................affine3d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 12<br />

Example<br />

Tuple CamPose, HomTransMat, HomTransMatTransl, HomTransMatInv;<br />

Tuple HomTransMatTransl2, HomTransMat2;<br />

// read camera pose<br />

::read_pose("campose.dat",&CamPose);<br />

// transform pose to transformation matrix<br />

::pose_to_hom_mat3d(CamPose,&HomTransMat);<br />

// translate destination coordinate along x-axis by 0.4 m<br />

::hom_mat3d_translate(HomTransMat,-0.4,0,0,"x",&HomTransMatTransl);<br />

// translate source coordinate along y-axis by -0.03 m<br />

½<br />

<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.1. AFFINE-TRANSFORMATIONS 637<br />

::hom_mat3d_invert(HomTransMat, &HomTransMatInv);<br />

::hom_mat3d_translate(HomTransMatInv,0,0.03,0,&HomTransMatTransl2);<br />

::hom_mat3d_invert(HomTransMatTransl2,&HomTransMat2);<br />

Result<br />

T hom mat3d identity always returns H MSG TRUE.<br />

Parallelization Information<br />

T hom mat3d translate is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T hom mat3d identity, T hom mat3d translate, T hom mat3d scale, T hom mat3d rotate<br />

Possible Successor Functions<br />

T hom mat3d translate, T hom mat3d scale, T hom mat3d rotate<br />

See Also<br />

T hom mat3d invert, T hom mat3d identity, T hom mat3d rotate, T hom mat3d translate,<br />

T pose to hom mat3d, T hom mat3d to pose, T hom mat3d compose<br />

Basic operators<br />

Module<br />

T vector angle to rigid ( Htuple Row1, Htuple Column1, Htuple Angle1,<br />

Htuple Row2, Htuple Column2, Htuple Angle2, Htuple *HomMat2D )<br />

Compute a rigid affine transformation from points and angles.<br />

T vector angle to rigid computes a rigid affine transformation from a point correspondence and two corresponding<br />

angles. The coordinates of the original point are passed in (Row1,Column1), while the corresponding<br />

angle is passed in Angle1. The coordinates of the transformed point are passed in (Row2,Column2), while the<br />

corresponding angle is passed in Angle2. In particular, the operator T vector angle to rigid is useful<br />

to construct a rigid affine transformation from the results of the pattern matching operators (best match rot<br />

and best match rot mg), which transforms a reference image to the current image or (if the parameters are<br />

passed in reverse order) from the current image to the reference image. The computed transformation is returned<br />

in HomMat2D and can be used directly with operators that transform data using affine transformations,<br />

e.g., affine trans image.<br />

Parameter<br />

º Row1 (input control) .................................................point.y Htuple . double / long<br />

Row coordinate of the original point.<br />

º Column1 (input control) .............................................point.x Htuple . double / long<br />

Column coordinate of the original point.<br />

º Angle1 (input control) ............................................angle.rad Htuple . double / long<br />

Angle of the original point.<br />

º Row2 (input control) .................................................point.y Htuple . double / long<br />

Row coordinate of the transformed point.<br />

º Column2 (input control) .............................................point.x Htuple . double / long<br />

Column coordinate of the transformed point.<br />

º Angle2 (input control) ............................................angle.rad Htuple . double / long<br />

Angle of the transformed point.<br />

º HomMat2D (output control) ........................................affine2d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 6<br />

Example<br />

draw_rectangle2 (WindowID, RowTempl, ColumnTempl, PhiTempl, Length1, Length2)<br />

gen_rectangle2 (Rectangle, RowTempl, ColumnTempl, PhiTempl, Length1, Length2)<br />

reduce_domain (ImageTempl, Rectangle, ImageReduced)<br />

create_template_rot (ImageReduced, 4, 0, rad(360), rad(1), ’sort’,<br />

<strong>HALCON</strong> 6.0


638 CHAPTER 12. TOOLS<br />

’original’, TemplateID)<br />

while (true)<br />

best_match_rot_mg (Image, TemplateID, 0, rad(360), 30, ’true’, 4, Row,<br />

Column, Angle, ErrMatch)<br />

if (ErrMatch


12.1. AFFINE-TRANSFORMATIONS 639<br />

T dvf to hom mat2d<br />

Alternatives<br />

See Also<br />

affine trans image, optical flow match<br />

Basic operators<br />

Module<br />

T vector to rigid ( Htuple Rows1, Htuple Columns1, Htuple Rows2,<br />

Htuple Columns2, Htuple *HomMat2D )<br />

Approximate a rigid affine transformation from point correspondences.<br />

T vector to rigid approximates a rigid affine transformation from at least two point correspondences. The<br />

point correspondences are passed in the tuples (Rows1, Columns1) and(Rows2,Columns2), where corresponding<br />

points must be at the same index positions in the tuples. The transformation is always overdetermined.<br />

Therefore, the returned transformation is the transformation that minimizes the distances between the original<br />

points (Rows1,Columns1) and the transformed points (Rows2,Columns2). The calculated transformation is<br />

returned in HomMat2D and can be used directly with operators that transform data using affine transformations,<br />

e.g., affine trans image.<br />

Parameter<br />

º Rows1 (input control) ................................................point.y-array Htuple . double<br />

Row coordinates of the original points.<br />

º Columns1 (input control) ............................................point.x-array Htuple . double<br />

Column coordinates of the original points.<br />

º Rows2 (input control) ................................................point.y-array Htuple . double<br />

Row coordinates of the transformed points.<br />

º Columns2 (input control) ............................................point.x-array Htuple . double<br />

Column coordinates of the transformed points.<br />

º HomMat2D (output control) ........................................affine2d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 6<br />

Parallelization Information<br />

T vector to rigid is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

affine trans image, affine trans region, affine trans contour xld,<br />

affine trans polygon xld, T affine trans point 2d<br />

Alternatives<br />

T vector to hom mat2d, T vector to similarity<br />

T dvf to hom mat2d<br />

Basic operators<br />

See Also<br />

Module<br />

T vector to similarity ( Htuple Rows1, Htuple Columns1, Htuple Rows2,<br />

Htuple Columns2, Htuple *HomMat2D )<br />

Approximate an similarity transformation from point correspondences.<br />

T vector to similarity approximates a similarity transformation from at least two point correspondences.<br />

The point correspondences are passed in the tuples (Rows1, Columns1) and(Rows2,Columns2), where corresponding<br />

points must be at the same index positions in the tuples. If more than two point correspondences<br />

are passed the transformation is overdetermined. In this case, the returned transformation is the transformation<br />

that minimizes the distances between the original points (Rows1,Columns1) and the transformed points<br />

<strong>HALCON</strong> 6.0


640 CHAPTER 12. TOOLS<br />

(Rows2,Columns2). The calculated transformation is returned in HomMat2D and can be used directly with<br />

operators that transform data using affine transformations, e.g., affine trans image.<br />

Parameter<br />

º Rows1 (input control) ................................................point.y-array Htuple . double<br />

Row coordinates of the original points.<br />

º Columns1 (input control) ............................................point.x-array Htuple . double<br />

Column coordinates of the original points.<br />

º Rows2 (input control) ................................................point.y-array Htuple . double<br />

Row coordinates of the transformed points.<br />

º Columns2 (input control) ............................................point.x-array Htuple . double<br />

Column coordinates of the transformed points.<br />

º HomMat2D (output control) ........................................affine2d-array Htuple . double *<br />

Output transformation matrix.<br />

Parameter Number : 6<br />

Parallelization Information<br />

T vector to similarity is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

affine trans image, affine trans region, affine trans contour xld,<br />

affine trans polygon xld, T affine trans point 2d<br />

Alternatives<br />

T vector to hom mat2d, T vector to rigid<br />

T dvf to hom mat2d<br />

Basic operators<br />

See Also<br />

Module<br />

12.2 Background-Estimator<br />

close all bg esti ( )<br />

Delete all background estimation data sets.<br />

close all bg esti deletes the background estimation data sets and releases all used memory.<br />

Attention<br />

Since all estimaters are closed by close all bg esti, all handles become invalid.<br />

Result<br />

If it is possible to close the background estimation data sets the operator close all bg esti returns the value<br />

H MSG TRUE. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

close all bg esti is local and processed completely exclusively without parallelization.<br />

close bg esti<br />

create bg esti<br />

Background estimation<br />

Alternatives<br />

See Also<br />

Module<br />

close bg esti ( long BgEstiHandle )<br />

Delete the background estimation data set.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.2. BACKGROUND-ESTIMATOR 641<br />

close bg esti deletes the background estimation data set and releases all used memory.<br />

Parameter<br />

º BgEstiHandle (input control) ................................................bg estimation long<br />

ID of the BgEsti data set.<br />

Example<br />

/* read Init-Image: */<br />

read_image(&InitImage,"Init_Image") ;<br />

/* initialize BgEsti-Dataset<br />

with fixed gains and threshold adaption: */<br />

create_bg_esti(InitImage,0.7,0.7,"fixed",0.002,0.02,<br />

"on",7,10,3.25,15.0,&BgEstiHandle) \’<br />

/* read the next image in sequence: */<br />

read_image(&Image1,"Image_1") ;<br />

/* estimate the Background: */<br />

run_bg_esti(Image1,&Region1,BgEstiHandle) ;<br />

/* display the foreground region: */<br />

disp_region(Region1,WindowHandle) ;<br />

/* read the next image in sequence: */<br />

read_image(&Image2,"Image_2") ;<br />

/* estimate the Background: */<br />

run_bg_esti(Image2,&Region2,BgEstiHandle) ;<br />

/* display the foreground region: */<br />

disp_region(Region2,WindowHandle) ;<br />

/* etc. */<br />

/* - end of background estimation - */<br />

/* close the dataset: */<br />

close_bg_est(BgEstiHandle) ;<br />

Result<br />

close bg esti returns H MSG TRUE if all parameters are correct.<br />

Parallelization Information<br />

close bg esti is local and processed completely exclusively without parallelization.<br />

run bg esti<br />

create bg esti<br />

Background estimation<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

create bg esti ( Hobject InitializeImage, double Syspar1,<br />

double Syspar2, const char *GainMode, double Gain1, double Gain2,<br />

const char *AdaptMode, double MinDiff, long StatNum, double ConfidenceC,<br />

double TimeC, long *BgEstiHandle )<br />

Generate and initialize a data set for the background estimation.<br />

create bg esti creates a new data set for the background estimation and initializes it with the appropriate<br />

parameters. The estimated background image is part of this data set. The newly created set automatically becomes<br />

the current set.<br />

InitializeImage is used as an initial prediction for the background image. For a good prediction an image of<br />

the ovserved scene without moving objects should be passed in InitializeImage. That way the foreground<br />

adaptation rate can be held low. If there is no empty scene image available, a homogenous gray image can be used<br />

instead. In that case the adaptation rate for the foreground image must be raised, because initially most of the image<br />

will be detected as foreground. The intialization image must to be of type byte or real. Because of processing<br />

<strong>HALCON</strong> 6.0


642 CHAPTER 12. TOOLS<br />

single-channel images, data sets must be created for every channel. Size and region of InitializeImage<br />

determines size and region for all background estimations (run bg esti) that are performed with this data set.<br />

Syspar1 and Syspar2 are the parameters of the Kalman system matrix. The system matrix describes the<br />

system of the gray value changes according to Kalman filter theory. The background estimator implements a<br />

different system for each pixel.<br />

GainMode defines whether a fixed Kalman gain should be used for the estimation or whether the gain should<br />

adapt itself depending on the difference between estimation and actual value. If GainMode is set to ’fixed’,<br />

then Gain1 is used as Kalman gain for pixels predicted as foreground and Gain2 as gain for pixels predicted as<br />

background. Gain1 should be smaller than Gain2, because adaptation of the foreground should be slower than<br />

adaptation of the background. Both Gain1 and Gain2 should be smaller than 1.0.<br />

If GainMode is set to ’frame’, then tables for foreground and background estimation are computed containing<br />

Kalman gains for all the 256 possible grayvalue changes. Gain1 and Gain2 then denote the number of frames<br />

necessary to adapt the difference between estimated value and actual value. So with a fixed time for adaptation<br />

(i.e. number of frames) the needed Kalman gain grows with the grayvalue difference. Gain1 should therefore<br />

be larger than Gain2. Different gains for different grayvalue differences are useful if the background estimator<br />

is used for generating an ’empty’ scene assuming that there are always moving objects in the observated area. In<br />

that case the adaptation time for foreground adaptaion (Gain1) must not be too big. Gain1 and Gain2 should<br />

be bigger than 1.0.<br />

AdaptMode denotes, whether the foreground/background decision threshold applied to the grayvalue difference<br />

between estimation and actual value is fixed or whether it adapts itself depending on the grayvalue deviation of the<br />

background pixels.<br />

If AdaptMode is set to ’off’, the parameter MinDiff denotes a fixed threshold. The parameters StatNum,<br />

ConfidenceC and TimeC are meaningless in this case.<br />

If AdaptMode is set to ’on’, thenMinDiff is interpreted as a base threshold. For each pixel an offset is added<br />

to this threshold depending on the statistical evaluation of the pixel value over time. StatNum holds the number<br />

of data sets (past frames) that are used for computing the grayvalue variance (FIR-Filter). ConfidenceC is used<br />

to determine the confidence interval.<br />

The confidence interval determines the values of the background statistics if background pixels are hidden by<br />

a foreground object and thus are detected as foreground. According to the student t-distribution the confidence<br />

constant is 4.30 (3.25, 2.82, 2.26) for a confidence interval of 99,8% (99,0%, 98,0%, 95,0%). TimeC holds a<br />

time constant for the exp-function that raises the threshold in case of a foreground estimation of the pixel. That<br />

means, the threshold is raised in regions where movement is detected in the foreground. That way larger changes in<br />

illumination are tolerated if the background becomes visible again. The main reason for increasing this tolerance is<br />

the impossibility for a prediction of illumintaion changes while the background is hidden. Therefore no adaptation<br />

of the estimated background image is possible.<br />

Attention<br />

If GainMode was set to ’frame’, the run-time can be extremly long for large values of Gain1 or Gain2, because<br />

the values for the gains’ table are determined by a simple binary search.<br />

Parameter<br />

º InitializeImage (input object) ......................................image Hobject : byte / real<br />

initialization image.<br />

º Syspar1 (input control) ..............................................................real double<br />

1. system matrix parameter.<br />

Default Value : 0.7<br />

Value Suggestions : Syspar1 ¾0.65, 0.7, 0.75<br />

Typical Range of Values : 0.05 Syspar1 1.0<br />

Recommended Value Step : 0.05<br />

º Syspar2 (input control) ..............................................................real double<br />

2. system matrix parameter.<br />

Default Value : 0.7<br />

Value Suggestions : Syspar2 ¾0.65, 0.7, 0.75<br />

Typical Range of Values : 0.05 Syspar2 1.0<br />

Recommended Value Step : 0.05<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.2. BACKGROUND-ESTIMATOR 643<br />

º GainMode (input control) ......................................................string const char *<br />

Gain type.<br />

Default Value : ’fixed’<br />

Value List : GainMode ¾’fixed’, ’frame’<br />

º Gain1 (input control) .................................................................real double<br />

Kalman gain / foreground adaptation time.<br />

Default Value : 0.002<br />

Value Suggestions : Gain1 ¾10.0, 20.0, 50.0, 0.1, 0.05, 0.01, 0.005, 0.001<br />

Restriction : 0.0 Gain1<br />

º Gain2 (input control) .................................................................real double<br />

Kalman gain / background adaptation time.<br />

Default Value : 0.02<br />

Value Suggestions : Gain2 ¾2.0, 4.0, 8.0, 0.5, 0.1, 0.05, 0.01<br />

Restriction : 0.0 Gain2<br />

º AdaptMode (input control) .....................................................string const char *<br />

Threshold adaptation.<br />

Default Value : ’on’<br />

Value List : AdaptMode ¾’on’, ’off’<br />

º MinDiff (input control) ..............................................................real double<br />

Foreground/background threshold.<br />

Default Value : 7.0<br />

Value Suggestions : MinDiff ¾3.0, 5.0, 7.0, 9.0, 11.0<br />

Recommended Value Step : 0.2<br />

º StatNum (input control) .............................................................integer long<br />

Number of statistic data sets.<br />

Default Value : 10<br />

Value Suggestions : StatNum ¾5, 10, 20, 30<br />

Typical Range of Values : 1 StatNum<br />

Recommended Value Step : 5<br />

º ConfidenceC (input control) .........................................................real double<br />

Confidence constant.<br />

Default Value : 3.25<br />

Value Suggestions : ConfidenceC ¾4.30, 3.25, 2.82, 2.62<br />

Recommended Value Step : 0.01<br />

Restriction : 0.0 ConfidenceC<br />

º TimeC (input control) .................................................................real double<br />

Constant for decay time.<br />

Default Value : 15.0<br />

Value Suggestions : TimeC ¾10.0, 15.0, 20.0<br />

Recommended Value Step : 5.0<br />

Restriction : 0.0 TimeC<br />

º BgEstiHandle (output control) .............................................bg estimation long *<br />

ID of the BgEsti data set.<br />

Example<br />

long Handle1, Handle2;<br />

/* read Init-Image: */<br />

read_image(&InitImage,"Init_Image") ;<br />

/* initialize 1. BgEsti-Dataset with<br />

fixed gains and threshold adaption: */<br />

create_bg_esti(InitImage,0.7,0.7,"fixed",0.002,0.02,<br />

"on",7.0,10,3.25,15.0:&BgEstiHandle) ;<br />

/* initialize 2. BgEsti-Dataset with<br />

frame orientated gains and fixed threshold */<br />

create_bg_esti(InitImage,0.7,0.7,"frame",30.0,4.0,<br />

"off",9.0,10,3.25,15.0:&BgEstiHandle2) ;<br />

Result<br />

create bg esti returns H MSG TRUE if all parameters are correct.<br />

<strong>HALCON</strong> 6.0


644 CHAPTER 12. TOOLS<br />

Parallelization Information<br />

create bg esti is local and processed completely exclusively without parallelization.<br />

run bg esti<br />

set bg esti params, close bg esti<br />

Background estimation<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

get bg esti params ( long BgEstiHandle, double *Syspar1,<br />

double *Syspar2, char *GainMode, double *Gain1, double *Gain2,<br />

char *AdaptMode, double *MinDiff, long *StatNum, double *ConfidenceC,<br />

double *TimeC )<br />

Return the parameters of the data set.<br />

get bg esti params returns the parameters of the data set. The returned parameters are the same as in<br />

create bg esti and set bg esti params (see these for an explanation).<br />

Parameter<br />

º BgEstiHandle (input control) ................................................bg estimation long<br />

ID of the BgEsti data set.<br />

º Syspar1 (output control) ...........................................................real double *<br />

1. system matrix parameter.<br />

º Syspar2 (output control) ...........................................................real double *<br />

2. system matrix parameter.<br />

º GainMode (output control) ..........................................................string char *<br />

Gain type.<br />

º Gain1 (output control) ..............................................................real double *<br />

Kalman gain / foreground adaptation time.<br />

º Gain2 (output control) ..............................................................real double *<br />

Kalman gain / background adaptation time.<br />

º AdaptMode (output control) .........................................................string char *<br />

Threshold adaptation.<br />

º MinDiff (output control) ...........................................................real double *<br />

Foreground / background threshold.<br />

º StatNum (output control) ..........................................................integer long *<br />

Number of statistic data sets.<br />

º ConfidenceC (output control) ......................................................real double *<br />

Confidence constant.<br />

º TimeC (output control) ..............................................................real double *<br />

Constant for decay time.<br />

Example<br />

/* read Init-Image:*/<br />

read_image(&InitImage,"Init_Image") ;<br />

/* initialize BgEsti-Dataset with<br />

fixed gains and threshold adaption: */<br />

create_bg_esti(InitImage,0.7,0.7,"fixed",0.002,0.02,<br />

"on",7.0,10,3.25,15.0,&BgEstiHandle) ;<br />

/* read the next image in sequence: */<br />

read_image(&Image1,"Image_1") ;<br />

/* estimate the Background: */<br />

run_bg_esti(Image1,&Region1,BgEstiHandle) ;<br />

/* display the foreground region: */<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.2. BACKGROUND-ESTIMATOR 645<br />

disp_region(Region1,WindowHandle) ;<br />

/* read the next image in sequence: */<br />

read_image(&Image2,"Image_2") ;<br />

/* estimate the Background: */<br />

run_bg_esti(Image2,&Region2,BgEstiHandle) ;<br />

/* display the foreground region: */<br />

disp_region(Region2,WindowHandle) ;<br />

/* etc. */<br />

/* change only the gain parameter in dataset: */<br />

get_bg_esti_params(BgEstiHandle,&par1,&par2,&par3,&par4,<br />

&par5,&par6,&par7,&par8,&par9,&par10);<br />

set_bg_esti_params(BgEstiHandle,par1,par2,par3,0.004,<br />

0.08,par6,par7,par8,par9,par10) ;<br />

/* read the next image in sequence: */<br />

read_image(&Image3,"Image_3") ;<br />

/* estimate the Background: */<br />

run_bg_esti(Image3,&Region3,BgEstiHandle) ;<br />

/* display the foreground region: */<br />

disp_region(Region3,WindowHandle) ;<br />

/* etc. */<br />

Result<br />

get bg esti params returns H MSG TRUE if all parameters are correct.<br />

Parallelization Information<br />

get bg esti params is reentrant and processed without parallelization.<br />

create bg esti<br />

run bg esti<br />

set bg esti params<br />

Background estimation<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

give bg esti ( Hobject *BackgroundImage, long BgEstiHandle )<br />

Return the estimated background image.<br />

give bg esti returns the estimated background image of the current BgEsti data set. The background image<br />

has the same type and size as the initialization image passed in create bg esti.<br />

Parameter<br />

º BackgroundImage (output object) ..................................image Hobject * : byte / real<br />

Estimated background image of the current data set.<br />

º BgEstiHandle (input control) ................................................bg estimation long<br />

ID of the BgEsti data set.<br />

Example<br />

/* read Init-Image: */<br />

read_image(&InitImage,"Init_Image") ;<br />

/* initialize BgEsti-Dataset with<br />

fixed gains and threshold adaption: */<br />

create_bg_esti(InitImage,0.7,0.7,"fixed",0.002,0.02,<br />

"on",7,10,3.25,15.0,&BgEstiHandle) ;<br />

/* read the next image in sequence: */<br />

<strong>HALCON</strong> 6.0


646 CHAPTER 12. TOOLS<br />

read_image(&Image1,"Image_1") ;<br />

/* estimate the Background: */<br />

run_bg_esti(Image1,&Region1,BgEstiHandle) ;<br />

/* give the background image from the aktive dataset: */<br />

give_bg_esti(&BgImage,BgEstiHandle) ;<br />

/* display the background image: */<br />

disp_image(BgImage,WindowHandle) ;<br />

Result<br />

give bg esti returns H MSG TRUE if all parameters are correct.<br />

Parallelization Information<br />

give bg esti is local and processed completely exclusively without parallelization.<br />

run bg esti<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

run bg esti, create bg esti, update bg esti<br />

See Also<br />

run bg esti, update bg esti, create bg esti<br />

Background estimation<br />

Module<br />

run bg esti ( Hobject PresentImage, Hobject *ForegroundRegion,<br />

long BgEstiHandle )<br />

Estimate the background and return the foreground region.<br />

run bg esti adapts the background image stored in the BgEsti data set using a Kalman filter on each pixel and<br />

returns a region of the foreground (detected moving objects).<br />

For every pixel an estimation of its grayvalue is computed using the values of the current data set and its stored<br />

background image and the current image (PresentImage). By comparison to the threshold (fixed or adaptive,<br />

see create bg esti) the pixels are classified as either foreground or background.<br />

The background estimation processes only single-channel images. Therefore the background has to be adapted<br />

separately for every channel.<br />

The background estimation should be used on half- or even quarter-sized images. For this, the input images (and<br />

the initialization image!) has to be reduced using zoom image factor. The advantage is a shorter run-time on<br />

one hand and a low-band filtering on the other. The filtering eliminates high frequency noise and results in a more<br />

reliable estimation. As a result the threshold (see create bg esti) can be lowered. The foreground region<br />

returned by run bg esti then has to be enlarged again for further processing.<br />

Attention<br />

The passed image (PresentImage) must have the same type and size as the background image of the current<br />

data set (initialized with create bg esti).<br />

Parameter<br />

º PresentImage (input object) ..........................................image Hobject : byte / real<br />

Current image.<br />

º ForegroundRegion (output object) ............................................region Hobject *<br />

Region of the detected foreground.<br />

º BgEstiHandle (input control) ................................................bg estimation long<br />

ID of the BgEsti data set.<br />

/* read Init-Image: */<br />

Example<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.2. BACKGROUND-ESTIMATOR 647<br />

read_image(&InitImage,"Init_Image") ;<br />

/* initialize BgEsti-Dataset with<br />

fixed gains and threshold adaption */<br />

create_bg_esti(InitImage,0.7,0.7,"fixed",0.002,0.02,<br />

"on",7,10,3.25,15.0,&BgEstiHandle) ;<br />

/* read the next image in sequence: */<br />

read_image(&Image1,"Image_1") ;<br />

/* estimate the Background: */<br />

run_bg_esti(Image1,&Region1,BgEstiHandle) ;<br />

/* display the foreground region: */<br />

disp_region(Region1,WindowHandle) ;<br />

/* read the next image in sequence: */<br />

read_image(&Image2,"Image_2") ;<br />

/* estimate the Background: */<br />

run_bg_esti(Image2,&Region2,BgEstiHandle) ;<br />

/* display the foreground region: */<br />

disp_region(Region2,WindowHandle) ;<br />

/* etc. */<br />

Result<br />

run bg esti returns H MSG TRUE if all parameters are correct.<br />

Parallelization Information<br />

run bg esti is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

create bg esti, update bg esti<br />

Possible Successor Functions<br />

run bg esti, give bg esti, update bg esti<br />

See Also<br />

set bg esti params, create bg esti, update bg esti, give bg esti<br />

Background estimation<br />

Module<br />

set bg esti params ( long BgEstiHandle, double Syspar1, double Syspar2,<br />

const char *GainMode, double Gain1, double Gain2, const char *AdaptMode,<br />

double MinDiff, long StatNum, double ConfidenceC, double TimeC )<br />

Change the parameters of the data set.<br />

set bg esti params is used to change the parameters of the data set. The parameters passed by<br />

set bg esti params are the same as in create bg esti (see there for an explanation).<br />

The image format cannot be changed! To do this, a new data set with an initialization image of the appropriate<br />

format has to be created.<br />

To exchange the background image completely, use update bg esti. The current image then has to be passed<br />

for both the input image and the update region.<br />

Attention<br />

If GainMode was set to ’frame’, the run-time can be extremly long for large values of Gain1 or Gain2, because<br />

the values for the gains’ table are determined by a simple binary search.<br />

Parameter<br />

º BgEstiHandle (input control) ................................................bg estimation long<br />

ID of the BgEsti data set.<br />

º Syspar1 (input control) ..............................................................real double<br />

1. system matrix parameter.<br />

Default Value : 0.7<br />

Value Suggestions : Syspar1 ¾0.65, 0.7, 0.75<br />

Typical Range of Values : 0.05 Syspar1 1.0<br />

Recommended Value Step : 0.05<br />

<strong>HALCON</strong> 6.0


648 CHAPTER 12. TOOLS<br />

º Syspar2 (input control) ..............................................................real double<br />

2. system matrix parameter.<br />

Default Value : 0.7<br />

Value Suggestions : Syspar2 ¾0.65, 0.7, 0.75<br />

Typical Range of Values : 0.05 Syspar2 1.0<br />

Recommended Value Step : 0.05<br />

º GainMode (input control) ......................................................string const char *<br />

Gain type.<br />

Default Value : ’fixed’<br />

Value List : GainMode ¾’fixed’, ’frame’<br />

º Gain1 (input control) .................................................................real double<br />

Kalman gain / foreground adaptation time.<br />

Default Value : 0.002<br />

Value Suggestions : Gain1 ¾10.0, 20.0, 50.0, 0.1, 0.05, 0.01, 0.005, 0.001<br />

Restriction : 0.0 Gain1<br />

º Gain2 (input control) .................................................................real double<br />

Kalman gain / background adaptation time.<br />

Default Value : 0.02<br />

Value Suggestions : Gain2 ¾2.0, 4.0, 8.0, 0.5, 0.1, 0.05, 0.01<br />

Restriction : 0.0 Gain2<br />

º AdaptMode (input control) .....................................................string const char *<br />

Threshold adaptation.<br />

Default Value : ’on’<br />

Value List : AdaptMode ¾’on’, ’off’<br />

º MinDiff (input control) ..............................................................real double<br />

Foreground/background threshold.<br />

Default Value : 7.0<br />

Value Suggestions : MinDiff ¾3.0, 5.0, 7.0, 9.0, 11.0<br />

Recommended Value Step : 0.2<br />

º StatNum (input control) .............................................................integer long<br />

Number of statistic data sets.<br />

Default Value : 10<br />

Value Suggestions : StatNum ¾5, 10, 20, 30<br />

Typical Range of Values : 1 StatNum<br />

Recommended Value Step : 5<br />

º ConfidenceC (input control) .........................................................real double<br />

Confidence constant.<br />

Default Value : 3.25<br />

Value Suggestions : ConfidenceC ¾4.30, 3.25, 2.82, 2.62<br />

Recommended Value Step : 0.01<br />

Restriction : 0.0 ConfidenceC<br />

º TimeC (input control) .................................................................real double<br />

Constant for decay time.<br />

Default Value : 15.0<br />

Value Suggestions : TimeC ¾10.0, 15.0, 20.0<br />

Recommended Value Step : 5.0<br />

Restriction : 0.0 TimeC<br />

Example<br />

/* read Init-Image:*/<br />

read_image(&InitImage,"Init_Image") ;<br />

/* initialize BgEsti-Dataset with<br />

fixed gains and threshold adaption: */<br />

create_bg_esti(InitImage,0.7,0.7,"fixed",0.002,0.02,<br />

"on",7.0,10,3.25,15.0,&BgEstiHandle) ;<br />

/* read the next image in sequence: */<br />

read_image(&Image1,"Image_1") ;<br />

/* estimate the Background: */<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.2. BACKGROUND-ESTIMATOR 649<br />

run_bg_esti(Image1,&Region1,BgEstiHandle) ;<br />

/* display the foreground region: */<br />

disp_region(Region1,WindowHandle) ;<br />

/* read the next image in sequence: */<br />

read_image(&Image2,"Image_2") ;<br />

/* estimate the Background: */<br />

run_bg_esti(Image2,&Region2,BgEstiHandle) ;<br />

/* display the foreground region: */<br />

disp_region(Region2,WindowHandle) ;<br />

/* etc. */<br />

/* change parameter in dataset: */<br />

set_bg_esti_params(BgEstiHandle,0.7,0.7,"fixed",<br />

0.004,0.08,"on",9.0,10,3.25,20.0) ;<br />

/* read the next image in sequence: */<br />

read_image(&Image3,"Image_3") ;<br />

/* estimate the Background: */<br />

run_bg_esti(Image3,&Region3,BgEstiHandle) ;<br />

/* display the foreground region: */<br />

disp_region(Region3,WindowHandle) ;<br />

/* etc. */<br />

Result<br />

set bg esti params returns H MSG TRUE if all parameters are correct.<br />

Parallelization Information<br />

set bg esti params is reentrant and processed without parallelization.<br />

create bg esti<br />

run bg esti<br />

update bg esti<br />

Background estimation<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

update bg esti ( Hobject PresentImage, Hobject UpDateRegion,<br />

long BgEstiHandle )<br />

Change the estimated background image.<br />

update bg esti overwrites the image stored in the current BgEsti data set with the grayvalues of<br />

PresentImage within the bounds of UpDateRegion. This can be used for a ”‘hard”’ adaptation: Image<br />

regions with a sudden change in (known) background can be adapted very fast this way.<br />

Attention<br />

The passed image (PresentImage) must have the same type and size as the background image of the current<br />

data set (initialized with create bg esti).<br />

Parameter<br />

º PresentImage (input object) ..........................................image Hobject : byte / real<br />

Current image.<br />

º UpDateRegion (input object) .....................................................region Hobject<br />

Region describing areas to change.<br />

º BgEstiHandle (input control) ................................................bg estimation long<br />

ID of the BgEsti data set.<br />

Example<br />

<strong>HALCON</strong> 6.0


650 CHAPTER 12. TOOLS<br />

/* read Init-Image: */<br />

read_image(&InitImage,"Init_Image") ;<br />

/* initialize BgEsti-Dataset with<br />

fixed gains and threshold adaption */<br />

create_bg_esti(InitImage,0.7,0.7,"fixed",0.002,0.02,<br />

"on",7,10,3.25,15.0,&BgEstiHandle) ;<br />

/* read the next image in sequence: */<br />

read_image(&Image1,"Image_1") ;<br />

/* estimate the Background: */<br />

run_bg_esti(Image1,&Region1,BgEstiHandle) ;<br />

/* use the Region and the information of a knowledge base */<br />

/* to calculate the UpDateRegion */<br />

update_bg_esti(Image1,UpdateRegion,BgEstiHandle) ;<br />

/* then read the next image in sequence: */<br />

read_image(&Image2,"Image_2") ;<br />

/* estimate the Background: */<br />

run_bg_esti(Image2,&Region2,BgEstiHandle) ;<br />

/* etc. */<br />

Result<br />

update bg esti returns H MSG TRUE if all parameters are correct.<br />

Parallelization Information<br />

update bg esti is reentrant and processed without parallelization.<br />

run bg esti<br />

run bg esti<br />

run bg esti, give bg esti<br />

Background estimation<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

12.3 Barcode<br />

T decode 1d bar code ( Htuple BarCodeElements, Htuple BarCodeDescr,<br />

Htuple *Characters, Htuple *<strong>Reference</strong>, Htuple *IsCorrect )<br />

Decoding of a sequence of elements of a barcode.<br />

T decode 1d bar code decodes a sequence of elements which have been extracted by T find 1d bar code<br />

or T get 1d bar code into a sequence of characters. As input the widths of the elements (in pixels) are<br />

used. The discrete form as it is returned from T discrete 1d bar code can optionally be used. Otherwise<br />

T decode 1d bar code creates the discrete form automatically.<br />

The result of T decode 1d bar code is a sequence of Characters and the corresponding reference numbers<br />

(<strong>Reference</strong>). In addition a parity check is applied, the result of which is returned in IsCorrect. If all<br />

characters are used to store user data (i.e. no parity is used) the value of this parameter has to be ignored.<br />

Parameter<br />

º BarCodeElements (input control) ..................................number-array Htuple . double<br />

Widths of the elements of the barcode.<br />

º BarCodeDescr (input control) .....................string-array Htuple . const char * / long / double<br />

Description of a bar code class.<br />

º Characters (output control) ..........................................string-array Htuple . char *<br />

Decoded characters in standard interpretation.<br />

º <strong>Reference</strong> (output control) ..........................................integer-array Htuple . long *<br />

Decoded characters as numbers.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.3. BARCODE 651<br />

º IsCorrect (output control) ................................................integer Htuple . long *<br />

Information whether the barcode is correct.<br />

Value List : IsCorrect ¾0, 1<br />

Example<br />

HTuple empty; // empty list of values<br />

HTuple BarCodeDescr;<br />

HTuple BarcodeFound,Elements,Orientation;<br />

HTuple Characters,<strong>Reference</strong>,IsCorrect;<br />

Hobject Image,CodeRegion;<br />

gen_1d_bar_code_descr("EAN 13",13,13,&BarCodeDescr);<br />

find_1d_bar_code(Image,&CodeRegion,BarCodeDescr,empty,empty,<br />

&BarcodeFound,&Elements,&Orientation);<br />

if (BarcodeFound[0].l)<br />

{<br />

decode_1d_bar_code(Elements,BarCodeDescr,<br />

&Characters,&<strong>Reference</strong>,&IsCorrect);<br />

if (IsCorrect[0].l)<br />

for (int i=0; i


652 CHAPTER 12. TOOLS<br />

Parameter<br />

º BarCodeDescr (input control) .....................string-array Htuple . const char * / long / double<br />

Description of the bar code class.<br />

º BarCodeDimension (input control) ....................................integer-array Htuple . long<br />

Tuple with the dimension of the examined symbol. In the case of ECC 200: width, height, symbol code.<br />

º BarCodeData (input control) ..........................................integer-array Htuple . long<br />

Tuple with the data values of the examined symbol.<br />

º SymbolCharacters (output control) ..................................string-array Htuple . char *<br />

Data and error codewords of the symbol.<br />

º CorrSymbolData (output control) ....................................integer-array Htuple . long *<br />

Corrected data codewords of the symbol.<br />

º DecodedData (output control) ........................................integer-array Htuple . long *<br />

Decoded data characters as numbers.<br />

º DecodingError (output control) ..........................................integer Htuple . long *<br />

Number of errors during the decoding process.<br />

º StructuredAppend (output control) .................................integer-array Htuple . long *<br />

If the symbol belongs to a group (“structured append”): position in the group, total symbol number, group<br />

(“file”) id.<br />

Result<br />

The return value signals incorrect parameters as well as a failure in the decoding procedure. The error code 8812,<br />

e.g., signals that the decoded data stream contained an invalid data word. Up to now, user-defined control words<br />

can not be handled by the operator. If such control words are detected in the decoded data stream, the error code<br />

8813 is returned.<br />

Parallelization Information<br />

T decode 2d bar code is reentrant and processed without parallelization.<br />

T get 2d bar code<br />

Barcode reader<br />

Possible Predecessor Functions<br />

Module<br />

T discrete 1d bar code ( Htuple Elements, Htuple BarCodeDescr,<br />

Htuple *DisrecteBarCode )<br />

Generate a discrete barcode from the elements widths.<br />

T discrete 1d bar code converts the list of element widths (output from T find 1d bar code or<br />

T get 1d bar code) into a discrete barcode. Thus every element is then represented by its number of modules<br />

(1,2,..) and no longer as its width in pixels.<br />

This operator is used if the barcode type is not available so that T decode 1d bar code cannot be applied,<br />

thus the user wants to find the barcode with the help of <strong>HALCON</strong> operators and then himself decode the<br />

barcode. To create the barcode description the operator T gen 1d bar code descr gen is used and with<br />

T find 1d bar code the element widths are extracted. Then T discrete 1d bar code is used to create<br />

the list of the multiple of the modules.<br />

Parameter<br />

º Elements (input control) ............................................number-array Htuple . double<br />

List of elements widths of the barcode.<br />

º BarCodeDescr (input control) .....................string-array Htuple . const char * / long / double<br />

Description of a bar code class.<br />

º DisrecteBarCode (output control) .................................number-array Htuple . long *<br />

Widths of elements as multiple of modules.<br />

Example<br />

HTuple empty; // empty list of values<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.3. BARCODE 653<br />

HTuple<br />

HTuple<br />

HTuple<br />

Hobject<br />

BarCodeDescr;<br />

BarcodeFound,Elements,Orientation;<br />

DiscreteBarCode;<br />

Image,CodeRegion;<br />

gen_1d_bar_code_descr_gen(20,40,2,empty,empty,-1.0,"false",&BarCodeDescr);<br />

find_1d_bar_code(Image,&CodeRegion,BarCodeDescr,empty,empty,<br />

&BarcodeFound,&Elements,&Orientation);<br />

if (BarcodeFound[0].l)<br />

{<br />

discrete_1d_bar_code(Elements,BarCodeDescr,&DiscreteBarCode);<br />

for (int i=0; i


654 CHAPTER 12. TOOLS<br />

’min size element’ During the analysis of elements (or parts of them) this parameter is used to eliminate very<br />

small objects which do not belong to the barcode. You have to be aware that with a low image quality<br />

elements can be divided into smaller pieces. The parameter has to be larger than the smallest piece. With<br />

good image quality the value can be larger to reduce runtime. In any case the value may not be larger than<br />

the length of one element (in pixels). The area calculated includes only the border of the elements and is<br />

thus smaller. If the value is too large parts of the barcode may be missing.<br />

Default value: 30<br />

Used for: Search for bar code region<br />

’max size element’ Similar to the minimal size this parameter is used to suppress large objects. You have to<br />

know that with a low resolution multiple elements can be extracted as one intermediate region. The value<br />

has thus to be larger than the size of this region. This can be the size of many elements. The area internally<br />

calculated includes only the border of the elements. Furthermore the value should be smaller than the total<br />

size of the barcode.<br />

Default value: 15000<br />

Used for: Search for bar code region<br />

’angle range’ This parameter has the same function as the parameter ’sum angles’ but here it is used during the<br />

inital search for elements of the barcode. It has influence on the estimation of the orientation of the elements.<br />

For low quality images this value has to be large. A small value results in a reduced runtime. The value is<br />

given in degrees. There is no need to change the parameter.<br />

Default value: 24<br />

Used for: Search for bar code region<br />

’correct angle’ This parameter is used to decide if a region can be part of a barcode. For this the orientation<br />

of all boundary points are calculated. If enough points have the same orientation the region is accepted for<br />

further processing. Increasing this value reduces the amount of accepted regions and improves speed. For<br />

low image quality this value has to be low.<br />

Default value: 0.5 (corresponds 50 percent)<br />

Used for: Search for bar code region<br />

’dilation factor’ After the initial step of finding elements these are conbined into a barcode region<br />

(CodeRegion). This is implemented using the closing operator. The mask size is automatically estimated.<br />

If this estimation is wrong it can be corrected using this parameter. If the barcode elements have<br />

large gaps the value has to be larger than one. If the barcode is very close to other objects and is wrongly<br />

connected to this object the value can be smaller than 1. The parameter is independent of the image quality<br />

and runtime.<br />

Default value: 1<br />

Used for: Search for bar code region<br />

’sum angles’ This parameter is used for the final estimation of the orientation of the barcode region (value of<br />

Orientation). For this at first the orientation of the boundaries of all elements are calculated. The most<br />

frequent orientation is calculated. Using the neighboring orientations the mean orientation is calculated. The<br />

parameter determines the amount of neighboring angles used for summing up. The value is given in degrees.<br />

Default value: 40<br />

Used for: Search for bar code region<br />

’min area bar code’ This value is used for the final decision if the region is a barcode. The parameter specifies<br />

the minimum area of the barcode. This area used here consists only of the boundary pixels of the elements<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.3. BARCODE 655<br />

and is thus smaller than the area of CodeRegion. If areas were found which are too small the value has<br />

to be increased. The parameter can also be used if small areas with the same orientation as the barcode<br />

elements were found. The parameter is independent of the image quality and runtime.<br />

Default value: 1000<br />

Used for: Search for bar code region<br />

’sigma project’ For the extraction of the element widths the gray values of the barcode region are projected in<br />

the direction of the elements. The data calculated this way is smoothed to reduce noise. For barcodes with<br />

large gaps between the elements this value can be increased if extra elements were detected. The value<br />

should be larger than 0.5.<br />

Default value: 0.7<br />

Used for: Extraction of element widths<br />

’amplitude project’ For the calculation of the element widths from the gray projections this parameter controls<br />

the minimum amplitude (gray value difference) between dark and light elements. With a lot of noise (e.g.<br />

scratches) this value can be increased. For low contrast images the value has to be low.<br />

Default value: 3<br />

Used for: Extraction of element widths<br />

’width project’ The gray value projections are calculated only in the center part of the barcode region. The<br />

parameter specifies the half width of this area. If the orientation of the region is not estimated correctly this<br />

value has to be small. If there are distortions (e.g. scratches) this value can be increased. For very small<br />

barcodes the value can be decreased.<br />

Default value: 25<br />

Used for: Extraction of element widths<br />

’add length project’ Because the length of the barcode is sometimes to short to get get elements at the beginning<br />

and at the end the region is extended based on this parameter. If the barcode lies near to another object<br />

resulting in a connection of both areas this value can be decreased.<br />

Default value: 5<br />

Used for: Extraction of element widths<br />

’interpolation project’ With this parameter the type of interpolation used for the gray projection is determined.<br />

With a value of 1 a bilinear interpolation is used. With 0 no interpolation is used. In this case the runtime is<br />

shorter but it might result in a wrong extraction of the elements.<br />

Default value: 1<br />

Used for: Extraction of element widths<br />

Please note that these parameters should normally not be changed.<br />

Parameter<br />

º Image (input object) ..............................................................image Hobject<br />

Image with bar code inside.<br />

º CodeRegion (output object) .....................................................region Hobject *<br />

Region of bar code.<br />

º BarCodeDescr (input control) .....................string-array Htuple . const char * / long / double<br />

Description of a bar code class.<br />

<strong>HALCON</strong> 6.0


656 CHAPTER 12. TOOLS<br />

º GenericName (input control) ...................................string(-array) Htuple . const char *<br />

Names of optional control parameters.<br />

Default Value : ’[]’<br />

Value List : GenericName ¾’amplitude sobel’, ’min size element’, ’max size element’, ’angle range’,<br />

’correct angle’, ’dilation factor’, ’sum angles’, ’sigma project’, ’amplitude project’, ’width project’,<br />

’add length project’, ’interpolation project’<br />

º GenericValue (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) Htuple . double / long<br />

Values of optional control parameters.<br />

Default Value : ’[]’<br />

º BarcodeFound (output control) ............................................integer Htuple . long *<br />

Information whether the barcode was found.<br />

Value List : BarcodeFound ¾0, 1<br />

º BarCodeElements (output control) ...............................number-array Htuple . double *<br />

Widths of elements.<br />

º Orientation (output control) .........................................angle.rad Htuple . double *<br />

Orientation of bar code.<br />

Example<br />

HTuple empty; // empty list of values<br />

HTuple BarCodeDescr;<br />

HTuple BarcodeFound,Elements,Orientation;<br />

HTuple Characters,<strong>Reference</strong>,IsCorrect;<br />

Hobject Image,CodeRegion;<br />

gen_1d_bar_code_descr("EAN 13",13,13,&BarCodeDescr);<br />

find_1d_bar_code(Image,&CodeRegion,BarCodeDescr,empty,empty,<br />

&BarcodeFound,&Elements,&Orientation);<br />

if (BarcodeFound[0].l)<br />

{<br />

decode_1d_bar_code(Elements,BarCodeDescr,<br />

&Characters,&<strong>Reference</strong>,&IsCorrect);<br />

if (IsCorrect[0].l)<br />

for (int i=0; i


12.3. BARCODE 657<br />

T find 1d bar code region ( Hobject Image, Hobject *CodeRegion,<br />

Htuple BarCodeDescr, Htuple GenericName, Htuple GenericValue,<br />

Htuple *Orientation )<br />

Look for multiple barcode regions in an image.<br />

T find 1d bar code region looks for multiple barcodes in the image. In contrast to T find 1d bar code<br />

this operator is used if an image contains more than one barcode. Here only the regions but not the widths of the<br />

elements are extracted. For every region the orientation in radians is calculated.<br />

The control of the image processing is identical to T find 1d bar code. The description of the parameters<br />

GenericName and GenericValue can be found at this operator.<br />

Parameter<br />

º Image (input object) ..............................................................image Hobject<br />

Image with barcodes inside.<br />

º CodeRegion (output object) ..............................................region(-array) Hobject *<br />

Regions of barcodes.<br />

º BarCodeDescr (input control) .....................string-array Htuple . const char * / long / double<br />

Description of a bar code class.<br />

º GenericName (input control) ...................................string(-array) Htuple . const char *<br />

Names of optional parameters.<br />

Default Value : ’[]’<br />

Value List : GenericName ¾’amplitude sobel’, ’min size element’, ’max size element’, ’angle range’,<br />

’correct angle’, ’dilation factor’, ’sum angles’<br />

º GenericValue (input control) . . . . . . . . . . . . . . . . . .number(-array) Htuple . double / long / const char *<br />

Values of optional parameters.<br />

Default Value : ’[]’<br />

º Orientation (output control) .......................................real(-array) Htuple . double *<br />

Orientation of bar code.<br />

Example<br />

HTuple empty; // empty list of values<br />

HTuple BarCodeDescr;<br />

HTuple Orientations, Elements;<br />

HTuple Characters,<strong>Reference</strong>,IsCorrect;<br />

Hobject Image,CodeRegions,CodeRegion,GrayRegion;<br />

long num;<br />

gen_1d_bar_code_descr("code 39",4,15,&BarCodeDescr);<br />

find_1d_bar_code_region(Image,&CodeRegion,BarCodeDescr,empty,empty,<br />

&Orientations);<br />

count_obj(CodeRegions,&num);<br />

for (long i=0; i


658 CHAPTER 12. TOOLS<br />

Possible Predecessor Functions<br />

T gen 1d bar code descr, T gen 1d bar code descr gen<br />

Possible Successor Functions<br />

T get 1d bar code, count obj, select obj, reduce domain<br />

T find 1d bar code<br />

sobel dir<br />

Barcode reader<br />

Alternatives<br />

See Also<br />

Module<br />

T find 2d bar code ( Hobject Image, Hobject *CodeRegion,<br />

Htuple BarCodeDescr, Htuple GenParamNames, Htuple GenParamValues,<br />

Htuple *CodeRegDescr )<br />

Find regions that might contain a 2D bar code.<br />

T find 2d bar code searches in the image Image for regions that might contain a 2D bar code. Candidate regions<br />

are returned in the array of regions CodeRegion. Whether such a region really contains a (readable) 2D bar<br />

code can only be determined with the help of the operator T get 2d bar code (or T get 2d bar code pos).<br />

Besides regions that might contain a 2D bar code, the operator passes further, internal information about the regions<br />

to the operator for extracting the data from a symbol (T get 2d bar code or T get 2d bar code pos). This<br />

information is stored in a region descriptor and returned in the parameter CodeRegDescr.<br />

Depending on the method for printing the bar code (’mode’), different image processing steps are performed.<br />

Together with other information about the 2D bar code, the actual printing method is part of a descriptor created<br />

with the help of the operator T gen 2d bar code descr and passed in the parameter BarCodeDescr.<br />

In the case of difficult conditions, additional control parameters can be passed to the operator with the help of the<br />

(optional) generic parameters GenParamNames nd GenParamValues, in the form of descriptor-value pairs.<br />

One group of parameters describes the appearance of the symbols in the actual images, e.g., the expected size of<br />

data elements in pixels. The operator will then check candidate regions against the specified criteria. Suitable<br />

values can be determined from the real images, e.g., by manually selecting a region with a bar code and then<br />

applying the corresponding operator. If the specification of such parameters does not lead to successfully extracted<br />

regions, the user can influence the underlying image processing operators directly with the help of a second group<br />

of parameters. As the image processing steps taken depend on the printing method, different parameters are to be<br />

applied.<br />

¯ Parameter that will be passed on in CodeRegDescr:<br />

’module width’ Mean size of a module (data element) in pixels.<br />

From this quantity, a set of other parameters will be derived. A module should have a size of 4 to 16<br />

pixels in order to be recognized successfully.<br />

GenParamValues: 0<br />

default: 10<br />

¯ Parameters for the printing method ’printed’:<br />

The following parameters are used to limit the set of candidate regions with the help of region features. To<br />

prevent the use of a certain feature, the corresponding parameter must be set to -1.<br />

’anisometry max’ Maximum anisometry (see operator eccentricity).<br />

GenParamValues: 1 (-1: feature not used)<br />

default: 1.45<br />

’compactness min’ Minimum compactness (see operator compactness).<br />

GenParamValues: 1 (-1: feature not used)<br />

default: 1.2<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.3. BARCODE 659<br />

’compactness max’ Maximum compactness.<br />

GenParamValues: ’compactness min’ (-1: feature not used)<br />

default: 3.0<br />

’circularity max’ Maximum circularity (see operator circularity).<br />

GenParamValues: 0...1.0 (-1: featurenotused)<br />

default: 0.8<br />

’circularity min’ Minimum circularity.<br />

GenParamValues: ’circularity max’ (-1: feature not used)<br />

default: 0.45<br />

’deviation min’ Minimum deviation of gray values (see operator intensity).<br />

GenParamValues: 1.0 (-1: feature not used)<br />

default: 20.0<br />

The following parameters are automatically derived from the size of a module, ’module width’, and from<br />

parameters of the bar code descriptor BarCodeDescr (see operator T gen 2d bar code descr). However,<br />

they can be adjusted individually, too.<br />

ATTENTION: If you want to set ’module width’ together with other parameters, make sure set ’module<br />

width’ BEFORE the others!<br />

’mean mask size 1’ Mask size for the first smoothing of the image.<br />

GenParamValues: 3<br />

default:<br />

¾ £ ¼ ÑÓÙÐ ÛØ ¼<br />

’mean mask size 2’ Mask size for the second smoothing of the image.<br />

GenParamValues: 5<br />

default:<br />

½¼¼ £ ¼ ÑÓÙÐ ÛØ ¼<br />

’area min’ Minimum size of the symbol in pixels squared.<br />

GenParamValues: 0<br />

default:<br />

¼¾ £ ¼ ÑÓÙÐ ÛØ ¼¾ £ ¼ ÓÐÙÑÒ× ÑÒ ¼ £ ¼ ÖÓÛ× ÑÒ ¼<br />

’area max’ Maximum size of the symbol in pixels squared.<br />

GenParamValues: ’area min’<br />

default:<br />

¼¼ £ ¼ ÑÓÙÐ ÛØ ¼¾ £ ¼ ÓÐÙÑÒ× ÑÒ ¼ £ ¼ ÖÓÛ× ÑÒ ¼<br />

’closing mask rad’ Mask size for calling the operator closing circle with a test region..<br />

GenParamValues: 0<br />

default:<br />

’module width’<br />

¯ Parameters for the printing method ’engraved darkfield’:<br />

’compactness min’ Minimum compactness (see operator compactness).<br />

GenParamValues: 1.0 (-1: feature not used)<br />

default: 1.2<br />

’compactness max’ .<br />

GenParamValues: ’compactness min’ (-1: feature not used)<br />

default: 3.0<br />

’edge thresh’ Maximum compactness.<br />

GenParamValues: 0...255<br />

default: 120<br />

’region rect2 rel’ Relation between the areas of the region and the smallest surrounding rectangle.<br />

GenParamValues: 1.0<br />

default: 0.7<br />

’median mask rad’ Mask size for the initial median filtering (see operator median image).<br />

GenParamValues: 0<br />

default:<br />

¼½ £ ¼ ÑÓÙÐ ÛØ ¼ ·¼<br />

<strong>HALCON</strong> 6.0


660 CHAPTER 12. TOOLS<br />

¯ Parameters for the printing method ’engraved lightfield’:<br />

’anisometry max’ Maximum anisometry (see operator eccentricity).<br />

GenParamValues: 1 (-1: feature not used)<br />

default: 1.45<br />

’compactness min’ Minimum compactness (see operator compactness).<br />

GenParamValues: 1 (-1: feature not used)<br />

default: 1.2<br />

’compactness max’ Maximum compactness.<br />

GenParamValues: ’compactness min’ (-1: feature not used)<br />

default: 3.0<br />

’circularity max’ Maximum circularity (see operator circularity).<br />

GenParamValues: 0...1.0 (-1: featurenotused)<br />

default: 0.8<br />

’circularity min’ Minimum circularity.<br />

GenParamValues: ’circularity max’ (-1: feature not used)<br />

default: 0.45<br />

’deviation min’ Minimum deviation of gray values (see operator intensity).<br />

GenParamValues: 1.0 (-1: feature not used)<br />

default: 20.0<br />

’mean mask size’ Mask size for smoothing the image.<br />

GenParamValues: 3<br />

default:<br />

½¼ £ ¼ ÑÓÙÐ ÛØ ¼<br />

’area min’ Minimum size of the symbol in pixels squared.<br />

GenParamValues: 0<br />

default:<br />

¼¾ £ ¼ ÑÓÙÐ ÛØ ¼¾ £ ¼ ÓÐÙÑÒ× ÑÒ ¼ £ ¼ ÖÓÛ× ÑÒ ¼<br />

’area max’ Maximum size of the symbol in pixels squared.<br />

GenParamValues: ’area min’<br />

default:<br />

¼¼ £ ¼ ÑÓÙÐ ÛØ ¼¾ £ ¼ ÓÐÙÑÒ× ÑÒ ¼ £ ¼ ÖÓÛ× ÑÒ ¼<br />

’closing mask rad’ Mask size for calling the operator closing circle with a test region..<br />

GenParamValues: 0<br />

default:<br />

’module width’<br />

’opening mask rad’ Mask size for calling the operator opening circle with a test region..<br />

GenParamValues: 0<br />

default:<br />

½ £ ¼ ÑÓÙÐ ÛØ ¼<br />

Parameter<br />

º Image (input object) ..............................................................image Hobject<br />

Image of one or more bar codes.<br />

º CodeRegion (output object) ..............................................region(-array) Hobject *<br />

Regions that might contain a bar code.<br />

º BarCodeDescr (input control) .....................string-array Htuple . const char * / long / double<br />

Description of a 2D bar code class to look for.<br />

º GenParamNames (input control) ................................string(-array) Htuple . const char *<br />

List of names of (optional) generic parameters controlling the image processing.<br />

Default Value : ’[]’<br />

º GenParamValues (input control) . . . . . . . . . . . . . . . number(-array) Htuple . double / long / const char *<br />

List of values of generic parameters controlling the image processing.<br />

Default Value : ’[]’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.3. BARCODE 661<br />

º CodeRegDescr (output control) ......................string-array Htuple . char * / long * / double *<br />

Additional parameters describing the bar code regions. They can be used for extracting the data (see<br />

T decode 2d bar code).<br />

Result<br />

The operator T find 2d bar code returns the value H MSG TRUE if the given parameters are correct. Otherwise,<br />

an exception will be raised.<br />

Parallelization Information<br />

T find 2d bar code is reentrant and processed without parallelization.<br />

T gen 2d bar code descr<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

T get 2d bar code, T get 2d bar code pos<br />

Barcode reader<br />

Module<br />

T gen 1d bar code descr ( Htuple CodeName, Htuple MinCharacters,<br />

Htuple MaxCharacters, Htuple *BarCodeDescr )<br />

Generate a decscription of a 1D bar code.<br />

T gen 1d bar code descr generates a description of a one dimensional bar code. This description<br />

is used for the search (T find 1d bar code or T find 1d bar code region) and the decoding<br />

(T decode 1d bar code) of the barcode. T gen 1d bar code descr is therefore the first operator in a<br />

program sequence for barcode processing. T gen 1d bar code descr has only to be called once at the beginning<br />

of a program. The descriptor can be used multiple times. In the case of different types of barcodes the<br />

operator has to be called once for each type.<br />

You have to be aware that this description contains only basic informations about the barcode. Thus an arbitrary<br />

description can be used to extract almost every type of barcode. On the other hand a specific description is<br />

important for the decoding of a barcode type.<br />

Parameter<br />

º CodeName (input control) ..............................................string Htuple . const char *<br />

Name of bar code.<br />

Default Value : ”EAN 13”<br />

Value List : CodeName ¾”2/5 industrial”, ”2/5 interleaved”, ”code 39”, ”EAN 13”, ”EAN 8”, ”Codabar”<br />

º MinCharacters (input control) .............................................integer Htuple . long<br />

Minimum number of characters (if not fixed).<br />

Default Value : 6<br />

Value Suggestions : MinCharacters ¾-1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 25, 30<br />

º MaxCharacters (input control) .............................................integer Htuple . long<br />

Maximum number of characters (if not fixed).<br />

Default Value : 10<br />

Value Suggestions : MaxCharacters ¾-1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 25, 30, 35, 40,<br />

50<br />

º BarCodeDescr (output control) ......................string-array Htuple . char * / long * / double *<br />

Description of a bar code class.<br />

Example<br />

HTuple empty; // empty list of values<br />

HTuple BarCodeDescr;<br />

HTuple BarcodeFound,Elements,Orientation;<br />

HTuple Characters,<strong>Reference</strong>,IsCorrect;<br />

Hobject Image,CodeRegion;<br />

gen_1d_bar_code_descr("EAN 13",13,13,&BarCodeDescr);<br />

<strong>HALCON</strong> 6.0


662 CHAPTER 12. TOOLS<br />

find_1d_bar_code(Image,&CodeRegion,BarCodeDescr,empty,empty,<br />

&BarcodeFound,&Elements,&Orientation);<br />

if (BarcodeFound[0].l)<br />

{<br />

decode_1d_bar_code(Elements,BarCodeDescr,<br />

&Characters,&<strong>Reference</strong>,&IsCorrect);<br />

if (IsCorrect[0].l)<br />

for (int i=0; i


12.3. BARCODE 663<br />

º StopElement (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) Htuple . long<br />

List of elements of the stop sequence. The width of an element is given as the number of modules. Gaps are<br />

given as negative values.<br />

Default Value : ’[1,-1]’<br />

º MaxSizeRatio (input control) ............................................number Htuple . double<br />

Maximum ratio length to height.<br />

Default Value : 2.5<br />

Value List : MaxSizeRatio ¾-1,2,3,4,5,6<br />

º DiscreteCode (input control) .........................................string Htuple . const char *<br />

Discrete code (ignore white elements).<br />

Default Value : ’false’<br />

Value List : DiscreteCode ¾’true’, ’false’<br />

º BarCodeDescr (output control) ......................string-array Htuple . char * / long * / double *<br />

Description of a bar code class.<br />

Example<br />

HTuple empty; // empty list of values<br />

HTuple BarCodeDescr;<br />

HTuple BarcodeFound,Elements,Orientation;<br />

HTuple DiscreteBarCode;<br />

Hobject Image,CodeRegion;<br />

gen_1d_bar_code_descr_gen(20,40,2,empty,empty,-1.0,"false",&BarCodeDescr);<br />

find_1d_bar_code(Image,&CodeRegion,BarCodeDescr,empty,empty,<br />

&BarcodeFound,&Elements,&Orientation);<br />

if (BarcodeFound[0].l)<br />

{<br />

discrete_1d_bar_code(Elements,BarCodeDescr,&DiscreteBarCode);<br />

for (int i=0; i


664 CHAPTER 12. TOOLS<br />

The bar code can be described more closely using the parameters GenParamNames and GenParamValues,<br />

which form pairs of descriptors and values. The following parameters describe the size and the form of the symbols:<br />

’columns’ Exact number of columns of the symbol.<br />

GenParamValues: 10, 12, 14, 16, 18, 20, 22, 24, 26, 32, 36, 40,<br />

44, 48, 52, 64, 72, 80, 88, 96, 104, 120, 132, 144<br />

default: -<br />

’columns min’ Minimum number of columns.<br />

GenParamValues: 10...144 (even)<br />

default: 10<br />

’columns max’ Maximum number of columns.<br />

GenParamValues: 10...144 (even)<br />

’rows’ Exact number of rows of the symbol.<br />

GenParamValues: 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 32, 36, 40,<br />

44, 48, 52, 64, 72, 80, 88, 96, 104, 120, 132, 144<br />

default: -<br />

’rows min’ Minimum number of rows.<br />

GenParamValues: 8...144 (even)<br />

default: 8<br />

’rows max’ Maximum number of rows.<br />

GenParamValues: 8...144 (even)<br />

default: 144<br />

’shape’ Form of the symbol.<br />

GenParamValues:<br />

default:<br />

’square’, ’rectangle’, ’any’<br />

’any’<br />

The following parameters describe the printing method and the appearance of the bar code:<br />

’foreground’ Appearance of bits corresponding to a logical 1 (foreground).<br />

2D bar codes can be printed dark on light or vice versa. If the appearance of bits corresponding to a logical<br />

1 can be specified in advance, computing time will be significantly reduced, especially when looking for<br />

regions that might contain a bar code (operator T find 2d bar code).<br />

GenParamValues: ’any’: unknown appearance<br />

’dark’,’black’: symbols are printed dark on light<br />

’light’,’white’: symbols are printed light on dark<br />

default:<br />

’any’<br />

’mode’ Method used for printing the 2D bar code.<br />

By specifying this parameter, image processing can be optimized.<br />

GenParamValues: ’printed’: Standard black-and-white printing. Modules appear as<br />

square regions; neighboring modules with the same value<br />

form one region.<br />

’engraved darkfield’: Modules with the value 1 are engraved into the surface,<br />

e.g. by a laser. Using dark field lighting these modules<br />

appear as dark round dots with a white corona; neighboring<br />

modules with the value 1 are therefore separated by<br />

gaps.<br />

’engraved lightfield’: Similar to ’engraved darkfield’, but using light field lighting.<br />

Modules with the value 1 therefore appear as light<br />

dots with a dark corona; neighboring modules with the<br />

value 1 are again separated by gaps.<br />

default:<br />

’printed’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.3. BARCODE 665<br />

Parameter<br />

º CodeType (input control) ..............................................string Htuple . const char *<br />

Type of the 2D bar code.<br />

Default Value : ”Data Matrix ECC 200”<br />

Value List : CodeType ¾”Data Matrix ECC 200”<br />

º GenParamNames (input control) ..................................string-array Htuple . const char *<br />

List of names of generic parameters describing the 2D bar code class.<br />

Default Value : ’[]’<br />

Value List : GenParamNames ¾’columns’, ’columns min’, ’columns max’, ’rows’, ’rows min’,<br />

’rows max’, ’foreground’, ’shape’, ’mode’<br />

º GenParamValues (input control) .................integer-array Htuple . long / const char * / double<br />

List of values of the generic parameters describing the 2D bar code class.<br />

Default Value : ’[]’<br />

Value List : GenParamValues ¾8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 32, 36, 40, 44, 48, 52, 64, 72, 80,<br />

88, 96, 104, 120, 132, 144, ’dark’, ’light’, ’square’, ’rectangle’, ’printed’, ’engraved darkfield’,<br />

’engraved lightfield’, ’any’<br />

º BarCodeDescr (output control) ......................string-array Htuple . char * / long * / double *<br />

Description of the 2D bar code class.<br />

Example<br />

gen_2d_bar_code_descr (’Data Matrix ECC 200’, [’mode’,’foreground’],<br />

[’printed’,’dark’], BarCodeDescr)<br />

Result<br />

The operator T gen 2d bar code descr returns the value H MSG TRUE if the given parameters are correct.<br />

Otherwise, an exception will be raised.<br />

Parallelization Information<br />

T gen 2d bar code descr is reentrant and processed without parallelization.<br />

T find 2d bar code<br />

Barcode reader<br />

Possible Successor Functions<br />

Module<br />

T get 1d bar code ( Hobject BarCodeRegion, Htuple BarCodeDescr,<br />

Htuple GenericName, Htuple GenericValue, Htuple Orientation,<br />

Htuple *BarCodeElements )<br />

Extract the widths of the elements inside a barcode region.<br />

T get 1d bar code extracts the widths of the elements of a barcode inside the specified region.<br />

The control of the processing is identical to T find 1d bar code. The description of the parameters<br />

GenericName and GenericValue can be found at this operator.<br />

Parameter<br />

º BarCodeRegion (input object) ....................................................image Hobject<br />

Region of bar code.<br />

º BarCodeDescr (input control) .....................string-array Htuple . const char * / long / double<br />

Description of a bar code class.<br />

º GenericName (input control) ...................................string(-array) Htuple . const char *<br />

Names of optional parameters.<br />

Default Value : ’[]’<br />

Value List : GenericName ¾’sigma project’, ’amplitude project’, ’width project’, ’add length project’,<br />

’interpolation project’<br />

º GenericValue (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) Htuple . double / long<br />

Values of optional parameters.<br />

Default Value : ’[]’<br />

<strong>HALCON</strong> 6.0


666 CHAPTER 12. TOOLS<br />

º Orientation (input control) ............................................angle.rad Htuple . double<br />

Orientation of bar code.<br />

º BarCodeElements (output control) ...............................number-array Htuple . double *<br />

Widths of elements.<br />

Example<br />

HTuple empty; // empty list of values<br />

HTuple BarCodeDescr;<br />

HTuple Orientations, Elements;<br />

HTuple Characters,<strong>Reference</strong>,IsCorrect;<br />

Hobject Image,CodeRegions,CodeRegion,GrayRegion;<br />

long num;<br />

gen_1d_bar_code_descr("code 39",4,15,&BarCodeDescr);<br />

find_1d_bar_code_region(Image,&CodeRegion,BarCodeDescr,empty,empty,<br />

&Orientations);<br />

count_obj(CodeRegions,&num);<br />

for (long i=0; i


12.3. BARCODE 667<br />

size of the data field is not to be confused with the size of the symbol which in turn encompasses additional finder<br />

and alignment patterns.<br />

If no 2D bar code could be extracted the operator returns a corresponding error code.<br />

In difficult cases, the user can influence image processing with the help of the (optional) generic parameters<br />

GenParamNames and GenParamValues. The width of a module in pixels (’module width’) does<br />

not need to be specified, it is part of the region descriptor CodeRegDescr. As in the case of the operator<br />

T find 2d bar code, for the different printing methods different image processing steps are applied, leading<br />

to different parameters.<br />

As a short overview, image processing falls into the following parts: First, the region BarCodeRegion is divided<br />

into a dark and a light region by applying a thresholding operator. Because there must be a “silent” area around<br />

each 2D bar code, this area can be examined to determine whether the bar code is printed black-on-white or vice<br />

versa. With this information, the dark and the light region can be assigned to the logical data values. Next,<br />

BarCodeRegion is approximated by a rectangle. Then, the special finder patterns that each each symbol must<br />

contain are searched for in the border areas of the rectangle. From the finder pattern, the size of the data matrix<br />

and the size and the position of the modules (data elements) can be determined. Finally, the value of the modules<br />

is determined.<br />

¯ Parameters controlling the classification of modules as being dark or light:<br />

’module rad ratio’ Part of the module that is to be used for its classification.<br />

This parameter controls which part of the module area (in percent, measured from the center) is used to<br />

determine its value. With a ’module rad ratio’ of 1.0, the whole area of the module will be examined.<br />

With very small ’module rad ratio’, only one point in the middle will be examined.<br />

GenParamValues: 0 ’module rad ratio’ 1<br />

default: printing method ’printed’, ’engraved lightfield’: 0.3<br />

printing method ’engraved darkfield’: 0.7<br />

’use grayvals’ Method for the classification of modules (Selectable only for the printing methods ’printed’<br />

and ’engraved lightfield’; for the printing method ’engraved darkfield’, the gray-value-based method<br />

is always used!).<br />

The parameter ’use grayvals’ controls by which method the modules are classified. If ’use grayvals’ is<br />

set to ’no’, the module’s value is determined by examining whether the part of the module specified by<br />

’module rad ratio’ is part of the region that has been assigned the value 1. If more than half of the<br />

module is part of this region, the module is interpreted as a logical one.<br />

In the case ’use grayvals’ is set to ’yes’, the gray values inside ’module rad ratio’ are examined. For<br />

this, the known border parts of the symbol are used to create classificators with the features “minimum<br />

gray value”, “maximum gray value”, and “range of gray values”. A feature will be automatically excluded<br />

if it cannot separate the known dark and light regions. It can also be excluded manually with<br />

the help of the parameters below. The value of the modules is then determined by applying the trained<br />

classificators. In case of ambiguous results, the majority decision is adopted.<br />

If none of the gray value features can separate the test regions, the operator switches automatically<br />

to the region-based method in case the printing method is set to ’printed’. This can be detected by<br />

examining the data values returned in BarCodeData: The region-based method yields multiples of 4,<br />

the gray-value-based method values between -3 and +3. If separation fails when the printing method is<br />

’engraved darkfield’, an error code is returned. Note, that classification performance can be enhanced<br />

by chosing a suitable value for ’module rad ratio’.<br />

GenParamValues: ’yes’, ’no’<br />

default:<br />

’yes’<br />

’use grayval min’ Use the feature “gray value minimum” for classifying module values.<br />

GenParamValues: ’yes’, ’no’<br />

default:<br />

’yes’<br />

’use grayval max’ Use the feature “gray value maximum” for classifying module values.<br />

GenParamValues: ’yes’, ’no’<br />

default: ’printed’, ’engraved lightfield’: ’yes’<br />

’engraved darkfield’:<br />

’no’<br />

<strong>HALCON</strong> 6.0


668 CHAPTER 12. TOOLS<br />

’use grayval range’ Use the feature “gray value range” for classifying module values.<br />

GenParamValues: ’yes’, ’no’<br />

default:<br />

’yes’<br />

¯ Parameters for the printing methods ’printed’ and ’engraved lightfield’:<br />

’enlarge region rad’ Enlarge the symbol region.<br />

GenParamValues: 0 ( 0: enlargment prohibited)<br />

default: 2.5<br />

’thresh percent’ Area of the histogram in which to look for an optimal threshold.<br />

The threshold for separating dark and light regions will be searched for in the middle ’thresh percent’<br />

percent of the gray value histogram. If ’thresh percent’ is set to 0, a threshold exactly in the middle of<br />

the histogram is selected. If ’thresh percent’ is set to 100, the whole histogram will be searched. Note,<br />

that the threshold influences not only the size of the data region, but also the position of the surrounding<br />

rectangle and with it, slightly, the position of the modules.<br />

GenParamValues: 0...100<br />

default: 50<br />

’thresh step width’ Step width for the search of the optimal threshold.<br />

The histogram area specified in the parameter ’thresh percent’ will be stepped through using<br />

’thresh step width’ until an optimal separation of dark and light regions is reached. The optimum<br />

is declared to be found when the number of individual regions is at its maximum. The smaller<br />

’thresh step width’ is, the better a threshold can be determined, however at the cost of rising computing<br />

time, of course.<br />

GenParamValues: 0<br />

default: 10<br />

’smooth cont’ Parameter for approximating the region by a polygon (rectangle).<br />

The parameter ’smooth cont’ controls to which degree the contour is smoothed before approximating it<br />

with a polygon (see operator segment contours xld).<br />

GenParamValues: 0,3,5,7,9,. . .<br />

default: 5<br />

’max line dist1’, ’max line dist2’ Distance between the contour and its approximation.<br />

The parameters ’max line dist1’ and ’max line dist2’ control the maximal distance between the contour<br />

and its approximation (see operator segment contours xld).<br />

GenParamValues: 0<br />

default: 4<br />

’min cont len’ Minimum length of the contour elements in pixel.<br />

Contour elements shorter than ’min cont len’ will be ignored when approximating the region by a<br />

rectangle. In the case of small symbols or low resolution, it can be helpful to decrease this parameter.<br />

GenParamValues: 0<br />

default: 50<br />

’border width min’ Minimum width of the border search area.<br />

The border area of the symbol region must contain the so-called finder patterns (ECC 200: two lines<br />

with the value 1, two with alternating values). To find these patterns, a search region is constructed<br />

along the sides of the rectangle. Starting with ’border width min’, the width of the seach region is<br />

increased until the finder patterns have been detected, or until ’border width max’ has been reached.<br />

GenParamValues: 0<br />

default: 2<br />

’border width max’ Maximum width of the border search area.<br />

GenParamValues: ’border width min’<br />

default: 5<br />

’border width’ Exact width of the border search area.<br />

Alternatively, the exact width of this search area can be specified in the parameter ’border width’. This<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.3. BARCODE 669<br />

automatically sets ’border width min’ and ’border width max’.<br />

GenParamValues: 0<br />

default: -<br />

Parameters for the printing method ’engraved darkfield’:<br />

’median mask rad’ Mask size for the initial median filtering (see operator median image).<br />

GenParamValues: 3,5,7,...,501<br />

default: ’module width’*0.1 + 0.5<br />

’gray erosion size’ Mask size for the subsequent gray value erosion (see operator gray erosion rect).<br />

GenParamValues: 3,5,7,...,511<br />

default: ’module width’*0.18 + 3.5<br />

’measure sigma’ Parameter for the extraction of linear edge segment pairs (see operator<br />

T measure pairs).<br />

GenParamValues: 0.4...100<br />

default: ’module width’ 20: 0.7<br />

’module width’ 20: 1.4<br />

’measure thresh’ Parameter for the extraction of linear edge segment pairs (see operator<br />

T measure pairs).<br />

GenParamValues: 1...255<br />

default: 2.0<br />

Attention<br />

The operator T get 2d bar code returns error codes to signal that the candidate region did not contain a valid<br />

2D bar code. As the region candidates extracted by the operator T find 2d bar code can perfectly well encompass<br />

regions without a bar code, every call to T get 2d bar code should be surrounded by error handling<br />

code (see example).<br />

Parameter<br />

º BarCodeRegion (input object) ...................................................region Hobject<br />

Region that might contain a 2D bar code.<br />

º Image (input object) ..............................................................image Hobject<br />

Corresponding image.<br />

º BarCodeDescr (input control) .....................string-array Htuple . const char * / long / double<br />

Description of the bar code class.<br />

º CodeRegDescr (input control) .....................string-array Htuple . const char * / long / double<br />

Additional parameters describing the bar code region. They can be used for extracting the data<br />

º GenParamNames (input control) ..................................string-array Htuple . const char *<br />

List of names of (optional) generic control parameters.<br />

Default Value : ’[]’<br />

º GenParamValues (input control) .............................number-array Htuple . double / long<br />

List of values of the generic parameters.<br />

Default Value : ’[]’<br />

º BarCodeDimension (output control) .................................integer-array Htuple . long *<br />

Tuple with the dimension of the extracted symbol. In the case of ECC 200: data field width, height, symbol<br />

index.<br />

º BarCodeData (output control) ........................................integer-array Htuple . long *<br />

Tuple with the data values of the extracted symbol. value 0: logical 1, value 0: logical 0, value =<br />

0: module could not be classified.<br />

Example<br />

dev_error_var (ErrorCode, 1)<br />

gen_2d_bar_code_descr (’Data Matrix ECC 200’, [’mode’], [’printed’],<br />

BarCodeDescr)<br />

<strong>HALCON</strong> 6.0


670 CHAPTER 12. TOOLS<br />

read_image (Image, ’bar2d.tif’)<br />

find_2d_bar_code (Image, CodeRegion, BarCodeDescr,<br />

[’module_width’], [10], CodeRegDescr)<br />

SymbolNum := |CodeRegion|<br />

for i := 1 to SymbolNum by 1<br />

ObjectSelected := CodeRegion[i]<br />

dev_set_check (’˜give_error’)<br />

get_2d_bar_code (ObjectSelected, Image, BarCodeDescr, CodeRegDescr,<br />

[], [], BarCodeDimension, BarCodeData)<br />

err := ErrorCode<br />

dev_set_check (’give_error’)<br />

if (err = 2)<br />

decode_2d_bar_code (BarCodeDescr, BarCodeDimension, BarCodeData,<br />

SymbolCharacters, CorrSymbolData, DecodedData,<br />

DecodingError, StructuredAppend)<br />

if (|DecodedData|)<br />

tuple_chrt (DecodedData, String)<br />

endif<br />

endif<br />

endfor<br />

Result<br />

The return value can signal incorrect parameters as well as the failure to extract a 2D bar code. Such a failure can be<br />

due to different causes: If no surrounding rectangle was found, the operator returns the error code 8808. Error code<br />

8807 signals that the rectangle does not lie completely inside the image. If no finder pattern was detected inside the<br />

border search area, the error code 8810 is returned. If the two continuous lines forming the ’L’ of the finder pattern<br />

could not be found, the error code 8809 is returned. In the case of the printing method ’engraved darkfield’, the<br />

error code 8811 signals that none of the gray value features can separate the test regions, i.e. that modules cannot<br />

be classified.<br />

Parallelization Information<br />

T get 2d bar code is reentrant and processed without parallelization.<br />

T find 2d bar code<br />

T decode 2d bar code<br />

T get 2d bar code pos<br />

Barcode reader<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

Module<br />

T get 2d bar code pos ( Hobject BarCodeRegion, Hobject Image,<br />

Htuple BarCodeDescr, Htuple CodeRegDescr, Htuple GenParamNames,<br />

Htuple GenParamValues, Htuple *BarCodeDimension, Htuple *BarCodeData,<br />

Htuple *DataElementRow, Htuple *DataElementCol )<br />

Extract the data values of the elements (in ECC 200: “modules”) inside a bar code region (“Data Matrix symbol”)<br />

and their positions in the image.<br />

T get 2d bar code pos extracts the 2D bar code data from a candidate symbol region given in<br />

BarCodeRegion and the corresponding image given in Image elements. In contrast to T get 2d bar code,<br />

this operator also returns the positions of the data elements in the image in the parameters DataElementRow<br />

and DataElementCol. This can be used to check the result of the operator, e.g., by displaying the data in the<br />

real image. For a description of the other parameters, see T get 2d bar code.<br />

Attention<br />

The operator T get 2d bar code pos returns error codes to signal that the candidate region did not contain a<br />

valid 2D bar code. As the region candidates extracted by the operator T find 2d bar code can perfectly well<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.3. BARCODE 671<br />

encompass regions without a bar code, every call to T get 2d bar code pos should be surrounded by error<br />

handling code (see example).<br />

Parameter<br />

º BarCodeRegion (input object) ...................................................region Hobject<br />

Region that might contain a bar code.<br />

º Image (input object) ..............................................................image Hobject<br />

Corresponding image.<br />

º BarCodeDescr (input control) .....................string-array Htuple . const char * / long / double<br />

Description of the 2D bar code class.<br />

º CodeRegDescr (input control) .....................string-array Htuple . const char * / long / double<br />

Additional parameters describing the bar code region. They can be used for extracting the data.<br />

º GenParamNames (input control) ..................................string-array Htuple . const char *<br />

List of names of (optional) generic control parameters.<br />

Default Value : ’[]’<br />

º GenParamValues (input control) .............................number-array Htuple . double / long<br />

List of values of the generic parameters.<br />

Default Value : ’[]’<br />

º BarCodeDimension (output control) .................................integer-array Htuple . long *<br />

Tuple with the dimension of the extracted symbol. In the case of ECC 200: data field width, height, symbol<br />

index.<br />

º BarCodeData (output control) ........................................integer-array Htuple . long *<br />

Tuple with the data values of the extracted symbol. value 0: logical 1, value 0: logical 0, value =<br />

0: module could not be classified.<br />

º DataElementRow (output control) ....................................real-array Htuple . double *<br />

Tuple with the row positions of the data elements of the extracted symbol in the image.<br />

º DataElementCol (output control) ....................................real-array Htuple . double *<br />

Tuple with the column positions of the data elements of the extracted symbol in the image.<br />

Example<br />

dev_set_check (’˜give_error’)<br />

get_2d_bar_code_pos (ObjectSelected, Image, BarCodeDescr,<br />

CodeRegDescr, [], [], BarCodeDimension, BarCodeData,<br />

DataElementRow, DataElementCol)<br />

err := ErrorCode<br />

dev_set_check (’give_error’)<br />

if (err = 2)<br />

idx := 0<br />

dev_update_pc (’off’)<br />

dev_update_time (’off’)<br />

dev_update_var (’off’)<br />

for m := 0 to BarCodeDimension[0]-1 by 1<br />

for n := 0 to BarCodeDimension[1]-1 by 1<br />

if (BarCodeData[idx]>0)<br />

set_color (WindowHandle, ’green’)<br />

else<br />

if (BarCodeData[idx]


672 CHAPTER 12. TOOLS<br />

dev_update_pc (’on’)<br />

dev_update_time (’on’)<br />

dev_update_var (’on’)<br />

decode_2d_bar_code (BarCodeDescr, BarCodeDimension, BarCodeData,<br />

SymbolCharacters, CorrSymbolData, DecodedData,<br />

DecodingError, StructuredAppend)<br />

endif<br />

Result<br />

The return value can signal incorrect parameters as well as the failure to extract a 2D bar code. Such a failure can be<br />

due to different causes: If no surrounding rectangle was found, the operator returns the error code 8808. Error code<br />

8807 signals that the rectangle does not lie completely inside the image. If no finder pattern was detected inside the<br />

border search area, the error code 8810 is returned. If the two continuous lines forming the ’L’ of the finder pattern<br />

could not be found, the error code 8809 is returned. In the case of the printing method ’engraved darkfield’, the<br />

error code 8811 signals that none of the gray value features can separate the test regions, i.e., that modules cannot<br />

be classified.<br />

Parallelization Information<br />

T get 2d bar code pos is reentrant and processed without parallelization.<br />

T find 2d bar code<br />

T decode 2d bar code<br />

T get 2d bar code<br />

T gen 2d bar code descr<br />

Barcode reader<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

See Also<br />

Module<br />

12.4 Calibration<br />

T caltab points ( Htuple CalTabDescrFile, Htuple *X, Htuple *Y,<br />

Htuple *Z )<br />

Read the mark center points from the calibration table description file.<br />

T caltab points is used to read the mark center points from the calibration table description file<br />

CalTabDescrFile. The mark center points are 3D coodinates in the calibration table coordinate system und describe<br />

the 3D model of the calibration table. The application of the operator T camera calibration projects<br />

these model points into the image. By minimizing the distance between the projected model points and the observed<br />

2D coordinates in the image (see T find marks and pose) the exact values for the internal and external<br />

camera parameters are computed.<br />

Parameter<br />

º CalTabDescrFile (input control) .....................................string Htuple . const char *<br />

File name of the calibration table description.<br />

Default Value : ’caltab.descr’<br />

º X (output control) ......................................................real-array Htuple . double *<br />

X-coordinates of the mark center points.<br />

º Y (output control) ......................................................real-array Htuple . double *<br />

Y-coordinates of the mark center points.<br />

º Z (output control) ......................................................real-array Htuple . double *<br />

Z-coordinates of the mark center points.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 673<br />

Example<br />

HTuple StartCamPar,NX,NY,NZ;<br />

HTuple RCoord1,CCoord1,StartPose1;<br />

HTuple StartPose,CamParam,FinalPose,Errors;<br />

// read calibration image<br />

HImage Image1("calib-01.tiff");<br />

// find calibration pattern<br />

HRegion Caltab1 = Image1.FindCaltab("caltab.descr",3,112,5);<br />

// find calibration marks and start pose<br />

StartCamPar[7] = 576;<br />

// ImageHeight<br />

StartCamPar[6] = 768;<br />

// ImageWidth<br />

StartCamPar[5] = 288;<br />

// Cy<br />

StartCamPar[4] = 384;<br />

// Cx<br />

StartCamPar[3] = 0.000011; // Sy<br />

StartCamPar[2] = 0.000011; // Sx<br />

StartCamPar[1] = 0.0;<br />

// Kappa<br />

StartCamPar[0] = 0.008; // Focus<br />

RCoord1 = Image1.FindMarksAndPose(Caltab1,"caltab.descr",StartCamPar,<br />

128,10,&CCoord1,&StartPose);<br />

// read 3D positions of calibration marks<br />

::caltab_points("caltab.descr",&NX,&NY,&NZ);<br />

// camera calibration<br />

::camera_calibration(NX,NY,NZ,RCoord1,CCoord1,StartCamPar,StartPose,<br />

11,&CamParam,&FinalPose,&Errors);<br />

// visualize calibration result<br />

::disp_image(Image1,WindowHandle);<br />

::set_color(WindowHandle,"red");<br />

::disp_caltab("caltab.descr",CamParam,FinalPose,1.0);<br />

Result<br />

T caltab points returns H MSG TRUE if all parameter values are correct and the file CalTabDescrFile<br />

has been read successfully. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

T caltab points is reentrant and processed without parallelization.<br />

T camera calibration<br />

Possible Successor Functions<br />

See Also<br />

find caltab, T find marks and pose, T camera calibration, T disp caltab,<br />

T sim caltab, T project 3d point, T get line of sight, create caltab<br />

Camera calibration<br />

Module<br />

T camera calibration ( Htuple NX, Htuple NY, Htuple NZ, Htuple NRow,<br />

Htuple NCol, Htuple StartCamParam, Htuple NStartPose,<br />

Htuple EstimateParams, Htuple *CamParam, Htuple *NFinalPose,<br />

Htuple *Errors )<br />

Determine all camera parameters by a simultanous minimization process.<br />

T camera calibration performs the calibration of a video camera. Thus, known 3D model points (with<br />

coordinates NX, NY, NZ) are projected in the image and the sum of the squared distance between these projections<br />

and the corresponding image points (with coordinates NRow, NCol) is minimized.<br />

In case of converging, the exact internal (CamParam)andexternal(NFinalPose) camera parameters are determined<br />

by this minimization algorithm. The parameters StartCamParam and NStartPose are used as initial<br />

values for the minimization process. Since this algorithm simultaneously handles correspondences between image<br />

and model points from different images, it is also called multi image calibration.<br />

<strong>HALCON</strong> 6.0


674 CHAPTER 12. TOOLS<br />

In general camera calibration means the exact determination of the parameters, which model the (optical) projection<br />

of any 3D world point È Ï into a (sub-)pixel [r,c] on the CCD sensor of the camera. This is of importance, if<br />

the original 3D pose of an object has to be computed using an image (e.g., measuring of industrial pieces).<br />

The underlying camera model is a pinhole camera with radial distortions if the focal length passed in<br />

StartCamParam is greater than 0. It describes the transform of a 3D world point È Ï into a (sub-)pixel [r,c] of<br />

the video image by the following equations:<br />

Ù <br />

½·<br />

È Ü Ý Þ℄ Ì Ê¡È Ï · Ì<br />

Ù Focus ¡ Ü Þ<br />

and Ú Focus ¡ Ý Þ<br />

¾Ù Ô½ ´Ù ¾·Ú and Ú Ô ¾Ú<br />

¾ µ<br />

½·<br />

Ù Ë Ü · Ü and Ö Ú<br />

Ë Ý · Ý<br />

½ ´Ù ¾·Ú ¾ µ<br />

If the focal length is passed as 0 in StartCamParam, the camera model of a telecentric camera with radial<br />

distortions is used, i.e., it is assumed that the optics of the lens of the camera performs a parallel projection. In<br />

this case, the corresponding equations are:<br />

Ù <br />

È Ü Ý Þ℄ Ì Ê¡È Ï · Ì<br />

Ù Ü and Ú Ý<br />

¾Ù<br />

½·<br />

Ô½ ´Ù ¾·Ú bzw. Ú ¾Ú<br />

¾ µ ½· ½ ´Ù ¾·Ú¾ µ<br />

Ô<br />

Ù Ë Ü · Ü bzw. Ö Ú<br />

Ë Ý · Ý<br />

These equations consist of a coordinate transform from the world coordinate system into the camera coordinate<br />

system, a perspective or parallel projection into the image plane, a radial distortion of the projected point, and<br />

finally a sampling and an image center displacement.<br />

The total of 15 camera parameters can be divided into the internal and external camera parameters:<br />

Internal camera parameters: These parameters describe the characterisctics of the used video camera, especially<br />

the dimension of the CCD sensor itself and the projection properties of the used combination of lens, camera,<br />

and frame grabber. The camera model (as described above) contains the following 8 parameters:<br />

Focus: Focal length of the lens. 0 for telecentric lenses.<br />

Kappa (): Distortion coefficient to model the pillow- or barrel-shaped distortions caused by the lens.<br />

Sx: Scale factor, corresponds to the horizontal distance between two neighboring cells on the CCD sensor.<br />

Attention: This value increases, if the image is subsampled!<br />

Sy: Scale factor, corresponds to the vertical distance between two neighboring cells on the CCD sensor.<br />

Since in most cases the image signal is sampled line-synchronously, this value is determined by the<br />

dimension of the CCD sensor and needn’t be estimated for pinhole cameras by the calibration process.<br />

Attention: This value increases, if the image is subsampled!<br />

Cx: Column coordinate of the image center point (center of the radial distortion).<br />

Cy: Row coordinate of the image center point (center of the radial distortion).<br />

ImageWidth: Width of the sampled video image. Attention: This value decreases, if the image is subsampled!<br />

ImageHeight: Height of the sampled video image. Attention: This value decreases, if the image is subsampled!<br />

External camera parameters: These 7 parameters describe the position and orientation of the camera and are<br />

also called as camera pose. The relative position of the camera with regard of a world or object coordinate<br />

system is defined by a 3D translational vector (parameters 1, 2, and 3). The orientation of the camera is<br />

described by the three rotation angles around the three coordinate axes (parameters 4, 5, and 6).<br />

The last value within the camera pose encodes the representation type of the described 3D transform: E.g.,<br />

the value ’0’ is the code of the representation type 1 and says, that the transform of a point is described,<br />

the 3D rotation is performed before the 3D translation, that the three rotations are specified as angles (in<br />

degree), and that the rotation order is ­-¬-«, i.e., the first rotation is around the Z-axis, the second one<br />

around the new Y-axis, and the third one around the new X-axis, which is generated after the second rotation.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 675<br />

T camera calibration operates with all types of 3D transform for NStartPose. The sense of the<br />

other representation types are explained at T create pose.<br />

Note, that in contrast to the external camera parameters the internal ones are the same for all positions and<br />

orientations of the camera.<br />

The use of T camera calibration leads to some questions, which are dealed with in the following sections:<br />

How to generate a appropriate calibration table? The simplest method to determine the internal parameter of<br />

a CCD camera is the use of the planar calibration table generated by the operator create caltab. In<br />

case of small distances between object and lens it may be sufficient to print the calibration pattern by a laser<br />

printer and to mount it on a cardboard. Otherwise – especially by using a wide-angle lens – it is possible to<br />

print the PostScript file on a large inkjet printer and to mount it on a aluminum table. It is very important,<br />

that the mark coordinates in the calibration table description file correspond to the real ones on the calibration<br />

table with high accuracy. Thus, the calibration table description file has to be modified in accordance with<br />

the measurement of the calibration table!<br />

How to take a set of suitable images? If you use the planar calibration table, you can proceed in the following<br />

way: With the combination of lens (fixed distance!), camera, and frame grabber to be calibrated a set of images<br />

of the calibration table has to be taken, see open framegrabber and grab image. The following<br />

items have to be considered:<br />

¯ At least a total of 10 to 20 images should be taken into account.<br />

¯ The calibration table has to be completely visible (incl. border!).<br />

¯ Reflections etc. on the calibration table should be avoided.<br />

¯ Within the set of images the calibration table should appear in different positions and orientations: Once<br />

left in the image, once right, once (left and right) at the bottom, once (left or right) at the top, from<br />

different distances etc. At this, the calibration table should be rotated a little around its X- and/or Y-axis,<br />

so the perspective distortions of the calibration pattern are clearly visible. Thus, the external camera<br />

parameters (camera pose with regard of the calibration table) should be set to a large variety of different<br />

values!<br />

¯ The calibration table should fill at least a quarter of the whole image to ensure the robust detection of the<br />

marks.<br />

How to extract the calibration marks in the images? If a planar calibration table is used, for each image the<br />

operators find caltab and T find marks and pose can be used to determine the coordinates of the<br />

calibration marks and to compute a rough estimate for the external camera parameters. The concatenation<br />

of these values can directly be used as initial values for the external camera parameters (NStartPose) in<br />

T camera calibration.<br />

Obviously, images, on which the segmentation of the calibration table (find caltab) hasfailedorthe<br />

calibration marks haven’t been determined successfully by T find marks and pose, should not be used.<br />

How to find suitable initial values for the internal camera parameters ? The<br />

operators<br />

T find marks and pose (determination of initial values for the external camera parameters) and<br />

T camera calibration require initial values for the internal camera parameters. These parameters<br />

can be provided by a appropriate text file (see T read cam par), which can be generated by<br />

T write cam par or can be edited manually.<br />

The following should be considered for the initial values of the single parameters:<br />

Focus: The initial value is the nominal focal length of the the used lens, e.g., 0.008 m.<br />

Kappa: Use 0.0 as initial value. The calibratied value normally lies between -1000.0 and -50000.0 1/Ñ ¾<br />

depending on the used lens.<br />

Sx: The initial value for the horizontal distance between two neighboring CCD cells depends on the dimension<br />

of the used CCD chip of the camera (see technical specifications of the camera). Generally, common<br />

CCD chips are either 1/3”-Chips (e.g., SONY XC-73, SONY XC-777), 1/2”-Chips (e.g., SONY XC-<br />

999, Panasonic WV-CD50), or 2/3”-Chips (e.g., SONY DXC-151, SONY XC-77). Notice: The value<br />

of Sx increases, if the image is subsampled! Appropriate initial values are:<br />

Full image (768*576) Subsampling (384*288)<br />

1/3"-Chip 0.0000055 m 0.0000110 m<br />

1/2"-Chip 0.0000086 m 0.0000172 m<br />

2/3"-Chip 0.0000110 m 0.0000220 m<br />

<strong>HALCON</strong> 6.0


676 CHAPTER 12. TOOLS<br />

The value for Sx is calibrated, since the video signal of a CCD camera normally isn’t sampled pixelsynchronously.<br />

Sy: Since most off-the-shelf cameras have quadratic pixels, the same values for Sy are valid as for Sx. In<br />

contrast to Sx the value for Sy will NOT be calibrated for pinhole cameras, because the video signal of a<br />

CCD camera normally is sampled line-synchronously. Thus, the initial value is equal to the final value.<br />

Appropriate initial values are:<br />

Full image (768*576) Subsampling (384*288)<br />

1/3"-Chip 0.0000055 m 0.0000110 m<br />

1/2"-Chip 0.0000086 m 0.0000172 m<br />

2/3"-Chip 0.0000110 m 0.0000220 m<br />

Cx and Cy: Initial values for the coordinates of the image center is the half image width and half image<br />

height. Notice: The values of Cx and Cy decrease, if the image is subsampled! Appropriate initial<br />

values are:<br />

Full image (768*576) Subsampling (384*288)<br />

Cx 384.0 192.0<br />

Cy 288.0 144.0<br />

ImageWidth and ImageHeight: These two parameters are set by the the used frame grabber and therefore<br />

are not calibrated. Appropriate initial values are:<br />

Full image (768*576) Subsampling (384*288)<br />

ImageWidth 768 384<br />

ImageHeight 576 288<br />

Which camera parameters have to be estimated? The input parameter EstimateParams is used to select<br />

which camera parameters to estimate. Usually this parameter is set to ’all’, i.e., all 6 external camera parameters<br />

(translation and rotation) and all internal camera parameters have to be determined. Otherwise,<br />

EstimateParams contains a tuple of strings indicating the combination of parameters to estimate.<br />

What is the order within the single parameters? The length of the tuple NStartPose corresponds to the<br />

number of calibration images, e.g., using 15 images leads to a length of the tuple NStartPose equal to<br />

½ ¡ ½¼ (15 times the 7 external camera parameters). The first 7 values correspond to the camera pose<br />

of the first image, the next 7 values to the pose of the second one, etc.<br />

This fixed number of calibration images has to be considered within the tuples with the coordinates of the 3D<br />

model marks and the extracted 2D marks. If 15 images are used, the length of the tuples NRow and NCol<br />

is 15 times the length of the tuples with the coordinates of the 3D model marks (NX, NY, andNZ). If every<br />

image consists 49 marks, the length of the tuples NRow and NCol is ½ ¡ ¿, while the length of the<br />

tuples NX, NY, andNZ is 49. The order of the values in NRow and NCol is “image after image”, i.e., using<br />

49 marks the first 3D model point corresponds to the 1st, 50th, 99th, 148th, 197th, 246th, etc. extracted 2D<br />

mark.<br />

The 3D model points can be read from a calibration table description file using the operator<br />

T caltab points. Initial values for the camera pose can be determined by applying<br />

T find marks and pose for each image. The tuple NStartPose is set by the concatenation of all<br />

these camera poses.<br />

What is the meaning of the output parameters? If the camera calibration process is finished successfully, i.e.,<br />

the minimization process is converged, the output parameters CamParam and NFinalPose contain the<br />

computed exact values for the internal and external camera parameters. The length of the tuple NFinalPose<br />

corresponds to the length of the tuple NStartPose.<br />

The representation types of NFinalPose correspond to the representation type of the first tuple of<br />

NStartPose. You can convert the representation type by T convert pose type. The sense of all<br />

kind of representation types for the 3D transform are explained at T create pose.<br />

The computed average errors (Errors) give an impression of the accuracy of the calibration. The error<br />

values (deviations in x- and y-coordinates) are measured in pixels.<br />

Must I use a planar calibration table? No. The operator T camera calibration is designed in a way, that<br />

the input tuples NX, NY, NZ, NRow, andNCol can contain any 3D/2D correspondences, see the above paragraph<br />

explaining the order of the single parameters.<br />

Thus, it makes no difference, how the required 3D model marks and the corresponding extracted 2D marks<br />

are determined. On the one hand it is possible to use a 3D calibration pattern, on the other hand you<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 677<br />

also can use any characteristic points (natural landmarks) with known position in the world. By setting<br />

EstimateParams to 6, it is possible to compute the world position of the camera! Hereby at least<br />

three 3D/2D-correspondences are necessary as input. Homogeneous transformation matrices are useful<br />

to generate NStartPose, see program example in T hom mat3d to pose and/or program example in<br />

T create pose for generating NStartPose directly.<br />

Attention<br />

The minimization process of the calibration depends on the initial values of the internal (StartCamParam)and<br />

external (NStartPose) camera parameters. The computed average errors Errors give an impression of the<br />

accuracy of the calibration. The errors (deviations in x- and y-coordinates) are measured in pixels.<br />

Parameter<br />

º NX (input control) .......................................................real-array Htuple . double<br />

Ordered Tuple with all X-coordinates of the calibration marks (in meters).<br />

º NY (input control) .......................................................real-array Htuple . double<br />

Ordered Tuple with all Y-coordinates of the calibration marks (in meters).<br />

º NZ (input control) .......................................................real-array Htuple . double<br />

Ordered Tuple with all Z-coordinates of the calibration marks (in meters).<br />

º NRow (input control) .....................................................real-array Htuple . double<br />

Ordered Tuple with all row-coordinates of the extracted calibration marks (in pixels).<br />

º NCol (input control) .....................................................real-array Htuple . double<br />

Ordered Tuple with all column-coordinates of the extracted calibration marks (in pixels).<br />

º StartCamParam (input control) ..................................real-array Htuple . double / long<br />

Initial values for the internal camera parameters.<br />

º NStartPose (input control) .....................................pose-array Htuple . double / long<br />

Ordered tuple with all initial values for the external camera parameters.<br />

º EstimateParams (input control) ................................string Htuple . const char * / long<br />

Camera parameters to be estimated.<br />

Default Value : ’all’<br />

Value List : EstimateParams ¾’all’, ’alpha’, ’beta’, ’gamma’, ’transx’, ’transy’, ’transz’, ’focus’,<br />

’kappa’, ’cx’, ’cy’, ’sx’, ’sy’<br />

º CamParam (output control) .................................number-array Htuple . double * / long *<br />

Internal camera parameters.<br />

º NFinalPose (output control) .................................pose-array Htuple . double * / long *<br />

Ordered tuple with all external camera parameters.<br />

º Errors (output control) ...............................................real-array Htuple . double *<br />

Average error distances in pixels.<br />

Example<br />

HTuple StartCamPar,NX,NY,NZ;<br />

HTuple RCoord1,CCoord1,StartPose1;<br />

HTuple RCoord2,CCoord2,StartPose2;<br />

HTuple RCoord3,CCoord3,StartPose3;<br />

HTuple StartPoses, RCoords, CCoords;<br />

HTuple CamParam,NFinalPose,Errors;<br />

// read calibration images<br />

HImage Image1("calib-01.tiff");<br />

HImage Image2("calib-02.tiff");<br />

HImage Image3("calib-03.tiff");<br />

// find calibration pattern<br />

HRegion Caltab1 = Image1.FindCaltab("caltab.descr",3,112,5);<br />

HRegion Caltab2 = Image2.FindCaltab("caltab.descr",3,112,5);<br />

HRegion Caltab3 = Image3.FindCaltab("caltab.descr",3,112,5);<br />

// find calibration marks and start poses<br />

StartCamPar[7] = 576;<br />

// ImageHeight<br />

StartCamPar[6] = 768;<br />

// ImageWidth<br />

StartCamPar[5] = 288;<br />

// Cy<br />

<strong>HALCON</strong> 6.0


678 CHAPTER 12. TOOLS<br />

StartCamPar[4] = 384;<br />

// Cx<br />

StartCamPar[3] = 0.000011; // Sy<br />

StartCamPar[2] = 0.000011; // Sx<br />

StartCamPar[1] = 0.0;<br />

// Kappa<br />

StartCamPar[0] = 0.008; // Focus<br />

RCoord1 = Image1.FindMarksAndPose(Caltab1,"caltab.descr",StartCamPar,<br />

128,10,&CCoord1,&StartPose1);<br />

RCoord2 = Image2.FindMarksAndPose(Caltab2,"caltab.descr",StartCamPar,<br />

128,10,&CCoord2,&StartPose2);<br />

RCoord3 = Image3.FindMarksAndPose(Caltab3,"caltab.descr",StartCamPar,<br />

128,10,&CCoord3,&StartPose3);<br />

// read 3D positions of calibration marks<br />

::caltab_points("caltab.descr",&NX,&NY,&NZ);<br />

// camera calibration<br />

StartPoses = (StartPose1.Append(StartPose2)).Append(StartPose3);<br />

RCoords = (RCoord1.Append(RCoord2)).Append(RCoord3);<br />

CCoords = (CCoord1.Append(CCoord2)).Append(CCoord3);<br />

::camera_calibration(NX,NY,NZ,RCoords,CCoords,StartCamPar,StartPoses,<br />

11,&CamParam,&NFinalPose,&Errors);<br />

// write internal camera parameters to file<br />

::write_cam_par(CamParam,"campar.dat");<br />

Result<br />

T camera calibration returns H MSG TRUE if all parameter values are correct and the desired camera<br />

parameters have been determined by the minimization algorithm. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

T camera calibration is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T find marks and pose, T caltab points, T read cam par<br />

Possible Successor Functions<br />

T write pose, T pose to hom mat3d, T disp caltab, T sim caltab<br />

See Also<br />

find caltab, T find marks and pose, T disp caltab, T sim caltab, T write cam par,<br />

T read cam par, T create pose, T convert pose type, T write pose, T read pose,<br />

T pose to hom mat3d, T hom mat3d to pose, T caltab points, create caltab<br />

Camera calibration<br />

Module<br />

T change radial distortion cam par ( Htuple Mode, Htuple CamParIn,<br />

Htuple Kappa, Htuple *CamParOut )<br />

Determine new camera parameters in accordance to the specified radial distortion.<br />

T change radial distortion cam par modifies the internal camera parameters in accordance to the specified<br />

radial distortion Kappa. ViaMode one of the following modes can be selected:<br />

¯ ’fixed’: OnlyKappa is modified, the other internal camera parameters remain unchanged. In general this<br />

leads to a change of the visible part of the scene.<br />

¯ ’fullsize’: The scale factors Ë Ü and Ë Ý and the image center point Ü Ý℄ Ì are modified in order to<br />

preserve the visible part of the scene. Thus, all points visible in the original video image are also visible in<br />

the modified (rectified) image. In general this leads to undefined pixels in the modified image.<br />

¯ ’adaptive’: A trade off between the other modes: The visible part of the scene is slightly reduced to prevent<br />

undefined pixels in the modified image. Similiar to ’fullsize’ the scale factors and the image center point are<br />

modified.<br />

In all modes the radial distortion coefficient in CamParOut is set to Kappa. The transformation of a pixel in<br />

the modified image into the image plane using CamParOut results in the same point as the transformation of a<br />

pixel in the original image via CamParIn.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 679<br />

Parameter<br />

º Mode (input control) ....................................................string Htuple . const char *<br />

Mode<br />

Default Value : ’adaptive’<br />

Value Suggestions : Mode ¾’fullsize’, ’adaptive’, ’fixed’<br />

º CamParIn (input control) ...............................................real-array Htuple . double<br />

Internal camera parameters (original).<br />

º Kappa (input control) .........................................................real Htuple . double<br />

Desired radial distortion.<br />

Default Value : 0.0<br />

º CamParOut (output control) ...........................................real-array Htuple . double *<br />

Internal camera parameters (modified).<br />

Result<br />

T change radial distortion cam par returns H MSG TRUE if all parameter values are correct. If necessary,<br />

an exception handling is raised.<br />

Parallelization Information<br />

T change radial distortion cam par is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T camera calibration, T read cam par<br />

Possible Successor Functions<br />

T change radial distortion image, T change radial distortion contours xld<br />

See Also<br />

T camera calibration, T read cam par, T change radial distortion image,<br />

T change radial distortion contours xld<br />

Module<br />

Camera calibration<br />

T change radial distortion contours xld ( Hobject Contours,<br />

Hobject *ContoursRectified, Htuple CamParIn, Htuple CamParOut )<br />

Change the radial distortion of contours.<br />

T change radial distortion contours xld changes the radial distortion of the input contours<br />

Contours in accordance to the internal camera parameters CamParIn and CamParOut. Each subpixel of<br />

an input contour is transformed into the image plane using CamParIn and subsequently projected into a subpixel<br />

of the corresponding contour in ContoursRectified using CamParOut.<br />

If CamParOut was computed via T change radial distortion cam par, the contours<br />

ContoursRectified are equivalent to Contours obtained with a lense with a modified radial distortion.<br />

If is ¼ , the contours are rectified. A subsequent pose estimation (determination of the external camera<br />

parameters) is not affected by this operation.<br />

Parameter<br />

º Contours (input object) .................................................xld cont(-array) Hobject<br />

Original contours.<br />

º ContoursRectified (output object) ..................................xld cont(-array) Hobject *<br />

Resulting contours with modified radial distortion.<br />

º CamParIn (input control) ...............................................real-array Htuple . double<br />

Internal camera parameter for Contours.<br />

º CamParOut (input control) ..............................................real-array Htuple . double<br />

Internal camera parameter for ContoursRectified.<br />

Parallelization Information<br />

T change radial distortion contours xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T change radial distortion cam par, gen contours skeleton xld, edges sub pix,<br />

smooth contours xld<br />

<strong>HALCON</strong> 6.0


680 CHAPTER 12. TOOLS<br />

Possible Successor Functions<br />

gen polygons xld, smooth contours xld<br />

See Also<br />

T change radial distortion cam par, T camera calibration, T read cam par,<br />

T change radial distortion image<br />

Module<br />

Camera calibration<br />

T change radial distortion image ( Hobject Image, Hobject Region,<br />

Hobject *ImageRectified, Htuple CamParIn, Htuple CamParOut )<br />

Change the radial distortion of an image.<br />

T change radial distortion image changes the radial distortion of the input image Image in accordance<br />

to the internal camera parameters CamParIn and CamParOut. The image size remains unchanged. Each<br />

pixel of the output image is transformed into the image plane using CamParOut and subsequently projected into<br />

a subpixel of Image using CamParIn. The resulting grayvalue is determined by bilinear interpolation. If the<br />

subpixel is outside of Image, the corresponding pixel in ImageRectified is set to ’black’ and eliminated from<br />

the image domain.<br />

If CamParOut was computed via T change radial distortion cam par, ImageRectified is equivalent<br />

to Image obtained with a lense with a modified radial distortion. If is ¼ , the image is rectified. A<br />

subsequent pose estimation (determination of the external camera parameters) is not affected by this operation.<br />

Parameter<br />

º Image (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject<br />

Original image.<br />

º Region (input object) .............................................................region Hobject<br />

Region of interest in Image.<br />

º ImageRectified (output object) . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image(-array) Hobject *<br />

Resulting image with modified radial distortion.<br />

º CamParIn (input control) ...............................................real-array Htuple . double<br />

Internal camera parameter for Image.<br />

º CamParOut (input control) ..............................................real-array Htuple . double<br />

Internal camera parameter for Image.<br />

Result<br />

T change radial distortion image returns H MSG TRUE if all parameter values are correct and the<br />

input is not empty. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

T change radial distortion image is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T change radial distortion cam par, read image, grab image<br />

edges image, threshold<br />

Possible Successor Functions<br />

See Also<br />

T change radial distortion cam par, T camera calibration, T read cam par,<br />

T change radial distortion contours xld<br />

Module<br />

Camera calibration<br />

T contour to world plane xld ( Hobject Contours,<br />

Hobject *ContoursTrans, Htuple CamParam, Htuple CamPose, Htuple Scale )<br />

Transform an XLD contour to a world plane represented by external camera parameters.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 681<br />

The operator T contour to world plane xld transforms contour points given in Contours into a plane<br />

in the world coordinate system. The plane is either equal to the plane of the calibration table or parallel to it if<br />

the operator T set origin pose has been applied previously to correct the thickness of the calibration table.<br />

In the first step the line of sight between the projection center and the image point is computed in the camera<br />

system, taking into account the radial distortion using the internal camera parameters CamParam. The line of<br />

sight is then transformed into the world coordinate system using the external camera parameters CamPose. By<br />

intersecting the plane (Z=0) with the line of sight the pseudo 3d coordinates are obtained, of which the X- and the<br />

Y-coordinates are stored in the transformed contour ContoursTrans. It is possible to scale the coordinates with<br />

the parameter Scale. This is particularly useful when displaying the coordinates in an image. The parameter<br />

Scale must be specified in [ÙÒØÔÜÐ]. The original unit is determined by the coordinates of the calibration<br />

targets. In many cases this unit is introduced into the calibration as ’meters’, i.e., one meter in the world coordinate<br />

system corresponds to one pixel in the image. In this case, it is possible to set the pixel size directly by selecting<br />

’m’, ’cm’, ’mm’ or ’m’ for the parameter Scale.<br />

Parameter<br />

º Contours (input object) .................................................xld cont(-array) Hobject<br />

Input XLD contours to be transformed.<br />

º ContoursTrans (output object) ........................................xld cont(-array) Hobject *<br />

Transformed XLD contours.<br />

º CamParam (input control) .....................................number-array Htuple . double / long<br />

Internal camera parameters.<br />

Parameter Number : 8<br />

º CamPose (input control) .........................................pose-array Htuple . double / long<br />

External camera parameters.<br />

Parameter Number : 7<br />

º Scale (input control) ...................................number Htuple . const char * / long / double<br />

Scale oder dimension<br />

Default Value : ’m’<br />

Value Suggestions : Scale ¾’m’, ’cm’, ’mm’, ’microns’, ’m’, 1.0, 0.01, 0.001, ’1e-6’, 0.0254, 0.3048,<br />

0.9144<br />

Result<br />

T contour to world plane xld returns H MSG TRUE if all parameter values are correct. If necessary, an<br />

exception handling is raised.<br />

Parallelization Information<br />

T contour to world plane xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create pose, T hom mat3d to pose, T camera calibration, T hand eye calibration,<br />

T set origin pose<br />

See Also<br />

T image points to world plane<br />

Module<br />

Camera calibration<br />

T convert pose type ( Htuple PoseIn, Htuple OrderOfTransform,<br />

Htuple OrderOfRotation, Htuple ViewOfTransform, Htuple *PoseOut )<br />

Change the representation type of 3D pose parameters.<br />

T convert pose type converts the 3D pose PoseIn into a 3D pose PoseOut with a different representation<br />

type.<br />

A 3D pose defines a 3D transformation consisting of a translation and a rotation. Halcon supports different representation<br />

types for such a transformation. This can be, for example, external camera parameters, given by a 3D<br />

translation vector (in meters), three rotation angles, and the code of the representation type of the 3D transformation.<br />

For example, the value ’0’ is the code of representation type 1, and signifies that the transformation of a point<br />

is described, that the 3D rotation is applied before the translation, that the rotation is given by angles (in degrees),<br />

and that the order of the rotations is ­-¬-«, i.e., the first rotation is around the z-axis, the second rotation around<br />

<strong>HALCON</strong> 6.0


682 CHAPTER 12. TOOLS<br />

the y-axis, and the third roation around the x-axis. The meaning of the other representation types is described with<br />

the operator T create pose.<br />

The parameter ViewOfTransform determines, whether the new transformation PoseOut describes the<br />

transformation of a point (’point’) or the transformation of a coordinate system (’coordinate system’).<br />

OrderOfTransform determines whether the rotation (’Rp+T’) or the translation (’R(p-T)’) is applied first.<br />

The meaning of the three rotation values is determined by OrderOfRotation. The values ’gba’ and ’abg’<br />

signify that the rotation parameters describe the three rotation angles « (around the x-axis), ¬ (around the y-axis),<br />

and ­ (around the z-axis) in the 3D transformation. For ’gba’, the rotation order is ­ , ¬ , « ,andfor’abg’ it is<br />

« , ¬ , ­ .IfOrderOfRotation is passed as ’rodriguez’, the rotation parameters are interpreted as Rodriguez<br />

rotation vector.<br />

Parameter<br />

º PoseIn (input control) ...........................................pose-array Htuple . double / long<br />

3D transformation.<br />

Parameter Number : 7<br />

º OrderOfTransform (input control) ...................................string Htuple . const char *<br />

Order of rotation and translation.<br />

Default Value : ”Rp+T”<br />

Value Suggestions : OrderOfTransform ¾”Rp+T”, ”R(p-T)”<br />

º OrderOfRotation (input control) .....................................string Htuple . const char *<br />

Meaning of the rotation values.<br />

Default Value : ”gba”<br />

Value Suggestions : OrderOfRotation ¾”gba”, ”abg”, ”rodriguez”<br />

º ViewOfTransform (input control) .....................................string Htuple . const char *<br />

View of transformation.<br />

Default Value : ”point”<br />

Value Suggestions : ViewOfTransform ¾”point”, ”coordinate system”<br />

º PoseOut (output control) .....................................pose-array Htuple . double * / long *<br />

3D transformation.<br />

Parameter Number : 7<br />

Example<br />

HTuple Pose, Pose2;<br />

// get pose (external camera parameters):<br />

::read_pose ("campose.dat", &Pose) ;<br />

// convert pose to a pose with desired semantic<br />

::convert_pose_type ( Pose, "Rp+T", "abg", "coordinate_system", &Pose2);<br />

Result<br />

T convert pose type returns H MSG TRUE if all parameter values are correct. If necessary, an exception<br />

handling is raised.<br />

Parallelization Information<br />

T convert pose type is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create pose, T hom mat3d to pose, T camera calibration, T hand eye calibration<br />

T write pose<br />

Possible Successor Functions<br />

See Also<br />

T create pose, T get pose type, T write pose, T read pose<br />

Camera calibration<br />

Module<br />

create caltab ( double Width, const char *CalTabDescrFile,<br />

const char *CalTabFile )<br />

Generate calibration table description file and corresponding PostScript file.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 683<br />

create caltab generates the description of a plane calibration table. This calibration table consists of 49 black<br />

circular marks on a white plane, which are surrounded by a black frame. The parameter Width sets the width<br />

(equal to the height) of the whole calibration table in meters. Using a width of 0.8 m the distance between two<br />

neighboring marks becomes 10 cm, and the mark radius and the frame width are set to 2.5 cm.<br />

The file CalTabDescrFile contains the calibration table description, e.g., the number of rows and columns<br />

of the calibration table, the geometry of the surrounding frame (see find caltab), and the coordinates and<br />

the radius of all calibration table marks given in the calibration table coordinate system. A file generated by<br />

create caltab looks like the following (comments are marked by a ’#’ at the beginning of a line):<br />

#<br />

# Description of the standard calibration table<br />

# used for the CCD-camera calibration in Halcon<br />

# (generated by create\_caltab())<br />

#<br />

# Halcon version 4.11 -- Fri Feb 7 16:13:56 1997<br />

#<br />

# 7 rows X 7 columns<br />

# Distance between mark centers [meter]: 0.1<br />

# Number of marks per row<br />

r 7<br />

# Number of marks per column<br />

c 7<br />

# Quadratic frame (with outer and inner border) around calibration table<br />

w 0.025<br />

o -0.41 0.41 0.41 -0.41<br />

i -0.4 0.4 0.4 -0.4<br />

# calibration marks: x y radius [Meter]<br />

# calibration marks at y = -0.3 m<br />

-0.3 -0.3 0.025<br />

-0.2 -0.3 0.025<br />

-0.1 -0.3 0.025<br />

0 -0.3 0.025<br />

0.1 -0.3 0.025<br />

0.2 -0.3 0.025<br />

0.3 -0.3 0.025<br />

# calibration marks at y = -0.2 m<br />

-0.3 -0.2 0.025<br />

-0.2 -0.2 0.025<br />

-0.1 -0.2 0.025<br />

0 -0.2 0.025<br />

0.1 -0.2 0.025<br />

0.2 -0.2 0.025<br />

0.3 -0.2 0.025<br />

# calibration marks at y = -0.1 m<br />

-0.3 -0.1 0.025<br />

-0.2 -0.1 0.025<br />

-0.1 -0.1 0.025<br />

0 -0.1 0.025<br />

0.1 -0.1 0.025<br />

0.2 -0.1 0.025<br />

0.3 -0.1 0.025<br />

<strong>HALCON</strong> 6.0


684 CHAPTER 12. TOOLS<br />

# calibration marks at y = 0 m<br />

-0.3 0 0.025<br />

-0.2 0 0.025<br />

-0.1 0 0.025<br />

0 0 0.025<br />

0.1 0 0.025<br />

0.2 0 0.025<br />

0.3 0 0.025<br />

# calibration marks at y = 0.1 m<br />

-0.3 0.1 0.025<br />

-0.2 0.1 0.025<br />

-0.1 0.1 0.025<br />

0 0.1 0.025<br />

0.1 0.1 0.025<br />

0.2 0.1 0.025<br />

0.3 0.1 0.025<br />

# calibration marks at y = 0.2 m<br />

-0.3 0.2 0.025<br />

-0.2 0.2 0.025<br />

-0.1 0.2 0.025<br />

0 0.2 0.025<br />

0.1 0.2 0.025<br />

0.2 0.2 0.025<br />

0.3 0.2 0.025<br />

# calibration marks at y = 0.3 m<br />

-0.3 0.3 0.025<br />

-0.2 0.3 0.025<br />

-0.1 0.3 0.025<br />

0 0.3 0.025<br />

0.1 0.3 0.025<br />

0.2 0.3 0.025<br />

0.3 0.3 0.025<br />

The file CalTabFile contains the corresponding PostScript description of the calibration table.<br />

Attention<br />

Dependent on the accuracy of the used output device (e.g. laser printer) the printed calibration table may not<br />

match the values in the calibration table descripton file CalTabDescrFile exactly. Thus, the coordinates of the<br />

calibration marks in the calibration table descripton file have to be corrected!<br />

Parameter<br />

º Width (input control) .................................................................real double<br />

Width of the calibration table in meters.<br />

Default Value : 0.8<br />

Value Suggestions : Width ¾1.2, 0.8, 0.6, 0.4, 0.2, 0.1<br />

Recommended Value Step : 0.1<br />

Restriction : 0.0 Width<br />

º CalTabDescrFile (input control) .............................................string const char *<br />

File name of the calibration table description.<br />

Default Value : ’caltab.descr’<br />

º CalTabFile (input control) ...................................................string const char *<br />

File name of the PostSript file.<br />

Default Value : ’caltab.ps’<br />

Example<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 685<br />

// create calibration table with width = 80 cm<br />

::create_caltab(0.8,"caltab.descr","caltab.ps");<br />

Result<br />

create caltab returns H MSG TRUE if all parameter values are correct and both files have been written<br />

successfully. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

create caltab is processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

T read cam par, T caltab points<br />

See Also<br />

find caltab, T find marks and pose, T camera calibration, T disp caltab, T sim caltab<br />

Camera calibration<br />

Module<br />

T create pose ( Htuple TransX, Htuple TransY, Htuple TransZ,<br />

Htuple Rot1, Htuple Rot2, Htuple Rot3, Htuple OrderOfTransform,<br />

Htuple OrderOfRotation, Htuple ViewOfTransform, Htuple *Pose )<br />

Create 3D pose parameters.<br />

T create pose creates 3D pose parameters Pose, which define a 3D transformation. The translation and rotation<br />

of the 3D pose are described by parameters (TransX, TransY, TransZ)and(Rot1, Rot2, Rot3), respectively.<br />

The parameter ViewOfTransform determines whether the transformation describes the transformation<br />

of a point (’point’) or of a coordinate system (’coordinate system’). OrderOfTransform determines whether<br />

during the transformation the rotation is applied first (’Rp+T’) or whether the translation is applied first (’R(p-T)’).<br />

The meaning of the three rotation parameters is determined by OrderOfRotation. Thevalues’gba’ and ’abg’<br />

specify that Rot1 is the rotation angle « (around the x-axis), Rot2 is the rotation angle ¬ (around the y-axis), and<br />

Rot3 is the rotation angle ­ (around the z-axis). For ’gba’, the order is ­ , ¬ , « , while for ’abg’ it is « , ¬ , ­<br />

.IfOrderOfRotation is passed as ’rodriguez’, the rotation parameters are interpreted as Rodriguez rotation<br />

vector.<br />

Pose is a tuple of length seven. The first three values hold the translation vector [TransX, TransY, TransZ],<br />

the following three parameters hold the rotations Rot1, Rot2, andRot3, and the last value holds the so-called<br />

representation type of the 3D pose parameters, and thus the transformation.<br />

The possible combinations of ViewOfTransform, OrderOfTransform,andOrderOfRotation lead to<br />

12 different representation types for the 3D transformations. In particular, they are:<br />

No. OrderOfTransform OrderOfRotation ViewOfTransform Code<br />

1 ’Rp+T’ ’gba’ ’point’ 0<br />

2 ’Rp+T’ ’abg’ ’point’ 2<br />

3 ’Rp+T’ ’rodriguez’ ’point’ 4<br />

4 ’Rp+T’ ’gba’ ’coordinate system’ 1<br />

5 ’Rp+T’ ’abg’ ’coordinate system’ 3<br />

6 ’Rp+T’ ’rodriguez’ ’coordinate system’ 5<br />

7 ’R(p-T)’ ’gba’ ’point’ 8<br />

8 ’R(p-T)’ ’abg’ ’point’ 10<br />

9 ’R(p-T)’ ’rodriguez’ ’point’ 12<br />

10 ’R(p-T)’ ’gba’ ’coordinate system’ 9<br />

11 ’R(p-T)’ ’abg’ ’coordinate system’ 11<br />

12 ’R(p-T)’ ’rodriguez’ ’coordinate system’ 13<br />

Note, that in general the symbols R and T in the parameter OrderOfTransform are not the same as within the<br />

common notation of a homogeneous transformation matrix.<br />

The type of a 3D transformation can be queried with T get pose type. The output of this operator, however,<br />

is not the code of the number of the transformation type, but the sight and order of the transformation, and the<br />

<strong>HALCON</strong> 6.0


686 CHAPTER 12. TOOLS<br />

order of the rotations, corresponding to the parameters of T create pose. Different representation types can be<br />

converted into one another with T convert pose type. The description of these conversions is given below.<br />

The representation type no. 1 with code ’0’ corresponds to a transformation using homogeneous transformation<br />

matrices, see T pose to hom mat3d, because when multiplying a 3D vector by a homogeneous transformation<br />

matrix, the rotation and translation as also determined first, a point is transformed, and the rotation order is set to<br />

­ - ¬ - « by T pose to hom mat3d (see also T affine trans point 3d). The three rotation angles « , ¬<br />

,and­ are determined by the parameters Rot1, Rot2,andRot3. Wehave:<br />

Ê Ü´«µ <br />

Ê Ý´¬µ <br />

Ê Þ´­µ <br />

µ<br />

È ¾ Ü Ý Þ℄ Ì Ê´½µ ¡ È ½ · Ì ´½µ<br />

Ê Ü´«µ ¡Ê Ý´¬µ ¡Ê Þ´­µ ¡ È ½ · Ì ´½µ<br />

where:<br />

¼<br />

½ ¼ ¼<br />

¼ Ó× « ×Ò «<br />

¼ ×Ò « Ó× «<br />

¼<br />

<br />

¼<br />

<br />

Ó× ¬ ¼ ×Ò ¬<br />

¼ ½ ¼<br />

×Ò ¬ ¼ Ó× ¬<br />

Ó× ­ ×Ò ­ ¼<br />

×Ò ­ Ó× ­ ¼<br />

¼ ¼ ½<br />

Ê´½µ <br />

½<br />

<br />

½<br />

<br />

½<br />

<br />

¼ ½<br />

Ö ½½ Ö ½¾ Ö ½¿<br />

Ö ¾½ Ö ¾¾ Ö ¾¿<br />

<br />

Ö ¿½ Ö ¿¾ Ö ¿¿<br />

where:<br />

rotation around the x-axis<br />

rotation around the y-axis<br />

rotation around the z-axis<br />

Ö ½½ Ó×´¬µÓ×´­µ<br />

Ö ½¾ Ó×´¬µ ×Ò´­µ<br />

Ö ½¿ ×Ò´¬µ<br />

Ö ¾½ ×Ò´«µ ×Ò´¬µ Ó×´­µ · Ó×´«µ ×Ò´­µ<br />

Ö ¾¾ ×Ò´«µ ×Ò´¬µ ×Ò´­µ · Ó×´«µ Ó×´­µ<br />

Ö ¾¿ ×Ò´«µ Ó×´¬µ<br />

Ö ¿½ Ó×´«µ ×Ò´¬µ Ó×´­µ · ×Ò´«µ ×Ò´­µ<br />

Ö ¿¾ Ó×´«µ ×Ò´¬µ ×Ò´­µ · ×Ò´«µ Ó×´­µ<br />

Ö ¿¿ Ó×´«µ Ó×´¬µ<br />

The representation type no. 1 is the reference type for all calibration operators in <strong>HALCON</strong>. Therefore, the<br />

conversions from all other representation types into type 1 will be given below. The inverse conversions can be<br />

obtained by inverting the calculations below. For the conversions, several basic conversion types can be identified.<br />

These are the conversions from the representation types 2, 3, 4, and 7. All other conversions are derived from these<br />

basic conversions. The individual conversions are given by:<br />

Type 2: (’Rp+T’, ’abg’, ’point’) With respect to type 1, the order of rotations is reversed. First, a rotation around<br />

the x-axis, then around the new y-axis, and finally around the z-axis created by the 2nd rotation is performed.<br />

As for type 1, the parameters Rot1, Rot2, Rot3 determine the rotation angles «, ¬, and­. The translation<br />

vector [TransX, TransY, TransZ] is identical for types 1 and 2. For the conversion we have:<br />

È ¾ Ü Ý Þ℄ Ì Ê¡È ½ · Ì<br />

Ê Þ´­´¾µ µ ¡Ê Ý´¬´¾µ µ ¡Ê Ü´«´¾µ µ ¡ È ½ · Ì ´¾µ<br />

Ê Ü´«´½µ µ ¡Ê Ý´¬´½µ µ ¡Ê Þ´­´½µ µ ¡ È ½ · Ì ´½µ<br />

µ<br />

Ê´½µ Ê´¾µ Ê Ü´«´½µ µ ¡Ê Ý´¬´½µ µ ¡Ê Þ´­´½µ µ ¡ È ½ · Ì ´½µ<br />

<br />

Ê Þ´­´¾µ µ ¡Ê Ý´¬´¾µ µ ¡Ê Ü´«´¾µ µ ¡ È ½ · Ì ´¾µ<br />

where:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 687<br />

Ê´¾µ <br />

¼<br />

<br />

<br />

Ö´¾µ<br />

½½<br />

Ö´¾µ<br />

¾½<br />

Ö´¾µ<br />

½¾<br />

Ö´¾µ<br />

¾¾<br />

Ö´¾µ<br />

½¿<br />

Ö´¾µ<br />

¾¿<br />

Ö´¾µ<br />

Ö´¾µ<br />

Ö´¾µ<br />

¿½ ¿¾ ¿¿<br />

where:<br />

½<br />

<br />

<br />

Ö´¾µ<br />

½½<br />

Ó×´­´¾µ µ Ó×´¬´¾µ µ<br />

Ö´¾µ<br />

½¾<br />

Ó×´­´¾µ µ ×Ò´¬´¾µ µ ×Ò´«´¾µ µ ×Ò´­´¾µ µ Ó×´«´¾µ µ<br />

Ö´¾µ<br />

½¿<br />

Ó×´­´¾µ µ ×Ò´¬´¾µ µ Ó×´«´¾µ µ · ×Ò´­´¾µ µ ×Ò´«´¾µ µ<br />

Ö´¾µ<br />

¾½<br />

×Ò´­´¾µ µ Ó×´¬´¾µ µ<br />

Ö´¾µ<br />

¾¾<br />

×Ò´­´¾µ µ ×Ò´¬´¾µ µ ×Ò´«´¾µ µ · Ó×´­´¾µ µ Ó×´«´¾µ µ<br />

Ö´¾µ<br />

¾¿<br />

×Ò´­´¾µ µ ×Ò´¬´¾µ µ Ó×´«´¾µ µ Ó×´­´¾µ µ ×Ò´«´¾µ µ<br />

Ó×´¬´½µ µ<br />

µ<br />

Ö´¾µ<br />

¿½<br />

×Ò´¬´¾µ µ<br />

Ö´¾µ<br />

¿¾<br />

Ó×´¬´¾µ µ ×Ò´«´¾µ µ<br />

Ö´¾µ<br />

¿¿<br />

Ó×´¬´¾µ µ Ó×´«´¾µ µ<br />

<br />

Õ<br />

Ö´¾µ<br />

½½<br />

­´½µ ÖØÒ ¾<br />

¬´½µ ÖØÒ ¾<br />

«´½µ ÖØÒ ¾<br />

¾ ¾<br />

· Ö´¾µ<br />

½¾<br />

<br />

<br />

Ê´¾µ<br />

Ó×´¬´½µ<br />

¾¿<br />

<br />

Ê´¾µ<br />

¿¿<br />

µ Ó×´¬´½µ µ<br />

<br />

Ê´¾µ<br />

½¿ Ó×´¬´½µ µ<br />

<br />

<br />

Ê´¾µ<br />

Ó×´¬´½µ<br />

½¾<br />

<br />

Ê´¾µ<br />

½½<br />

µ Ó×´¬´½µ µ<br />

<br />

Ì ´½µ Ì ´¾µ<br />

Here, ÖØÒ ¾´Ý ܵ denotes ÖØÒ´ Ü<br />

Ý<br />

µ while taking into account the signs of Ü and Ý, in order to determine<br />

the correct quadrant. For the pathological case Ó×´¬´½µ µ¼, the problem is unsolvable because the representation<br />

of a rotation by three parameters exhibits a singularity. In this case, the rotation matrix is perturbed<br />

minimally, thus avoiding the singularity. (The angle ¬ is modified in steps of 0.00001 degrees.)<br />

Type 3: (’Rp+T’, ’rodriguez’, ’point’) The Rodriguez vector is an alternative representation of a rotation in<br />

space. The direction of the vector defines the axis of rotation. The length of the vector usually defines the<br />

rotation angle with positive orientation. Here, a variation of the Rodriguez vector is used, where the length<br />

of the vector defines the tangent of half the rotation angle.<br />

Thus, the parameters Rot1, Rot2, andRot3 do not describe rotation angles, but correspond to the three<br />

values of the vector [Ö Ü Ö Ý Ö Þ ]. The translation vector [TransX, TransY, TransZ] is identical for types 1<br />

and 3. The conversion of the rotation part of the transformation from type 3 to type 1 is given by converting<br />

the Rodriguez vector to the rotation matrix Ê´½µ :<br />

<strong>HALCON</strong> 6.0


688 CHAPTER 12. TOOLS<br />

<br />

<br />

¾<br />

½·Ö ¾ Ü·Ö¾ Ý·Ö¾ Þ<br />

Ö ½½ ½ ´ÖÝ ¾ · Ö¾ Þ µ<br />

Ö ½¾ ´Ö Ü Ö Ý Ö Þ µ<br />

Ö ½¿ ´Ö Ü Ö Þ · Ö Ý µ<br />

Ö ¾½ ´Ö Ý Ö Ü · Ö Þ µ<br />

Ö ¾¾ <br />

Ö ¾¿ <br />

½ ´ÖÞ ¾ · Ö¾ Ü µ<br />

´Ö Ý Ö Þ Ö Ü µ<br />

Ö ¿½ ´Ö Þ Ö Ü Ö Ý µ<br />

Ö ¿¾ ´Ö Þ Ö Ý · Ö Ü µ<br />

Ö ¿¿ ½ ´ÖÜ ¾ · Ö¾ Ý µ<br />

Type 4: (’Rp+T’, ’gba’, ’coordinate system’) In contrast to type 1, type 4 describes the transformation of a<br />

coordinate system instead of the transformation of a point. As for type 1, the parameters Rot1, Rot2, Rot3<br />

define the rotation angles «, ¬, and­. The translation vector [TransX, TransY, TransZ] is identical for<br />

types 1 and 4. The only difference is that the rotation angles are negated. For the conversion we have:<br />

È ¾ Ü Ý Þ℄ Ì Ê¡È ½ · Ì<br />

Ê Ü´«´µ µ ¡Ê Ý´¬´µ µ ¡Ê Þ´­´µ µ ¡ È ½ · Ì ´µ<br />

Ê Ü´«´½µ µ ¡Ê Ý´¬´½µ µ ¡Ê Þ´­´½µ µ ¡ È ½ · Ì ´½µ<br />

where:<br />

Ì ´½µ Ì ´µ<br />

«´½µ «´µ<br />

¬´½µ ¬´µ<br />

­´½µ ­´µ<br />

Type 5: (’Rp+T’, ’abg’, ’coordinate system’) For the conversion of type 5 into type 1, a conversion into type 2<br />

can be done first, followed by a conversion from type 2 to type 1; see the explanations there. Types 5 and<br />

2 differ in the sight of the transformation (ViewOfTransform). Thus, as was the case for the conversion<br />

from type 4 to type 1, the signs of the rotation angles have to be changed. Again, the parameters Rot1,<br />

Rot2, Rot3 denote the rotation angles «, ¬, and­. The translation vector [TransX, TransY, TransZ]<br />

is identical for types 1 and 5. For the conversion to type 2 we have:<br />

È ¾ Ü Ý Þ℄ Ì Ê¡È ½ · Ì<br />

Ê Þ´­´µ µ ¡Ê Ý´¬´µ µ ¡Ê Ü´«´µ µ ¡ È ½ · Ì ´µ<br />

Ê Þ´­´¾µ µ ¡Ê Ý´¬´¾µ µ ¡Ê Ü´«´¾µ µ ¡ È ½ · Ì ´¾µ<br />

where:<br />

Ì ´¾µ Ì ´µ<br />

«´¾µ «´µ<br />

¬´¾µ ¬´µ<br />

­´¾µ ­´µ<br />

Type 6: (’Rp+T’, ’rodriguez’, ’coordinate system’) As for type 3, the rotation for type 6 is given by a Rodrigues<br />

vector. The parameters Rot1, Rot2,andRot3 do not describe angles, but correspond to the three values of<br />

the vector [Ö Ü , Ö Ý , Ö Þ ]. The translation vector (TransX, TransY, TransZ) is identical to type 1. As above,<br />

the conversion of the rotation part to type 1 is done in two steps: First, the vector [Ö Ü , Ö Ý , Ö Ü ]isconvertedto<br />

a rotation matrix, resulting in a representation of type 4. See the explanations on the conversion from type 3<br />

to type 1.<br />

The second step is the conversion from type 4 to type 1, where additionally the rotation angles have to be<br />

negated. See the explanations on the conversion from type 4 to type 1.<br />

Type 7: (’R(p-T)’, ’gba’, ’point’) In contrast to type 1, type 7 describes a transformation in which the translation<br />

is applied first, followed by the rotation. As for type 1, the parameters Rot1, Rot2, andRot3 define the<br />

rotation angles «, ¬, and­. For the transformation we have:<br />

È ¾ Ü Ý Þ℄ Ì Ê´½µ ¡ È ½ · Ì ´½µ<br />

Ê´µ ¡ È Ì´µ¡<br />

½<br />

µ<br />

<br />

Ê´µ ¡ È ½<br />

Ê´µ<br />

¡Ì´µ<br />

Ê´½µ Ê´µ<br />

Ì ´½µ Ê´µ<br />

¡Ì´µ<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 689<br />

Type 8: (’R(p-T)’, ’abg’, ’point’) The conversion from type 8 to type 1 is again carried out in two steps: First,<br />

a conversion to type 7 is done. See the explanations on the conversion from type 2 to type 1. In the second<br />

step, a conversion from type 7 to type 1 is done. See the explanations there. The parameters Rot1, Rot2,<br />

and Rot3 again denote the rotation angles «, ¬,and­.<br />

Type 9: (’R(p-T)’, ’rodriguez’, ’point’) The conversion from type 9 to type 1 is again carried out in two steps:<br />

First, a conversion to type 7 is done. See the explanations on the conversion from type 3 to type 1. In the<br />

second step, a conversion from type 7 to type 1 is done. See the explanations there. The parameters Rot1,<br />

Rot2,andRot3 do not describe rotation angles, but correspond to the three values of the Rodriguez vector<br />

[Ö Ü , Ö Ý , Ö Þ ].<br />

Type 10: (’R(p-T)’, ’gba’, ’coordinate system’) The conversion from type 10 to type 1 is again carried out in<br />

two steps: First, a conversion to type 7 is done. See the explanations on the conversion from type 4 to type<br />

1. In the second step, a conversion from type 7 to type 1 is done. See the explanations there. The parameters<br />

Rot1, Rot2,andRot3 again denote the rotation angles «, ¬, and­.<br />

Type 11: (’R(p-T)’, ’abg’, ’coordinate system’) The conversion from type 11 to type 1 is carried out in three<br />

steps: First, a conversion to type 8 is done. See the explanations on the conversion from type 5 to type 1. In<br />

the second step, a conversion from type 8 to type 7 is done. See the explanations on the conversion from type<br />

2 to type 1. In the third step, the conversion from type 7 to type 1 is done. See the explanations there. The<br />

parameters Rot1, Rot2,andRot3 again denote the rotation angles «, ¬, and­.<br />

Type 12: (’R(p-T)’, ’rodriguez’, ’coordinate system’) The conversion from type 11 to type 1 is also carried out<br />

in three steps: First, a conversion to type 10 is done. See the explanations on the conversion from type 6<br />

to type 1. In the second step, a conversion from type 10 to Type 7 is done. See the explanations on the<br />

conversion from type 4 to type 1. In the third step, the conversion from type 7 to type 1 is done. See the<br />

explanations there. The parameters Rot1, Rot2,andRot3 do not describe rotation angles, but correspond<br />

to the three values of the Rodriguez vector [Ö Ü , Ö Ý , Ö Þ ].<br />

Useful hint: For the description of the pose of a new coordinate system within a base coordinate system, it is<br />

usually easiest to start by visualizing both coordinate systems to be identical, i.e., to lie exactly on top of one<br />

another. After this, the new coordinate system is translated until its origin rests in the correct position. The vector<br />

describing this translation is given by [TransX, TransY, TransZ]. After this, the rotations are applied until the<br />

desired orientation of the new coordinate system is achieved within the base coordinate system. If the rotation<br />

order is chosen as ­ - ¬ - « , first a rotation around the z-axis in positive orientation is done. Then, a rotation<br />

around the new y-axis, and finally a rotation around the x-axis resulting from the second rotation is done. The<br />

rotation angle around the x-axis corresponds to « , and must be passed in Rot1, the rotation angle around the<br />

y-axis corresponds to ¬ , and must be passed in Rot2, while the rotation angle around the z-axis corresponds to ­<br />

and has to be passed in Rot3. This description of a 3D transformation corresponds to type 10 with code ’9’. Thus,<br />

ViewOfTransform = ’coordinate system’, OrderOfTransform = ’R(p-T)’, andOrderOfRotation =<br />

’gba’ have to be passed to the operator.<br />

In the programming example below, it is shown how the initial camera pose for a subsequent call to<br />

T camera calibration can be determined, if the position of the camera is coarsly measured in the world<br />

coordinate system. This is of special interest if the standard planar calibration target (see create caltab)<br />

is not used, and thus the operator T find marks and pose cannot be applied. Instead, natural or artificial<br />

landmarks with known world coordinates can, of course, be used for calibration.<br />

Let, for example, the relative camera position with respect to the origin of the world coordinate system be given by<br />

x = 1.08 m, y = 0.25 m, z = 0.62 m, i.e., the origin of the camera coordinate system has the world coordinates [1.08,<br />

0.25, 0.62]. Let the camera coordinate system be oriented such that the line of sight of the camera corresponds to<br />

the positive z-axis. The orientation of the camera coordinate system with respect to the world coordinate system<br />

can be described by three rotation angles. In the example, the camera coordinate system is first rotated around<br />

the z-axis of the world coordinate system by 100 degrees, followed by a rotation around the new x-axis by -120<br />

degrees. See also the example for T hom mat3d to pose.<br />

Parameter<br />

º TransX (input control) .......................................................real Htuple . double<br />

Translation along the x-axis.<br />

Default Value : 0.1<br />

Value Suggestions : TransX ¾-1.0, -0.75, -0.5, -0.25, -0.2, -0.1, -0.5, -0.25, -0.125, -0.01, 0, 0.01, 0.125,<br />

0.25, 0.5, 0.1, 0.2, 0.25, 0.5, 0.75, 1.0<br />

Typical Range of Values : 0.05 TransX<br />

Recommended Value Step : 0.05<br />

<strong>HALCON</strong> 6.0


690 CHAPTER 12. TOOLS<br />

º TransY (input control) .......................................................real Htuple . double<br />

Translation along the y-axis.<br />

Default Value : 0.1<br />

Value Suggestions : TransY ¾-1.0, -0.75, -0.5, -0.25, -0.2, -0.1, -0.5, -0.25, -0.125, -0.01, 0, 0.01, 0.125,<br />

0.25, 0.5, 0.1, 0.2, 0.25, 0.5, 0.75, 1.0<br />

Typical Range of Values : 0.05 TransY<br />

Recommended Value Step : 0.05<br />

º TransZ (input control) .......................................................real Htuple . double<br />

Translation along the z-axis.<br />

Default Value : 0.1<br />

Value Suggestions : TransZ ¾-1.0, -0.75, -0.5, -0.25, -0.2, -0.1, -0.5, -0.25, -0.125, -0.01, 0, 0.01, 0.125,<br />

0.25, 0.5, 0.1, 0.2, 0.25, 0.5, 0.75, 1.0<br />

Typical Range of Values : 0.05 TransZ<br />

Recommended Value Step : 0.05<br />

º Rot1 (input control) ..........................................................real Htuple . double<br />

First rotation value.<br />

Default Value : 90<br />

Value Suggestions : Rot1 ¾90, 180, 270<br />

Typical Range of Values : 0 Rot1 360<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.2<br />

º Rot2 (input control) ..........................................................real Htuple . double<br />

Second rotation value.<br />

Default Value : 90<br />

Value Suggestions : Rot2 ¾90, 180, 270<br />

Typical Range of Values : 0 Rot2 360<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.2<br />

º Rot3 (input control) ..........................................................real Htuple . double<br />

Third rotation value.<br />

Default Value : 90<br />

Value Suggestions : Rot3 ¾90, 180, 270<br />

Typical Range of Values : 0 Rot3 360<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.2<br />

º OrderOfTransform (input control) ...................................string Htuple . const char *<br />

Order of rotation and translation.<br />

Default Value : ”Rp+T”<br />

Value Suggestions : OrderOfTransform ¾”Rp+T”, ”R(p-T)”<br />

º OrderOfRotation (input control) .....................................string Htuple . const char *<br />

Meaning of the rotation values.<br />

Default Value : ”gba”<br />

Value Suggestions : OrderOfRotation ¾”gba”, ”abg”, ”rodriguez”<br />

º ViewOfTransform (input control) .....................................string Htuple . const char *<br />

View of transformation.<br />

Default Value : ”point”<br />

Value Suggestions : ViewOfTransform ¾”point”, ”coordinate system”<br />

º Pose (output control) ..........................................pose-array Htuple . double * / long *<br />

3D-Transformation.<br />

Parameter Number : 7<br />

Example<br />

HTuple CamParam, StartPose, FinalPose, Errors, Dummy;<br />

// get the following parameter (landmark positions in world and image<br />

// coordinates) by suitable operations<br />

HTuple WorldPointsX, WorldPointsY, WorldPointsZ, PixelsRow, PixelsColumn;<br />

// get internal camera parameters: */<br />

::read_cam_par ("campar.dat", &CamParam) ;<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 691<br />

// get rough camera start pose from relative camera pose:<br />

::create_pose(1.08, 0.25, 0.62, -120, 0, 100, "R(p-T)", "gba",<br />

"coordinate_system", &StartPose);<br />

// calibration of external camera params:<br />

::camera_calibration (WorldPointsX, WorldPointsY, WorldPointsZ,<br />

PixelsRow, PixelsColumn, CamParam, StartPose, 6,<br />

&Dummy, &FinalPose, &Errors) ;<br />

Result<br />

T create pose returns H MSG TRUE if all parameter values are correct. If necessary, an exception handling<br />

is raised.<br />

Parallelization Information<br />

T create pose is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

T pose to hom mat3d, T write pose, T camera calibration, T hand eye calibration<br />

T read pose, T hom mat3d to pose<br />

Alternatives<br />

See Also<br />

T convert pose type, T get pose type, T hom mat3d to pose, T pose to hom mat3d,<br />

T write pose, T read pose<br />

Camera calibration<br />

Module<br />

T disp caltab ( Htuple WindowHandle, Htuple CalTabDescrFile,<br />

Htuple CamParam, Htuple CamPose, Htuple ScaleFac )<br />

Project and visualize the 3D model of the calibration table in the image.<br />

T disp caltab is used to visualize the calibration marks and the connecting lines between the marks of the<br />

used calibration table (CalTabDescrFile) in the actual output window. Thus, the 3D model of the calibration<br />

table is projected into the image plane using the internal camera parameters (CamParam) and the camera pose<br />

(external camera parameters (CamPose). The underlying camera model (pinhole camera with radial distortion) is<br />

described in T write cam par.<br />

Typically T disp caltab is used to verificate the result of the camera calibration (see<br />

T camera calibration) by superimposing it onto the original image. The actual linewidth can be set<br />

by set line width, the actual color can be set by set color.<br />

The parameter ScaleFac influences the number of supporting points to approximate the elliptic contours of the<br />

calibration marks. You should increase the number of supporting points, if the image part in the actual output<br />

window is displayed with magnification (see set part).<br />

Parameter<br />

º WindowHandle (input control) .............................................window Htuple . long<br />

Window id.<br />

º CalTabDescrFile (input control) .....................................string Htuple . const char *<br />

File name of the calibration table description.<br />

Default Value : ’caltab.descr’<br />

º CamParam (input control) .....................................number-array Htuple . double / long<br />

Internal camera parameters.<br />

Parameter Number : 8<br />

º CamPose (input control) .........................................pose-array Htuple . double / long<br />

External camera parameters.<br />

Parameter Number : 7<br />

<strong>HALCON</strong> 6.0


692 CHAPTER 12. TOOLS<br />

º ScaleFac (input control) .....................................................real Htuple . double<br />

Scaling factor for the visualization.<br />

Default Value : 1.0<br />

Value Suggestions : ScaleFac ¾0.5, 1.0, 2.0, 3.0<br />

Recommended Value Step : 0.05<br />

Restriction : 0.0 ScaleFac<br />

Example<br />

HTuple StartCamPar,NX,NY,NZ;<br />

HTuple RCoord1,CCoord1,StartPose1;<br />

HTuple StartPose,CamParam,FinalPose,Errors;<br />

// read calibration image<br />

HImage Image1("calib-01.tiff");<br />

// find calibration pattern<br />

HRegion Caltab1 = Image1.FindCaltab("caltab.descr",3,112,5);<br />

// find calibration marks and start pose<br />

StartCamPar[7] = 576;<br />

// ImageHeight<br />

StartCamPar[6] = 768;<br />

// ImageWidth<br />

StartCamPar[5] = 288;<br />

// Cy<br />

StartCamPar[4] = 384;<br />

// Cx<br />

StartCamPar[3] = 0.000011; // Sy<br />

StartCamPar[2] = 0.000011; // Sx<br />

StartCamPar[1] = 0.0;<br />

// Kappa<br />

StartCamPar[0] = 0.008; // Focus<br />

RCoord1 = Image1.FindMarksAndPose(Caltab1,"caltab.descr",StartCamPar,<br />

128,10,&CCoord1,&StartPose);<br />

// read 3D positions of calibration marks<br />

::caltab_points("caltab.descr",&NX,&NY,&NZ);<br />

// camera calibration<br />

::camera_calibration(NX,NY,NZ,RCoord1,CCoord1,StartCamPar,StartPose,<br />

11,&CamParam,&FinalPose,&Errors);<br />

// visualize calibration result<br />

::disp_image(Image1,WindowHandle);<br />

::set_color(WindowHandle,"red");<br />

::disp_caltab("caltab.descr",CamParam,FinalPose,1.0);<br />

Result<br />

T disp caltab returns H MSG TRUE if all parameter values are correct. If necessary, an exception handling<br />

is raised.<br />

Parallelization Information<br />

T disp caltab is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

T camera calibration, T read cam par, T read pose<br />

See Also<br />

T find marks and pose, T camera calibration, T sim caltab, T write cam par,<br />

T read cam par, T create pose, T write pose, T read pose, T project 3d point,<br />

T get line of sight<br />

Module<br />

Camera calibration<br />

find caltab ( Hobject Image, Hobject *Caltab,<br />

const char *CalTabDescrFile, long SizeGauss, long MarkThresh,<br />

long MinDiamMarks )<br />

Segment the calibration table region in the image.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 693<br />

find caltab is used to determine the region of a plane calibration table with circular marks in the input image<br />

Image. First the input image is smoothed (see gauss image); the size of the used filter mask is given by<br />

SizeGauss. Afterwards a thresholding operator (see threshold) with minimum gray value MarkThresh<br />

and maximum gray value 255 is applied. Among the extracted connected regions the most convex region with<br />

almost correct number of holes (corresponding to the dark marks of the calibration table) is selected. Holes with<br />

a diameter smaller than the expected size of the marks MinDiamMarks are eliminated to reduce the impact of<br />

noise. The number of marks is read from the calibration table description file CalTabDescrFile. The complete<br />

explanation of this file can be found within the description of create caltab.<br />

Parameter<br />

º Image (input object) .........................................................image Hobject : byte<br />

Input image.<br />

º Caltab (output object) ..........................................................region Hobject *<br />

Output region.<br />

º CalTabDescrFile (input control) .............................................string const char *<br />

File name of the calibration table description.<br />

Default Value : ’caltab.descr’<br />

º SizeGauss (input control) ...........................................................integer long<br />

Filter size of the Gaussian.<br />

Default Value : 3<br />

Value List : SizeGauss ¾0, 3, 5, 7, 9, 11, 13<br />

º MarkThresh (input control) .........................................................integer long<br />

Threshold value for mark extraction.<br />

Default Value : 112<br />

Value List : MarkThresh ¾48, 64, 80, 96, 112, 128, 144, 160<br />

º MinDiamMarks (input control) ......................................................integer long<br />

Expected minimal diameter of the marks on the calibration table.<br />

Default Value : 5<br />

Value List : MinDiamMarks ¾3, 5, 9, 15, 30, 50, 70<br />

Example<br />

// read calibration image<br />

HImage Image("calib-01.tiff") ;<br />

// find calibration pattern<br />

HRegion Caltab = Image.FindCaltab("caltab.descr",3,112,5);<br />

Result<br />

find caltab returns H MSG TRUE if all parameter values are correct and an image region is<br />

found. The behavior in case of empty input (no image given) can be set via set system<br />

(’no object result’,) and the behavior in case of an empty result region via set system<br />

(’store empty region’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

find caltab is reentrant and processed without parallelization.<br />

read image<br />

T find marks and pose<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

T find marks and pose, T camera calibration, T disp caltab, T sim caltab,<br />

T caltab points, create caltab<br />

Camera calibration<br />

Module<br />

<strong>HALCON</strong> 6.0


694 CHAPTER 12. TOOLS<br />

T find marks and pose ( Hobject Image, Hobject CalTabRegion,<br />

Htuple CalTabDescrFile, Htuple StartCamParam, Htuple StartThresh,<br />

Htuple DeltaThresh, Htuple MinThresh, Htuple Alpha, Htuple MinContLength,<br />

Htuple MaxDiamMarks, Htuple *RCoord, Htuple *CCoord, Htuple *StartPose )<br />

Extract the 2D calibration marks from the video image and calculate initial values for the external camera parameters.<br />

T find marks and pose is used to determine the necessary input data for the subsequent camera calibration<br />

(see T camera calibration): On the one hand the 2D center points [RCoord,CCoord] of the calibration<br />

marks within the region CalTabRegion of the input image Image are extracted and ordered. On the other hand<br />

a rough estimate for the external camera parameters (StartPose) is computed, i.e., the 3D pose of the camera<br />

in the calibration table coordinate system.<br />

In the input image Image an edge detector is applied (see edges image, mode ’lanser2’) to the region<br />

CalTabRegion, which may have been found by applying the operator find caltab. The filter parameter for<br />

this edge detection can be tuned via Alpha. In the edge image closed contours are searched for: The number of<br />

closed contours must correspond to the number of calibration marks as described in the calibration table description<br />

file CalTabDescrFile and the contours have to be ellipticly shaped. Contours shorter than MinContLength<br />

are discarded, just as contours enclosing regions with a diameter larger than MaxDiamMarks (e.g., the border of<br />

the calibration table).<br />

For the detection of contours a threshold operator is applied to amplitude of the edge detector. All points with a<br />

high amplitude (i.e. borders of marks) are selected.<br />

First, the threshold value is set to StartThresh. If the search for the closed contours or the successive pose<br />

estimate fails, this threshold value is successively decreased by DeltaThresh down to a minimum value of<br />

MinThresh.<br />

Each of the found contours is refined with subpixel accuracy (see edges sub pix) and subsequently approximated<br />

by an ellipse. The center points of these ellipses represent a good approximation of the desired 2D image<br />

coordinates [RCoord,CCoord] of the calibration mark center points. The order of the values within these two<br />

tuples is in row-major order beginning at the upper left in the image. This order must correspond to the order of<br />

the 3D coordinates of the calibration marks in the calibration table description file CalTabDescrFile, since<br />

this fixes the correspondences between extracted image marks and known model marks!<br />

Based on the ellipse parameters for each calibration mark a rough estimate for the external camera parameters is<br />

computed finally. For that purpose the fixed correspondences between extracted image marks and known model<br />

marks are used. The estimate StartPose describes the pose of the camera in the calibration table coordinate<br />

system (see T create pose) as desired by the operator T camera calibration.<br />

Parameter<br />

º Image (input object) .........................................................image Hobject : byte<br />

Input image.<br />

º CalTabRegion (input object) .....................................................region Hobject<br />

Region of the calibration table.<br />

º CalTabDescrFile (input control) .....................................string Htuple . const char *<br />

File name of the calibration table description.<br />

Default Value : ’caltab.descr’<br />

º StartCamParam (input control) ...............................number-array Htuple . double / long<br />

Initial values for the internal camera parameters.<br />

º StartThresh (input control) ...............................................number Htuple . long<br />

Initial threshold value for contour detection.<br />

Default Value : 128<br />

Value List : StartThresh ¾80, 96, 112, 128, 144, 160<br />

º DeltaThresh (input control) ...............................................number Htuple . long<br />

Loop value for successive reduction of StartThresh.<br />

Default Value : 10<br />

Value List : DeltaThresh ¾6, 8, 10, 12, 14, 16, 18, 20, 22<br />

º MinThresh (input control) ..................................................number Htuple . long<br />

Minimum threshold for contour detection.<br />

Default Value : 18<br />

Value List : MinThresh ¾8, 10, 12, 14, 16, 18, 20, 22<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 695<br />

º Alpha (input control) .........................................................real Htuple . double<br />

Filter parameter for contour detection, see edges image.<br />

Default Value : 0.9<br />

Value Suggestions : Alpha ¾0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1<br />

Typical Range of Values : 0.2 Alpha 50.0<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Alpha 0.0<br />

º MinContLength (input control) ..............................................real Htuple . double<br />

Minimum length of the contours of the marks.<br />

Default Value : 15.0<br />

Value Suggestions : MinContLength ¾10.0, 15.0, 20.0, 30.0, 40.0, 100.0<br />

Restriction : MinContLength 0.0<br />

º MaxDiamMarks (input control) ...............................................real Htuple . double<br />

Maximum expected diameter of the marks.<br />

Default Value : 100.0<br />

Value Suggestions : MaxDiamMarks ¾50.0, 100.0, 150.0, 200.0, 300.0<br />

Restriction : MaxDiamMarks 0.0<br />

º RCoord (output control) ...............................................real-array Htuple . double *<br />

Tuple with row-coordinates of the detected marks.<br />

º CCoord (output control) ...............................................real-array Htuple . double *<br />

Tuple with column-coordinates of the detected marks.<br />

º StartPose (output control) ...................................pose-array Htuple . double * / long *<br />

Estimation for the external camera parameters.<br />

Parameter Number : 7<br />

Example<br />

HTuple StartCamPar,RCoord,CCoord,StartPose;<br />

// read calibration image<br />

HImage Image("calib-01.tiff");<br />

// find calibration pattern<br />

HRegion Caltab = Image.FindCaltab("caltab.descr",3,112,5);<br />

// read internal camera parameters from file<br />

::read_cam_par("campar.dat",&StartCamPar);<br />

// find calibration marks and start pose<br />

RCoord = Image.FindMarksAndPose(Caltab,"caltab.descr",StartCamPar,<br />

128,10,18,0.9,15.0,100.0,<br />

&CCoord,&StartPose);<br />

Result<br />

T find marks and pose returns H MSG TRUE if all parameter values are correct and an estimation for the<br />

external camera parameters has been determined successfully. If necessary, an exception handling is raised.<br />

Parallelization Information<br />

T find marks and pose is reentrant and processed without parallelization.<br />

find caltab<br />

T camera calibration<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

find caltab, T camera calibration, T disp caltab, T sim caltab, T read cam par,<br />

T read pose, T create pose, T pose to hom mat3d, T caltab points, create caltab,<br />

edges sub pix, edges image<br />

Camera calibration<br />

Module<br />

<strong>HALCON</strong> 6.0


696 CHAPTER 12. TOOLS<br />

T get line of sight ( Htuple Row, Htuple Column, Htuple CamParam,<br />

Htuple *PX, Htuple *PY, Htuple *PZ, Htuple *QX, Htuple *QY, Htuple *QZ )<br />

Compute the line of sight corresponding to a point in the image.<br />

T get line of sight computes the line of sight corresponding to a pixel (Row, Column) in the image plane.<br />

The line of sight is a (straight) line in the camera coordinate system, which is described by two points (PX,PY,PZ)<br />

and (QX,QY,QZ) on the line. A pinhole or telecentric camera model with radial distortions described by the internal<br />

camera parameters CamParam is used (see T camera calibration). If a pinhole camera is used, the second<br />

point lies on the focal plane, i.e., the output parameter QZ is equivalent to the focal length of the camera. The<br />

equation of the line of sight is given by<br />

¼<br />

Ü Ý<br />

Þ<br />

½ ¼<br />

Ô Ü<br />

Ô Ý<br />

Ô Þ<br />

½ ¼<br />

· Ø<br />

Õ Ü<br />

Õ Ý<br />

Õ Þ<br />

The advantage of representing the line of sight as two points is that with this, it is easier to transform the line in<br />

3D. To do so, all that is necessary is to apply the operator T affine trans point 3d to the two points.<br />

Parameter<br />

º Row (input control) ......................................................real-array Htuple . double<br />

Row coordinate of the pixel.<br />

º Column (input control) ..................................................real-array Htuple . double<br />

Column coordinate of the pixel.<br />

º CamParam (input control) .....................................number-array Htuple . double / long<br />

Internal camera parameters.<br />

Parameter Number : 8<br />

º PX (output control) .....................................................real-array Htuple . double *<br />

X coordinate of the first point on the line of sight<br />

º PY (output control) .....................................................real-array Htuple . double *<br />

Y coordinate of the first point on the line of sight<br />

º PZ (output control) .....................................................real-array Htuple . double *<br />

Z coordinate of the first point on the line of sight<br />

º QX (output control) .....................................................real-array Htuple . double *<br />

X coordinate of the second point on the line of sight<br />

º QY (output control) .....................................................real-array Htuple . double *<br />

Y coordinate of the second point on the line of sight<br />

º QZ (output control) .....................................................real-array Htuple . double *<br />

Z coordinate of the second point on the line of sight<br />

Example<br />

Ô Ü<br />

Ô Ý<br />

Ô Þ<br />

½<br />

<br />

HTuple CamParam,Row,Column,PX,PY,PZ,QX,QY,QZ;<br />

// get internal camera parameters<br />

::read_cam_par("campar.dat",&CamParam);<br />

// inverse projection<br />

Row[1] = 100;<br />

Row[0] = 50;<br />

Column[1] = 200;<br />

Column[0] = 100;<br />

::get_line_of_sight(Row,Column,CamParam,&PX,&PY,&PZ,&QX,&QY,&QZ);<br />

Result<br />

T get line of sight returns H MSG TRUE if all parameter values are correct. If necessary, an exception<br />

handling is raised.<br />

Parallelization Information<br />

T get line of sight is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T read cam par, T camera calibration<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 697<br />

T affine trans point 3d<br />

Possible Successor Functions<br />

See Also<br />

T camera calibration, T disp caltab, T read cam par, T project 3d point,<br />

T affine trans point 3d<br />

Module<br />

Camera calibration<br />

T get pose type ( Htuple Pose, Htuple *OrderOfTransform,<br />

Htuple *OrderOfRotation, Htuple *ViewOfTransform )<br />

Get the representation type of 3D pose parameters.<br />

With T get pose type, the representation type of the 3D pose Pose can be queried.<br />

A 3D pose defines a 3D transformation consisting of a translation and a rotation. Halcon supports different representation<br />

types for such a transformation. This can be, for example, external camera parameters, given by a 3D<br />

translation vector (in meters), three rotation angles, and the code of the representation type of the 3D transformation.<br />

For example, the value ’0’ is the code of representation type 1, and signifies that the transformation of a point<br />

is described, that the 3D rotation is applied before the translation, that the rotations are given as angles (in degrees),<br />

and that the order of the rotations is ­-¬-«, i.e., the first rotation is around the z-axis, the second rotation around<br />

the new y-axis, and the third rotation around the x-axis created by the previous two rotations. The meaning of the<br />

other representation types is described with the operator T create pose.<br />

The returned parameter ViewOfTransform determines, whether the transformation Pose describes the<br />

transformation of a point (’point’) or the transformation of a coordinate system (’coordinate system’).<br />

OrderOfTransform determines whether the rotation (’Rp+T’) or the translation (’R(p-T)’) is applied first.<br />

The meaning of the three rotation values is determined by OrderOfRotation. The values ’gba’ and ’abg’<br />

signify that the rotation values describe the three rotation angles « (around the x-axis), ¬ (around the y-axis), and<br />

­ (around the z-axis) in the 3D transformation. For ’gba’, the rotation order is ­ , ¬ , « ,andfor’abg’ it is « , ¬ ,<br />

­ .IfOrderOfRotation is ’rodriguez’, the rotation values are interpreted as Rodriguez rotation vector.<br />

Parameter<br />

º Pose (input control) ..............................................pose-array Htuple . double / long<br />

3D transformation.<br />

Parameter Number : 7<br />

º OrderOfTransform (output control) .......................................string Htuple . char *<br />

Order of rotation and translation.<br />

º OrderOfRotation (output control) .........................................string Htuple . char *<br />

Meaning of the rotation values.<br />

º ViewOfTransform (output control) .........................................string Htuple . char *<br />

View of transformation.<br />

Example<br />

HTuple Pose, OrderT, OrderR, SightT;<br />

// get pose (external camera parameters):<br />

::read_pose("campose.dat", &CamPose) ;<br />

/* get semantic type of pose */<br />

::get_pose_type(CamPose, &OrderT, &OrderR, &SightT);<br />

Result<br />

T create pose returns H MSG TRUE if all parameter values are correct. If necessary, an exception handling<br />

is raised.<br />

Parallelization Information<br />

T get pose type is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create pose, T hom mat3d to pose, T camera calibration, T hand eye calibration<br />

<strong>HALCON</strong> 6.0


698 CHAPTER 12. TOOLS<br />

T convert pose type<br />

Possible Successor Functions<br />

See Also<br />

T create pose, T convert pose type, T write pose, T read pose<br />

Camera calibration<br />

Module<br />

T hand eye calibration ( Htuple NX, Htuple NY, Htuple NZ, Htuple NRow,<br />

Htuple NCol, Htuple MPointsOfImage, Htuple MRelPoses,<br />

Htuple BaseStartPose, Htuple CamStartPose, Htuple CamParam,<br />

Htuple ToEstimate, Htuple StopCriterion, Htuple MaxIterations,<br />

Htuple MinError, Htuple *BaseFinalPose, Htuple *CamFinalPose,<br />

Htuple *NumErrors )<br />

Perform a hand-eye-calibration.<br />

The operator T hand eye calibration can be used to determine the 3D pose of the origin of the camera<br />

coordinate system with respect to the origin of the manipulator coordinate system (tool center point). This is typically<br />

used for robots equipped with a camera, where the pose of the camera (the “eye”) relative to the manipulator<br />

(the “hand”) has to be determined, in order to enable a video-based gripping of objects.<br />

The assumption for the following desciption is, that the camera is fixed to the end-effector of the manipulator<br />

(hand-in-eye-configuration). In this case the calibration determines the (constant) pose of the camera in respect to<br />

the tool coordination system of the end-effector. In the other case (the camera is stationary and looks to the moving<br />

manipulator) the (constant) pose of the base coordination system of the manipulator in respect to the camera is<br />

computed. This can be performed by using T hand eye calibration, too.<br />

T hand eye calibration works in a similar manner to the conventional calibration of the exterior camera<br />

parameters (camera pose); see T camera calibration. However, T hand eye calibration not only<br />

determines the camera pose as a simple transformation, but as a chain of transformations from the world coordinate<br />

system to the base coordinate system of the active system (robot or vehicle) to the manipulator coordinate system,<br />

and finally to the camera coordinate system. Thus, the transformation of a point È Ï in world coordinates to the<br />

camera coordinate system can be described by:<br />

È Ü Ý Þ℄ Ì Ê¡È Ï · Ì<br />

Ê ´Ê Ñ ´Ê Ú ¡ È Ï · Ì Ú µ·Ì Ñ µ·Ì <br />

where<br />

Ê Ú , Ì Ú :<br />

Ê Ñ , Ì Ñ :<br />

Ê , Ì :<br />

Rotation and translation from the world coordinate system<br />

to the base coordinate system of the active system (vehicle)<br />

Rotation and translation from the base coordinate system<br />

to the manipulator coordinate system<br />

Rotation and translation from the manipulator coordinate system<br />

to the camera coordinate system<br />

The goal of the hand-eye-calibration is to determine (Ê , Ì ). In order to avoid having to construct an exactly<br />

measured set-up, a least-squares error adjustment is used, which estimates (Ê Ú , Ì Ú ) as well. Therefore, measurements<br />

referring to different positions of the manipulator are used. Hence, it must be possible to determine the<br />

different positions of the manipulator with sufficient accuracy. For a robot arm, they can be determined from the<br />

angle positions of the individual joints of the arm. Analogously to the determination of the interior camera parameters<br />

(see T camera calibration), a large number of different manipulator positions is used to achieve more<br />

robust results.<br />

A Newton-type algorithm is used to minimize an error function based on normal equations. Therefore, suitable<br />

starting values have to be passed for (Ê , Ì ), and (Ê Ú , Ì Ú ) by the user.<br />

Starting values for (Ê , Ì ) can be obtained by a coarse measurement of the set-up. Starting values for (Ê Ú , Ì Ú )<br />

can be obtained from the starting values for (Ê , Ì ), the exterior camera parameters (Ê , Ì ) (pose of the camera<br />

in the entire transformation chain; see T camera calibration), and the corresponding pose (Ê Ñ , Ì Ñ )ofthe<br />

manipulator. We have:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 699<br />

È Ê ¡ È Ï · Ì <br />

Ê ´Ê Ñ ´Ê Ú ¡ È Ï · Ì Ú µ·Ì Ñ µ·Ì <br />

where<br />

Ê , Ì :<br />

Rotation and translation from the world coordinate system<br />

to the camera coordinate system (camera pose).<br />

The following sections discuss individual questions arising from the use of T hand eye calibration and<br />

are intended to be a guide line for using the operator in an application, as well as to aid the understanding of the<br />

operator.<br />

HowdoIget3Dmodelpoints? 3D model points, given in the world coordinate system (NX, NY, NZ), and their<br />

associated projections to the camera coordinate system (NRow, NCol) form the basis of the hand-eyecalibration.<br />

In order ro be able to perform a successful hand-eye-calibration, 3D model points must be<br />

used, which were obtained from sufficiently many different positions of the manipulator.<br />

Arbitrary known points in the world coordinate system along with their associated projections to the camera<br />

coordinate system can be used for the calibration. However, it is usually most convenient to use a standard<br />

calibration table, e.g., the one that can be generated with create caltab. By using this calibration table,<br />

the calibration table and position of the calibration marks can be extracted by using find caltab and<br />

T find marks and pose, respectively.<br />

Please refer to T camera calibration for a description of the extraction of the calibration table and its<br />

associated 3D model points.<br />

The parameter MPointsOfImage detemines the number of 3D model points used for each pose of the<br />

manipulator, i.e., for each image. With this, the 3D model points, which are stored in a linearized fashion<br />

in NX, NY, NZ, and their corresponding projections (NRow, NCol) can be associated with the corresponding<br />

position of the manipulator (MRelPoses).<br />

The 3D model points can be read from a calibration table description file for the standard calibration table<br />

with the operator T caltab points.<br />

How do I acquire a suitable set of images? If a planar standard calibration table is used, the following procedure<br />

should be used: Images of the calibration table are taken with the active system to be calibrated, i.e., the<br />

combination of the base of the manipulator (the vehicle, in case of mobile systems, which is used as a<br />

fixed point for the manipulator), the manipulator (robot arm, pan-tilt-head, etc.), and the camera system; see<br />

open framegrabber and grab image. For the image acquisition, the following points should be taken<br />

into account:<br />

¯ At least 10 to 20 images from different positions should be taken in which the position of the camera<br />

with respect to the calibration table is sufficiently different. The position of the calibration table must<br />

not be changed between images.<br />

¯ In each image, the calibration table must be completely visible (including its border).<br />

¯ No reflections or other disturbances should be visible on the calibration table.<br />

¯ The set of images must show the calibration table from very different positions of the manipulator.<br />

The calibration table can and should be visible in different parts of the images. Furthermore, it should<br />

be slightly to moderately rotated around its x- or y-axis, in order to clearly exhibit distortions of the<br />

calibration marks. In other words, the corresponding exterior camera parameters (pose of the camera<br />

with respect to the calibration table) should take on many different values. Consider that the manipulator<br />

only has six degrees of freedom (three for rotation and three for translation), while twelve degrees of<br />

freedom have to be estimated for BaseFinalPose and CamFinalPose. This means that the space<br />

of the degrees of freedom for the manipulator has to be used as exhaustively as possible.<br />

¯ In each image, the calibration table should fill at least one quarter of the entire image, in order to ensure<br />

the robust detection of the calibration marks.<br />

¯ The interior camera parameters of the camera to be used must have been determined earlier and must be<br />

passed in CamParam; seeT camera calibration. Note that changes of the image size, the focal<br />

length, the aperture, or the focus effect a change of the interior camera parameters.<br />

¯ The camera must not be modified between the acquisition of the individual images, i.e., neither focal<br />

length, nor aperture, nor focus must be changed, because all calibration images use the same interior<br />

camera parameters. Please make sure that the focus is sufficient for the expected changes of the distance<br />

the camera from the calibration table. Therefore, bright lighting conditions for the calibration table are<br />

important because smaller apertures result in larger depth of focus.<br />

<strong>HALCON</strong> 6.0


700 CHAPTER 12. TOOLS<br />

How do I obtain suitable starting values? The starting values for (Ê , Ì )and(Ê Ú , Ì Ú ) are passed as 3D poses<br />

in the parameters CamStartPose and BaseStartPose, just like the exterior camera parameters.<br />

CamStartPose can be obtained by measuring the pose of the camera in the manipulator coordinate system.<br />

This is the same procedure as the determination of starting values for the calibration of the exterior camera<br />

parameters without using the standard calibration table. Use T create pose to create a pose from your<br />

measurements. For the measurement, it is usually easier to determine the translation of the origin of the<br />

camera coordinate system within the manipulator coordinate system first, followed by the determination of<br />

the orientation.<br />

The camera coordinate system is oriented such that the line of sight of the camera corresponds to the positive<br />

z-axis. The orientation of the camera coordinate system with respect to the world coordinate system can<br />

be described by three rotation angles. In order to determine the orientation, one can, for example, first<br />

“rotate” around the z-axis of the manipulator coordinate system, then around the new y-axis, and finally<br />

around the new x-axis created by the previous two rotations. In this case, the rotation angles around the x-,<br />

y-, and z-axis correspond directly to the rotation parameters of T create pose. Hence, according to this<br />

description of the pose, the following settings must be passed to T create pose: ’coordinate system’<br />

for the sight of the transformation (a transformation of a coordinate system is described), ’R(p-T)’ for the<br />

order of the transformations (first a translation, then a rotation), and ’gba’ for the order of rotations (­, ¬,<br />

«). This corresponds to representation type 10. For further information, please refer to the description of<br />

T create pose.<br />

In order to determine BaseStartPose, a calibration of the exterior camera parameters<br />

(T camera calibration) should be performed for one of the acquired images. From the pose of<br />

the camera coordinate system in the world coordinate system thus determined, and from the other poses<br />

in the transformation chain (starting values for (Ê , Ì ) and exact values for the corresponding position of<br />

the manipulator (Ê Ñ , Ì Ñ )), the starting value can be determined very elegantly and easily by the use of<br />

homogeneous 3D transformation matrices. We have:<br />

È Ê¡È Ï · Ì<br />

À¡È Ï<br />

and<br />

À Ú À Ñ ½ ¡À ´×ØÖص ½ ¡À <br />

where<br />

À Ú : Transformation from world coordinate system to<br />

base coordinate system (starting value)<br />

À Ñ : Transformation from base coordinate system and<br />

manipulator coordinate system<br />

À ´×ØÖص : Transformation from manipulator coordinate system<br />

to camera coordinate system (starting value, measured)<br />

À : Transformation from world coordinate system to camera<br />

coordinate system (determined from exterior calibration).<br />

See T pose to hom mat3d, T affine trans point 3d, T hom mat3d invert,<br />

T hom mat3d compose,andT hom mat3d to pose.<br />

How do I obtain the poses of the manipulator? The parameter MRelPoses determines the positions of the<br />

manipulator. If Ñ positions were obtained by positioning the manipulator, these Ñ positions must be passed<br />

linearized. The representation of these 3D poses is the same as for the exterior camera parameters and<br />

the starting parameters CamStartPose and BaseStartPose. 3D poses are tuples of length 7, see<br />

T create pose.<br />

It is extremely important for the algorithm of the hand-eye-calibration that the poses MRelPoses can be<br />

obtained exactly from the manipulator. The transformation of the angles of a robot arm to the representation<br />

of a pose (rotation and translation) can be performed with T create pose. It is advisable to use the<br />

same procedure as for the determination of the starting value CamStartPose of the camera pose in the<br />

manipulator coordinate system. The manipulator coordinate system must be oriented such that it is identical<br />

or at least parallel to the base coordinate system in the initial position of the manipulator. In order to determine<br />

the poses of the individual manipulator positions, first the three translation parameters between the origin<br />

of the base coordinate system and the origin of the manipulator coordinate system should be determined.<br />

The translations should be determined along the axes of the base coordinate system when passing them<br />

to T create pose. For the orientation of the coordinate systems with respect to each other, one first<br />

“rotates” around the z-axis of the translated coordinate system, then around the new y-axis, and finally around<br />

the new x-axis created by the previous two rotations. The three rotation angles are used as parameters to<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 701<br />

T create pose. Hence, according to this description of the pose, the following settings must be passed<br />

to T create pose: ’coordinate system’ for the sight of the transformation, ’R(p-T)’ for the order of the<br />

transformations, and ’gba’ for the order of rotations. This corresponds to representation type 10. See also<br />

the description of T create pose.<br />

How can I exclude individual pose parameters from the estimation? T hand eye calibration estimates<br />

a maximum of 12 pose parameters. They are three rotation and three translation parameters each<br />

for the pose of the base coordinate system in the world coordinate system and for the pose of the camera<br />

coordinate system in the manipulator coordinate system. However, it is possible to exclude some of these<br />

pose parameters from the estimation. This means that the starting values of the poses remain unchanged<br />

and are assumed constant for the estimation of all other pose parameters. The parameter ToEstimate is<br />

used to determine which pose parameters should be estimated. In ToEstimate, a list of keywords for the<br />

parameters to be estimated is passed. They are:<br />

For the pose of the base coordinate system in the world coordinate system:<br />

’baseTx’ = translation along the x-axis<br />

’baseTy’ = translation along the y-axis<br />

’baseTz’ = translation along the z-axis<br />

’baseRa’ = rotation around the x-axis<br />

’baseRb’ = rotation around the y-axis<br />

’baseRg’ = rotation around the z-axis<br />

For the pose of the camera coordinate system in the manipulator coordinate system:<br />

’camTx’ = translation along the x-axis<br />

’camTy’ = translation along the y-axis<br />

’camTz’ = translation along the z-axis<br />

’camRa’ = rotation around the x-axis<br />

’camRb’ = rotation around the y-axis<br />

’camRg’ = rotation around the z-axis<br />

In order to estimate all 12 of the pose parameters, all 12 keywords can be passed. Alternatively, the keyword<br />

’all’ can be used.<br />

It is useful to exclude individual parameters from the estimation if some of the pose parameters have been<br />

measured exactly. On the other hand, fixing some parameters reduces the degrees of freedom in the estimation,<br />

and thus increases the robustness to the estimated parameters, if the manipulator only has limited<br />

movement abilities, e.g., a pan-tilt head.<br />

Which terminating criteria can be used for the error minimization? The error minimization terminates either<br />

after a fixed number of iterations or if the error falls below a given minimum error. The parameter<br />

StopCriterion is used to choose between these two alternatives. If ’CountIterations’ is passed, the<br />

algorithm terminates after MaxIterations iterations.<br />

If StopCriterion is passed as ’MinError’, the algorithm runs until the error falls below the error<br />

threshold given in MinError. If, however, the number of iterations reaches the number given in<br />

MaxIterations, the algorithm terminates with an error message.<br />

What is the order of the individual parameters? The length of the tuple MPointsOfImage corresponds to<br />

the number of different positions of the manipulator. The parameter MPointsOfImage determines the<br />

number of model points used in the individual positions. If the standard calibration table is used, this means<br />

49 points per position (image). If 15 images were acquired, MPointsOfImage is a tuple of length 15,<br />

where all elements of the tuple have the value 49.<br />

The number of calibration images, which is determined by the length of MPointsOfImage, mustalsobe<br />

taken into account for the 3D model point tuples and the extracted 2D marks tuples, respectively. Hence,<br />

for 15 calibration images with 49 model points each, the tuples NX, NY, NZ, NRow, andNCol must contain<br />

½ ¡ ¿ values each. These tuples are ordered according to the image the respective points lie in, i.e.,<br />

the first 49 values correspond to the 49 model points in the first image. The order of the 3D model points and<br />

the extracted 2D model points must be the same in each image.<br />

The length of the tuple MRelPoses corresponds to the number of calibration images. If, for example, 15<br />

images from different positions were acquired, the length of the tuple MRelPoses is ½ ¡ ½¼ (15 times<br />

7 pose parameters). The first seven parameters thus determine the pose of the manipulator in the first image,<br />

and so on.<br />

<strong>HALCON</strong> 6.0


702 CHAPTER 12. TOOLS<br />

What do the output parameters mean? If StopCriterion was set to ’CountIterations’, the output parameters<br />

are returned, even if the algorithm didn’t converge. If, however, StopCriterion was set to ’Min-<br />

Error’, the error must fall below ’MinError’ in order for output parameters to be returned.<br />

The output parameters are the pose of the base coordinate system in the world coordinate system<br />

(BaseFinalPose) and the pose of the camera coordinate system in the manipulator coordinate system<br />

(CamFinalPose).<br />

The representation type of BaseFinalPose and CamFinalPose is the same as the corresponding starting<br />

values. It can be changed with the operator T convert pose type. The description of the different<br />

representation types and of their conversion can be found with the documentation of the operator<br />

T create pose.<br />

The parameter NumErrors contains a list of (numerical) errors from the individual iterations of the algorithm.<br />

Based on the evolution of the errors, it can be decided whether the algorithm has converged for the<br />

given starting values. The error values are returned as 3D deviations in meters. Thus, the last entry of the<br />

error list corresponds to an estimate of the accuracy of the returned pose parameters.<br />

Attention<br />

The quality of the calibration depends on the accuracy of the input parameters (position of the calibration marks and<br />

the starting positions BaseStartPose, CamStartPose). Based on the returned error measures NumErrors,<br />

it can be decided, whether the algorithm has converged. Furthermore, the accuracy of the returned pose can be<br />

estimated. The error measures are 3D differences in meters.<br />

Parameter<br />

º NX (input control) .......................................................real-array Htuple . double<br />

Linear list containing all the X-coordinates of the calibration points (in the order of the image).<br />

º NY (input control) .......................................................real-array Htuple . double<br />

Linear list containing all the Y-coordinates of the calibration points (in the order of the image).<br />

º NZ (input control) .......................................................real-array Htuple . double<br />

Linear list containing all the Z-coordinates of the calibration points (in the order of the image).<br />

º NRow (input control) .....................................................real-array Htuple . double<br />

Linear list containing all the labelled abscissas (in the order of the image).<br />

º NCol (input control) .....................................................real-array Htuple . double<br />

Linear list containing all the labelled ordinates (in the order of the image).<br />

º MPointsOfImage (input control) ......................................integer-array Htuple . long<br />

Number of the calibration points for each image.<br />

º MRelPoses (input control) .......................................pose-array Htuple . double / long<br />

Measured values of relative pose of gripping device for each image.<br />

º BaseStartPose (input control) .................................pose-array Htuple . double / long<br />

Initial value for robot pose in world coordinate system.<br />

º CamStartPose (input control) ...................................pose-array Htuple . double / long<br />

Initial value for camera pose relative to end-effector.<br />

º CamParam (input control) .....................................number-array Htuple . double / long<br />

Internal camera parameters.<br />

º ToEstimate (input control) ......................................string-array Htuple . const char *<br />

Parameters to be estimated (max. 12 free degrees).<br />

Default Value : ”all”<br />

Value List : ToEstimate ¾”all”, ”baseTx”, ”baseTy”, ”baseTz”, ”baseRa”, ”baseRb”, ”baseRg”,<br />

”camTx”, ”camTy”, ”camTz”, ”camRa”, ”camRb”, ”camRg”<br />

º StopCriterion (input control) .......................................string Htuple . const char *<br />

Type of stopping criterion.<br />

Default Value : ”CountIterations”<br />

Value List : StopCriterion ¾”CountIterations”, ”MinError”<br />

º MaxIterations (input control) .............................................integer Htuple . long<br />

Maximum number of iterations to be executed.<br />

Default Value : 15<br />

Value Suggestions : MaxIterations ¾10, 15, 20, 25, 30<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 703<br />

º MinError (input control) .....................................................real Htuple . double<br />

Minimum error used as the stopping criterion.<br />

Default Value : 0.0005<br />

Value Suggestions : MinError ¾0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05, 0.1<br />

º BaseFinalPose (output control) .............................pose-array Htuple . double * / long *<br />

Computed pose of base system to world coodinate system.<br />

º CamFinalPose (output control) ...............................pose-array Htuple . double * / long *<br />

Computed pose of the camera relative to the coodinate system of the gripping device .<br />

º NumErrors (output control) ..........................................real(-array) Htuple . double *<br />

Error measures for each iteration.<br />

Example<br />

HTuple<br />

HTuple<br />

HTuple<br />

HTuple<br />

HTuple<br />

Hobject<br />

char<br />

char<br />

CamParam, RCoord, CCoord;<br />

ManuPose, NumMarker, X, Y, Z, XPositions, YPositions;<br />

ZPositions, RCoordTmp, CCoordTmp, StartPose;<br />

ManuPoseTmp, BaseStartPose, CamStartPose, BaseFinalPose;<br />

CamFinalPose, NumErrors;<br />

Image, Caltab;<br />

Datname[256];<br />

CaltabName[256];<br />

sprintf(CaltabName, "Caltab.descr");<br />

::read_cam_par("CamParam.cal",&CamParam);<br />

RCoord = HTuple();<br />

CCoord = HTuple();<br />

ManuPose = HTuple();<br />

NumMarker = HTuple();<br />

::caltab_points(CaltabName,&X,&Y,&Z);<br />

XPositions = HTuple();<br />

YPositions = HTuple();<br />

ZPositions = HTuple();<br />

// find landmarks in every image<br />

for (long i=0; i


704 CHAPTER 12. TOOLS<br />

Result<br />

T hand eye calibration returns H MSG TRUE if all parameter values are correct and the method coverges<br />

with an error less than the specified minimum error (if StopCriterion = ’MinError’). If necessary, an<br />

exception handling is raised.<br />

Parallelization Information<br />

T hand eye calibration is reentrant and processed without parallelization.<br />

T find marks and pose<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

T write pose, T convert pose type, T pose to hom mat3d, T disp caltab, T sim caltab<br />

See Also<br />

find caltab, T find marks and pose, T disp caltab, T sim caltab, T write cam par,<br />

T read cam par, T create pose, T convert pose type, T write pose, T read pose,<br />

T pose to hom mat3d, T hom mat3d to pose, T caltab points, create caltab<br />

Camera calibration<br />

Module<br />

T hom mat3d to pose ( Htuple HomMat3D, Htuple *Pose )<br />

Convert homogeneous transformation matrix into 3D pose parameter.<br />

T hom mat3d to pose is used to convert a homogeneous transformation matrix into the correspondent representation<br />

of the transformation as translational vector and rotational angles.<br />

The homogeneous 4x3 transformation matrix is given as a tupel HomMat3D in the following order: The first four<br />

values describe the first row of the rotation matrix and x-value of the translation vector. The next four values<br />

describe the second row of the rotation matrix and the y-value of the translation vector. These are followed by the<br />

values of the third row of the rotation matrix and the z-value of the translation vector.<br />

The output tupel Pose describes the external camera parameter by the 3D translational vector (in meters), the<br />

three rotation angles and the representation type of the 3D transform. The representation type of a 3D transform<br />

generated by T hom mat3d to pose has Type 1 with code ’0’. This means, that the transform of a point is<br />

described, hereby the 3D rotation is performed before the 3D translation, that the three rotations are specified as<br />

angles (in degrees), and that the rotation order is ­-¬-«, i.e., the first rotation is around the Z-axis, the second one<br />

around the new Y-axis, and the third one around the new X-axis, which is generated after the second rotation. This<br />

corrensponds to the transformation by homogenous matixes directly. This can be explained by the following holds:<br />

È Ü Ý Þ℄ Ì À¡È Ï<br />

Ê´½µ ¡ È Ï · Ì ´½µ<br />

The sense of the other representation types are explained at T create pose. With T convert pose type<br />

you can convert Pose to every other kind of representation type.<br />

The subsequent program example shows how to generate an appropriate initial camera pose for<br />

T camera calibration, if the camera pose is roughly measured in the world coordinate system. This is<br />

especially important if no planar calibration table (see create caltab) is used and therefore the operator<br />

T find marks and pose cannot be applied. Instead of this natural or artificial landmarks with known world<br />

position can be used.<br />

Let for example the relative camera position in the world coordinate system be the following: x = 1.08 m, y = 0.25<br />

m, z = 0.62 m. This means, that the origin of the camera coordinate system in world coordinates has the value<br />

[1.08, 0.25, 0.62]. The camera coordinate system is oriented that way, that the line of sight of the camera is along<br />

the positive Z-axis. The orientation of the camera coordinate system is given by three rotational angles. In the<br />

program example the camera coordinate system is first rotated by 100 degrees around the Z-axis. Subsequently<br />

it is rotated by -120 degree around the new (!!!) X-axis. Note that the parameter with the rotation angle in<br />

T hom mat3d rotate is negated. This is because the description of a point transfomation and the description<br />

of a coordinate system transformation differs in the sign of the rotational angles. See also explanation and example<br />

at T create pose.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 705<br />

Parameter<br />

º HomMat3D (input control) ...........................................affine3d-array Htuple . double<br />

Homogeneous transformation matrix.<br />

Parameter Number : 12<br />

º Pose (output control) ..........................................pose-array Htuple . double * / long *<br />

External camera parameters.<br />

Parameter Number : 7<br />

Example<br />

HTuple CamParam,StartPose,FinalPose,Errors,Dummy;<br />

HTuple HomMat3DIdent,HomMat3DWorldStart;<br />

HTuple HomMat3DTransX,HomMat3DTransY,HomMat3DTransZ;<br />

HTuple HomMat3DRotX,HomMat3DRotY,HomMat3DRotZ;<br />

HTuple WorldPointsX,WorldPointsY,WorldPointsZ,PixelsRow,PixelsColumn;<br />

// read 3D world points [WorldPointsX,WorldPointsY,WorldPointsZ]<br />

// extract correspondent 2D image points [PixelsRow,PixelsColumn]<br />

// read internal camera parameters:<br />

::read_cam_par("campar.dat",&CamParam);<br />

// get rough camera pose from relative camera pose:<br />

::hom_mat3d_identity(&HomMat3DIdent);<br />

::hom_mat3d_translate(HomMat3DIdent,-1.08,-0.25,-0.62,&HomMat3DTrans);<br />

::hom_mat3d_rotate(HomMat3DTrans,-100.0*3.14159/180.0,"z",0,0,0,<br />

&HomMat3DRotZ);<br />

::hom_mat3d_rotate(HomMat3DRotZ,+120.0*3.14159/180.0,"x",0,0,0,<br />

&HomMat3DWorldStart);<br />

// convert transformation matrix to pose (rotation and translation)<br />

::hom_mat3d_to_pose(HomMat3DWorldStart,&StartPose);<br />

// calibration of external camera params:<br />

::camera_calibration(WorldPointsX,WorldPointsY,WorldPointsZ,<br />

PixelsRow,PixelsColumn,CamParam,StartPose,6,<br />

&Dummy,&FinalPose,&Errors);<br />

Result<br />

T hom mat3d to pose returns H MSG TRUE if all parameter values are correct. If necessary, an exception<br />

handling is raised<br />

Parallelization Information<br />

T hom mat3d to pose is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T hom mat3d rotate, T hom mat3d translate, T hom mat3d invert<br />

Possible Successor Functions<br />

T camera calibration, T write pose, T disp caltab, T sim caltab<br />

See Also<br />

T create pose, T camera calibration, T disp caltab, T sim caltab, T write pose,<br />

T read pose, T pose to hom mat3d, T project 3d point, T get line of sight,<br />

T hom mat3d rotate, T hom mat3d translate, T hom mat3d invert,<br />

T affine trans point 3d<br />

Module<br />

Camera calibration<br />

T image points to world plane ( Htuple CamParam, Htuple CamPose,<br />

Htuple Rows, Htuple Cols, Htuple Scale, Htuple *X, Htuple *Y )<br />

Transform image points to a world plane represented by external camera parameters.<br />

The operator T image points to world plane transforms image points which are given in Rows and Cols<br />

into a plane in the world coordinate system. The plane is either equal to the plane of the calibration plate or parallel<br />

<strong>HALCON</strong> 6.0


706 CHAPTER 12. TOOLS<br />

to it if the operator T set origin pose has been applied previously to correct the thickness of the calibration<br />

plate. In the first step the line of sight between the projection center and the image point is computed in the camera<br />

coordinate system, taking into account the radial distortions using the internal camera parameters CamParam. The<br />

line of sight is then transformed into the world coordinate system using the external camera parameters CamPose.<br />

By intersecting the plane (Z=0) with the line of sight the pseudo 3d coordinates X and Y are obtained. It is possible<br />

to scale the coordinates with the parameter Scale. This is particularly useful when displaying the coordinates<br />

in an image. The parameter Scale must be specified in [ÙÒØÔÜÐ]. The original unit is determined by the<br />

coordinates of the calibration targets. In many cases this unit is introduced into the calibration as ’meters’, i.e. one<br />

meter in the world coordinate system corresponds to one pixel in the image. In this case, it is possible to set the<br />

pixel size directly by selecting ’m’, ’cm’, ’mm’ or ’m’ for the parameter Scale.<br />

Parameter<br />

º CamParam (input control) .....................................number-array Htuple . double / long<br />

Internal camera parameters.<br />

Parameter Number : 8<br />

º CamPose (input control) .........................................pose-array Htuple . double / long<br />

External camera parameters.<br />

Parameter Number : 7<br />

º Rows (input control) ......................................coordinates.y-array Htuple . double / long<br />

line indices of the points to be transformed<br />

Default Value : 100.0<br />

º Cols (input control) ......................................coordinates.x-array Htuple . double / long<br />

column indices of the points to be transformed<br />

Default Value : 100.0<br />

º Scale (input control) ...................................number Htuple . const char * / long / double<br />

Scale or dimension<br />

Default Value : ’m’<br />

Value Suggestions : Scale ¾’m’, ’cm’, ’mm’, ’microns’, ’m’, 1.0, 0.01, 0.001, ’1e-6’, 0.0254, 0.3048,<br />

0.9144<br />

º X (output control) .............................................coordinates.x-array Htuple . double *<br />

x-coordinate in the world coordinate system.<br />

º Y (output control) .............................................coordinates.y-array Htuple . double *<br />

y-coordinate in the world coordinate system.<br />

Result<br />

T image points to world plane returns H MSG TRUE if all parameter values are correct. If necessary,<br />

an exception handling is raised.<br />

Parallelization Information<br />

T image points to world plane is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create pose, T hom mat3d to pose, T camera calibration, T hand eye calibration,<br />

T set origin pose<br />

See Also<br />

T contour to world plane xld<br />

Module<br />

Camera calibration<br />

T pose to hom mat3d ( Htuple Pose, Htuple *HomMat3D )<br />

Convert 3d pose parameters into homogeneous transformation matrix.<br />

T pose to hom mat3d is used to convert 3D pose parameters, like external camera parameter (camera pose<br />

Pose) into the equivalent homogeneous 4x3 transformation matrix HomMat3D.<br />

This transformation matrix consists of a 3x3 rotation matrix and a translational vector. The values are given as a<br />

tupel HomMat3D in the following order: The first four values describe the first row of the rotation matrix and x-<br />

value of the translation vector. The next four values describe the second row of the rotation matrix and the y-value<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 707<br />

of the translation vector. These are followed by the values of the third row of the rotation matrix and the z-value of<br />

the translation vector.<br />

The input tupel Pose describes 3D pose parameters which describe a 3D transform, for example the external<br />

camera parameter. These are given by the 3D translational vector (in meters), the three rotational angles and the<br />

code of the representation type of the 3D transform: E.g., the value ’0’ is the code of the representation type 1 and<br />

says, that the transform of a point is described, hereby the 3D rotation is performed before the 3D translation, that<br />

the three rotations are specified as angles (in degrees), and that the rotation order is ­-¬-«, i.e., the first rotation<br />

is around the Z-axis, the second one around the new Y-axis, and the third one around the new X-axis, which<br />

is generated after the second rotation. T pose to hom mat3d operates with all types of 3D transform. The<br />

sense of the other representation types are explained at T create pose. The 3D transform with type 1 directly<br />

corrensponds to the transformation by homogenous matixes. This can be explained by the following holds:<br />

È Ü Ý Þ℄ Ì Ê´½µ ¡ È Ï · Ì ´½µ<br />

À¡È Ï<br />

Parameter<br />

º Pose (input control) ..............................................pose-array Htuple . double / long<br />

External camera parameters.<br />

Parameter Number : 7<br />

º HomMat3D (output control) ........................................affine3d-array Htuple . double *<br />

Homogeneous transformation matrix.<br />

Parameter Number : 12<br />

Example<br />

HTuple CamParam,StartCamPose,FinalCamPose,Errors,Dummy;<br />

HTuple HomMat3DWorldCam;<br />

HTuple WorldPointsX,WorldPointsY,WorldPointsZ,PixelsRow,PixelsColumn;<br />

// read 3D world points [WorldPointsX,WorldPointsY,WorldPointsZ]<br />

// extract correspondent 2D image points [PixelsRow,PixelsColumn]<br />

// read internal camera parameters:<br />

::read_cam_par("campar.dat",&CamParam);<br />

// read initial camera pose<br />

::read_pose(::"campose.initial":StartCamPose);<br />

// calibration of external camera params:<br />

::camera_calibration(WorldPointsX,WorldPointsY,WorldPointsZ,<br />

PixelsRow,PixelsColumn,CamParam,StartCamPose,6,<br />

&Dummy,&FinalCamPose,&Errors);<br />

// transform FinalCamPose to 4x3 transformation matrix<br />

::pose_to_hom_mat3d(FinalCamPose,&HomMat3DWorldCam);<br />

Result<br />

T pose to hom mat3d returns H MSG TRUE if all parameter values are correct. If necessary, an exception<br />

handling is raised<br />

Parallelization Information<br />

T pose to hom mat3d is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T camera calibration, T read pose<br />

Possible Successor Functions<br />

T affine trans point 3d, T hom mat3d invert, T hom mat3d translate,<br />

T hom mat3d rotate, T hom mat3d to pose<br />

See Also<br />

T create pose, T camera calibration, T write pose, T read pose, T hom mat3d to pose,<br />

T project 3d point, T get line of sight, T hom mat3d rotate, T hom mat3d translate,<br />

T hom mat3d invert, T affine trans point 3d<br />

Camera calibration<br />

Module<br />

<strong>HALCON</strong> 6.0


708 CHAPTER 12. TOOLS<br />

T project 3d point ( Htuple X, Htuple Y, Htuple Z, Htuple CamParam,<br />

Htuple *Row, Htuple *Column )<br />

Project 3D points into (sub-)pixels.<br />

T project 3d point is used to project one or more 3D points (with coordinates X, Y, andZ) into the image<br />

plane (in pixels). The coordinates X, Y, andZ are given in the camera coordinate system, i.e., they describe the<br />

position of the point relative to the camera.<br />

The internal camera parameters CamParam (Focus, Sx, Sy, Cx, Cy, Kappa (), ImageWidth and ImageHeight)<br />

describe the projection characteristics of the camera. The underlying camera model is a pinhole camera with<br />

radial distortions if the focal length passed in CamParam is greater than 0. It describes the transform of a 3D<br />

point È into a (sub-)pixel [r,c] of the video image by the following equations:<br />

Ù <br />

½·<br />

È Ü Ý Þ℄ Ì<br />

Ù Focus ¡ Ü Þ<br />

and Ú Focus ¡ Ý Þ<br />

¾Ù<br />

Ô½ ´Ù ¾·Ú and Ú Ô<br />

¾Ú<br />

¾ µ<br />

½·<br />

Ù Ë Ü · Ü and Ö Ú<br />

Ë Ý · Ý<br />

½ ´Ù ¾·Ú ¾ µ<br />

If the focal length is passed as 0 in CamParam, the camera model of a telecentric camera with radial distortions<br />

is used, i.e., it is assumed that the optics of the lens of the camera performs a parallel projection. In this case, the<br />

corresponding equations are:<br />

Ù <br />

È Ü Ý Þ℄ Ì Ê¡È Ï · Ì<br />

Ù Ü and Ú Ý<br />

¾Ù<br />

½·<br />

Ô½ ´Ù ¾·Ú bzw. Ú ¾Ú<br />

¾ µ ½· ½ ´Ù ¾·Ú¾ µ<br />

Ô<br />

Ù Ë Ü · Ü bzw. Ö Ú<br />

Ë Ý · Ý<br />

These equations consist of a coordinate transform from the world coordinate system into the camera coordinate<br />

system, a perspective or parallel projection into the image plane, a radial distortion of the projected point, and<br />

finally a sampling and an image center displacement.<br />

Parameter<br />

º X (input control) .........................................................real-array Htuple . double<br />

X-coordinates of the 3D points to be projected.<br />

º Y (input control) .........................................................real-array Htuple . double<br />

Y-coordinates of the 3D points to be projected.<br />

º Z (input control) .........................................................real-array Htuple . double<br />

Z-coordinates of the 3D points to be projected.<br />

º CamParam (input control) .....................................number-array Htuple . double / long<br />

Internal camera parameters.<br />

Parameter Number : 8<br />

º Row (output control) ...................................................real-array Htuple . double *<br />

Row-coordinates of pixels.<br />

Default Value : ’ProjectedRow’<br />

º Column (output control) ...............................................real-array Htuple . double *<br />

Column-coordinates of pixels.<br />

Default Value : ’ProjectedCol’<br />

Example<br />

HTuple CamPose,HomMat3D,X1,Y1,Z1,X2,Y2,Z2,CamParam,Row,Column;<br />

// read camera pose<br />

::read_pose("campose.dat",&CamPose);<br />

// transform camera pose to transformation matrix<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 709<br />

::pose_to_hom_mat3d(CamPose,&HomMat3D);<br />

// transform 3D points from source into destination coordinate system<br />

X1[1] = 3.2;<br />

X1[0] = 3.0;<br />

Y1[1] = 4.5;<br />

Y1[0] = 4.5;<br />

Z1[1] = 6.2;<br />

Z1[0] = 5.8;<br />

::affine_trans_point_3d(X1,Y1,Z1,HomMat3D,&X2,&Y2,&Z2);<br />

// read internal camera parameters<br />

::read_cam_par("campar.dat",&CamParam);<br />

// project 3D points into image<br />

::project_3d_point(X2,Y2,Z2,CamParam,&Row,&Column);<br />

Result<br />

T project 3d point returns H MSG TRUE if all parameter values are correct. If necessary, an exception<br />

handling is raised.<br />

Parallelization Information<br />

T project 3d point is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T read cam par, T affine trans point 3d<br />

Possible Successor Functions<br />

gen region points, gen region polygon, disp polygon<br />

See Also<br />

T camera calibration, T disp caltab, T read cam par, T get line of sight,<br />

T affine trans point 3d<br />

Module<br />

Camera calibration<br />

T read cam par ( Htuple CamParFile, Htuple *CamParam )<br />

Read the internal camera parameters from text file.<br />

T read cam par is used to read the internal camera parameters CamParam from a text file with name<br />

CamParFile.<br />

The format of the text file is a (Halcon-independent) generic parameter description. Thus, arbitrary sets of parameters<br />

can be grouped together in a hierarchical way. The description of a single parameter within a parameter group<br />

consists of the following 3 lines:<br />

Name : Shortname : Actual value ;<br />

Type : Lower bound (optional) : Upper bound (optional) ;<br />

Description (optional) ;<br />

The Halcon operator T write cam par expects in the file CamParFile the parameter group Camera:<br />

Parameter. This parameter group consists of the 8 parameters Focus, Sx, Sy, Cx, Cy, Kappa (), ImageWidth<br />

and ImageHeight. Comments are marked by a ’#’ at the beginning of a line. A suitable file can look like the<br />

following:<br />

# INTERNAL CAMERA PARAMETERS<br />

ParGroup: Camera: Parameter;<br />

"Internal CCD-camera parameters";<br />

Focus:foc: 0.00806039;<br />

DOUBLE:0.0:;<br />

"Focal length of the lens [meter]";<br />

<strong>HALCON</strong> 6.0


710 CHAPTER 12. TOOLS<br />

Sx:sx: 1.0629e-05;<br />

DOUBLE:0.0:;<br />

"Width of a cell on the CCD-chip [meter]";<br />

Sy:sy: 1.1e-05;<br />

DOUBLE:0.0:;<br />

"Height of a cell on the CCD-chip [meter]";<br />

Cx:cx: 378.236;<br />

DOUBLE:0.0:;<br />

"X-coordinate of the image center [pixel]";<br />

Cy:cy: 297.587;<br />

DOUBLE:0.0:;<br />

"Y-coordinate of the image center [pixel]";<br />

Kappa:kappa: -2253.5;<br />

DOUBLE::;<br />

"Radial distortion coefficient [1/(meter*meter)]";<br />

ImageWidth:imgw: 768;<br />

INT:0:2048;<br />

"Width of the used calibration images [pixel]";<br />

ImageHeight:imgh: 576;<br />

INT:0:2048;<br />

"Height of the used calibration images [pixel]";<br />

The underlying camera model is a pinhole or telecentric camera with radial distortions. A detailed description<br />

of these camera models can be found with description of T write cam par.<br />

Parameter<br />

º CamParFile (input control) ...........................................string Htuple . const char *<br />

File name of internal camera parameters.<br />

Default Value : ’campar.dat’<br />

Value List : CamParFile ¾’campar.dat’, ’campar.initial’, ’campar.final’<br />

º CamParam (output control) .................................number-array Htuple . double * / long *<br />

Internal camera parameters.<br />

Parameter Number : 8<br />

Example<br />

HTuple CamParam;<br />

// get internal camera parameters:<br />

::read_cam_par("campar.dat",&CamParam);<br />

Result<br />

T read cam par returns H MSG TRUE if all parameter values are correct and the file has been read successfully.<br />

If necessary an exception handling is raised.<br />

Parallelization Information<br />

T read cam par is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

T find marks and pose, T sim caltab, create caltab, T disp caltab,<br />

T camera calibration<br />

See Also<br />

find caltab, T find marks and pose, T camera calibration, T disp caltab,<br />

T sim caltab, T write cam par, T write pose, T read pose, T project 3d point,<br />

T get line of sight<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 711<br />

Camera calibration<br />

Module<br />

T read pose ( Htuple PoseFile, Htuple *Pose )<br />

Read 3D pose data from text file.<br />

T read pose is used to read the 3D pose Pose from a text file with the name PoseFile.<br />

The output tupel Pose describes 3D pose parameters which describe a 3D transform, for example the external<br />

camera parameters. These are given by the 3D translational vector (in meters), the three rotation angles and the<br />

code of the representation type of the 3D transform: E.g., the value ’0’ is the code of the representation type 1 and<br />

says, that the transform of a point is described, hereby the 3D rotation is performed before the 3D translation, that<br />

the three rotations are specified as angles (in degrees), and that the rotation order is ­-¬-«, i.e., the first rotation<br />

is around the Z-axis, the second one around the new Y-axis, and the third one around the new X-axis, which is<br />

generated after the second rotation. T pose to hom mat3d operates with all types of 3D transforms. The sense<br />

of the other representation types is explained at T create pose.<br />

A suitable file can be generated by the operator T write pose and looks like the following:<br />

# 3D POSE PARAMETERS: rotation and translation<br />

# Used representation type:<br />

f 0<br />

# Rotation angles [deg] or Rodriguez-vector:<br />

r -17.8134 1.83816 0.288092<br />

# Translational vector (x y z [m]):<br />

t 0.280164 0.150644 1.7554<br />

Parameter<br />

º PoseFile (input control) ...........................................filename Htuple . const char *<br />

File name of the external camera parameters.<br />

Default Value : ’campose.dat’<br />

Value List : PoseFile ¾’campose.dat’, ’campose.initial’, ’campose.final’<br />

º Pose (output control) ..........................................pose-array Htuple . double * / long *<br />

External camera parameters.<br />

Parameter Number : 7<br />

Example<br />

HTuple CamPose;<br />

// get pose (external camera parameters):<br />

::read_pose("campose.dat",&CamPose);<br />

Result<br />

T read pose returns H MSG TRUE if all parameter values are correct and the file has been read successfully.<br />

If necessary an exception handling is raised.<br />

Parallelization Information<br />

T read pose is reentrant and processed without parallelization.<br />

T read cam par<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

T pose to hom mat3d, T camera calibration, T disp caltab, T sim caltab<br />

See Also<br />

T create pose, T find marks and pose, T camera calibration, T disp caltab,<br />

T sim caltab, T write pose, T pose to hom mat3d, T hom mat3d to pose<br />

<strong>HALCON</strong> 6.0


712 CHAPTER 12. TOOLS<br />

Camera calibration<br />

Module<br />

T set origin pose ( Htuple PoseIn, Htuple DX, Htuple DY, Htuple DZ,<br />

Htuple *PoseNewOrigin )<br />

Translate the origin of the external camera parameters.<br />

T set origin pose translates the origin of the external camera parameters (pose) by a vector, determined<br />

by DX, DY and DZ. This can be used, for example, to correct the obtained parameters from camera calibration<br />

(PoseIn) with respect to the thickness of the calibration plate. To achieve this, the translation vector<br />

must have the form (0,0,-), where is the thickness of the calibration plate. The resulting new parameters<br />

PoseNewOrigin correspond to a calibration with a calibration plate of infinitely small thickness. Therefore, it is<br />

possible to measure points in the world coordinate system (e.g., by calling T image points to world plane<br />

or T contour to world plane xld) directly in the requested measurement plane instead of the plane of the<br />

calibration plate). In this context it is now also possible to avoid negative coordinates in the world coordinate<br />

system by choosing suitable values for DX and DY.<br />

Parameter<br />

º PoseIn (input control) ...........................................pose-array Htuple . double / long<br />

original 3D transformation.<br />

Parameter Number : 7<br />

º DX (input control) .............................................................real Htuple . double<br />

translation of the origin in x-direction.<br />

Default Value : 0<br />

º DY (input control) .............................................................real Htuple . double<br />

translation of the origin in y-direction.<br />

Default Value : 0<br />

º DZ (input control) .............................................................real Htuple . double<br />

translation of the origin in z-direction.<br />

Default Value : 0<br />

º PoseNewOrigin (output control) .............................pose-array Htuple . double * / long *<br />

new 3D description after applying the translation.<br />

Parameter Number : 7<br />

Result<br />

T set origin pose returns H MSG TRUE if all parameter values are correct. If necessary, an exception<br />

handling is raised.<br />

Parallelization Information<br />

T set origin pose is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create pose, T hom mat3d to pose, T camera calibration, T hand eye calibration<br />

Possible Successor Functions<br />

T write pose, T pose to hom mat3d, T image points to world plane,<br />

T contour to world plane xld<br />

Module<br />

Camera calibration<br />

T sim caltab ( Hobject *SimImage, Htuple CalTabDescrFile,<br />

Htuple CamParam, Htuple CamPose, Htuple GrayBackground, Htuple GrayCaltab,<br />

Htuple GrayMarks, Htuple ScaleFac )<br />

Simulate a video image with calibration table.<br />

T sim caltab is used to generate a simulated calibration image. The calibration table description is read from<br />

the file CalTabDescrFile and will be projected into the image plane using the given camera parameters (internal<br />

camera parameters CamParam and external camera parameters CamPose), see also T project 3d point.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 713<br />

In the simulated image only the calibration table is shown. The image background is set to the gray value<br />

GrayBackground, the calibration table background is set to GrayCaltab, and the calibration marks are<br />

set to the gray value GrayMarks. The parameter ScaleFac influences the number of supporting points to<br />

approximate the elliptic contours of the calibration marks, see also T disp caltab. Increasing the number of<br />

supporting points causes a more accurate determination of the mark boundary, but increases the computation time,<br />

too. For each pixel of the simulated video image, which touches a subpixel-boundary of this kind, the gray value<br />

is set linearly between GrayMarks and GrayCaltab dependent on the proportion Inside/Outside.<br />

By applying the operator T sim caltab you can generate synthetic calibration images (with known camera<br />

parameters!) to test the quality of the calibration algorithm (see T camera calibration).<br />

Parameter<br />

º SimImage (output object) .................................................image Hobject * : byte<br />

Simulated calibration image.<br />

º CalTabDescrFile (input control) .....................................string Htuple . const char *<br />

File name of the calibration table description.<br />

Default Value : ’caltab.descr’<br />

º CamParam (input control) .....................................number-array Htuple . double / long<br />

Internal camera parameters.<br />

Parameter Number : 8<br />

º CamPose (input control) .........................................pose-array Htuple . double / long<br />

External camera parameters.<br />

Parameter Number : 7<br />

º GrayBackground (input control) ............................................integer Htuple . long<br />

Gray value of image background.<br />

Default Value : 128<br />

Value Suggestions : GrayBackground ¾0, 32, 64, 96, 128, 160<br />

Restriction : ´0 GrayBackgroundµ 255<br />

º GrayCaltab (input control) .................................................integer Htuple . long<br />

Gray value of calibration table.<br />

Default Value : 224<br />

Value Suggestions : GrayCaltab ¾144, 160, 176, 192, 208, 224, 240<br />

Restriction : ´0 GrayCaltabµ 255<br />

º GrayMarks (input control) ...................................................integer Htuple . long<br />

Gray value of calibration marks.<br />

Default Value : 80<br />

Value Suggestions : GrayMarks ¾16, 32, 48, 64, 80, 96, 112<br />

Restriction : ´0 GrayMarksµ 255<br />

º ScaleFac (input control) .....................................................real Htuple . double<br />

Scaling factor to reduce oversampling.<br />

Default Value : 1.0<br />

Value Suggestions : ScaleFac ¾1.0, 0.5, 0.25, 0.125<br />

Recommended Value Step : 0.05<br />

Restriction : 1.0 ScaleFac<br />

Example<br />

HTuple StartCamPar,NX,NY,NZ;<br />

HTuple RCoord1,CCoord1,StartPose1;<br />

HTuple StartPose,RCoords,CCoords;<br />

HTuple CamParam,FinalPose,Errors;<br />

// read calibration image<br />

HImage Image1("calib-01.tiff");<br />

// find calibration pattern<br />

HRegion Caltab1 = Image1.FindCaltab("caltab.descr",3,112,5);<br />

// find calibration marks and initial pose<br />

StartCamPar[7] = 576;<br />

// ImageHeight<br />

StartCamPar[6] = 768;<br />

// ImageWidth<br />

StartCamPar[5] = 288;<br />

// Cy<br />

<strong>HALCON</strong> 6.0


714 CHAPTER 12. TOOLS<br />

StartCamPar[4] = 384;<br />

// Cx<br />

StartCamPar[3] = 0.000011; // Sy<br />

StartCamPar[2] = 0.000011; // Sx<br />

StartCamPar[1] = 0.0;<br />

// Kappa<br />

StartCamPar[0] = 0.008; // Focus<br />

RCoord1 = Image1.FindMarksAndPose(Caltab1,"caltab.descr",StartCamPar,<br />

128,10,&CCoord1,&StartPose);<br />

// read 3D positions of calibration marks<br />

::caltab_points("caltab.descr",&NX,&NY,&NZ);<br />

// camera calibration<br />

::camera_calibration(NX,NY,NZ,RCoord1,CCoord1,StartCamPar,StartPose,<br />

11,&CamParam,&FinalPose,&Errors);<br />

HImage Image1Sim = HImage::SimCaltab("caltab.descr",CamParam,FinalPose,<br />

128,224,80,1.0);<br />

Result<br />

T sim caltab returns H MSG TRUE if all parameter values are correct. If necessary, an exception handling is<br />

raised.<br />

Parallelization Information<br />

T sim caltab is processed under mutual exclusion against itself and without parallelization.<br />

Possible Predecessor Functions<br />

T camera calibration, T find marks and pose, T read pose, T read cam par,<br />

T hom mat3d to pose<br />

Possible Successor Functions<br />

find caltab<br />

See Also<br />

find caltab, T find marks and pose, T camera calibration, T disp caltab,<br />

T create pose, T hom mat3d to pose, T project 3d point, create caltab<br />

Camera calibration<br />

Module<br />

T write cam par ( Htuple CamParam, Htuple CamParFile )<br />

Write the internal camera parameters to text file.<br />

T write cam par is used to write the internal camera parameters CamParam to a text file with name<br />

CamParFile.<br />

The format of the text file is a (Halcon-independent) generic parameter description. Thus, arbitrary sets of parameters<br />

can be grouped together in a hierarchical way. The description of a single parameter within a parameter group<br />

consists of the following 3 lines:<br />

Name : Shortname : Actual value ;<br />

Type : Lower bound (optional) : Upper bound (optional) ;<br />

Description (optional) ;<br />

The following parameter types are supported in this generic format: BOOL, XBOOL (exclusive BOOL), INT,<br />

FLOAT, DOUBLE, STRING and FILE SELECTOR. Comments are marked by a ’#’ at the beginning of a line.<br />

The operator T write cam par writes the parameter group Camera:Parameter into the text file CamParFile.<br />

This parameter group consists of the 8 parameters Focus, Sx, Sy, Cx, Cy, Kappa (), ImageWidth and ImageHeight.<br />

The underlying camera model is a pinhole camera with radial distortions if the focal length passed in<br />

CamParam is greater than 0. It describes the transform of a 3D point È into a (sub-)pixel [r,c] of the video<br />

image by the following equations:<br />

È Ü Ý Þ℄ Ì<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 715<br />

Ù <br />

½·<br />

Ù Focus ¡ Ü Þ<br />

and Ú Focus ¡ Ý Þ<br />

¾Ù<br />

Ô½ ´Ù ¾·Ú and Ú Ô<br />

¾Ú<br />

¾ µ<br />

½·<br />

Ù Ë Ü · Ü and Ö Ú<br />

Ë Ý · Ý<br />

½ ´Ù ¾·Ú ¾ µ<br />

If the focal length is passed as 0 in CamParam, the camera model of a telecentric camera with radial distortions<br />

is used, i.e., it is assumed that the optics of the lens of the camera performs a parallel projection. In this case, the<br />

corresponding equations are:<br />

Ù <br />

È Ü Ý Þ℄ Ì Ê¡È Ï · Ì<br />

Ù Ü and Ú Ý<br />

¾Ù<br />

½·<br />

Ô½ ´Ù ¾·Ú bzw. Ú ¾Ú<br />

¾ µ ½· ½ ´Ù ¾·Ú¾ µ<br />

Ô<br />

Ù Ë Ü · Ü bzw. Ö Ú<br />

Ë Ý · Ý<br />

These equations consist of a coordinate transform from the world coordinate system into the camera coordinate<br />

system, a perspective or parallel projection into the image plane, a radial distortion of the projected point, and<br />

finally a sampling and an image center displacement.<br />

The parameter Ê and Ì describe the 3D pose of the camera coordinate system in the world coordinate system.<br />

They are called external camera parameters, see also T hom mat3d to pose and T create pose.<br />

The internal camera parameters consist of the focal length (Focus), the radial distortion coefficient (), the scale<br />

factor Ë Ü and Ë Ý (horizontal and vertical distance between cells on the CCD chip), the image center Ü Ý ℄ Ì ,<br />

and the used image width and height. The internal camera parameters are - in contrast to the external parameters -<br />

independent of the actual pose of the CCD camera. They describe the projection process of the used combination<br />

of camera, lens, and frame grabber. The determination of these parameters is done by the camera calibration, see<br />

T camera calibration.<br />

Parameter<br />

º CamParam (input control) .....................................number-array Htuple . double / long<br />

Internal camera parameters.<br />

Parameter Number : 8<br />

º CamParFile (input control) ...........................................string Htuple . const char *<br />

File name of internal camera parameters.<br />

Default Value : ’campar.dat’<br />

Value List : CamParFile ¾’campar.dat’, ’campar.initial’, ’campar.final’<br />

Example<br />

HTuple StartCamPar,NX,NY,NZ;<br />

HTuple RCoord1,CCoord1,StartPose1;<br />

HTuple RCoord2,CCoord2,StartPose2;<br />

HTuple RCoord3,CCoord3,StartPose3;<br />

HTuple StartPoses,RCoords,CCoords;<br />

HTuple CamParam,NFinalPose,Errors;<br />

// read calibration images<br />

HImage Image1("calib-01.tiff");<br />

HImage Image2("calib-02.tiff");<br />

HImage Image3("calib-03.tiff");<br />

// find calibration pattern<br />

HRegion Caltab1 = Image1.FindCaltab("caltab.descr",3,112,5);<br />

HRegion Caltab2 = Image2.FindCaltab("caltab.descr",3,112,5);<br />

HRegion Caltab3 = Image3.FindCaltab("caltab.descr",3,112,5);<br />

// find calibration marks and start poses<br />

StartCamPar[7] = 576;<br />

// ImageHeight<br />

StartCamPar[6] = 768;<br />

// ImageWidth<br />

StartCamPar[5] = 288;<br />

// Cy<br />

StartCamPar[4] = 384;<br />

// Cx<br />

<strong>HALCON</strong> 6.0


716 CHAPTER 12. TOOLS<br />

StartCamPar[3] = 0.000011; // Sy<br />

StartCamPar[2] = 0.000011; // Sx<br />

StartCamPar[1] = 0.0;<br />

// Kappa<br />

StartCamPar[0] = 0.008; // Focus<br />

RCoord1 = Image1.FindMarksAndPose(Caltab1,"caltab.descr",StartCamPar,<br />

128,10,&CCoord1,&StartPose1);<br />

RCoord2 = Image2.FindMarksAndPose(Caltab2,"caltab.descr",StartCamPar,<br />

128,10,&CCoord2,&StartPose2);<br />

RCoord3 = Image3.FindMarksAndPose(Caltab3,"caltab.descr",StartCamPar,<br />

128,10,&CCoord3,&StartPose3);<br />

// read 3D positions of calibration marks<br />

::caltab_points("caltab.descr",&NX,&NY,&NZ);<br />

// camera calibration<br />

StartPoses = (StartPose1.Append(StartPose2)).Append(StartPose3);<br />

RCoords = (RCoord1.Append(RCoord2)).Append(RCoord3);<br />

CCoords = (CCoord1.Append(CCoord2)).Append(CCoord3);<br />

::camera_calibration(NX,NY,NZ,RCoords,CCoords,StartCamPar,StartPoses,<br />

11,&CamParam,&NFinalPose,&Errors);<br />

// write internal camera parameters to file<br />

::write_cam_par(CamParam,"campar.dat");<br />

Result<br />

T write cam par returns H MSG TRUE if all parameter values are correct and the file has been written successfully.<br />

If necessary an exception handling is raised.<br />

Parallelization Information<br />

T write cam par is local and processed completely exclusively without parallelization.<br />

T camera calibration<br />

Possible Predecessor Functions<br />

See Also<br />

find caltab, T find marks and pose, T camera calibration, T disp caltab,<br />

T sim caltab, T read cam par, T write pose, T read pose, T project 3d point,<br />

T get line of sight<br />

Module<br />

Camera calibration<br />

T write pose ( Htuple Pose, Htuple PoseFile )<br />

Write 3D pose data to text file.<br />

T write pose is used to write 3D pose data Pose into a text file with the name PoseFile.<br />

The input tupel Pose describes 3D pose parameters which describe a 3D transform, for example the external<br />

camera parameters. These are given by the 3D translational vector (in meters), the three rotation angles and the<br />

code of the representation type of the 3D transform: E.g., the value ’0’ is the code of the representation type 1 and<br />

says, that the transform of a point is described, hereby the 3D rotation is performed before the 3D translation, that<br />

the three rotations are specified as angles (in degrees), and that the rotation order is ­-¬-«, i.e., the first rotation<br />

is around the Z-axis, the second one around the new Y-axis, and the third one around the new X-axis, which is<br />

generated after the second rotation. T pose to hom mat3d operates with all types of 3D transform. The sense<br />

of the other representation types are explained at T create pose.<br />

A file generated by T write pose looks like the following:<br />

# 3D POSE PARAMETERS: rotation and translation<br />

# Used representation type:<br />

f 0<br />

# Rotation angles [deg] or Rodriguez-vector:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.4. CALIBRATION 717<br />

r -17.8134 1.83816 0.288092<br />

# Translational vector (x y z [m]):<br />

t 0.280164 0.150644 1.7554<br />

Parameter<br />

º Pose (input control) ..............................................pose-array Htuple . double / long<br />

External camera parameters.<br />

Parameter Number : 7<br />

º PoseFile (input control) ...........................................filename Htuple . const char *<br />

File name of the external camera parameters.<br />

Default Value : ’campose.dat’<br />

Value List : PoseFile ¾’campose.dat’, ’campose.initial’, ’campose.final’<br />

Example<br />

HTuple StartCamPar,NX,NY,NZ;<br />

HTuple RCoord1,CCoord1,StartPose1;<br />

HTuple RCoord2,CCoord2,StartPose2;<br />

HTuple RCoord3,CCoord3,StartPose3;<br />

HTuple StartPoses,RCoords,CCoords;<br />

HTuple CamParam,NFinalPose,FinalPose,Errors;<br />

// read calibration images<br />

HImage Image1("calib-01.tiff");<br />

HImage Image2("calib-02.tiff");<br />

HImage Image3("calib-03.tiff");<br />

// find calibration pattern<br />

HRegion Caltab1 = Image1.FindCaltab("caltab.descr",3,112,5);<br />

HRegion Caltab2 = Image2.FindCaltab("caltab.descr",3,112,5);<br />

HRegion Caltab3 = Image3.FindCaltab("caltab.descr",3,112,5);<br />

// find calibration marks and start poses<br />

StartCamPar[7] = 576;<br />

// ImageHeight<br />

StartCamPar[6] = 768;<br />

// ImageWidth<br />

StartCamPar[5] = 288;<br />

// Cy<br />

StartCamPar[4] = 384;<br />

// Cx<br />

StartCamPar[3] = 0.000011; // Sy<br />

StartCamPar[2] = 0.000011; // Sx<br />

StartCamPar[1] = 0.0;<br />

// Kappa<br />

StartCamPar[0] = 0.008; // Focus<br />

RCoord1 = Image1.FindMarksAndPose(Caltab1,"caltab.descr",StartCamPar,<br />

128,10,&CCoord1,&StartPose1);<br />

RCoord2 = Image2.FindMarksAndPose(Caltab2,"caltab.descr",StartCamPar,<br />

128,10,&CCoord2,&StartPose2);<br />

RCoord3 = Image3.FindMarksAndPose(Caltab3,"caltab.descr",StartCamPar,<br />

128,10,&CCoord3,&StartPose3);<br />

// read 3D positions of calibration marks<br />

::caltab_points("caltab.descr",&NX,&NY,&NZ);<br />

// camera calibration<br />

StartPoses = (StartPose1.Append(StartPose2)).Append(StartPose3);<br />

RCoords = (RCoord1.Append(RCoord2)).Append(RCoord3);<br />

CCoords = (CCoord1.Append(CCoord2)).Append(CCoord3);<br />

::camera_calibration(NX,NY,NZ,RCoords,CCoords,StartCamPar,StartPoses,<br />

11,&CamParam,&NFinalPose,&Errors);<br />

/* write external camera parameters of first calibration image */<br />

FinalPose[6] = NFinalPose[6];<br />

FinalPose[5] = NFinalPose[5];<br />

FinalPose[4] = NFinalPose[4];<br />

FinalPose[3] = NFinalPose[3];<br />

FinalPose[2] = NFinalPose[2];<br />

<strong>HALCON</strong> 6.0


718 CHAPTER 12. TOOLS<br />

FinalPose[1] = NFinalPose[1];<br />

FinalPose[0] = NFinalPose[0];<br />

::write_pose(FinalPose,"campose.dat");<br />

Result<br />

T write pose returns H MSG TRUE if all parameter values are correct and the file has been written successfully.<br />

If necessary an exception handling is raised.<br />

Parallelization Information<br />

T write pose is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

T camera calibration, T hom mat3d to pose<br />

See Also<br />

T create pose, T find marks and pose, T camera calibration, T disp caltab,<br />

T sim caltab, T read pose, T pose to hom mat3d, T hom mat3d to pose<br />

Camera calibration<br />

Module<br />

12.5 Fourier-Descriptor<br />

T abs invar fourier coeff ( Htuple RealInvar, Htuple ImaginaryInvar,<br />

Htuple CoefP, Htuple CoefQ, Htuple AZInvar, Htuple *RealAbsInvar,<br />

Htuple *ImaginaryAbsInvar )<br />

Normalizing of the Fourier coefficients with respect to the displacment of the starting point.<br />

The operator T abs invar fourier coeff normalizes the Fourier coefficients with regard to the displacements<br />

of the starting point. These occur when an object is rotated. The contour tracer get region contour<br />

starts with recording the contour in the upper lefthand corner of the region and follows the contour clockwise. If<br />

the object is rotated, the starting value for the contour point chain is different which leads to a phase shift in the<br />

frequency space. The following two kinds of normalizing are available:<br />

abs amount: The phase information will be eliminated; the normalizing does not retain the structure, i.e. if the<br />

AZ-invariants are backtransformed, no similarity with the pattern can be recognized anymore.<br />

az invar1: AZ-invariants of the 1st order execute the normalizing with respect to displacing the starting point so<br />

that the structure is retained; they are however more prone to local and global disturbances, in particular to<br />

projective distortions.<br />

Parameter<br />

º RealInvar (input control) ..............................................real-array Htuple . double<br />

Real parts of the normalized Fourier coefficients.<br />

º ImaginaryInvar (input control) .......................................real-array Htuple . double<br />

Imaginary parts of the normalized Fourier coefficients.<br />

º CoefP (input control) ........................................................integer Htuple . long<br />

Normalizing coefficients p.<br />

Default Value : 1<br />

Value Suggestions : CoefP ¾1, 2<br />

Restriction : CoefP 1<br />

º CoefQ (input control) ........................................................integer Htuple . long<br />

Normalizing coefficients q.<br />

Default Value : 1<br />

Value Suggestions : CoefQ ¾1, 2<br />

Restriction : ´CoefQ 1µ ´CoefQ CoefPµ<br />

º AZInvar (input control) ...............................................string Htuple . const char *<br />

Order of the AZ-invariants.<br />

Default Value : ’abs amount’<br />

Value List : AZInvar ¾’abs amount’, ’az invar1’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.5. FOURIER-DESCRIPTOR 719<br />

º RealAbsInvar (output control) .......................................real-array Htuple . double *<br />

Real parts of the normalized Fourier coefficients.<br />

º ImaginaryAbsInvar (output control) ................................real-array Htuple . double *<br />

Imaginary parts of the normalized Fourier coefficients.<br />

Example<br />

get_region_contour(single,&row,&col);<br />

length_of_contour = length_tuple(row);<br />

move_contour_orig(row,col,&trow,&tcol);<br />

prep_contour_fourier(trow,tcol,"unsigned_area",&param_scale);<br />

fourier_1dim(trow,tcol,param_scale,50,&frow,&fcol);<br />

invar_fourier_coeff(frow,fcol,1,"affine_invar",&invrow,&invcol);<br />

abs_invar_fourier_coeff(invrow,invcol,1,2,"az_invar1",&absrow,&abscol);<br />

fourier_1dim_inv(absrow,abscol,length_of_contour,&fsynrow,&fsyncol);<br />

Parallelization Information<br />

T abs invar fourier coeff is reentrant and processed without parallelization.<br />

T invar fourier coeff<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

T fourier 1dim inv, T match fourier coeff<br />

Fourier descriptors<br />

Module<br />

T fourier 1dim ( Htuple Rows, Htuple Columns, Htuple ParContour,<br />

Htuple MaxCoef, Htuple *RealCoef, Htuple *ImaginaryCoef )<br />

Calculate the Fourier coefficients of a parameterized contour.<br />

The operator T fourier 1dim calculates the Fourier coefficients of a parameterized contour by using a<br />

valid parameter scale. This parameter scale may, for instance, be created with the help of the procedure<br />

T prep contour fourier. This function serves to calculate the Fourier coefficients of closed contours which<br />

are treated like complex-valued curves. Therefore, in order to determine the Fourier coefficients, the Fourier transform<br />

for periodical functions is used. Hereby the parameter MaxCoef determines the ×ÓÐÙØÚÐÙ ·½of<br />

the maximal number of Fourier coefficients, i.e. if Ò coefficients are indicated, the procedure will calculate coefficients<br />

ranging from Ò to Ò. The contour will be approximated without loss, if Ò ÒÙÑÖÓØÓÒØÓÙÖÔÓÒØ×,<br />

whereby Ò ½¼¼ approximates the contour so well that an error can hardly be distinguished; Ò ¾ ¼ ¼℄ however<br />

is sufficient for most applications. If the parameter MaxCoef is set to 0, all coefficients will be determined.<br />

Parameter<br />

º Rows (input control) ..................................................contour.y-array Htuple . long<br />

Row coordinates of the contour.<br />

º Columns (input control) ..............................................contour.x-array Htuple . long<br />

Colmumn coordinates of the contour.<br />

º ParContour (input control) ............................................real-array Htuple . double<br />

Parameter scale.<br />

º MaxCoef (input control) .....................................................integer Htuple . long<br />

Desired number of Fourier coefficients or all of them (0).<br />

Default Value : 50<br />

Value Suggestions : MaxCoef ¾0, 5, 10, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100, 150, 200, 400<br />

Restriction : MaxCoef 0<br />

º RealCoef (output control) ............................................real-array Htuple . double *<br />

Real parts of the Fourier coefficients.<br />

º ImaginaryCoef (output control) ......................................real-array Htuple . double *<br />

Imaginary parts of the Fourier coefficients.<br />

<strong>HALCON</strong> 6.0


720 CHAPTER 12. TOOLS<br />

Example<br />

get_region_contour(single,&row,&col);<br />

move_contour_orig(row,col,&trow,&tcol);<br />

prep_contour_fourier(trow,tcol,"unsigned_area",&param_scale);<br />

fourier_1dim(trow,tcol,param_scale,&frow,&fcol);<br />

invar_fourier_coeff(frow,fcol,1,"affine_invar",&invrow,&invcol);<br />

abs_invar_fourier_coeff(invrow,invcol,1,2,"az_invar1",&absrow,&abscol);<br />

Parallelization Information<br />

T fourier 1dim is reentrant and processed without parallelization.<br />

T prep contour fourier<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

T invar fourier coeff, disp polygon<br />

Fourier descriptors<br />

Module<br />

T fourier 1dim inv ( Htuple RealCoef, Htuple ImaginaryCoef,<br />

Htuple MaxCoef, Htuple *Rows, Htuple *Columns )<br />

One dimensional Fourier synthesis (inverse Fourier transform).<br />

Backtransformation of Fourier coefficients respectively of Fourier descriptors. The number of values to be backtransformed<br />

should not exceed the length of the transformed contour.<br />

Parameter<br />

º RealCoef (input control) ...............................................real-array Htuple . double<br />

Real parts.<br />

º ImaginaryCoef (input control) ........................................real-array Htuple . double<br />

Imaginary parts.<br />

º MaxCoef (input control) .....................................................integer Htuple . long<br />

Input of the steps for the backtransformation.<br />

Default Value : 100<br />

Value Suggestions : MaxCoef ¾5, 10, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100, 150, 200, 400<br />

Restriction : MaxCoef 1<br />

º Rows (output control) .............................................contour.y-array Htuple . double *<br />

Row coordinates.<br />

º Columns (output control) .........................................contour.x-array Htuple . double *<br />

Column coordinates.<br />

Example<br />

get_region_contour(single,&row,&col);<br />

length_of_contour = row.Num();<br />

move_contour_orig(row,col,&trow,&tcol);<br />

prep_contour_fourier(trow,tcol,"unsigned_area",&param_scale);<br />

fourier_1dim(trow,tcol,param_scale,50,&frow,&fcol);<br />

invar_fourier_coeff(frow,fcol,1,"affine_invar",&invrow,&invcol);<br />

abs_invar_fourier_coeff(invrow,invcol,1,2,"az_invar1",&absrow,&abscol);<br />

fourier_1dim_inv(absrow,abscol,length_of_contour,&fsynrow,&fsyncol);<br />

Parallelization Information<br />

T fourier 1dim inv is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T invar fourier coeff, T fourier 1dim<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.5. FOURIER-DESCRIPTOR 721<br />

disp polygon<br />

Fourier descriptors<br />

Possible Successor Functions<br />

Module<br />

T invar fourier coeff ( Htuple RealCoef, Htuple ImaginaryCoef,<br />

Htuple NormPar, Htuple InvarType, Htuple *RealInvar,<br />

Htuple *ImaginaryInvar )<br />

Normalize the Fourier coefficients.<br />

Elimination of affine information from the Fourier coefficients, determination of affine invariants. The Fourier<br />

coefficients will be normalized suitably so that all affine correlated contours will be projected to one and the same<br />

contour. The following levels of affine mappings are available:<br />

1. Translations (InvarType =’translinvar’)<br />

2. + Rotations (InvarType = ’congr invar’)<br />

3. + Scalings (InvarType =’similinvar’)<br />

4. + Slanting (InvarType =’affineinvar’)<br />

The control parameter InvarType indicates up to which level the affine representation shall be normalized.<br />

Please note that indicating a certain level implies that the normalizing is executed with regard to all levels below.<br />

For most applications a subsequent normalizing of the starting point is recommended!<br />

Parameter<br />

º RealCoef (input control) ...............................................real-array Htuple . double<br />

Real parts of the Fourier coefficients.<br />

º ImaginaryCoef (input control) ........................................real-array Htuple . double<br />

Imaginary parts of the Fourier coefficients.<br />

º NormPar (input control) .....................................................integer Htuple . long<br />

Input of the normalizing coefficients.<br />

Default Value : 1<br />

Value Suggestions : NormPar ¾1, 2<br />

Restriction : NormPar 1<br />

º InvarType (input control) .............................................string Htuple . const char *<br />

Indicates the level of the affine mappings.<br />

Default Value : ’affine invar’<br />

Value List : InvarType ¾’affine invar’, ’simil invar’, ’congr invar’, ’transl invar’<br />

º RealInvar (output control) ...........................................real-array Htuple . double *<br />

Real parts of the normalized Fourier coefficients.<br />

º ImaginaryInvar (output control) ....................................real-array Htuple . double *<br />

Imaginary parts of the normalized Fourier coefficients.<br />

Example<br />

prep_contour_fourier(trow,tcol,"unsigned_area",&param_scale);<br />

fourier_1dim(trow,tcol,param_scale,&frow,&fcol);<br />

invar_fourier_coeff(frow,fcol,1,"affine_invar",&invrow,&invcol);<br />

abs_invar_fourier_coeff(invrow,invcol,1,2,"az_invar1",&absrow,&abscol);<br />

Parallelization Information<br />

T invar fourier coeff is reentrant and processed without parallelization.<br />

T fourier 1dim<br />

T invar fourier coeff<br />

Fourier descriptors<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Module<br />

<strong>HALCON</strong> 6.0


722 CHAPTER 12. TOOLS<br />

T match fourier coeff ( Htuple RealCoef1, Htuple ImaginaryCoef1,<br />

Htuple RealCoef2, Htuple ImaginaryCoef2, Htuple MaxCoef, Htuple Damping,<br />

Htuple *Distance )<br />

Similarity of two contours.<br />

The operator T match fourier coeff calculates the Euclidean distance between two contours which are<br />

available as Fourier coefficients. In order to avoid that the higher frequencies are in some way too dominant, the<br />

following attenuation can be used:<br />

none: No attenuation.<br />

1/index: Absolute amounts of the Fourier coefficients will be divided by their index.<br />

1/(index*index): Absolute amounts of the Fourier coefficients will be divided by their square index.<br />

The higher the result value, the greater the differences between the pattern and the test contour. If the number of<br />

coefficients is not the same, only the first Ò coefficients will be compared. The parameter MaxCoef indicates the<br />

number of the coefficients to be compared. If MaxCoef is set to zero, all coefficients will be used.<br />

Parameter<br />

º RealCoef1 (input control) ..............................................real-array Htuple . double<br />

Real parts of the pattern Fourier coefficients.<br />

º ImaginaryCoef1 (input control) .......................................real-array Htuple . double<br />

Imaginary parts of the pattern Fourier coefficients.<br />

º RealCoef2 (input control) ..............................................real-array Htuple . double<br />

Real parts of the Fourier coefficients to be compared.<br />

º ImaginaryCoef2 (input control) .......................................real-array Htuple . double<br />

Imaginary parts of the Fourier coefficients to be compared.<br />

º MaxCoef (input control) .....................................................integer Htuple . long<br />

Total number of Fourier coefficients.<br />

Default Value : 50<br />

Value Suggestions : MaxCoef ¾0, 5, 10, 15, 20, 30, 40, 50, 70, 100, 200, 400<br />

Restriction : MaxCoef 0<br />

º Damping (input control) ...............................................string Htuple . const char *<br />

Kind of attenuation.<br />

Default Value : ”1/index”<br />

Value Suggestions : Damping ¾’none’, ”1/index”, ”1/(index*index)”<br />

º Distance (output control) ..................................................real Htuple . double *<br />

Similarity of the contours.<br />

Example<br />

prep_contour_fourier(trow,tcol,"unsigned_area",&param_scale);<br />

fourier_1dim(trow,tcol,param_scale,50,&frow,&fcol);<br />

invar_fourier_coeff(frow,fcol,1,"affine_invar",&invrow,&invcol);<br />

abs_invar_fourier_coeff(invrow,invcol,1,2,<br />

"az_invar1",&absrow,&abscol);<br />

match_fourier_coeff(contur1_row, contur1_col,<br />

contur2_row, contur2_col, 50,<br />

"1/index", &Distance_wert);<br />

Parallelization Information<br />

T match fourier coeff is reentrant and processed without parallelization.<br />

T invar fourier coeff<br />

Fourier descriptors<br />

Possible Predecessor Functions<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.5. FOURIER-DESCRIPTOR 723<br />

T move contour orig ( Htuple Rows, Htuple Columns, Htuple *RowsMoved,<br />

Htuple *ColumnsMoved )<br />

Transformation of the origin into the centre of gravity.<br />

The operator T move contour orig relocates the input contour so that the origin lies in the centre of gravity.<br />

Parameter<br />

º Rows (input control) ..................................................contour.y-array Htuple . long<br />

Row coordinates of the contour.<br />

º Columns (input control) ..............................................contour.x-array Htuple . long<br />

Column coordinates of the contour.<br />

º RowsMoved (output control) ........................................contour.y-array Htuple . long *<br />

Row coordinates of the displaced contour.<br />

º ColumnsMoved (output control) ....................................contour.x-array Htuple . long *<br />

Column coordinates of the displaced contour.<br />

Parallelization Information<br />

T move contour orig is processed completely exclusively without parallelization.<br />

get region contour<br />

T prep contour fourier<br />

Fourier descriptors<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Module<br />

T prep contour fourier ( Htuple Rows, Htuple Columns, Htuple TransMode,<br />

Htuple *ParContour )<br />

Parameterize the passed contour.<br />

The operator T prep contour fourier parameterizes the transmitted contour in order to prepare it for the<br />

one dimensional Fourier transformation. Hereby the contour must be available in closed form. Three parameter<br />

functions are available for the control parameter TransMode:<br />

arc: Parameterization by the radian.<br />

signed area: Parameterization by the signed area.<br />

unsigned area: Parameterization by the absolute area.<br />

Please note that in contrast to the signed or unsigned area the affine mapping of the radian will not be transformed<br />

linearly.<br />

Parameter<br />

º Rows (input control) ..................................................contour.y-array Htuple . long<br />

Row indices of the contour.<br />

º Columns (input control) ..............................................contour.x-array Htuple . long<br />

Column indices of the contour.<br />

º TransMode (input control) .............................................string Htuple . const char *<br />

Kind of parameterization.<br />

Default Value : ’signed area’<br />

Value Suggestions : TransMode ¾’arc’, ’unsigned area’, ’signed area’<br />

º ParContour (output control) ..........................................real-array Htuple . double *<br />

Parameterized contour.<br />

Example<br />

get_region_contour(single,&row,&col);<br />

move_contour_orig(row,col,&trow,&tcol);<br />

prep_contour_fourier(trow,tcol,"unsigned_area",&param_scale);<br />

fourier_1dim(trow,tcol,param_scale,&frow,&fcol);<br />

<strong>HALCON</strong> 6.0


724 CHAPTER 12. TOOLS<br />

Parallelization Information<br />

T prep contour fourier is reentrant and processed without parallelization.<br />

T move contour orig<br />

T fourier 1dim<br />

Fourier descriptors<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Module<br />

12.6 Function<br />

T abs funct 1d ( Htuple Function, Htuple *FunctionAbsolute )<br />

Absolute value of the y values.<br />

T abs funct 1d calculates the absolute values of all y values of Function.<br />

Parameter<br />

º Function (input control) ..................................function 1d-array Htuple . double / long<br />

Input function.<br />

º FunctionAbsolute (output control) ...................function 1d-array Htuple . double * / long *<br />

Function with the absolute values of the y values.<br />

Parallelization Information<br />

T abs funct 1d is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create funct 1d pairs, T create funct 1d array<br />

Tools<br />

Module<br />

T create funct 1d array ( Htuple YValues, Htuple *Function )<br />

Create a function from a sequence of y-values.<br />

T create funct 1d array creates a one-dimensional function from a set of y-values YValues. The resulting<br />

function can then be processed and analyzed with the operators for 1d functions. YValues is interpreted as<br />

follows: the first value of YValues is the function value at zero, the second value is the function value at one, etc.<br />

Thus, the values define a function at equidistant x values (with distance 1), starting at 0.<br />

Alternatively, the operator T create funct 1d pairs can be used to create a function.<br />

T create funct 1d pairs also allows to define a function with non-equidistant x valus by specifiying<br />

them explicitely. Thus to get the same definition as with T create funct 1d array, one would pass a tuple<br />

of x values to T create funct 1d pairs that has the same length as YValues and contains values starting<br />

at 0 and increasing by 1 in each position. Note, however, that T create funct 1d pairs leads to a different<br />

internal representation of the function which needs more storage (because all (x,y) pairs are stored) and sometimes<br />

cannot be processed as efficiently as functions created by T create funct 1d array.<br />

Parameter<br />

º YValues (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) Htuple . double / long<br />

X value for function points.<br />

º Function (output control) ..............................function 1d-array Htuple . double * / long *<br />

Created function.<br />

Parallelization Information<br />

T create funct 1d array is reentrant and processed without parallelization.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.6. FUNCTION 725<br />

Possible Successor Functions<br />

T write funct 1d, gnuplot plot funct 1d, T y range funct 1d, T get pair funct 1d,<br />

T transform funct 1d<br />

Alternatives<br />

T create funct 1d pairs, (T )read funct 1d<br />

T funct 1d to pairs<br />

Tools<br />

See Also<br />

Module<br />

T create funct 1d pairs ( Htuple XValues, Htuple YValues,<br />

Htuple *Function )<br />

Create a function from a set of (x,y) pairs.<br />

T create funct 1d pairs creates a one-dimensional function from a set of pairs of (x,y) values. The<br />

XValues of the functions have to be passed in ascending order. The resulting function can then be processed<br />

and analyzed with the operators for 1d functions.<br />

Alternatively, functions can be created with the operator T create funct 1d array. In contrast to this operator,<br />

x values with arbitrary positions can be specified with T create funct 1d pairs. Hence, it is the more<br />

general operator. It should be noted, however, that because of this generality the processing of a function created<br />

with T create funct 1d pairs cannot be carried out as efficiently as for equidistant functions. In particular,<br />

not all operators accept such functions. If necessary, a function can be transformed into an equidistant function<br />

with the operator T sample funct 1d.<br />

Parameter<br />

º XValues (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) Htuple . double / long<br />

X value for function points.<br />

º YValues (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) Htuple . double / long<br />

Y-value for function points.<br />

º Function (output control) ..............................function 1d-array Htuple . double * / long *<br />

Created function.<br />

Parallelization Information<br />

T create funct 1d pairs is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

T write funct 1d, gnuplot plot funct 1d, T y range funct 1d, T get pair funct 1d<br />

Alternatives<br />

T create funct 1d array, (T )read funct 1d<br />

T funct 1d to pairs<br />

Tools<br />

See Also<br />

Module<br />

T distance funct 1d ( Htuple Function1, Htuple Function2, Htuple Mode,<br />

Htuple Sigma, Htuple *Distance )<br />

Compute the distance of two functions.<br />

T distance funct 1d calculates the distance of two functions. The two functions may differ in length.<br />

Parameter<br />

º Function1 (input control) ................................function 1d-array Htuple . double / long<br />

Input function 1.<br />

º Function2 (input control) ................................function 1d-array Htuple . double / long<br />

Input function 2.<br />

<strong>HALCON</strong> 6.0


726 CHAPTER 12. TOOLS<br />

º Mode (input control) .............................................string(-array) Htuple . const char *<br />

Modes of invariants.<br />

Default Value : ’length’<br />

Value List : Mode ¾’length’, ’mean’<br />

º Sigma (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) Htuple . double<br />

Variance of the optional smoothing with a Gaussian filter.<br />

Default Value : 0.0<br />

Value Suggestions : Sigma ¾0.0, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 7.0, 10.0, 15.0, 20.0, 25.0, 30.0, 40.0,<br />

50.0<br />

º Distance (output control) .....................................real-array Htuple . double * / long *<br />

Distance of the functions.<br />

Parallelization Information<br />

T distance funct 1d is reentrant and processed without parallelization.<br />

Tools<br />

Module<br />

T funct 1d to pairs ( Htuple Function, Htuple *XValues,<br />

Htuple *YValues )<br />

Access to the x/y values of a function.<br />

T funct 1d to pairs splits the input function Function into tuples for the x and y values.<br />

Parameter<br />

º Function (input control) ..................................function 1d-array Htuple . double / long<br />

Input function.<br />

º XValues (output control) ...................................number-array Htuple . double * / long *<br />

X values of the function.<br />

º YValues (output control) ...................................number-array Htuple . double * / long *<br />

Y values of the function.<br />

Parallelization Information<br />

T funct 1d to pairs is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create funct 1d pairs, T create funct 1d array<br />

Tools<br />

Module<br />

T get pair funct 1d ( Htuple Function, Htuple Index, Htuple *X,<br />

Htuple *Y )<br />

Access a function value using the index of the control points.<br />

T get pair funct 1d accesses a function value of Function. This is done by specifying the index of one or<br />

more control points of the function.<br />

Parameter<br />

º Function (input control) ..................................function 1d-array Htuple . double / long<br />

Input function.<br />

º Index (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) Htuple . long<br />

Index of the control points.<br />

º X (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) Htuple . double *<br />

X value at the given control points.<br />

º Y (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) Htuple . double *<br />

Y value at the given control points.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.6. FUNCTION 727<br />

Parallelization Information<br />

T get pair funct 1d is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create funct 1d pairs, T create funct 1d array<br />

Tools<br />

Module<br />

T integrate funct 1d ( Htuple Function, Htuple *Positive,<br />

Htuple *Negative )<br />

Compute the positive and negative areas of a function.<br />

T integrate funct 1d integrates the function Function (see T create funct 1d array and<br />

T create funct 1d pairs) and returns the integral of the positive and negative parts of the function in<br />

Positive and Negative, respectively. Hence, the integral of the function is the difference Positive -<br />

Negative. The integration is done on the interval on which the function is defined. For the integration, the<br />

function is interpolated linearly.<br />

Parameter<br />

º Function (input control) ........................................function 1d-array Htuple . double<br />

Input function.<br />

º Positive (output control) ..............................................number Htuple . double *<br />

Area under the positive part of the function.<br />

º Negative (output control) .........................................number-array Htuple . double *<br />

Area under the negative part of the function.<br />

Parallelization Information<br />

T integrate funct 1d is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create funct 1d pairs, T create funct 1d array<br />

See Also<br />

T create funct 1d array, T create funct 1d pairs<br />

Tools<br />

Module<br />

T match funct 1d trans ( Htuple Function1, Htuple Function2,<br />

Htuple Border, Htuple ParamsConst, Htuple UseParams, Htuple *Params,<br />

Htuple *ChiSquare, Htuple *Covar )<br />

Calculate transformation parameters between two functions.<br />

T match funct 1d trans calculates the transformation parameters between two functions given as the tuples<br />

Function1 and Function2 (see T create funct 1d array und T create funct 1d pairs). The<br />

following model is used for the transformation between the two functions:<br />

Ý ½´Üµ ½ Ý ¾´ ¿ Ü · µ· ¾<br />

<br />

The transformation parameters are determined by a least-squares minimization of the following function:<br />

Ò<br />

½<br />

¼<br />

Ý ½´Ü µ ½ Ý ¾´ ¿ Ü · µ· ¾<br />

¡ ¾<br />

<br />

The values of the function Ý ¾ are obtained by linear interpolation. The parameter Border determines the values<br />

of the function Function2 outside of its domain. For Border=’zero’ these values are set to 0, for<br />

Border=’constant’ they are set to the corresponding value at the border, for Border=’mirror’ they are mirrored<br />

<strong>HALCON</strong> 6.0


728 CHAPTER 12. TOOLS<br />

at the border, and for Border=’cyclic’ they are continued cyclically. The calculated transformation parameters<br />

are returned as a 4-tuple in Params. If some of the parameter values are known, the respective parameters can<br />

be excluded from the least-squares adjustment by setting the corresponding value in the tuple UseParams to the<br />

value ’false’. In this case, the tuple ParamsConst must contain the known value of the respective parameter. If<br />

a parameter is used for the adjustment (UseParams = ’true’), the corresponding parameter in ParamsConst is<br />

ignored. On output, T match funct 1d trans additionally returns the sum of the squared errors ChiSquare<br />

of the resulting function, i.e., the function obtained by transforming the input function with the transformation parameters,<br />

as well as the covariance matrix Covar of the transformation parameters Params. These parameters<br />

can be used to decide whether a successful matching of the functions was possible.<br />

Parameter<br />

º Function1 (input control) ................................function 1d-array Htuple . double / long<br />

Function 1.<br />

º Function2 (input control) ................................function 1d-array Htuple . double / long<br />

Function 2.<br />

º Border (input control) .................................................string Htuple . const char *<br />

Border treatment for function 2.<br />

Default Value : ’constant’<br />

Value List : Border ¾’zero’, ’constant’, ’mirror’, ’cyclic’<br />

º ParamsConst (input control) ........................................number-array Htuple . double<br />

Values of the parameters to remain constant.<br />

Default Value : ’[1.0,0.0,1.0,0.0]’<br />

Parameter Number : 4<br />

º UseParams (input control) .......................................string-array Htuple . const char *<br />

Should a parameter be adapted for it?<br />

Default Value : ’[’true’,’true’,’true’,’true’]’<br />

Value List : UseParams ¾’true’, ’false’<br />

Parameter Number : 4<br />

º Params (output control) ............................................number-array Htuple . double *<br />

Transformation parameters between the functions.<br />

Parameter Number : 4<br />

º ChiSquare (output control) .............................................number Htuple . double *<br />

Quadratic error of the output function.<br />

º Covar (output control) .............................................number-array Htuple . double *<br />

Covariance Matrix of the transformation parameters.<br />

Parameter Number : 16<br />

Parallelization Information<br />

T match funct 1d trans is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create funct 1d array, T create funct 1d pairs<br />

gray projections<br />

Tools<br />

See Also<br />

Module<br />

T negate funct 1d ( Htuple Function, Htuple *FunctionInverted )<br />

Negation of the y values.<br />

T negate funct 1d negates all y values of Function.<br />

Parameter<br />

º Function (input control) ..................................function 1d-array Htuple . double / long<br />

Input function.<br />

º FunctionInverted (output control) ...................function 1d-array Htuple . double * / long *<br />

Function with the negated y values.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.6. FUNCTION 729<br />

Parallelization Information<br />

T negate funct 1d is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create funct 1d pairs, T create funct 1d array<br />

Tools<br />

Module<br />

T num points funct 1d ( Htuple Function, Htuple *Length )<br />

Number of control points of the function.<br />

T num points funct 1d calculates the number of control points of Function.<br />

Parameter<br />

º Function (input control) ..................................function 1d-array Htuple . double / long<br />

Input function.<br />

º Length (output control) ....................................................integer Htuple . long *<br />

Number of control points.<br />

Parallelization Information<br />

T num points funct 1d is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create funct 1d pairs, T create funct 1d array<br />

Tools<br />

Module<br />

read funct 1d ( const char *FileName, double *Function )<br />

T read funct 1d ( Htuple FileName, Htuple *Function )<br />

Read a function from a file.<br />

The operator (T )read funct 1d reads the contents of FileName and converts it into the function<br />

Function. The file has be generated by T write funct 1d.<br />

Parameter<br />

º FileName (input control) ..........................................filename (Htuple .) const char *<br />

Name of the file to be read.<br />

º Function (output control) ...........................function 1d(-array) (Htuple .) double * / long *<br />

Function from the file.<br />

Result<br />

If the parameters are correct the operator (T )read funct 1d returns the value H MSG TRUE. If the file could<br />

not be opened (T )read funct 1d returns H MSG FAIL. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

(T )read funct 1d is reentrant and processed without parallelization.<br />

fread string, read tuple<br />

Alternatives<br />

See Also<br />

T write funct 1d, gnuplot plot ctrl, write image, write region, open file<br />

Basic operators<br />

Module<br />

<strong>HALCON</strong> 6.0


730 CHAPTER 12. TOOLS<br />

T sample funct 1d ( Htuple Function, Htuple XMin, Htuple XMax,<br />

Htuple XDist, Htuple Border, Htuple *SampledFunction )<br />

Sample a function equidistantly in an interval.<br />

T sample funct 1d samples the input function Function in the interval [XMin,XMax] at equidistant points<br />

with the distance XDist. The last point lies in the interval if XMax-XMin is not an integer multiple of XDist. To<br />

obtain the samples, the input function is interpolated linearly. The parameter Border determines the values of the<br />

function Function outside of its domain. For Border=’zero’ these values are set to 0, for Border=’constant’<br />

they are set to the corresponding value at the border, for Border=’mirror’ they are mirrored at the border, and<br />

for Border=’cyclic’ they are continued cyclically.<br />

Parameter<br />

º Function (input control) ..................................function 1d-array Htuple . double / long<br />

Input function.<br />

º XMin (input control) ................................................number Htuple . double / long<br />

Minimum x value of the output function.<br />

º XMax (input control) ................................................number Htuple . double / long<br />

Maximum x value of the output function.<br />

Restriction : XMax XMin<br />

º XDist (input control) ...............................................number Htuple . double / long<br />

Distance of the samples.<br />

Restriction : XDist 0<br />

º Border (input control) .................................................string Htuple . const char *<br />

Border treatment for the input function.<br />

Default Value : ’constant’<br />

Value List : Border ¾’zero’, ’constant’, ’mirror’, ’cyclic’<br />

º SampledFunction (output control) ............................function 1d-array Htuple . double *<br />

Sampled function.<br />

Parallelization Information<br />

T sample funct 1d is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T transform funct 1d, T create funct 1d array, T create funct 1d pairs<br />

Tools<br />

Module<br />

T scale y funct 1d ( Htuple Function, Htuple Mult, Htuple Add,<br />

Htuple *FunctionScaled )<br />

Multiplication and addition of the y values.<br />

T scale y funct 1d multiplies and adds the y values of Function with the parameters Mult and Add.<br />

Parameter<br />

º Function (input control) ..................................function 1d-array Htuple . double / long<br />

Input function.<br />

º Mult (input control) .......................................................number Htuple . double<br />

Factor for scaling of the y values.<br />

Default Value : 2<br />

Value Suggestions : Mult ¾0.1, 0.3, 0.5, 1, 2, 5, 10<br />

º Add (input control) ........................................................number Htuple . double<br />

Constant which is added to the y values.<br />

Default Value : 0<br />

Value Suggestions : Add ¾-10,-5,1,0,5,10<br />

º FunctionScaled (output control) .....................function 1d-array Htuple . double * / long *<br />

Transformed function.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.6. FUNCTION 731<br />

Parallelization Information<br />

T scale y funct 1d is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create funct 1d pairs, T create funct 1d array<br />

Tools<br />

Module<br />

T smooth funct 1d gauss ( Htuple Function, Htuple Sigma,<br />

Htuple *SmoothedFunction )<br />

Smooth an equidistant function with a Gaussian function.<br />

The operator T smooth funct 1d gauss smooths a one-dimensional function with a Gaussian function.<br />

Parameter<br />

º Function (input control) ..................................function 1d-array Htuple . double / long<br />

Function to be smoothed.<br />

º Sigma (input control) .....................................................number Htuple . double<br />

Sigma of the Gaussian function for the smoothing.<br />

Default Value : 2.0<br />

Value Suggestions : Sigma ¾0.5, 1.0, 2.0, 3.0, 4.0, 5.0<br />

Typical Range of Values : 0.1 Sigma 50.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.2<br />

º SmoothedFunction (output control) ..........................function 1d-array Htuple . double *<br />

Smoothed function.<br />

Parallelization Information<br />

T smooth funct 1d gauss is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create funct 1d pairs, T create funct 1d array<br />

Possible Successor Functions<br />

T match funct 1d trans, T distance funct 1d<br />

Tools<br />

Module<br />

T smooth funct 1d mean ( Htuple Function, Htuple SmoothSize,<br />

Htuple Iterations, Htuple *SmoothedFunction )<br />

Smooth a 1D function by averaging its values.<br />

The operator T smooth funct 1d mean smooths a one dimensional function by applying an average (mean)<br />

filter multiple times.<br />

Parameter<br />

º Function (input control) ..................................function 1d-array Htuple . long / double<br />

1D function.<br />

º SmoothSize (input control) .................................................integer Htuple . long<br />

Size of the averaging mask.<br />

Default Value : 10<br />

Value Suggestions : SmoothSize ¾1, 3, 5, 7, 9, 11, 13, 15, 21, 31, 51<br />

Typical Range of Values : 1 SmoothSize 1000 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : SmoothSize 0<br />

<strong>HALCON</strong> 6.0


732 CHAPTER 12. TOOLS<br />

º Iterations (input control) .................................................integer Htuple . long<br />

Number of iterations for the smoothing.<br />

Default Value : 3<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9<br />

Typical Range of Values : 1 Iterations 100 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Restriction : Iterations 1<br />

º SmoothedFunction (output control) ..........................function 1d-array Htuple . double *<br />

Smoothed function.<br />

Parallelization Information<br />

T smooth funct 1d mean is reentrant and processed without parallelization.<br />

T create funct 1d array<br />

T smooth funct 1d gauss<br />

Tools<br />

Possible Predecessor Functions<br />

Alternatives<br />

Module<br />

T transform funct 1d ( Htuple Function, Htuple Params,<br />

Htuple *TransformedFunction )<br />

Transform a function using given transformation parameters.<br />

T transform funct 1d transforms the input function Function using the transformation parameters<br />

given in Params. The function Function is passed as a tuple (see T create funct 1d array und<br />

T create funct 1d pairs). The following model is used for the transformation between the two functions<br />

(see T match funct 1d trans):<br />

Ý Ø´Üµ ½ Ý´ ¿ Ü · µ· ¾<br />

<br />

The output function TransformedFunction is obtained by transforming the x and y values of the input function<br />

separately with the above formula, i.e., the output function is not sampled again. To do so, the operator<br />

T sample funct 1d can be used.<br />

Parameter<br />

º Function (input control) ..................................function 1d-array Htuple . double / long<br />

Input function.<br />

º Params (input control) ..............................................number-array Htuple . double<br />

Transformation parameters between the functions.<br />

Parameter Number : 4<br />

º TransformedFunction (output control) ...............function 1d-array Htuple . double * / long *<br />

Transformed function.<br />

Parallelization Information<br />

T transform funct 1d is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create funct 1d pairs, T create funct 1d array, T match funct 1d trans<br />

Tools<br />

Module<br />

T write funct 1d ( Htuple Function, Htuple FileName )<br />

Write a function to a file.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.6. FUNCTION 733<br />

The operator T write funct 1d writes the contents of Function to a file. The data is written in an ASCII<br />

format. Therefore, the file can be exchanged between different architectures. The data can be read by the operator<br />

(T )read funct 1d. There is no specific extension for this kind of file.<br />

Parameter<br />

º Function (input control) ..................................function 1d-array Htuple . double / long<br />

Function to be written.<br />

º FileName (input control) ...........................................filename Htuple . const char *<br />

Name of the file to be written.<br />

Result<br />

If the parameters are correct the operator T write funct 1d returns the value H MSG TRUE. If the file could<br />

not be opened T write funct 1d returns H MSG FAIL. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T write funct 1d is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create funct 1d pairs, T create funct 1d array<br />

write tuple, fwrite string<br />

Alternatives<br />

See Also<br />

(T )read funct 1d, write image, write region, open file<br />

Basic operators<br />

Module<br />

T x range funct 1d ( Htuple Function, Htuple *XMin, Htuple *XMax )<br />

Smallest and largest x value of the function.<br />

T x range funct 1d calculates the smallest and the largest x value of Function.<br />

Parameter<br />

º Function (input control) ..................................function 1d-array Htuple . double / long<br />

Input function.<br />

º XMin (output control) ....................................................number Htuple . double *<br />

Smallest x value.<br />

º XMax (output control) ....................................................number Htuple . double *<br />

Largest x value.<br />

Parallelization Information<br />

T x range funct 1d is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create funct 1d pairs, T create funct 1d array<br />

Tools<br />

Module<br />

T y range funct 1d ( Htuple Function, Htuple *YMin, Htuple *YMax )<br />

Smallest and largest y value of the function.<br />

T y range funct 1d calculates the smallest and the largest y value of Function.<br />

Parameter<br />

º Function (input control) ..................................function 1d-array Htuple . double / long<br />

Input function.<br />

º YMin (output control) ....................................................number Htuple . double *<br />

Smallest y value.<br />

<strong>HALCON</strong> 6.0


734 CHAPTER 12. TOOLS<br />

º YMax (output control) ....................................................number Htuple . double *<br />

Largest y value.<br />

Parallelization Information<br />

T y range funct 1d is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create funct 1d pairs, T create funct 1d array<br />

Tools<br />

Module<br />

12.7 Geometry<br />

angle ll ( double RowA1, double ColumnA1, double RowA2, double ColumnA2,<br />

double RowB1, double ColumnB1, double RowB2, double ColumnB2,<br />

double *Angle )<br />

T angle ll ( Htuple RowA1, Htuple ColumnA1, Htuple RowA2,<br />

Htuple ColumnA2, Htuple RowB1, Htuple ColumnB1, Htuple RowB2,<br />

Htuple ColumnB2, Htuple *Angle )<br />

Calculate the angle between two lines.<br />

The operator (T )angle ll calculates the angle between two lines. As input the rows and columns of the first<br />

line (RowA1,ColumnA1, RowA2,ColumnA2) and of the second line (RowB1,ColumnB1, RowB2,ColumnB2)<br />

are expected. The calculation in done as follows: We interpret the lines as vectors with starting points<br />

RowA1,ColumnA1 and RowB1,ColumnB1 and end points RowA2,ColumnA2 and RowB2,ColumnB2, respectively.<br />

Turning the vector counterclockwise onto the vector (the center of rotation is the intersection point of<br />

the two lines) yields the angle. The result depends on the order of the points and on the order of the lines. The<br />

parameter Angle returns the angle in radians. The angles range from ÒÐ .<br />

Parameter<br />

º RowA1 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the first point of the first line.<br />

º ColumnA1 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the first point of the first line.<br />

º RowA2 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the second point of the first line.<br />

º ColumnA2 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the second point of the first line.<br />

º RowB1 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the first point of the second line.<br />

º ColumnB1 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the first point of the second line.<br />

º RowB2 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the second point of the second line.<br />

º ColumnB2 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the second point of the second line.<br />

º Angle (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Angle between the lines.<br />

Example<br />

RowA1 := 255<br />

ColumnA1 := 10<br />

RowA2 := 255<br />

ColumnA2 := 501<br />

disp_line (WindowHandle, RowA1, ColumnA1, RowA2, ColumnA2)<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.7. GEOMETRY 735<br />

RowB1 := 255<br />

ColumnB1 := 255<br />

for i := 1 to 360 by 1<br />

RowB2 := 255 + sin(rad(i)) * 200<br />

ColumnB2 := 255 + cos(rad(i)) * 200<br />

disp_line (WindowHandle, RowB1, ColumnB1, RowB2, ColumnB2)<br />

angle_ll (RowA1, ColumnA1, RowA2, ColumnA2,<br />

RowB1, ColumnB1, RowB2, ColumnB2, Angle)<br />

endfor<br />

(T )angle ll returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )angle ll is reentrant and processed without parallelization.<br />

(T )angle lx<br />

Basic operators<br />

Alternatives<br />

Module<br />

angle lx ( double Row1, double Column1, double Row2, double Column2,<br />

double *Angle )<br />

T angle lx ( Htuple Row1, Htuple Column1, Htuple Row2, Htuple Column2,<br />

Htuple *Angle )<br />

Calculate the angle between one line and the vertical axis.<br />

The operator (T )angle lx calculates the angle between one line and the abscissa. As input the row and column<br />

of the line (Row1,Column1, Row2,Column2) are expected. The calculation in done as follows: We interprete<br />

the line as a vector with starting point Row1,Column1 and end point Row2,Column2. Turning the vector counter<br />

clockwise onto the abscissa (center of rotation is the intersection point of the abscissa) yields the angle. The result<br />

is dependant on the order of points of line. The parameters Angle returns the angle in radians. The angles range<br />

from ÒÐ .<br />

Parameter<br />

º Row1 (input control) ........................................point.y(-array) (Htuple .) double / long<br />

Row of the first point of the line.<br />

º Column1 (input control) ....................................point.x(-array) (Htuple .) double / long<br />

Column of the first point of the line.<br />

º Row2 (input control) ........................................point.y(-array) (Htuple .) double / long<br />

Row of the second point of the line.<br />

º Column2 (input control) ....................................point.x(-array) (Htuple .) double / long<br />

Column of the second point of the line.<br />

º Angle (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Angle between the line and the abscissa.<br />

Example<br />

RowX1 := 255<br />

ColumnX1 := 10<br />

RowX2 := 255<br />

ColumnX2 := 501<br />

disp_line (WindowHandle, RowX1, ColumnX1, RowX2, ColumnX2)<br />

Row1 := 255<br />

Column1 := 255<br />

for i := 1 to 360 by 1<br />

Row2 := 255 + sin(rad(i)) * 200<br />

<strong>HALCON</strong> 6.0


736 CHAPTER 12. TOOLS<br />

Column2 := 255 + cos(rad(i)) * 200<br />

disp_line (WindowHandle, Row1, Column1, Row2, Column2)<br />

angle_lx (Row1, Column1, Row2, Column2, Angle)<br />

endfor<br />

(T )angle lx returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )angle lx is reentrant and processed without parallelization.<br />

(T )angle ll<br />

Basic operators<br />

Alternatives<br />

Module<br />

distance lr ( Hobject Region, double Row1, double Column1, double Row2,<br />

double Column2, double *DistanceMin, double *DistanceMax )<br />

T distance lr ( Hobject Region, Htuple Row1, Htuple Column1,<br />

Htuple Row2, Htuple Column2, Htuple *DistanceMin, Htuple *DistanceMax )<br />

Calculate the distance between one line and one region.<br />

The operator (T )distance lr calculates the orthogonal distance between one line and one region. As input<br />

the coordinates of 2 points that the line represent (Row1,Column1, Row2,Column2) and one region are expected.<br />

The parameters DistanceMin and DistanceMax return the result of the calculation.<br />

Attention<br />

Due to efficiency of (T )distance lr holes are ignored. Furthermore, if the lines intersects the region a<br />

minimal distance larger than 0.5 can be returned.<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Input region.<br />

º Row1 (input control) ........................................point.y(-array) (Htuple .) double / long<br />

Row of the first point of the line.<br />

º Column1 (input control) ....................................point.x(-array) (Htuple .) double / long<br />

Column of the first point of the line.<br />

º Row2 (input control) ........................................point.y(-array) (Htuple .) double / long<br />

Row of the second point of the line.<br />

º Column2 (input control) ....................................point.x(-array) (Htuple .) double / long<br />

Column of the second point of the line.<br />

º DistanceMin (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Minimal distance between the line and the region<br />

º DistanceMax (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Maximal distance between the line and the region<br />

Example<br />

dev_close_window ()<br />

read_image (Image, ’fabrik’)<br />

dev_open_window (0, 0, 512, 512, ’white’, WindowHandle)<br />

threshold (Image, Region, 180, 255)<br />

connection (Region, ConnectedRegions)<br />

select_shape (ConnectedRegions, SelectedRegions, ’area’, ’and’,<br />

5000, 100000000)<br />

dev_clear_window ()<br />

dev_set_color (’black’)<br />

dev_display (SelectedRegions)<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.7. GEOMETRY 737<br />

dev_set_color (’red’)<br />

Row1 := 100<br />

Row2 := 400<br />

for Col := 50 to 400 by 4<br />

disp_line (WindowHandle, Row1, Col+100, Row2, Col)<br />

distance_lr (SelectedRegions, Row1, Col+100, Row2, Col,<br />

DistanceMin, DistanceMax)<br />

endfor<br />

(T )distance lr returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )distance lr is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )distance pr, (T )distance sr, diameter region<br />

See Also<br />

hamming distance, select region point, test region point, smallest rectangle2<br />

Basic operators<br />

Module<br />

distance pl ( double Row, double Column, double Row1, double Column1,<br />

double Row2, double Column2, double *Distance )<br />

T distance pl ( Htuple Row, Htuple Column, Htuple Row1, Htuple Column1,<br />

Htuple Row2, Htuple Column2, Htuple *Distance )<br />

Calculate the distance between one point and one line.<br />

The operator (T )distance pl calculates the orthogonal distance between a point (Row,Column) and a line,<br />

given by two arbitrary points of the line. The result is passed in Distance.<br />

Parameter<br />

º Row (input control) ..........................................point.y(-array) (Htuple .) double / long<br />

Row of the point.<br />

º Column (input control) ......................................point.x(-array) (Htuple .) double / long<br />

Column of the point.<br />

º Row1 (input control) ........................................point.y(-array) (Htuple .) double / long<br />

Row of the first point of the line.<br />

º Column1 (input control) ....................................point.x(-array) (Htuple .) double / long<br />

Column of the first point of the line.<br />

º Row2 (input control) ........................................point.y(-array) (Htuple .) double / long<br />

Row of the second point of the line.<br />

º Column2 (input control) ....................................point.x(-array) (Htuple .) double / long<br />

Column of the second point of the line.<br />

º Distance (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Distance between the points<br />

Example<br />

double row,column,row1,column1,row2,column2,distance;<br />

draw_point(WindowHandle,&row,&column);<br />

draw_line(WindowHandle,&row1,&column1,&row2,&column2);<br />

distance_pl(row,column,row1,column1,row2,column2,&distance);<br />

(T )distance pl returns H MSG TRUE.<br />

Result<br />

<strong>HALCON</strong> 6.0


738 CHAPTER 12. TOOLS<br />

Parallelization Information<br />

(T )distance pl is reentrant and processed without parallelization.<br />

(T )distance ps<br />

(T )distance pp, (T )distance pr<br />

Basic operators<br />

Alternatives<br />

See Also<br />

Module<br />

distance pp ( double Row1, double Column1, double Row2, double Column2,<br />

double *Distance )<br />

T distance pp ( Htuple Row1, Htuple Column1, Htuple Row2,<br />

Htuple Column2, Htuple *Distance )<br />

Calculate the distance between two points.<br />

The operator (T )distance pp calculates the distance between pairs of points according to the following formula:<br />

Ô<br />

×ØÒ ´´ÊÓÛ½ ÊÓÛ¾µ ¾ ·´ÓÐÙÑÒ½ ÓÐÙÑÒ¾µ ¾ µ<br />

The result is passed in Distance.<br />

Parameter<br />

º Row1 (input control) ........................................point.y(-array) (Htuple .) double / long<br />

Row of the first point.<br />

º Column1 (input control) ....................................point.x(-array) (Htuple .) double / long<br />

Column of the first point.<br />

º Row2 (input control) ........................................point.y(-array) (Htuple .) double / long<br />

Row of the second point.<br />

º Column2 (input control) ....................................point.x(-array) (Htuple .) double / long<br />

Column of the second point.<br />

º Distance (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Distance between the points<br />

Example<br />

double<br />

row1,column1,row2,column2,distance;<br />

draw_point(WindowHandle,&row1,&column1);<br />

draw_point(WindowHandle,&row2,&column2);<br />

distance_pp(row1,column1,row2,column2,&distance);<br />

(T )distance pp returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )distance pp is reentrant and processed without parallelization.<br />

(T )distance ps<br />

(T )distance pl, (T )distance pr<br />

Basic operators<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.7. GEOMETRY 739<br />

distance pr ( Hobject Region, double Row, double Column,<br />

double *DistanceMin, double *DistanceMax )<br />

T distance pr ( Hobject Region, Htuple Row, Htuple Column,<br />

Htuple *DistanceMin, Htuple *DistanceMax )<br />

Calculate the distance between one point and one region.<br />

The operator (T )distance pr calculates the distance between one point and one region. As input the column<br />

und Row of the point (Row,Column) and one region are expected. If the pint is inside the region the minimal<br />

distance is zero. The parameters DistanceMin and DistanceMax return the result of the calculation.<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Input region.<br />

º Row (input control) ..........................................point.y(-array) (Htuple .) double / long<br />

Row of the point.<br />

º Column (input control) ......................................point.x(-array) (Htuple .) double / long<br />

Column of the point.<br />

º DistanceMin (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Minimal distance between the point and the region<br />

º DistanceMax (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Maximal distance between the point and the region<br />

Example<br />

dev_close_window ()<br />

read_image (Image, ’mreut’)<br />

dev_open_window (0, 0, 512, 512, ’white’, WindowHandle)<br />

dev_set_color (’black’)<br />

threshold (Image, Region, 180, 255)<br />

connection (Region, ConnectedRegions)<br />

select_shape (ConnectedRegions, SelectedRegions, ’area’, ’and’,<br />

10000, 100000000)<br />

Row1 := 255<br />

Column1 := 255<br />

dev_clear_window ()<br />

dev_display (SelectedRegions)<br />

dev_set_color (’red’)<br />

for i := 1 to 360 by 1<br />

Row2 := 255 + sin(rad(i)) * 200<br />

Column2 := 255 + cos(rad(i)) * 200<br />

disp_line (WindowHandle, Row1, Column1, Row2, Column2)<br />

distance_pr (SelectedRegions, Row2, Column2,<br />

DistanceMin, DistanceMax)<br />

endfor<br />

(T )distance pr returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )distance pr is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )distance lr, (T )distance sr, diameter region<br />

See Also<br />

hamming distance, select region point, test region point, smallest rectangle2<br />

Basic operators<br />

Module<br />

<strong>HALCON</strong> 6.0


740 CHAPTER 12. TOOLS<br />

distance ps ( double Row, double Column, double Row1, double Column1,<br />

double Row2, double Column2, double *DistanceMin, double *DistanceMax )<br />

T distance ps ( Htuple Row, Htuple Column, Htuple Row1, Htuple Column1,<br />

Htuple Row2, Htuple Column2, Htuple *DistanceMin, Htuple *DistanceMax )<br />

Calculate the distances between a point and a line segment.<br />

The operator (T )distance ps calculates the minimal and maximal distance between a point (Row,Column)<br />

and a line segment which is represented by the start point (Row1,Column1) and the end point (Row2,Column2).<br />

DistanceMax is the maximal distance between the point and the end points of the line segment. DistanceMin<br />

is identical to (T )distance pl in the case that the point is “between” the two endpoints. Otherwise the<br />

minimal distance to one of the endpoints is used.<br />

Parameter<br />

º Row (input control) ..........................................point.y(-array) (Htuple .) double / long<br />

Row of the first point.<br />

º Column (input control) ......................................point.x(-array) (Htuple .) double / long<br />

Column of the first point.<br />

º Row1 (input control) ........................................point.y(-array) (Htuple .) double / long<br />

Row of the first point of the line segment.<br />

º Column1 (input control) ....................................point.x(-array) (Htuple .) double / long<br />

Column of the first point of the line segment.<br />

º Row2 (input control) ........................................point.y(-array) (Htuple .) double / long<br />

Row of the second point of the line segment.<br />

º Column2 (input control) ....................................point.x(-array) (Htuple .) double / long<br />

Column of the second point of the line segment.<br />

º DistanceMin (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Minimal distance between the point and the line segment<br />

º DistanceMax (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Maximal distance between the point and the line segment<br />

Example<br />

double row,column,row1,column1,row2,column2;<br />

double distance_min,distance_max;<br />

distance_ps(row,column,row1,column1,row2,column2,<br />

&distance_min,&distance_max);<br />

(T )distance ps returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )distance ps is reentrant and processed without parallelization.<br />

(T )distance pl<br />

(T )distance pp, (T )distance pr<br />

Basic operators<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.7. GEOMETRY 741<br />

distance rr min ( Hobject Regions1, Hobject Regions2,<br />

double *MinDistance, long *Row1, long *Column1, long *Row2,<br />

long *Column2 )<br />

T distance rr min ( Hobject Regions1, Hobject Regions2,<br />

Htuple *MinDistance, Htuple *Row1, Htuple *Column1, Htuple *Row2,<br />

Htuple *Column2 )<br />

Minimum distance between the contour pixels of two regions each.<br />

The operator (T )distance rr min calculates the minimum distance of pairs of regions. If several regions are<br />

passed in Regions1 and Regions2 the distance between the contour pixels of each i-th element is calculated<br />

and then forms the i-th entry in the output parameter MinDistance. The calculation is carried out by comparing<br />

all contour pixels. The Euclidean distance is used. The parameters (Row1,Column1) and(Row2, Column2)<br />

indicate the position on the contour of Regions1 and Regions2, respectively, the distance between which is<br />

the minimum distance.<br />

Attention<br />

Each region must consist of exactly one connection component. Both input parameters must contain the same<br />

number of regions. The regions must not be empty. If the regions overlap the distance is indicated as 0.0. In this<br />

case the positions are not reliable.<br />

Parameter<br />

º Regions1 (input object) ...................................................region(-array) Hobject<br />

Regions to be examined.<br />

º Regions2 (input object) ...................................................region(-array) Hobject<br />

Regions to be examined.<br />

º MinDistance (output control) .....................................real(-array) (Htuple .) double *<br />

Minimum distance between contours of the regions.<br />

Assertion : 0 MinDistance<br />

º Row1 (output control) ..............................................point.y(-array) (Htuple .) long *<br />

Line index on contour in Regions1.<br />

º Column1 (output control) ..........................................point.x(-array) (Htuple .) long *<br />

Column index on contour in Regions1.<br />

º Row2 (output control) ..............................................point.y(-array) (Htuple .) long *<br />

Line index on contour in Regions2.<br />

º Column2 (output control) ..........................................point.x(-array) (Htuple .) long *<br />

Column index on contour in Regions2.<br />

Complexity<br />

If Æ ½,Æ ¾ are the lengths of the contours the runtime complexity is Ç´Æ ½ £ Æ ¾µ.<br />

Result<br />

The operator (T )distance rr min returns the value H MSG TRUE if the input is not empty. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

(T )distance rr min is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

Alternatives<br />

(T )distance rr min dil, dilation1, intersection<br />

Region processing<br />

Module<br />

<strong>HALCON</strong> 6.0


742 CHAPTER 12. TOOLS<br />

distance rr min dil ( Hobject Regions1, Hobject Regions2,<br />

long *MinDistance )<br />

T distance rr min dil ( Hobject Regions1, Hobject Regions2,<br />

Htuple *MinDistance )<br />

Minimum distance between two regions with the help of dilatation.<br />

The operator (T )distance rr min dil calculates the minimum distance between pairs of regions. If several<br />

regions are passed in Regions1 and Regions2 the distance between the i-th elements in each case is calculated.<br />

It then forms the i-th entry in the output parameter MinDistance. The calculation is carried out with the help of<br />

dilatation with the Golay element ’h’. The result is:<br />

ÆÙÑÖØÖØÓÒ× £ ¾ ½<br />

.<br />

The mask ’h’ has the effect that precisely the maximum metrics are calculated.<br />

Attention<br />

Both parameters must contain the same number of regions. The regions must not be empty.<br />

Parameter<br />

º Regions1 (input object) ...................................................region(-array) Hobject<br />

Regions to be examined.<br />

º Regions2 (input object) ...................................................region(-array) Hobject<br />

Regions to be examined.<br />

º MinDistance (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long *<br />

Minimum distances of the regions.<br />

Assertion : -1 MinDistance<br />

Result<br />

The operator (T )distance rr min dil returns the value H MSG TRUE if the input is not empty. Otherwise<br />

an exception handling is raised.<br />

Parallelization Information<br />

(T )distance rr min dil is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, regiongrowing, connection<br />

Alternatives<br />

(T )distance rr min, dilation1, intersection<br />

Region processing<br />

Module<br />

distance sl ( double RowA1, double ColumnA1, double RowA2,<br />

double ColumnA2, double RowB1, double ColumnB1, double RowB2,<br />

double ColumnB2, double *DistanceMin, double *DistanceMax )<br />

T distance sl ( Htuple RowA1, Htuple ColumnA1, Htuple RowA2,<br />

Htuple ColumnA2, Htuple RowB1, Htuple ColumnB1, Htuple RowB2,<br />

Htuple ColumnB2, Htuple *DistanceMin, Htuple *DistanceMax )<br />

Calculate the distances between one line segment and one line.<br />

The operator (T )distance sl calculates the minimal and maximal orthogonal distance between one line segment<br />

and one line. As input the columns and rows of the line segment (RowA1,ColumnA1,RowA2,ColumnA2)<br />

and of the line (RowB1,ColumnB1,RowB2,ColumnB2) are expected. The parameters DistanceMin and<br />

DistanceMax return the result of the calculation. If the line segments are intersecting DistanceMin returns<br />

zero.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.7. GEOMETRY 743<br />

Parameter<br />

º RowA1 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the first point of the line segment.<br />

º ColumnA1 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the first point of the line segment.<br />

º RowA2 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the second point of the line segment.<br />

º ColumnA2 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the second point of the line segment.<br />

º RowB1 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the first point of the line.<br />

º ColumnB1 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the first point of the line.<br />

º RowB2 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the second point of the line.<br />

º ColumnB2 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the second point of the line.<br />

º DistanceMin (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Minimal distance between the line segment and the line<br />

º DistanceMax (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Maximal distance between the line segment and the line<br />

Example<br />

create_tuple(&RowA1, 1);<br />

set_i(RowA1, 8, 0);<br />

create_tuple(&ColumnA1, 1);<br />

set_i(ColumnA1, 7, 0);<br />

create_tuple(&RowA2, 1);<br />

set_i(RowA2, 15, 0);<br />

create_tuple(&ColumnA2, 1);<br />

set_i(ColumnA2, 11, 0);<br />

create_tuple(&RowB1, 1);<br />

set_i(RowB1, 2, 0);<br />

create_tuple(&ColumnB1, 1);<br />

set_i(ColumnB1, 4, 0);<br />

create_tuple(&RowB2, 1);<br />

set_i(RowB2, 6, 0);<br />

create_tuple(&ColumnB2, 1);<br />

set_i(ColumnB2, 10, 0);<br />

T_distance_sl(RowA1,ColumnA1,RowA2,ColumnA2,RowB1,ColumnB1,RowB2,ColumnB2,<br />

&distance_min,&distance_max);<br />

aa_min = get_d(distance_min,0);<br />

aa_max = get_d(distance_max,0);<br />

(T )distance sl returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )distance sl is reentrant and processed without parallelization.<br />

(T )distance pl<br />

(T )distance ps, (T )distance pp<br />

Basic operators<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


744 CHAPTER 12. TOOLS<br />

distance sr ( Hobject Region, double Row1, double Column1, double Row2,<br />

double Column2, double *DistanceMin, double *DistanceMax )<br />

T distance sr ( Hobject Region, Htuple Row1, Htuple Column1,<br />

Htuple Row2, Htuple Column2, Htuple *DistanceMin, Htuple *DistanceMax )<br />

Calculate the distance between one line segment and one region.<br />

The operator (T )distance sr calculates the distance between one line segment and one region. Row1,<br />

Column1, Row2, Column2 are the the initial and end coordinates of the line segment. The parameters<br />

DistanceMin and DistanceMax contain the resulting distances.<br />

Attention<br />

Due to efficiency of (T )distance sr holes are ignored. Furthermore, if the lines intersects the region a<br />

minimal distance larger than 0.5 can be returned.<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Input region.<br />

º Row1 (input control) ........................................point.y(-array) (Htuple .) double / long<br />

Row of the first point of the line segment.<br />

º Column1 (input control) ....................................point.x(-array) (Htuple .) double / long<br />

Column of the first point of the line segment.<br />

º Row2 (input control) ........................................point.y(-array) (Htuple .) double / long<br />

Row of the second point of the line segment.<br />

º Column2 (input control) ....................................point.x(-array) (Htuple .) double / long<br />

Column of the second point of the line segment.<br />

º DistanceMin (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Minimal distance between the line segment and the region<br />

º DistanceMax (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Maximal distance between the line segment and the region<br />

Example<br />

threshold(Image, &Region, 0.0, 120.0);<br />

distance_sr(Region,row1,column1,row2,column2<br />

&distance_min, &distance_max);<br />

(T )distance sr returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )distance sr is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )distance lr, (T )distance pr, diameter region<br />

See Also<br />

hamming distance, select region point, test region point, smallest rectangle2<br />

Basic operators<br />

Module<br />

distance ss ( double RowA1, double ColumnA1, double RowA2,<br />

double ColumnA2, double RowB1, double ColumnB1, double RowB2,<br />

double ColumnB2, double *DistanceMin, double *DistanceMax )<br />

T distance ss ( Htuple RowA1, Htuple ColumnA1, Htuple RowA2,<br />

Htuple ColumnA2, Htuple RowB1, Htuple ColumnB1, Htuple RowB2,<br />

Htuple ColumnB2, Htuple *DistanceMin, Htuple *DistanceMax )<br />

Calculate the distances between two line segments.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.7. GEOMETRY 745<br />

The operator (T )distance ss calculates the minimal and maximal distance between two line segments.<br />

As input the rows and columns of the first line segments (RowA1,ColumnA1, RowA2,ColumnA2) and of the<br />

second line segment (RowB1,ColumnB1,RowB2,ColumnB2) are used. The parameters DistanceMin and<br />

DistanceMax return the result of the calculation. If the line segments are intersecting DistanceMin returns<br />

zero.<br />

Parameter<br />

º RowA1 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the first point of the line segment.<br />

º ColumnA1 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the first point of the line segment.<br />

º RowA2 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the second point of the line segment.<br />

º ColumnA2 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the second point of the line segment.<br />

º RowB1 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the first point of the line.<br />

º ColumnB1 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the first point of the line.<br />

º RowB2 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the second point of the line.<br />

º ColumnB2 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the second point of the line.<br />

º DistanceMin (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Minimal distance between the line segments<br />

º DistanceMax (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Maximal distance between the line segments<br />

Example<br />

create_tuple(&RowA1, 1);<br />

set_i(RowA1, 8, 0);<br />

create_tuple(&ColumnA1, 1);<br />

set_i(ColumnA1, 7, 0);<br />

create_tuple(&RowA2, 1);<br />

set_i(RowA2, 15, 0);<br />

create_tuple(&ColumnA2, 1);<br />

set_i(ColumnA2, 11, 0);<br />

create_tuple(&RowB1, 1);<br />

set_i(RowB1, 2, 0);<br />

create_tuple(&ColumnB1, 1);<br />

set_i(ColumnB1, 4, 0);<br />

create_tuple(&RowB2, 1);<br />

set_i(RowB2, 6, 0);<br />

create_tuple(&ColumnB2, 1);<br />

set_i(ColumnB2, 10, 0);<br />

T_distance_ss(RowA1,ColumnA1,RowA2,ColumnA2,RowB1,ColumnB1,RowB2,ColumnB2,<br />

&distance_min,&distance_max);<br />

aa_min = get_d(distance_min,0);<br />

aa_max = get_d(distance_max,0);<br />

(T )distance ss returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )distance ss is reentrant and processed without parallelization.<br />

(T )distance pp<br />

Alternatives<br />

<strong>HALCON</strong> 6.0


746 CHAPTER 12. TOOLS<br />

(T )distance pl, (T )distance ps<br />

Basic operators<br />

See Also<br />

Module<br />

get points ellipse ( double Angle, double Row, double Column,<br />

double Phi, double Radius1, double Radius2, double *RowPoint,<br />

double *ColPoint )<br />

T get points ellipse ( Htuple Angle, Htuple Row, Htuple Column,<br />

Htuple Phi, Htuple Radius1, Htuple Radius2, Htuple *RowPoint,<br />

Htuple *ColPoint )<br />

Points of an ellipse corresponding to specific angles.<br />

(T )get points ellipse returns the points (RowPoint,ColPoint) on the specified ellipse corresponding<br />

to the angles in Angle, which refer to the main axis of the ellipse. The ellipse itself is characterized by the center<br />

(Row, Column), the orientation of the main axis Phi, the length of the larger half axis Radius1, and the length<br />

of the smaller half axis Radius2.<br />

Parameter<br />

º Angle (input control) ................................................real(-array) (Htuple .) double<br />

Angles corresponding to the resulting points [rad].<br />

Default Value : 0<br />

Restriction : ´Angle 0µ ´Angle 6.283185307µ<br />

º Row (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.y (Htuple .) double<br />

Row coordinate of the center of the ellipse.<br />

º Column (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ellipse.center.x (Htuple .) double<br />

Column coordinate of the center of the ellipse.<br />

º Phi (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.angle.rad (Htuple .) double<br />

Orientation of the main axis [rad].<br />

Restriction : ´Phi 0µ ´Phi 6.283185307µ<br />

º Radius1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius1 (Htuple .) double<br />

Length of the larger half axis.<br />

Restriction : Radius1 0<br />

º Radius2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius2 (Htuple .) double<br />

Length of the smaller half axis.<br />

Restriction : Radius2 0<br />

º RowPoint (output control) ....................................point.row(-array) (Htuple .) double *<br />

Row coordinates of the points on the ellipse.<br />

º ColPoint (output control) .................................point.column(-array) (Htuple .) double *<br />

Column coordinates of the points on the ellipse.<br />

Example<br />

draw_ellipse(WindowHandle,Row,Column,Phi,Radius1,Radius2)<br />

get_points_ellipse([0,3.14],Row,Column,Phi,Radius1,Radius2,RowPoint,ColPoint)<br />

Result<br />

(T )get points ellipse returns H MSG TRUE if all parameter values are correct. If necessary, an exception<br />

is raised.<br />

Parallelization Information<br />

(T )get points ellipse is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

fit ellipse contour xld, draw ellipse, gen ellipse contour xld<br />

gen ellipse contour xld<br />

See Also<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.7. GEOMETRY 747<br />

Basic operators<br />

Module<br />

intersection ll ( double RowA1, double ColumnA1, double RowA2,<br />

double ColumnA2, double RowB1, double ColumnB1, double RowB2,<br />

double ColumnB2, double *Row, double *Column, long *IsParallel )<br />

T intersection ll ( Htuple RowA1, Htuple ColumnA1, Htuple RowA2,<br />

Htuple ColumnA2, Htuple RowB1, Htuple ColumnB1, Htuple RowB2,<br />

Htuple ColumnB2, Htuple *Row, Htuple *Column, Htuple *IsParallel )<br />

Calculate the intersection point of two lines.<br />

The operator (T )intersection ll calculates the intersection point of two lines. As input the columns<br />

and rows of the lines (RowA1,ColumnA1, RowA2,ColumnA2) and(RowB1,ColumnB1, RowB2,ColumnB2)<br />

are expected. The parameters Row and Column return the result of the calculation. If the lines are parallel<br />

IsParallel is 1 else 0. In addition the values of Row and Column are undefined.<br />

Attention<br />

If the lines are parallel the values of Row and Column are undefined.<br />

Parameter<br />

º RowA1 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the first point of the first line.<br />

º ColumnA1 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the first point of the first line.<br />

º RowA2 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the second point of the first line.<br />

º ColumnA2 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the second point of the first line.<br />

º RowB1 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the first point of the second line.<br />

º ColumnB1 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the first point of the second line.<br />

º RowB2 (input control) .......................................point.y(-array) (Htuple .) double / long<br />

Row of the second point of the second line.<br />

º ColumnB2 (input control) ...................................point.x(-array) (Htuple .) double / long<br />

Column of the second point of the second line.<br />

º Row (output control) .............................................point.y(-array) (Htuple .) double *<br />

Row of the intersection point<br />

º Column (output control) .........................................point.x(-array) (Htuple .) double *<br />

Column of the intersection point<br />

º IsParallel (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long *<br />

Are the two lines parallel?<br />

create_tuple(&rowA1, 1);<br />

set_i(rowA1, 8, 0);<br />

create_tuple(&columnA1, 1);<br />

set_i(columnA1, 7, 0);<br />

create_tuple(&rowA2, 1);<br />

set_i(rowA2, 15, 0);<br />

create_tuple(&columnA2, 1);<br />

set_i(columnA2, 11, 0);<br />

create_tuple(&RowB1, 1);<br />

set_i(RowB1, 2, 0);<br />

create_tuple(&ColumnB1, 1);<br />

Example<br />

<strong>HALCON</strong> 6.0


748 CHAPTER 12. TOOLS<br />

set_i(ColumnB1, 4, 0);<br />

create_tuple(&RowB2, 1);<br />

set_i(RowB2, 6, 0);<br />

create_tuple(&ColumnB2, 1);<br />

set_i(ColumnB2, 10, 0);<br />

T_intersection_ll(rowA1,columnA1,rowA2,columnA2,RowB1,ColumnB1,RowB2,ColumnB2,<br />

&row_i,&column_i,&parallel);<br />

aa_min = get_d(row_i,0);<br />

aa_max = get_d(column_i,0);<br />

(T )intersection ll returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )intersection ll is reentrant and processed without parallelization.<br />

Basic operators<br />

Module<br />

projection pl ( double Row, double Column, double Row1, double Column1,<br />

double Row2, double Column2, double *RowProj, double *ColProj )<br />

T projection pl ( Htuple Row, Htuple Column, Htuple Row1,<br />

Htuple Column1, Htuple Row2, Htuple Column2, Htuple *RowProj,<br />

Htuple *ColProj )<br />

Calculate the projection of a point onto a line.<br />

The operator (T )projection pl calculates the projection of a point (Row,Column) onto a line which is<br />

represent by the start point (Row1,Column1) and the end point (Row2,Column2). RowProj is the row of the<br />

projection point and ColProj is the column of the projection point.<br />

Parameter<br />

º Row (input control) ..........................................point.y(-array) (Htuple .) double / long<br />

Row of the point.<br />

º Column (input control) ......................................point.x(-array) (Htuple .) double / long<br />

Column of the point.<br />

º Row1 (input control) ........................................point.y(-array) (Htuple .) double / long<br />

Row of the first point of the line.<br />

º Column1 (input control) ....................................point.x(-array) (Htuple .) double / long<br />

Column of the first point of the line.<br />

º Row2 (input control) ........................................point.y(-array) (Htuple .) double / long<br />

Row of the second point of the line.<br />

º Column2 (input control) ....................................point.x(-array) (Htuple .) double / long<br />

Column of the second point of the line.<br />

º RowProj (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Row of the projection<br />

º ColProj (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Column of the projection<br />

Example<br />

projection_pl(row,column,row1,column1,row2,column2,<br />

&row_proj,&col_proj);<br />

(T )projection pl returns H MSG TRUE.<br />

Result<br />

Parallelization Information<br />

(T )projection pl is reentrant and processed without parallelization.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.8. HOUGH 749<br />

Basic operators<br />

Module<br />

12.8 Hough<br />

hough circle trans ( Hobject Region, Hobject *HoughImage, long Radius )<br />

T hough circle trans ( Hobject Region, Hobject *HoughImage,<br />

Htuple Radius )<br />

Return the Hough-Transform for circles with a given radius.<br />

The operator (T )hough circle trans calculates the Hough transform for circles with a certain Radius<br />

in the regions passed by Region. Hereby the centres of all possible circles in the parameter space (the Hough<br />

or accumulator space respectively) will be accumulated for each point in the image space. Circle hypotheses<br />

supported by many points in the input region thereby generate a maximum in the area showing the circle’s centre<br />

in the output image (HoughImage). The circles’ centres in the image space can be deduced from the coordinates<br />

of these maximums by subtracting the Radius. If more than one radius is transmitted, all Hough images will be<br />

shifted according to the maximal radius.<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Binary edge image in which the circles are to be detected.<br />

º HoughImage (output object) ........................................image(-array) Hobject * :int2<br />

Hough transform for circles with a given radius.<br />

Parameter Number : HoughImage Radius<br />

º Radius (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Radius of the circle to be searched in the image.<br />

Default Value : 12<br />

Typical Range of Values : 3 Radius (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Parameter Number : ´1 Radiusµ 500<br />

Result<br />

The operator (T )hough circle trans returns the value H MSG TRUE if the input is not empty.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,), the behavior in case of empty region is set via set system<br />

(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )hough circle trans is reentrant and processed without parallelization.<br />

Region processing<br />

Module<br />

hough circles ( Hobject RegionIn, Hobject *RegionOut, long Radius,<br />

long Percent, long Mode )<br />

T hough circles ( Hobject RegionIn, Hobject *RegionOut, Htuple Radius,<br />

Htuple Percent, Htuple Mode )<br />

Centres of circles for a specific radius.<br />

(T )hough circle trans detects the centres of circles in regions with the help of the Hough transform for<br />

circles with a specific radius.<br />

<strong>HALCON</strong> 6.0


750 CHAPTER 12. TOOLS<br />

Parameter<br />

º RegionIn (input object) ..........................................................region Hobject<br />

Binary edge image in which the circles are to be detected.<br />

º RegionOut (output object) ...............................................region(-array) Hobject *<br />

Centres of those circles which are included in the edge image by Percent percent.<br />

Parameter Number : RegionOut ´´Radius ¡ Percentµ ¡ Modeµ<br />

º Radius (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Radius of the circle to be searched in the image.<br />

Default Value : 12<br />

Typical Range of Values : 2 Radius 500 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Parameter Number : ´1 Radiusµ 500<br />

º Percent (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Indicates the percentage (approximately) of the (ideal) circle which must be present in the edge image<br />

RegionIn.<br />

Default Value : 60<br />

Typical Range of Values : 10 Percent 100 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 5<br />

Parameter Number : ´1 Percentµ 100<br />

º Mode (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

The modus defines the position of the circle in question:<br />

0 - the radius is equivalent to the outer border of the set pixels.<br />

1 - the radius is equivalent to the centres of the circle lines pixels.<br />

2 - both 0 and 1 (a little more fuzzy, but more reliable in contrast to circles set slightly differently, necessitates<br />

50 % more processing capacity compared to 0 or 1 alone).<br />

Value List : Mode ¾0, 1, 2<br />

Parameter Number : ´1 Modeµ 3<br />

Result<br />

The operator (T )hough circles returns the value H MSG TRUE if the input is not empty. The<br />

behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,), the behavior in case of empty region is set via set system<br />

(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

(T )hough circles is reentrant and processed without parallelization.<br />

Region processing<br />

Module<br />

hough line trans ( Hobject Region, Hobject *HoughImage,<br />

long AngleResolution )<br />

Produce the Hough transform for lines within regions.<br />

The operator hough line trans calculates the Hough transform for lines in those regions transmitted by<br />

Region. Thereby the angles and the lengths of the lines normal vectors are registered in the parameter space<br />

(the Hough- or accumulator space respectively). This means that the parameterization is executed according to the<br />

HNF.<br />

The result is registered in a newly generated Int2-Image (HoughImage), whereby the x-axis is equivalent to the<br />

angle between the normal vector and the x-axis (in the original image), and the y-axis is equivalent to the distance<br />

of the line from the origin.<br />

The angle ranges from -90 to 180 degrees and will be registered with a resolution of ½ÒÐÊ×ÓÐÙØÓÒ,which<br />

means that one pixel in x-direction is equivalent to ½ÒÐÊ×ÓÐÙØÓÒand that the HoughImage has a width of<br />

¾¼£ÒÐÊ×ÓÐÙØÓÒ·½ pixel. The height of the HoughImage corresponds to the diagonal of the surrounding<br />

rectangle of the input region.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.8. HOUGH 751<br />

The maxima in the result image are equivalent to the parameter values of the lines in the original image.<br />

Parameter<br />

º Region (input object) .............................................................region Hobject<br />

Binary edge image in which lines are to be detected.<br />

º HoughImage (output object) ...............................................image Hobject * :int2<br />

Hough transform for lines.<br />

º AngleResolution (input control) ..................................................integer long<br />

Adjusting the resolution in the angle area.<br />

Default Value : 4<br />

Value List : AngleResolution ¾1, 2, 4, 8<br />

Result<br />

The operator hough line trans returns the value H MSG TRUE if the input is not empty. The<br />

behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,), the behavior in case of empty region is set via set system<br />

(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

hough line trans is reentrant and processed without parallelization.<br />

threshold, skeleton<br />

threshold, local max<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

(T )hough circle trans, gen region hline<br />

Region processing<br />

Module<br />

T hough lines ( Hobject RegionIn, Htuple AngleResolution,<br />

Htuple Threshold, Htuple AngleGap, Htuple DistGap, Htuple *Angle,<br />

Htuple *Dist )<br />

Detect lines in edge images with the help of the Hough transform and returns it in HNF.<br />

The operator T hough lines allows the selection of linelike structures in a region, whereby it is not necessary<br />

that the individual points of a line are connected. This process is based on the Hough transform. The lines are<br />

returned in HNF, that is by the direction and length of their normal vector.<br />

The parameter AngleResolution defines the degree of exactness concerning the determination of the angles.<br />

It amounts to ½ÒÐÊ×ÓÐÙØÓÒ degree. The parameter Threshold determines by how many points of the<br />

original region a line’s hypothesis has to be supported at least in order to be taken over into the output. The parameters<br />

AngleGap and DistGap define a neighborhood of the points in the Hough image in order to determine the<br />

local maxima. The lines are returned in HNF.<br />

Parameter<br />

º RegionIn (input object) ..........................................................region Hobject<br />

Binary edge image in which the lines are to be detected.<br />

º AngleResolution (input control) ..........................................integer Htuple . long<br />

Adjusting the resolution in the angle area.<br />

Default Value : 4<br />

Value List : AngleResolution ¾1, 2, 4, 8<br />

º Threshold (input control) ...................................................integer Htuple . long<br />

Threshold value in the Hough image.<br />

Default Value : 100<br />

Typical Range of Values : 1 Threshold<br />

º AngleGap (input control) ....................................................integer Htuple . long<br />

Minimal distance of two maxima in the Hough image (direction: angle).<br />

Default Value : 5<br />

Typical Range of Values : 0 AngleGap<br />

<strong>HALCON</strong> 6.0


752 CHAPTER 12. TOOLS<br />

º DistGap (input control) .....................................................integer Htuple . long<br />

Minimal distance of two maxima in the Hough image (direction: distance).<br />

Default Value : 5<br />

Typical Range of Values : 0 DistGap<br />

º Angle (output control) ...................................hesseline.angle.rad-array Htuple . double *<br />

Angles (in radians) of the detected lines’ normal vectors.<br />

Typical Range of Values : -1.5707963 Angle 3.1415927<br />

º Dist (output control) .....................................hesseline.distance-array Htuple . double *<br />

Distance of the detected lines from the origin.<br />

Typical Range of Values : -1.5707963 Dist 3.1415927<br />

Parameter Number : Dist Angle<br />

Result<br />

The operator T hough lines returns the value H MSG TRUE if the input is not empty. The behavior<br />

in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,), the behavior in case of empty region is set via set system<br />

(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

T hough lines is reentrant and processed without parallelization.<br />

threshold, skeleton<br />

T select matching lines<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

hough line trans, gen region hline, (T )hough circles<br />

Region processing<br />

Module<br />

T select matching lines ( Hobject RegionIn, Hobject *RegionLines,<br />

Htuple AngleIn, Htuple DistIn, Htuple LineWidth, Htuple Thresh,<br />

Htuple *AngleOut, Htuple *DistOut )<br />

Select those lines from a set of lines (in HNF) which fit best into a region.<br />

Lines which fit best into a region can be selected from a set of lines which are available in HNF with the help of the<br />

operator T select matching lines; the region itself is also transmitted as a parameter (RegionIn). The<br />

width of the lines can be indicated by the parameter LineWidth. The selected lines will be returned in HNF and<br />

as regions (RegionLines).<br />

The lines are selected iteratively in a loop: At first, the line showing the greatest overlap with the input region<br />

is selected from the set of input lines. This line will then be taken over into the ouput set whereby all points<br />

belonging to that line will not be considered in the further steps determining overlaps. The loop will be left when<br />

the maximum overlap value of the region and the lines falls below a certain threshold value (Thresh). The<br />

selected lines will be returned as regions as well as in HNF.<br />

Parameter<br />

º RegionIn (input object) ..........................................................region Hobject<br />

Region in which the lines are to be matched.<br />

º RegionLines (output object) ..............................................region-array Hobject *<br />

Region array containing the matched lines.<br />

º AngleIn (input control) ...................................hesseline.angle.rad-array Htuple . double<br />

Angles (in radians) of the normal vectors of the input lines.<br />

Typical Range of Values : -1.5707963 AngleIn 3.1415927<br />

º DistIn (input control) .....................................hesseline.distance-array Htuple . double<br />

Distances of the input lines form the origin.<br />

Typical Range of Values : -1.5707963 DistIn 3.1415927<br />

Parameter Number : DistIn AngleIn<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.9. KALMAN-FILTER 753<br />

º LineWidth (input control) ...................................................integer Htuple . long<br />

Widths of the lines.<br />

Default Value : 7<br />

Typical Range of Values : 1 LineWidth<br />

º Thresh (input control) .......................................................integer Htuple . long<br />

Threshold value for the number of line points in the region.<br />

Default Value : 100<br />

Typical Range of Values : 1 Thresh<br />

º AngleOut (output control) ..............................hesseline.angle.rad-array Htuple . double *<br />

Angles (in radians) of the normal vectors of the selected lines.<br />

Typical Range of Values : -1.5707963 AngleOut 3.1415927<br />

Parameter Number : AngleOut AngleIn<br />

º DistOut (output control) .................................hesseline.distance-array Htuple . double *<br />

Distances of the selected lines from the origin.<br />

Typical Range of Values : -1.5707963 DistOut 3.1415927<br />

Parameter Number : DistOut AngleOut<br />

Result<br />

The operator T select matching lines returns the value H MSG TRUE if the input is not empty.<br />

The behavior in case of empty input (no input regions available) is set via the operator set system<br />

(’no object result’,), the behavior in case of empty region is set via set system<br />

(’empty region result’,). If necessary an exception handling is raised.<br />

Parallelization Information<br />

T select matching lines is reentrant and processed without parallelization.<br />

T hough lines<br />

Region processing<br />

Possible Predecessor Functions<br />

Module<br />

12.9 Kalman-Filter<br />

T filter kalman ( Htuple Dimension, Htuple Model, Htuple Measurement,<br />

Htuple PredictionIn, Htuple *PredictionOut, Htuple *Estimate )<br />

Estimate the current state of a system with the help of the Kalman filtering.<br />

The operator T filter kalman returns an estimate of the current state (or also a prediction of a future state)<br />

of a discrete, stochastically disturbed, linear system. In practice, Kalman filters are used successfully in image<br />

processing in the analysis of image sequences (background identification, lane tracking with the help of line tracing<br />

or region analysis, etc.). A short introduction concerning the theory of the Kalman filters will be followed by a<br />

detailed description of the routine T filter kalman itself.<br />

KALMAN FILTER: A discrete, stochastically disturbed, linear system is characterized by the following markers:<br />

¯ State ܴص: Describes the current state of the system (speeds, temperatures,...).<br />

¯ Parameter ٴص: Inputs from outside into the system.<br />

¯ Measurement ݴص: Measurements gained by observing the system. They indicate the state of the system (or<br />

at least parts of it).<br />

¯ An output function describing the dependence of the measurements on the state.<br />

¯ A transition function indicating how the state changes with regard to time, the current value and the parameters.<br />

The output function and the transition function are linear. Their application can therefore be written as a multiplication<br />

with a matrix.<br />

The transition function is described with the help of the transition matrix ´Øµ and the parameter matrix , the initial<br />

function is described by the measurement matrix ´Øµ. Hereby ´Øµ characterizes the dependency of the new state<br />

<strong>HALCON</strong> 6.0


754 CHAPTER 12. TOOLS<br />

on the old, ´Øµ indicates the dependency on the parameters. In practice it is rarely possible (or at least too time<br />

consuming) to describe a real system and its behaviour in a complete and exact way. Normally only a relatively<br />

small number of variables will be used to simulate the behaviour of the system. This leads to an error, the so called<br />

system error (also called system disturbance) ڴص.<br />

The output function, too, is usually not exact. Each measurement is faulty. The measurement errors will be called<br />

۴ص. Therefore the following system equations arise:<br />

Ü´Ø ·½µ´ØµÜ´Øµ ·´ØµÙ´Øµ ·Ú´Øµ<br />

ݴص ´ØµÜ´Øµ ·Û´Øµ<br />

The system error ڴص and the measurement error ۴ص are not known. As far as systems are concerned which<br />

are interpreted with the help of the Kalman filter, these two errors are considered as Gaussian distributed random<br />

vectors (therefore the expression ”‘stochastically disturbed systems”’). Therefore the system can be calculated, if<br />

the corresponding expected values for ڴص and ۴ص as well as the covariance matrices are known.<br />

The estimation of the state of the system is carried out in the same way as in the Gaussian-Markov-estimation.<br />

However, the Kalman filter is a recursive algorithm which is based only on the current measurements ݴص and the<br />

latest state ܴص. The latter implicitly also includes the knowlegde about earlier measurements.<br />

A suitable estimate value Ü ¼, which is interpreted as the expected value of a random variable for Ü´¼µ, mustbe<br />

indicated for the initial value Ü´¼µ. This variable should have an expected error value of 0 and the covariance<br />

matrix È ¼ which also has to be indicated. At a certain time Ø the expected values of both disturbances ڴص and<br />

۴ص should be 0 and their covariances should be ɴص and ʴص. ܴص, ڴص and ۴ص will usually be assumed to be<br />

not correlated (any kind of noise-process can be modelled - however the development of the necessary matrices by<br />

the user will be considerably more demanding). The following conditions must be met by the searched estimate<br />

values Ü Ø :<br />

¯ The estimate values Ü Ø are linearly dependent on the actual value ܴص and on the measurement sequence<br />

Ý´¼µ, Ý´½µ, ¡¡¡, ݴص.<br />

¯ Ü Ø being hereby considered to meet its expectations, i.e. Ü Ø Ü´Øµ.<br />

¯ The grade criterion for Ü Ø is the criterion of minimal variance, i.e. the variance of the estimation error defined<br />

as ܴص Ü Ø , being as small as possible.<br />

After the initialization<br />

Ü´¼µ Ü ¼ , È ´¼µ È ¼<br />

at each point in time Ø the Kalman filter executes the following calculation steps:<br />

È ´Øµ ¼´Øµ<br />

´Ã ÁÁÁµ ôص <br />

´Øµ È ´Øµ ¼´Øµ·Ê´Øµ<br />

´Ã ÁÎ µ Ü Ø Ü´Øµ ·Ã´Øµ´Ý´Øµ ´ØµÜ´Øµµ<br />

´Ã Î µ È ´Øµ È ´Øµ ôص´Øµ È ´Øµ<br />

´Ã Áµ Ü´Ø ·½µ ´ØµÜ Ø · ´ØµÙ´Øµ<br />

´Ã ÁÁµ È ´Ø ·½µ ´Øµ È ´Øµ ¼´Øµ ·É´Øµ<br />

Hereby È ´Øµ is the covariance matrix of the estimation error, ܴص is the extrapolation value respective the prediction<br />

value of the state, È ´Øµ are the covariances of the prediction error Ü Ü, à is the amplifier matrix (the so<br />

called Kalman gain), and ¼ is the transposed of a matrix .<br />

Please note that the prediction of the future state is also possible with the equation (K-I). Somtimes this is very<br />

useful in image processing in order to determine ”‘regions of interest”’ in the next image.<br />

As mentioned above, it is much more demanding to model any kind of noise processes. If for example the system<br />

noise and the measurement noise are correlated with the corresponding covariance matrix Ä, the equations for the<br />

Kalman gain and the error covariance matrix have to be modified:<br />

È ´Øµ ¼´Øµ·Ä´Øµ<br />

´Ã ÁÁÁµ ôص <br />

´Øµ È ´Øµ·´ØµÐ´Øµ·Ä ¼ ¼´Øµ·Ê´Øµ<br />

´Ã Î µ È ´Øµ ´ È ´Øµ ôص´Øµ È ´Øµµ È ´Øµ ôصĴص<br />

This means that the user himself has to establish the linear system equations from (K-I) up to (K-V) with respect to<br />

the actual problem. The user must therefore develop a mathematical model upon which the solution to the problem<br />

can be based. Statistical characteristics describing the inaccuracies of the system as well as the measurement<br />

errors, which are to be expected, thereby have to be estimated if they cannot be calculated exactly. Therefore the<br />

following individual steps are necessary:<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.9. KALMAN-FILTER 755<br />

1. Developing a mathematical model<br />

2. Selecting characteristic state variables<br />

3. Establishing the equations describing the changes of these state variables and their linearization (matrices <br />

and )<br />

4. Establishing the equations describing the dependency of the measurement values of the system on the state<br />

variables and their linearization (matrix )<br />

5. Developing or estimating of statistical dependencies between the system disturbances (matrix É)<br />

6. Developing or estimating of statistical dependencies between the measurement errors (matrix Ê)<br />

7. Initialization of the initial state<br />

As mentioned above, the initialization of the system (point 7) hereby necessitates to indicate an estimate Ü ¼ of the<br />

state of the system at the time 0 and the corresponding covariance matrix È ¼ . If the exact initial state is not known,<br />

it is recommendable to set the components of the vector Ü ¼ to the average values of the corresponding range, and<br />

to set high values for È ¼ (about the size of the squares of the range). After a few iterations (when the number of the<br />

accumulated measurement values in total has exceeded the number of the system values), the values which have<br />

been determined in this way are also useable.<br />

If on the other hand the initial state is known exactly, all entries for È ¼ have to be set to 0, because È ¼ describes<br />

the covariances of the error between the estimated value Ü ¼ and the actual value Ü´¼µ.<br />

THE FILTER ROUTINE:<br />

A Kalman filter is dependent on a range of data which can be organized in four groups:<br />

Model parameter: transition matrix , control matrix including the parameter Ù and the measurement matrix<br />

<br />

Model stochastic: system-error covariance matrix É, system-error - measurement-error covariance matrix Ä,and<br />

measurement-error covariance matrix Ê<br />

Measurement vector: Ý<br />

History of the system: extrapolation vector Ü and extrapolation-error covariance matrix È <br />

Thereby many systems can work without input ”‘from outside”’, i.e. without and Ù. Further, system errors and<br />

measurement errors are normally not correlated (Ä is dropped).<br />

Actually the data necessary for the routine will be set by the following parameters:<br />

Dimension: This parameter includes the dimensions of the status vector, the measurement vector and the controller<br />

vector. Dimension thereby is a vector [n,m,p], whereby n indicates the number of the state variables,<br />

m the number of the measurement values and p the number of the controller members. For a system without<br />

determining control (i.e. without influence ”‘from outside”’) therefore [n,m,0] has to be passed.<br />

Model: This parameter includes the lined up matrices (vectors) A,C,Q,G,u and (if necessary) L having been<br />

stored in row-major order. Model therefore is a vector of the length ҢҷҢѷҢҷҢԷԷҢÑ℄.<br />

The last summand is dropped, in case the system errors and measurement errors are not correlated, i.e. there<br />

is no value for L.<br />

Measurement: This parameter includes the matrix R which has been stored in row-major order, and the measurement<br />

vector y lined up. Measurement therefore is a vector of the dimension Ñ ¢ Ñ · Ñ.<br />

PredictionIn / PredictionOut: These two parameters include the matrix È (the extrapolation-error covariance<br />

matrix) which has been stored in row-major order and the extrapolation vector Ü lined up. This<br />

means, they are vectors of the length Ò ¢ Ò · Ò. PredictionIn therefore is an input parameter, which<br />

must contain È ´Øµ and ܴص at the current time Ø. With PredictionOut the routine returns the corresponding<br />

predictions È ´Ø ·½µand Ü´Ø ·½µ.<br />

Estimate: With this parameter the routine returns the matrix È (the estimation-error covariance matrix) which<br />

has been stored in row-major order and the estimated state Ü lined up. Estimate therefore is a vector of<br />

the length Ò ¢ Ò · Ò.<br />

Please note that the covariance matrices (É Ê È È ) must of course be symmetric.<br />

<strong>HALCON</strong> 6.0


756 CHAPTER 12. TOOLS<br />

Parameter<br />

º Dimension (input control) .............................................integer-array Htuple . long<br />

The dimensions of the state vector, the measurement and the controller vector.<br />

Default Value : ’[3,1,0]’<br />

Typical Range of Values : 0 Dimension 30<br />

º Model (input control) ...................................................real-array Htuple . double<br />

The lined up matrices É, possibly and Ù, and if necessary Ä which have been stored in row-major<br />

order.<br />

Default Value : ’[1.0,1.0,0.5,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,54.3,37.9,48.0,37.9,34.3,42.5,48.0,42.5,43.7]’<br />

Typical Range of Values : 0.0 Model 10000.0<br />

º Measurement (input control) ...........................................real-array Htuple . double<br />

The matrix Ê stored in row-major order and the measurement vector Ý lined up.<br />

Default Value : ’[1.2,1.0]’<br />

Typical Range of Values : 0.0 Measurement 10000.0<br />

º PredictionIn (input control) ..........................................real-array Htuple . double<br />

The matrix È (the extrapolation-error covariances) stored in row-major order and the extrapolation vector Ü<br />

lined up.<br />

Default Value : ’[0.0,0.0,0.0,0.0,180.5,0.0,0.0,0.0,100.0,0.0,100.0,0.0]’<br />

Typical Range of Values : 0.0 PredictionIn 10000.0<br />

º PredictionOut (output control) ......................................real-array Htuple . double *<br />

The matrix P£ (the extrapolation-error covariances)stored in row-major order and the extrapolation vector Ü<br />

lined up.<br />

º Estimate (output control) ............................................real-array Htuple . double *<br />

The matrix È (the estimation-error covariances) stored in row-major order and the estimated state Ü lined up.<br />

Example<br />

/* Typical procedure: */<br />

/* 1. To initialize the variables<br />

which describe the model, e.g. with */<br />

read_kalman("kalman.init",Dim,Mod,Meas,Pred) ;<br />

/* Generation of the first measurements (typically of the<br />

first image of an image series) with an appropriate<br />

problem-specific routine (there is a fictitious routine<br />

extract_features in this example): */<br />

extract_features(Image1,Meas,&Meas1) ;<br />

/* first Kalman-Filtering: */<br />

filter_kalman(Dim,Mod,Meas1,Pred,&Pred1,&Est1) ;<br />

/* To use the estimate value (if need be the prediction too) */<br />

/* with a problem-specific routine (here use_est): */<br />

use_est(Est1) ;<br />

/* To get the next measurements (e.g. from the next image): */<br />

extract_next_features(Image2,Meas1,&Meas2) ;<br />

/* if need be Update of the model parameter (a constant model) */<br />

/* second Kalman-Filtering: */<br />

filter_kalman(Dim,Mod,Meas2,Pred1,&Pred2,&Est2) ;<br />

use_est(Est2) ;<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.9. KALMAN-FILTER 757<br />

extract_next_features(Image3,Meas2,&Meas3) ;<br />

/* etc. */<br />

Result<br />

If the parameter values are correct, the operator T filter kalman returns the value H MSG TRUE. Otherwise<br />

an exception handling will be raised.<br />

Parallelization Information<br />

T filter kalman is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T read kalman, T sensor kalman<br />

T update kalman<br />

Possible Successor Functions<br />

See Also<br />

T read kalman, T update kalman, T sensor kalman<br />

Bibliography<br />

W.Hartinger: ”‘Entwurf eines anwendungsunabh”angigen Kalman-Filters mit Untersuchungen im Bereich der<br />

Bildfolgenanalyse”’; Diplomarbeit; Technische Universit”at M”unchen, Institut f”ur Informatik, Lehrstuhl Prof.<br />

Radig; 1991.<br />

R.E.Kalman: ”‘A New Approach to Linear Filtering and Prediction Problems”’; Transactions ASME, Ser.D: Journal<br />

of Basic Engineering; Vol. 82, S.34-45; 1960.<br />

R.E.Kalman, P.l.Falb, M.A.Arbib: ”‘Topics in Mathematical System Theory”’; McGraw-Hill Book Company,<br />

New York; 1969.<br />

K-P. Karmann, A.von Brandt: ”‘Moving Object Recognition Using an Adaptive Background Memory”’; Time-<br />

Varying Image Processing and Moving Object Recognition 2 (ed.: V. Cappellini), Proc. of the 3rd Interantional<br />

Workshop, Florence, Italy, May, 29th - 31st, 1989; Elsevier, Amsterdam; 1990.<br />

Module<br />

Tools<br />

T read kalman ( Htuple FileName, Htuple *Dimension, Htuple *Model,<br />

Htuple *Measurement, Htuple *Prediction )<br />

Read the description file of a Kalman filter.<br />

The operator T read kalman reads the description file FileName of a Kalman filter. Kalman filters return<br />

an estimate of the current state (or even the prediction of a future state) of a discrete, stochastically disturbed,<br />

linear system. They are successfully used in image processing, especially in the analysis of image sequences. A<br />

Kalman filtering is based on a mathematical model of the system to be examined which at any point in time has<br />

the following characteristics:<br />

Model parameter: transition matrix , control matrix including the controller output Ù and the measurement<br />

matrix <br />

Model stochastic: system-error covariance matrix É, system-error - measurement-error covariance matrix Ä and<br />

measurement-error covariance matrix Ê<br />

Estimate of the initial state of the system: state Ü ¼ and corresponding covariance matrix È ¼<br />

Many systems do not need entries ”‘from outside”’, and therefore and Ù can be dropped. Further, system errors<br />

and measurement errors are normally not correlated (Ä is dropped). The characteristics mentioned above can be<br />

stored in an ASCII-file and then can be read with the help of the operator T read kalman. This ASCII-file must<br />

have the following structure:<br />

+ content row<br />

+matrix<br />

+ atrix <br />

+matrixÉ<br />

Dimension row<br />

<strong>HALCON</strong> 6.0


758 CHAPTER 12. TOOLS<br />

[ + matrix + vector Ù ]<br />

[ + matrix Ä ]<br />

+matrixÊ<br />

[ + matrix È ¼ ]<br />

[ + vector Ü ¼ ]<br />

The dimension row thereby is always of the following form:<br />

n=integer m=integer p=integer<br />

whereby n indicates the number of the state variables, m the number of the measurement values and p the number<br />

of the controller members (see also Dimension). The maximal dimension will hereby be limited by a system<br />

constant (= 30 for the time being).<br />

The content row has the following form:<br />

£ £ É £ £ Ù £ Ä £ Ê £ È £ Ü£<br />

and describes the following content of the file. Instead of ’£’, ’+’ (= parameter is available) respectively ’-’ (=<br />

parameter is missing) have to be set. Please note that only the parameters marked by [...] in the above list may be<br />

left out in the description file. If the initial state estimate ¼ is missing (i.e. ’x-’), the components of the vector will<br />

supposed to be 0.0. If the covariance matrix È ¼ of the initial state estimate is missing (i.e. ’P-’), the error will be<br />

supposed to be tremendous. In this case the matrix elements will be set to 10000.0. This value seems to be very<br />

high, however, it is only sufficient if the range of components of the state vector x is smaller to the tenth power.<br />

´Ö ¢ ×µ matrices will be stored per row in the following form:<br />

ÃÓÑÑÒØÖ ×ØÖÒ <br />

½½ ½¾ ¡¡¡ ½× <br />

.<br />

. .. . Ö½ Ö¾ ¡¡¡ Ö× <br />

(the spaces and line feed characters can be chosen at will),<br />

vectors will be stored correspondingly in the following form:<br />

ÓÑÑÒØ ×ØÖÒ <br />

½ ¡¡¡ <br />

The following parameter values are returned by the operator T read kalman:<br />

Dimension: This parameter includes the dimensions of the status vector, the measurement vector and the controller<br />

vector. Dimension thereby is a vector [n,m,p], whereby n indicates the number of the state variables,<br />

m the number of the measurement values and p the number of the controller members. For a system without<br />

determining control (i.e. without influence ”‘from outside”’) therefore Dimension = [n,m,0].<br />

Model: This parameter includes the lined up matrices (vectors) A, C, Q, G, u and (if necessary) L having been<br />

stored in row-major order. Model therefore is a vector of the length ҢҷҢѷҢҷҢԷԷҢÑ℄.<br />

The last summand is dropped, in case the system errors and measurement errors are not correlated, i.e. there<br />

is no value for L.<br />

Measurement: This parameter includes the matrix Ê which has been stored in row-major order.<br />

Measurement therefore is vector of the dimension Ñ ¢ Ñ.<br />

Prediction: This parameter includes the matrix È ¼ (the error covariance matrix of the initial state estimate)<br />

and the initial state estimate Ü ¼ lined up. This means, it is a vector of the length Ò ¢ Ò · Ò.<br />

Parameter<br />

º FileName (input control) ...........................................filename Htuple . const char *<br />

Description file for a Kalman filter.<br />

Default Value : ”kalman.init”<br />

º Dimension (output control) ..........................................integer-array Htuple . long *<br />

The dimensions of the state vector, the measurement vector and the controller vector.<br />

º Model (output control) ................................................real-array Htuple . double *<br />

The lined up matrices É, possibly and Ù, and if necessary Ä stored in row-major order.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.9. KALMAN-FILTER 759<br />

º Measurement (output control) ........................................real-array Htuple . double *<br />

The matrix Ê stored in row-major order.<br />

º Prediction (output control) ..........................................real-array Htuple . double *<br />

The matrix È ¼ (error covariance matrix of the initial state estimate) stored in row-major order and the initial<br />

state estimate Ü ¼ lined up.<br />

Example<br />

/*An example of the description-file: */<br />

/* */<br />

/*n=3 m=1 p=0 */<br />

/*A+C+Q+G-u-L-R+P+x+ */<br />

/*transition matrix A: */<br />

/*1 1 0.5 */<br />

/*0 1 1 */<br />

/*0 0 1 */<br />

/*measurement matrix C: */<br />

/*1 0 0 */<br />

/*system-error covariance matrix Q: */<br />

/*54.3 37.9 48.0 */<br />

/*37.9 34.3 42.5 */<br />

/*48.0 42.5 43.7 */<br />

/*measurement-error covariance matrix R: */<br />

/*1.2 */<br />

/*estimation-error covariance matrix (for the initial estimate) P0: */<br />

/*0 0 0 */<br />

/*0 180.5 0 */<br />

/*0 0 100 */<br />

/*initial estimate x0: */<br />

/*0 100 0 */<br />

/* */<br />

/*the result of read_kalman with the upper descriptionfile */<br />

/*as inputparameter: */<br />

/* */<br />

/*Dimension = [3,1,0] */<br />

/*Model = [1.0,1.0,0.5,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0, */<br />

/* 54.3,37.9,48.0,37.9,34.3,42.5,48.0,42.5,43.7] */<br />

/*Measurement = [1.2] */<br />

/*Prediction = [0.0,0.0,0.0,0.0,180.5,0.0,0.0,0.0,100.0,0.0,100.0, */<br />

/* 0.0] */<br />

Result<br />

If the description file is readable and correct, the operator T read kalman returns the value H MSG TRUE.<br />

Otherwise an exception handling will be raised.<br />

Parallelization Information<br />

T read kalman is reentrant and processed without parallelization.<br />

T filter kalman<br />

Possible Successor Functions<br />

See Also<br />

T update kalman, T filter kalman, T sensor kalman<br />

Tools<br />

Module<br />

T sensor kalman ( Htuple Dimension, Htuple MeasurementIn,<br />

Htuple *MeasurementOut )<br />

Interactive input of measurement values for a Kalman filtering.<br />

<strong>HALCON</strong> 6.0


760 CHAPTER 12. TOOLS<br />

The operator T sensor kalman supports the interactive input of measurement values for a Kalman filtering.<br />

Kalman filters return an estimate of the current state (or even the prediction of a future state) of a discrete, stochastically<br />

disturbed, linear system. They are successfully used in image processing, especially in the analysis of image<br />

sequences.<br />

Each filtering is hereby based on certain measurement values. How these values are extracted from images or<br />

sensor data depends strongly on the individual application and therefore must be entirely up to the user. However,<br />

the operator T sensor kalman allows an interactive input of (fictitious) measurement values Ý and the corresponding<br />

measurement-error covariance matrix Ê. Especially the testing of Kalman filters during the development<br />

can hereby be facilitated.<br />

The parameters MeasurementIn and MeasurementOut include the matrix Ê which has been stored in rowmajor<br />

order and the measurement vector Ý lined up, i.e. they are vectors of the length ÑÒ×ÓÒ¢ ÑÒ×ÓÒ ·<br />

ÑÒ×ÓÒ<br />

Parameter<br />

º Dimension (input control) ...................................................integer Htuple . long<br />

Number of measurement values.<br />

Default Value : 1<br />

Typical Range of Values : 0 Dimension 30<br />

º MeasurementIn (input control) ........................................real-array Htuple . double<br />

The matrix Ê stored in row-major order and the measurement vector Ý lined up.<br />

Default Value : ’[1.2,1.0]’<br />

Typical Range of Values : 0.0 MeasurementIn 10000.0<br />

º MeasurementOut (output control) ....................................real-array Htuple . double *<br />

The matrix Ê stored in row-major order and the measurement vector Ý lined up.<br />

Result<br />

If the parameters are correct, the operator T sensor kalman returns the value H MSG TRUE. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

T sensor kalman is reentrant and processed without parallelization.<br />

T filter kalman<br />

Possible Successor Functions<br />

See Also<br />

T filter kalman, T read kalman, T update kalman<br />

Tools<br />

Module<br />

T update kalman ( Htuple FileName, Htuple DimensionIn, Htuple ModelIn,<br />

Htuple MeasurementIn, Htuple *DimensionOut, Htuple *ModelOut,<br />

Htuple *MeasurementOut )<br />

Read an update file of a Kalman filter.<br />

The operator T update kalman reads the update file FileName of a Kalman filter. Kalman filters return an<br />

estimate of the current state (or even the prediction of a future state) of a discrete, stochastically disturbed, linear<br />

system.<br />

A Kalman filtering is based on a mathematical model of the system to be examined which at any point in time has<br />

the following characteristics:<br />

Model parameter: transition matrix , control matrix including the controller output Ù and the measurement<br />

matrix <br />

Model stochastic: system-error covariance matrix É, system-error - measurement-error covariance matrix Ä and<br />

measurement-error covariance matrix Ê<br />

Measurement vector: Ý<br />

History of the system: extrapolation vector Ü and extrapolation-error covariance matrix È <br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.9. KALMAN-FILTER 761<br />

Many systems do not need entries ”‘from outside”’ and therefore and Ù can be dropped. Further, system errors<br />

and measurement errors are normally not correlated (Ä is dropped). Some of the characteristics mentioned above<br />

may change dynamically (from one iteration to the next). The operator T update kalman serves to modify<br />

parts of the system according to an update file (ASCII) with the following structure (see also T read kalman):<br />

Dimension row<br />

+ content row<br />

+matrix<br />

+matrix<br />

+matrixÉ<br />

+matrix + vector Ù<br />

+matrixÄ<br />

+matrixÊ<br />

The dimension row thereby has the following form:<br />

n=integer m=integer p=integer<br />

whereby n indicates the number of the state variables, m the number of the measurement values and p the number<br />

of the controller members (see also DimensionIn / DimensionOut). The maximal dimension will hereby be<br />

limited by a system constant (= 30 for the time being). As in this case changes should take effect at a valid model,<br />

the dimensions Ò and Ñ are invariant (and will only be indicated for purposes of control).<br />

The content row has the following form:<br />

£ £ É £ £ Ù £ Ä £ Ê£<br />

and describes the further content of the file. Instead of ’£’, ’+’ (= parameter is available) respectively ’-’ (=<br />

parameter is missing) has to be set. In contrast to description files for T read kalman, the system description<br />

needs not be complete in this case. Only those parts of the system which are changed must be indicated. The<br />

indication of estimated values is unnecessary, as these values must stem from the latest filtering according to the<br />

structure of the filter.<br />

´Ö ¢ ×µ matrices will be stored in row-major order in the following form:<br />

ÓÑÑÒØ ×ØÖÒ <br />

½½ ½¾ ¡¡¡ ½× <br />

.<br />

. .. .<br />

Ö½ Ö¾ ¡¡¡ Ö× <br />

(the spaces/line feed characters can be chosen at will),<br />

vectors will be stored correspondingly in the following form:<br />

ÓÑÑÒØÖ ×ØÖÒ <br />

½ ¡¡¡ <br />

The following parameter values of the operator T read kalman will be changed:<br />

DimensionIn / DimensionOut: These parameters include the dimensions of the state vector, measurement<br />

vector and controller vector and therefore are vectors [n,m,p], whereby n indicates the number of the state<br />

variables, m the number of the measurement values and p the number of the controller members. n and m<br />

are invariant for a given system, i.e. they must not differ from corresponding input values of the update file.<br />

For a system without without influence ”‘from outside”’ p=0.<br />

ModelIn / ModelOut: These parameters include the lined up matrices (vectors) A, C, Q, G, u and if necessary<br />

L which have been stored in row-major order. ModelIn / ModelOut therefore are vectors of the length<br />

ҢҷҢѷҢҷҢԷԷҢÑ℄. The last summand is dropped if system errors and measurement<br />

errors are not correlated, i.e. no value has been set for L.<br />

MeasurementIn / MeasurementOut: These parameters include the matrix R stored in row-major order, and<br />

therefore are vectors of the dimension Ñ ¢ Ñ.<br />

<strong>HALCON</strong> 6.0


762 CHAPTER 12. TOOLS<br />

Parameter<br />

º FileName (input control) ...........................................filename Htuple . const char *<br />

Update file for a Kalman filter.<br />

Default Value : ”kalman.updt”<br />

º DimensionIn (input control) ..........................................integer-array Htuple . long<br />

The dimensions of the state vector, measurement vector and controller vector.<br />

Default Value : ’[3,1,0]’<br />

Typical Range of Values : 0 DimensionIn 30<br />

º ModelIn (input control) .................................................real-array Htuple . double<br />

The lined up matrices A,C,Q, possibly G and u, and if necessary L which all have been stored in row-major<br />

order.<br />

Default Value : ’[1.0,1.0,0.5,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,54.3,37.9,48.0,37.9,34.3,42.5,48.0,42.5,43.7]’<br />

Typical Range of Values : 0.0 ModelIn 10000.0<br />

º MeasurementIn (input control) ........................................real-array Htuple . double<br />

The matrix R stored in row-major order.<br />

Default Value : ’[1,2]’<br />

Typical Range of Values : 0.0 MeasurementIn 10000.0<br />

º DimensionOut (output control) ......................................integer-array Htuple . long *<br />

The dimensions of the state vector, measurement vector and controller vector.<br />

º ModelOut (output control) ............................................real-array Htuple . double *<br />

The lined up matrices A,C,Q, possibly G and u, and if necessary L which all have been stored in row-major<br />

order.<br />

º MeasurementOut (output control) ....................................real-array Htuple . double *<br />

The matrix R stored in row-major order.<br />

Example<br />

/* The following values are describing the system */<br />

/* */<br />

/*DimensionIn = [3,1,0] */<br />

/*ModelIn = [1.0,1.0,0.5,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0, */<br />

/* 54.3,37.9,48.0,37.9,34.3,42.5,48.0,42.5,43.7] */<br />

/*MeasurementIn = [1,2] */<br />

/* */<br />

/*An example of the Updatefile: */<br />

/* */<br />

/*n=3 m=1 p=0 */<br />

/*A+C-Q-G-u-L-R- */<br />

/*transitions at time t=15: */<br />

/*2 1 1 */<br />

/*0 2 2 */<br />

/*0 0 2 */<br />

/* */<br />

/*the results of update_kalman: */<br />

/* */<br />

/*DimensionOut = [3,1,0] */<br />

/*ModelOut = [2.0,1.0,1.0,0.0,2.0,2.0,0.0,0.0,2.0,1.0,0.0,0.0, */<br />

/* 54.3,37.9,48.0,37.9,34.3,42.5,48.0,42.5,43.7] */<br />

/*MeasurementOut = [1.2] */<br />

Result<br />

If the update file is readable and correct, the operator T update kalman returns the value H MSG TRUE.<br />

Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T update kalman is reentrant and processed without parallelization.<br />

T filter kalman<br />

Possible Successor Functions<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.10. MATCHING 763<br />

See Also<br />

T read kalman, T filter kalman, T sensor kalman<br />

Tools<br />

Module<br />

12.10 Matching<br />

clear shape model ( long ModelID )<br />

Free the memory of a shape model.<br />

The operator clear shape model frees the memory of a shape model which has been created by<br />

create shape model. After execution of the operator clear shape model the model can no longer be<br />

used. The handle ModelID becomes invalid.<br />

Parameter<br />

º ModelID (input control) ........................................................shape model long<br />

Handle of the model.<br />

Result<br />

If the handle of the model is valid, the operator clear shape model returns the value H MSG TRUE. If<br />

necessary an exception handling is raised.<br />

Parallelization Information<br />

clear shape model is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

create shape model, read shape model, write shape model<br />

Template matching<br />

Module<br />

create shape model ( Hobject Template, long NumLevels,<br />

double AngleStart, double AngleExtent, double AngleStep,<br />

const char *Optimization, const char *Metric, long Contrast,<br />

long MinContrast, long *ModelID )<br />

Prepare a shape model for matching.<br />

The operator create shape model prepares a template, which is passed in the image Template, asashape<br />

model used for matching.<br />

The model is generated using multiple image pyramid levels and multiple rotations and is stored in memory.<br />

The output parameter ModelID is a handle for this model, which is used in subsequent calls to<br />

T find shape model.<br />

The number of pyramid levels is determined with the parameter NumLevels. It should be chosen as large as possible<br />

because by this the time necessary to find the object is significantly reduced. On the other hand, NumLevels<br />

must be chosen such that the model is still recognizable and contains a sufficient number of points (at least four)<br />

on the highest pyramid level. This can be checked using the output of inspect shape model. If not enough<br />

model points are generated, create shape model returns with an error message.<br />

The parameters AngleStart and AngleExtent determine the range of possible rotations, in which the model<br />

can occur in the image. Note that the model can only be found in this range of angles by T find shape model.<br />

The parameter AngleStep determines the step length within the selected range of angles. Hence, if subpixel<br />

accuracy is not specified in T find shape model, this parameter specifies the accuracy that is achievable for<br />

the angles in T find shape model. AngleStep should be chosen based on the size of the object. Smaller<br />

models do not possess many (discrete) rotations in the image, and hence AngleStep should be chosen larger<br />

for smaller models. If AngleExtent is not an integer multiple of AngleStep, AngleStep is modified<br />

accordingly. The model is pre-generated for the selected angle range and stored in memory. The memory required<br />

<strong>HALCON</strong> 6.0


764 CHAPTER 12. TOOLS<br />

to store the model is proportional to the number of angle steps and the number of points in the model. Hence, if<br />

AngleStep is too small or AngleExtent too big, it may happen that the model no longer fits into the (virtual)<br />

memory. In this case, either AngleStep must be enlarged or AngleExtent must be reduced. In any case,<br />

it is desirable that the model completely fits into the main memory, because this avoids paging by the operating<br />

system, and hence the time to find the object will be much smaller. Since angles can be determined with subpixel<br />

resolution by T find shape model, ÒÐËØÔ ½ can be selected for models of a diameter smaller than 300<br />

pixels.<br />

For particularly large models, it may be useful to reduce the number of model points by setting Optimization<br />

to a value different from ’none’. IfÇÔØÑÞØÓÒ ¼ ÒÓÒ ¼ , all model points are stored. In all other cases, the<br />

number of points is reduced according to the value of Optimization. If the number of points is reduced, it may<br />

be necessary in T find shape model to set the parameter Greediness to a smaller value, e.g., 0.7 or 0.8. For<br />

small models, the reduction of the number of model points does not result in a speed-up of the search because in<br />

this case usually significantly more potential instances of the model must be examined.<br />

The parameter Contrast determines, which contrast the model points must have. The contrast is a measure<br />

for local gray value differences between the object and the background and between different parts of the object.<br />

Contrast should be chosen such that only the significant features of the template are used for the model. The<br />

effect of this parameter can be checked in advance with inspect shape model.<br />

With MinContrast, it can be determined which contrast the model must at least have in the recognition performed<br />

by T find shape model. In other words, this parameter separates the model from the noise in the<br />

image. Therefore, a good choice is the range of gray value changes caused by the noise in the image. If, for<br />

example, the gray values fluctuate within a range of 10 gray levels, MinContrast should be set to 10. Obviously,<br />

MinContrast must be smaller than Contrast. If the model should be recognized in very low contrast<br />

images, MinContrast must be set to a correspondingly small value. If the model should be recognized even if<br />

it is severely occluded, MinContrast should be slightly larger than the range of gray value fluctuations created<br />

by noise in order to ensure that the position and rotation of the model are extracted robustly and accurately by<br />

T find shape model.<br />

The parameter Metric determines the conditions under which the model is recognized in the image. If ÅØÖ <br />

¼ Ù× ÔÓÐÖØÝ ¼ , the object in the image and the model must have the same contrast. If, for example, the model is a<br />

bright object on a dark background, the object is found only if it is also brighter than the background. If ÅØÖ <br />

¼ ÒÓÖ ÐÓÐ ÔÓÐÖØÝ ¼ , the object is found in the image also if the the contrast reverses globally. In the above<br />

example, the object hence is also found if it is darker than the background. The runtime of T find shape model<br />

will increase slightly in this case. If ÅØÖ ¼ ÒÓÖ ÐÓÐ ÔÓÐÖØÝ ¼ , the model is found even if the contrast<br />

changes locally. This mode can, for example, be useful if the object consists of a part with medium gray value,<br />

within which either darker of brighter sub-objects lie. Since in this case the runtime of T find shape model<br />

increases significantly, it is usually better to create several models that reflect the possible contrast variations of the<br />

object with create shape model, and to match them separately with T find shape model.<br />

Parameter<br />

º Template (input object) .....................................................image Hobject : byte<br />

Input image whose domain will be used to create the model.<br />

º NumLevels (input control) ...........................................................integer long<br />

Maximum number of pyramid levels.<br />

Default Value : 4<br />

Value List : NumLevels ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10<br />

º AngleStart (input control) .....................................................angle.rad double<br />

Smallest rotation of the pattern.<br />

Default Value : -0.39<br />

Value Suggestions : AngleStart ¾-3.14, -1.57, -0.79, -0.39, -0.20, 0.0<br />

º AngleExtent (input control) ....................................................angle.rad double<br />

Extent of the rotation angles.<br />

Default Value : 0.79<br />

Value Suggestions : AngleExtent ¾6.28, 3.14, 1.57, 0.79, 0.39<br />

Restriction : AngleExtent 0<br />

º AngleStep (input control) ......................................................angle.rad double<br />

Step length of the angles (resolution).<br />

Default Value : 0.0982<br />

Value Suggestions : AngleStep ¾0.3927, 0.1963, 0.0982, 0.0491, 0.0245<br />

Restriction : AngleStep 0<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.10. MATCHING 765<br />

º Optimization (input control) .................................................string const char *<br />

Kind of optimization.<br />

Default Value : ’none’<br />

Value List : Optimization ¾’none’, ’point reduction low’, ’point reduction medium’,<br />

’point reduction high’<br />

º Metric (input control) .........................................................string const char *<br />

Match metric.<br />

Default Value : ’use polarity’<br />

Value List : Metric ¾’use polarity’, ’ignore global polarity’, ’ignore local polarity’<br />

º Contrast (input control) ...........................................................number long<br />

Contrast of the object in the template image.<br />

Default Value : 60<br />

Value Suggestions : Contrast ¾20, 40, 60, 80, 100, 120, 140, 160<br />

º MinContrast (input control) .......................................................number long<br />

Minimum contrast of the objects in the search images.<br />

Default Value : 10<br />

Value Suggestions : MinContrast ¾10, 20, 20, 40<br />

Restriction : MinContrast Contrast<br />

º ModelID (output control) .....................................................shape model long *<br />

Handle of the model.<br />

Result<br />

If the parameters are valid, the operator create shape model returns the value H MSG TRUE. If necessary<br />

an exception handling is raised. If the parameters NumLevels and Contrast are chosen such that the model<br />

contains too few points, the error 8510 is raised.<br />

Parallelization Information<br />

create shape model is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

draw region, reduce domain, threshold<br />

Possible Successor Functions<br />

T find shape model, clear shape model, write shape model<br />

create template rot<br />

Template matching<br />

Alternatives<br />

Module<br />

T find shape model ( Hobject Image, Htuple ModelID, Htuple AngleStart,<br />

Htuple AngleExtent, Htuple MinScore, Htuple NumMatches, Htuple MaxOverlap,<br />

Htuple SubPixel, Htuple NumLevels, Htuple Greediness, Htuple *Row,<br />

Htuple *Column, Htuple *Angle, Htuple *Score )<br />

Find the best matches of a shape model in an image.<br />

The operator T find shape model finds the best NumMatches instances of the shape model ModelID in<br />

the input image Image. The model must have been created previously by calling create shape model or<br />

read shape model.<br />

The position and rotation of the found instances of the model is returned in Row, Column and Angle. Additionally,<br />

the score of each found instance is returned in Score. The score is a number between 0 and 1, which is<br />

an approximate measure of how much of the model is visible in the image. If, for example, half of the model is<br />

occluded, the score cannot exceed 0.5.<br />

The model is searched within those points of the domain of the image, in which the model lies completely within<br />

the image. This means that the model will not be found if it extends beyond the borders of the image, even if it<br />

would achieve a score greater than MinScore (see below). The parameters AngleStart and AngleExtent<br />

determine the range of rotations for which the model is searched. If necessary, the range of rotations is clipped to<br />

the range given when the model was created with create shape model.<br />

<strong>HALCON</strong> 6.0


766 CHAPTER 12. TOOLS<br />

The parameter MinScore determines what score a potential match must at least have to be regarded as an instance<br />

of the model in the image. The larger MinScore is chosen, the faster the search is. If the model can be expected<br />

never to be occluded in the images, MinScore may be set as high as 0.8 or even 0.9.<br />

The maximum number of instances to be found can be determined with NumMatches. If more than<br />

NumMatches instances with a score greater than MinScore are found in the image, only the best NumMatches<br />

instances are returned. If fewer than NumMatches are found, only that number is returned, i.e., the parameter<br />

MinScore takes precedence over NumMatches.<br />

If the model exhibits symmetries it may happen that multiple instances with similar positions but different rotations<br />

are found in the image. The parameter MaxOverlap determines by what fraction (i.e., a number between<br />

0 and 1) two instances may at most overlap in order to consider them as different instances, and hence to be<br />

returned separately. If two instances overlap each other by more than MaxOverlap only the best instance is<br />

returned. The calculation of the overlap is based on the smallest enclosing rectangle of arbitrary orientation (see<br />

smallest rectangle2) of the found instances. If ÅÜÇÚÖÐÔ ¼, the found instances may not overlap at<br />

all, while for ÅÜÇÚÖÐÔ ½all instances are returned.<br />

The parameter SubPixel determines whether the instances should be extracted with subpixel accuracy. If<br />

SubPixel is set to ’true’, the position as well as the rotation is determined with subpixel accuracy.<br />

The number of pyramid levels used during the search is determined with NumLevels. If necessary, the number<br />

of levels is clipped to the range given when the template was created with create shape model.<br />

The parameter Greediness determines how “greedily” the search should be carried out. If ÖÒ×× ¼,a<br />

safe search heuristic is used, which always finds the model if it is visible in the image. However, the search will be<br />

relatively time consuming in this case. If ÖÒ×× ½, an unsafe search heuristic is used, which may cause<br />

the model not to be found in rare cases, even though it is visible in the image. For ÖÒ×× ½, the maximum<br />

search speed is achieved. In almost all cases, the template will always be found for ÖÒ×× ¼.<br />

Parameter<br />

º Image (input object) .........................................................image Hobject : byte<br />

Input image in which the model should be found.<br />

º ModelID (input control) ................................................shape model Htuple . long<br />

Handle of the model.<br />

º AngleStart (input control) .............................................angle.rad Htuple . double<br />

Smallest rotation of the model.<br />

Default Value : -0.39<br />

Value Suggestions : AngleStart ¾-3.14, -1.57, -0.78, -0.39, -0.20, 0.0<br />

º AngleExtent (input control) ............................................angle.rad Htuple . double<br />

Extent of the rotation angles.<br />

Default Value : 0.78<br />

Value Suggestions : AngleExtent ¾6.28, 3.14, 1.57, 0.78, 0.39, 0.0<br />

Restriction : AngleExtent 0<br />

º MinScore (input control) .....................................................real Htuple . double<br />

Minumum score of the instances of the model to be found.<br />

Default Value : 0.5<br />

Value Suggestions : MinScore ¾0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0<br />

Typical Range of Values : 0 MinScore 1<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.05<br />

º NumMatches (input control) .................................................integer Htuple . long<br />

Number of instances of the model to be found.<br />

Default Value : 1<br />

Value Suggestions : NumMatches ¾0, 1, 2, 3, 4, 5, 10, 20<br />

º MaxOverlap (input control) ..................................................real Htuple . double<br />

Maximum overlap of the instances of the model to be found.<br />

Default Value : 0.5<br />

Value Suggestions : MaxOverlap ¾0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0<br />

Typical Range of Values : 0 MaxOverlap 1<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.05<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.10. MATCHING 767<br />

º SubPixel (input control) ..............................................string Htuple . const char *<br />

Subpixel accuracy if ’true’.<br />

Default Value : ’false’<br />

Value List : SubPixel ¾’true’, ’false’<br />

º NumLevels (input control) ...................................................integer Htuple . long<br />

Number of pyramid levels used in the matching.<br />

Default Value : 3<br />

Value List : NumLevels ¾1, 2, 3, 4, 5, 6<br />

º Greediness (input control) ..................................................real Htuple . double<br />

“Greediness” of the search heuristic (0: safe but slow; 1: fast but matches may be missed).<br />

Default Value : 0.9<br />

Value Suggestions : Greediness ¾0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0<br />

Typical Range of Values : 0 Greediness 1<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.05<br />

º Row (output control) ................................................point.y-array Htuple . double *<br />

Row coordinate of the found instances of the model.<br />

º Column (output control) ............................................point.x-array Htuple . double *<br />

Column coordinate of the found instances of the model.<br />

º Angle (output control) ...........................................angle.rad-array Htuple . double *<br />

Rotation angle of the found instances of the model.<br />

º Score (output control) ................................................real-array Htuple . double *<br />

Score of the found instances of the model.<br />

Result<br />

If the parameter values are correct, the operator T find shape model returns the value H MSG TRUE.<br />

If the input is empty (no input images are available) the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception handling is raised.<br />

Parallelization Information<br />

T find shape model is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

create shape model, read shape model<br />

best match rot mg<br />

Template matching<br />

Alternatives<br />

Module<br />

inspect shape model ( Hobject Image, Hobject *ModelImages,<br />

Hobject *ModelRegions, long NumLevels, long Contrast )<br />

Create the representation of a shape model.<br />

inspect shape model creates a representation of a shape model. The operator is particularly useful in order<br />

to determine the parameters NumLevels and Contrast, which are used in create shape model, quickly<br />

and conveniently. The representation of the model is created on multiple image pyramid levels, where the number<br />

of levels is determined by NumLevels. In contrast to create shape model, the model is only created<br />

for the rotation of the object in the input image, i.e., ¼ Æ . As output, inspect shape model creates an image<br />

object ModelImages containing the images of the individual levels of the image pyramid as well as a region<br />

in ModelRegions for each pyramid level that represents the model at the respective pyramid level. The individual<br />

objects can be accessed with select obj. As described for create shape model, the number of<br />

pyramid levels should be chosen as large as possible, while taking into account that the model must be recognizable<br />

on the highest pyramid level and must have enough model points. The parameter Contrast should be<br />

chosen such that only the significant features of the template object are used for the model. In its typical use,<br />

inspect shape model is called interactively multiple times with different parameters for NumLevels and<br />

Contrast, until a satisfactory model is obtained. After this, create shape model is called with the parameters<br />

thus obtained.<br />

<strong>HALCON</strong> 6.0


768 CHAPTER 12. TOOLS<br />

Parameter<br />

º Image (input object) .........................................................image Hobject : byte<br />

Input image.<br />

º ModelImages (output object) ........................................image-array Hobject * : byte<br />

Image pyramid of the input image<br />

º ModelRegions (output object) ............................................region-array Hobject *<br />

Model region pyramid<br />

º NumLevels (input control) ...........................................................integer long<br />

Number of pyramid levels.<br />

Default Value : 4<br />

Value List : NumLevels ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10<br />

º Contrast (input control) ...........................................................number long<br />

Contrast of the object in the image.<br />

Default Value : 60<br />

Value Suggestions : Contrast ¾20, 40, 60, 80, 100, 120, 140, 160<br />

Result<br />

If the parameters are valid, the operator inspect shape model returns the value H MSG TRUE. If necessary<br />

an exception handling is raised.<br />

Parallelization Information<br />

inspect shape model is reentrant and processed without parallelization.<br />

reduce domain<br />

select obj<br />

create shape model<br />

Template matching<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

read shape model ( const char *FileName, long *ModelID )<br />

Read a shape model from a file.<br />

The operator read shape model reads a shape model, which has been written with write shape model,<br />

from the file FileName.<br />

Parameter<br />

º FileName (input control) ...................................................filename const char *<br />

File name.<br />

º ModelID (output control) .....................................................shape model long *<br />

Handle of the model.<br />

Result<br />

If the file name is valid, the operator read shape model returns the value H MSG TRUE. If necessary an<br />

exception handling is raised.<br />

Parallelization Information<br />

read shape model is processed completely exclusively without parallelization.<br />

T find shape model<br />

Possible Successor Functions<br />

See Also<br />

create shape model, clear shape model<br />

Template matching<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.11. MEASURE 769<br />

write shape model ( long ModelID, const char *FileName )<br />

Write a shape model to a file.<br />

The operator write shape model writes a shape model to the file FileName. The model can be read again<br />

with read shape model.<br />

Parameter<br />

º ModelID (input control) ........................................................shape model long<br />

Handle of the model.<br />

º FileName (input control) ...................................................filename const char *<br />

File name.<br />

Result<br />

If the file name is valid (write permission), the operator write shape model returns the value H MSG TRUE.<br />

If necessary an exception handling is raised.<br />

Parallelization Information<br />

write shape model is reentrant and processed without parallelization.<br />

create shape model<br />

Template matching<br />

Possible Predecessor Functions<br />

Module<br />

12.11 Measure<br />

close measure ( long MeasureHandle )<br />

Delete a measure object.<br />

close measure deletes the measure object given by MeasureHandle. The memory used for the measure<br />

object is freed.<br />

Parameter<br />

º MeasureHandle (input control) .................................................measureid long<br />

Measure object handle.<br />

Result<br />

If the parameter values are correct the operator close measure returns the value H MSG TRUE. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

close measure is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen measure rectangle2, T measure pos, T measure pairs<br />

Sub-pixel operators<br />

Module<br />

gen measure arc ( double CenterRow, double CenterCol, double Radius,<br />

double AngleStart, double AngleExtent, double AnnulusRadius, long Width,<br />

long Height, const char *Interpolation, long *MeasureHandle )<br />

Prepare the extraction of straight edges perpendicular to an annular arc.<br />

gen measure arc prepares the extraction of straight edges which lie perpendicular to an annular arc. Here,<br />

annular arc denotes a circular arc with an associated width. The center of the arc is passed in the parameters<br />

CenterRow and CenterCol, its radius in Radius, the starting angle in AngleStart, and its angular extent<br />

<strong>HALCON</strong> 6.0


770 CHAPTER 12. TOOLS<br />

relative to the starting angle in AngleExtent. IfÒÐÜØÒØ ¼, an arc with counterclockwise orientation<br />

is generated, otherwise an arc with clockwise orientation. The radius of the annular arc, i.e., half its width, is<br />

determined by AnnulusRadius.<br />

The edge extraction algorithm is described in the documentation of the operator T measure pos. As discussed<br />

there, different types of interpolation can be used for the calculation of the one-dimensional gray value profile. For<br />

Interpolation = ’nearest neighbor’, the gray values in the measurement are obtained from the gray values<br />

of the closest pixel, i.e., by constant interpolation. For Interpolation = ’bilinear’, bilinear interpolation is<br />

used, while for Interpolation = ’bicubic’, bicubic interpolation is used.<br />

With gen measure rectangle2, all computations which can be used for multiple measurements are removed<br />

from the actual measurement. To effect this, an optimized data structure, a so-called measure object,<br />

is constructed and returned in MeasureHandle. In order to perform the measurement at the optimum<br />

speed, the size of the images for which subsequent measurements will be made must already be specified in<br />

gen measure rectangle2 with the parameters Width and Height. This technique increases the speed of<br />

the actual measurement significantly.<br />

Parameter<br />

º CenterRow (input control) ..................................................point.y double / long<br />

Row coordinate of the center of the arc.<br />

Default Value : 100.0<br />

Value Suggestions : CenterRow ¾10.0, 20.0, 50.0, 100.0, 200.0, 300.0, 400.0, 500.0<br />

Typical Range of Values : 0.0 CenterRow 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º CenterCol (input control) ..................................................point.x double / long<br />

Column coordinate of the center of the arc.<br />

Default Value : 100.0<br />

Value Suggestions : CenterCol ¾10.0, 20.0, 50.0, 100.0, 200.0, 300.0, 400.0, 500.0<br />

Typical Range of Values : 0.0 CenterCol 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Radius (input control) .....................................................number double / long<br />

Radius of the arc.<br />

Default Value : 50.0<br />

Value Suggestions : Radius ¾10.0, 20.0, 50.0, 100.0, 200.0, 300.0, 400.0, 500.0<br />

Typical Range of Values : 0.0 Radius 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º AngleStart (input control) ...............................................angle.rad double / long<br />

Start angle of the arc in radians.<br />

Default Value : 0.0<br />

Value Suggestions : AngleStart ¾-3.14159265359, -2.35619449019, -1.5707963268,<br />

-0.785398163398, 0.0, 0.785398163398, 1.5707963268, 2.35619449019, 3.14159265359<br />

Typical Range of Values : -3.14159265359 AngleStart 3.14159265359 (lin)<br />

Minimal Value Step : 0.0314159265359<br />

Recommended Value Step : 0.314159265359<br />

º AngleExtent (input control) .............................................angle.rad double / long<br />

Angular extent of the arc in radians.<br />

Default Value : 6.28318530718<br />

Value Suggestions : AngleExtent ¾-6.28318530718, -5.49778714378, -4.71238898038, -3.926990817,<br />

-3.14159265359, -2.35619449019, -1.5707963268, -0.785398163398, 0.785398163398, 1.5707963268,<br />

2.35619449019, 3.14159265359, 3.926990817, 4.71238898038, 5.49778714378, 6.28318530718<br />

Typical Range of Values : -6.28318530718 AngleExtent 6.28318530718 (lin)<br />

Minimal Value Step : 0.0314159265359<br />

Recommended Value Step : 0.314159265359<br />

Restriction : AngleExtent 0.0<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.11. MEASURE 771<br />

º AnnulusRadius (input control) ............................................number double / long<br />

Radius (half width) of the the annulus.<br />

Default Value : 10.0<br />

Value Suggestions : AnnulusRadius ¾10.0, 20.0, 50.0, 100.0, 200.0, 300.0, 400.0, 500.0<br />

Typical Range of Values : 0.0 AnnulusRadius 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : AnnulusRadius Radius<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the image to be processed subsequently.<br />

Default Value : 512<br />

Value Suggestions : Width ¾128, 160, 192, 256, 320, 384, 512, 640, 768<br />

Typical Range of Values : 0 Width 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 16<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the image to be processed subsequently.<br />

Default Value : 512<br />

Value Suggestions : Height ¾120, 128, 144, 240, 256, 288, 480, 512, 576<br />

Typical Range of Values : 0 Height 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 16<br />

º Interpolation (input control) ...............................................string const char *<br />

Type of interpolation to be used.<br />

Default Value : ’nearest neighbor’<br />

Value List : Interpolation ¾’nearest neighbor’, ’bilinear’, ’bicubic’<br />

º MeasureHandle (output control) ..............................................measure id long *<br />

Measure object handle.<br />

Result<br />

If the parameter values are correct, the operator gen measure arc returns the value H MSG TRUE. Otherwise<br />

an exception handling is raised.<br />

Parallelization Information<br />

gen measure arc is reentrant and processed without parallelization.<br />

draw circle<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

T measure pos, T measure pairs<br />

edges sub pix<br />

Sub-pixel operators<br />

Alternatives<br />

Module<br />

gen measure rectangle2 ( double Row, double Column, double Phi,<br />

double Length1, double Length2, long Width, long Height,<br />

const char *Interpolation, long *MeasureHandle )<br />

Prepare the extraction of straight edges perpendicular to a rectangle.<br />

gen measure rectangle2 prepares the extraction of straight edges which lie perpendicular to the major axis<br />

of a rectangle. The center of the rectangle is passed in the parameters Row and Column, the direction of the major<br />

axis of the rectangle in Phi, and the length of the two axes, i.e., half the diameter of the rectangle, in Length1<br />

and Length2.<br />

The edge extraction algorithm is described in the documentation of the operator T measure pos. As discussed<br />

there, different types of interpolation can be used for the calculation of the one-dimensional gray value profile. For<br />

Interpolation = ’nearest neighbor’, the gray values in the measurement are obtained from the gray values<br />

<strong>HALCON</strong> 6.0


772 CHAPTER 12. TOOLS<br />

of the closest pixel, i.e., by constant interpolation. For Interpolation = ’bilinear’, bilinear interpolation is<br />

used, while for Interpolation = ’bicubic’, bicubic interpolation is used.<br />

With gen measure rectangle2, all computations which can be used for multiple measurements are removed<br />

from the actual measurement. To effect this, an optimized data structure, a so-called measure object,<br />

is constructed and returned in MeasureHandle. In order to perform the measurement at the optimum<br />

speed, the size of the images for which subsequent measurements will be made must already be specified in<br />

gen measure rectangle2 with the parameters Width and Height. This technique increases the speed of<br />

the actual measurement significantly.<br />

Parameter<br />

º Row (input control) ...............................................rectangle2.center.y double / long<br />

Row coordinate of the center of the rectangle.<br />

Default Value : 50.0<br />

Value Suggestions : Row ¾10.0, 20.0, 50.0, 100.0, 200.0, 300.0, 400.0, 500.0<br />

Typical Range of Values : 0.0 Row 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Column (input control) ...........................................rectangle2.center.x double / long<br />

Column coordinate of the center of the rectangle.<br />

Default Value : 100.0<br />

Value Suggestions : Column ¾10.0, 20.0, 50.0, 100.0, 200.0, 300.0, 400.0, 500.0<br />

Typical Range of Values : 0.0 Column 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Phi (input control) ..............................................rectangle2.angle.rad double / long<br />

Angle of longitudinal axis to horizontal (radians).<br />

Default Value : 0.0<br />

Value Suggestions : Phi ¾-1.178097, -0.785398, -0.392699, 0.0, 0.392699, 0.785398, 1.178097<br />

Typical Range of Values : -1.178097 Phi 1.178097 (lin)<br />

Minimal Value Step : 0.001<br />

Recommended Value Step : 0.1<br />

Restriction : ´ pi Phiµ ´Phi piµ<br />

º Length1 (input control) ...........................................rectangle2.hwidth double / long<br />

Half width.<br />

Default Value : 200.0<br />

Value Suggestions : Length1 ¾3.0, 5.0, 10.0, 15.0, 20.0, 50.0, 100.0, 200.0, 300.0, 500.0<br />

Typical Range of Values : 0.0 Length1 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Length2 (input control) ..........................................rectangle2.hheight double / long<br />

Half height.<br />

Default Value : 100.0<br />

Value Suggestions : Length2 ¾1.0, 2.0, 3.0, 5.0, 10.0, 15.0, 20.0, 50.0, 100.0, 200.0<br />

Typical Range of Values : 0.0 Length2 511.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

Restriction : Length2 Length1<br />

º Width (input control) ...............................................................extent.x long<br />

Width of the image to be processed subsequently.<br />

Default Value : 512<br />

Value Suggestions : Width ¾128, 160, 192, 256, 320, 384, 512, 640, 768<br />

Typical Range of Values : 0 Width 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 16<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.11. MEASURE 773<br />

º Height (input control) ..............................................................extent.y long<br />

Height of the image to be processed subsequently.<br />

Default Value : 512<br />

Value Suggestions : Height ¾120, 128, 144, 240, 256, 288, 480, 512, 576<br />

Typical Range of Values : 0 Height 1024 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 16<br />

º Interpolation (input control) ...............................................string const char *<br />

Type of interpolation to be used.<br />

Default Value : ’nearest neighbor’<br />

Value List : Interpolation ¾’nearest neighbor’, ’bilinear’, ’bicubic’<br />

º MeasureHandle (output control) ..............................................measure id long *<br />

Measure object handle.<br />

Result<br />

If the parameter values are correct the operator gen measure rectangle2 returns the value H MSG TRUE.<br />

Otherwise an exception handling is raised.<br />

Parallelization Information<br />

gen measure rectangle2 is reentrant and processed without parallelization.<br />

draw rectangle2<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

T measure pos, T measure pairs, T measure thresh<br />

edges sub pix<br />

Sub-pixel operators<br />

Alternatives<br />

Module<br />

T measure pairs ( Hobject Image, Htuple MeasureHandle, Htuple Sigma,<br />

Htuple Threshold, Htuple Transition, Htuple Select, Htuple *RowEdgeFirst,<br />

Htuple *ColumnEdgeFirst, Htuple *AmplitudeFirst, Htuple *RowEdgeSecond,<br />

Htuple *ColumnEdgeSecond, Htuple *AmplitudeSecond, Htuple *IntraDistance,<br />

Htuple *InterDistance )<br />

Extract straight edge pairs perpendicular to a rectangle.<br />

T measure pairs serves to extract straight edge pairs which lie perpendicular to the major axis of a rectangle.<br />

The extraction algorithm is identical to T measure pos. In addition the edges are grouped to pairs: If<br />

Transition = ’positive’, the edge points with a dark-to-light transition in the direction of the major axis of<br />

the rectangle are returned in RowEdgeFirst and ColumnEdgeFirst. In this case, the corresponding edges<br />

with a light-to-dark transition are returned in RowEdgeSecond and ColumnEdgeSecond. IfTransition =<br />

’negative’, the behavior is exactly opposite. If Transition = ’all’, the first detected edge defines the transition<br />

for RowEdgeFirst and ColumnEdgeFirst. If more than one edge with the same transition is found, the first<br />

one is used as a pair element. Finally, it is possible to select which edge pairs are returned. If Select is set to<br />

’all’, all edge pairs are returned. If it is set to ’first’, only the first of the extracted edge pairs is returned, while it<br />

is set to ’last’, only the last one is returned.<br />

The extracted edges are returned as single points which lie on the major axis of the rectangle. The corresponding<br />

edge amplitudes are returned in AmplitudeFirst and AmplitudeSecond. In addition, the distance between<br />

each edge pair is returned in IntraDistance and the distance between consecutive edge pairs is returned<br />

in InterDistance. Here, IntraDistance[i] corresponds to the distance between EdgeFirst[i] and EdgeSecond[i],<br />

while InterDistance[i] corresponds to the distance between EdgeSecond[i] and EdgeFirst[i+1], i.e., the<br />

tuple InterDistance contains one element less than the tuples of the edge pairs.<br />

Attention<br />

T measure pairs only returns meaningful results if the assumptions that the edges are straight and perpendicular<br />

to the major axis of the rectangle are fulfilled. Thus, it should not be used to extract edges from curved objects,<br />

<strong>HALCON</strong> 6.0


774 CHAPTER 12. TOOLS<br />

for example. Furthermore, the user should ensure that the rectangle is as close to perpendicular as possible to the<br />

edges in the image.<br />

Parameter<br />

º Image (input object) ...........................................singlechannel-image Hobject : byte<br />

Input image.<br />

º MeasureHandle (input control) .........................................measure id Htuple . long<br />

Measure object handle.<br />

º Sigma (input control) .....................................................number Htuple . double<br />

Sigma of gaussian smoothing.<br />

Default Value : 1.0<br />

Value Suggestions : Sigma ¾0.4, 0.6, 0.8, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 7.0, 10.0<br />

Typical Range of Values : 0.4 Sigma 100 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Sigma 0.4<br />

º Threshold (input control) ................................................number Htuple . double<br />

Minimum edge amplitude.<br />

Default Value : 30.0<br />

Value Suggestions : Threshold ¾5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 90.0, 110.0<br />

Typical Range of Values : 1 Threshold 255 (lin)<br />

Minimal Value Step : 0.5<br />

Recommended Value Step : 2<br />

º Transition (input control) ...........................................string Htuple . const char *<br />

Light/dark or dark/light edge.<br />

Default Value : ’all’<br />

Value List : Transition ¾’all’, ’positive’, ’negative’<br />

º Select (input control) .................................................string Htuple . const char *<br />

Selection of end points.<br />

Default Value : ’all’<br />

Value List : Select ¾’all’, ’first’, ’last’<br />

º RowEdgeFirst (output control) ....................................point.y-array Htuple . double *<br />

Row coordinate of the center of the edge.<br />

º ColumnEdgeFirst (output control) ................................point.x-array Htuple . double *<br />

Column coordinate of the center of the edge.<br />

º AmplitudeFirst (output control) ....................................real-array Htuple . double *<br />

Edge amplitude of found edges (with sign).<br />

º RowEdgeSecond (output control) ...................................point.y-array Htuple . double *<br />

Row coordinate of the center of the edge.<br />

º ColumnEdgeSecond (output control) ..............................point.x-array Htuple . double *<br />

Column coordinate of the center of the edge.<br />

º AmplitudeSecond (output control) ...................................real-array Htuple . double *<br />

Edge amplitude of found edges (with sign).<br />

º IntraDistance (output control) ......................................real-array Htuple . double *<br />

Distance between edges of an edge pair.<br />

º InterDistance (output control) ......................................real-array Htuple . double *<br />

Distance between consecutive edge pairs.<br />

Result<br />

If the parameter values are correct the operator T measure pairs returns the value H MSG TRUE. Otherwise<br />

an exception handling is raised.<br />

Parallelization Information<br />

T measure pairs is reentrant and processed without parallelization.<br />

gen measure rectangle2<br />

close measure<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.11. MEASURE 775<br />

edges sub pix, T measure pos<br />

Sub-pixel operators<br />

Alternatives<br />

Module<br />

T measure pos ( Hobject Image, Htuple MeasureHandle, Htuple Sigma,<br />

Htuple Threshold, Htuple Transition, Htuple Select, Htuple *RowEdge,<br />

Htuple *ColumnEdge, Htuple *Amplitude, Htuple *Distance )<br />

Extract straight edges perpendicular to a rectangle.<br />

T measure pos extracts straight edges which lie perpendicular to the major axis of a rectangle.<br />

The algorithm works by averaging the gray values in “slices” perpendicular to the major axis of the rectangle in<br />

order to obtain a one-dimensional edge profile. The sampling is done at subpixel positions in the image Image<br />

at integer row and column distances (in the coordinate frame of the rectangle) from the center of the rectangle.<br />

Since this involves some calculations which can be used repeatedly in several mesurements, the operator<br />

gen measure rectangle2 is used to perform these calculations only once, and thus to increase the speed of<br />

T measure pos significantly. Since there is a trade-off between accuracy and speed in the subpixel calculations<br />

of the gray values, and thus in the accuracy of the extracted edge positions, different interpolation schemes can<br />

be selected in gen measure rectangle2. (The interpolation only influences rectangles not aligned with the<br />

image axes.) The measure object generated with gen measure rectangle2 is passed in MeasureHandle.<br />

After the one-dimensional edge profile has been calculated, subpixel edge locations are computed by convolving<br />

the profile with the derivatives of a Gaussian smoothing kernel of standard deviation Sigma. Salient edges can be<br />

selected with the parameter Threshold, which constitutes a thresold on the amplitude, i.e., the absolute value of<br />

the first derivative, of the edge. Additionally, it is possible to select only positive edges, i.e., edges which constitute<br />

a dark-to-light transition in the direction of the major axis of the rectangle (Transition = ’positive’), only<br />

negative edges, i.e., light-to-dark transitions (Transition = ’negative’), or both types of edges (Transition<br />

= ’all’). Finally, it is possible to select which edge points are returned. If Select is set to ’all’, all edge points<br />

are returned. If it is set to ’first’, only the first of the extracted edge points is returned, while it is set to ’last’, only<br />

the last one is returned.<br />

The extracted edges are returned as single points which lie on the major axis of the rectangle in<br />

(RowEdge,ColumnEdge). The corresponding edge amplitudes are returned in Amplitude. In addition, the<br />

distance between consecutive edge points is returned in Distance. Here, Distance[i] corresponds to the distance<br />

between Edge[i] and Edge[i+1], i.e., the tuple Distance contains one element less than the tuples RowEdge and<br />

ColumnEdge.<br />

Attention<br />

T measure pos only returns meaningful results if the assumptions that the edges are straight and perpendicular<br />

to the major axis of the rectangle are fulfilled. Thus, it should not be used to extract edges from curved objects,<br />

for example. Furthermore, the user should ensure that the rectangle is as close to perpendicular as possible to the<br />

edges in the image.<br />

Parameter<br />

º Image (input object) ...........................................singlechannel-image Hobject : byte<br />

Input image.<br />

º MeasureHandle (input control) .........................................measure id Htuple . long<br />

Measure object handle.<br />

º Sigma (input control) .....................................................number Htuple . double<br />

Sigma of gaussian smoothing.<br />

Default Value : 1.0<br />

Value Suggestions : Sigma ¾0.4, 0.6, 0.8, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 7.0, 10.0<br />

Typical Range of Values : 0.4 Sigma 100 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Sigma 0.4<br />

<strong>HALCON</strong> 6.0


776 CHAPTER 12. TOOLS<br />

º Threshold (input control) ................................................number Htuple . double<br />

Minimum edge amplitude.<br />

Default Value : 30.0<br />

Value Suggestions : Threshold ¾5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 90.0, 110.0<br />

Typical Range of Values : 1 Threshold 255 (lin)<br />

Minimal Value Step : 2<br />

Recommended Value Step : 0.5<br />

º Transition (input control) ...........................................string Htuple . const char *<br />

Light/dark or dark/light edge.<br />

Default Value : ’all’<br />

Value List : Transition ¾’all’, ’positive’, ’negative’<br />

º Select (input control) .................................................string Htuple . const char *<br />

Selection of end points.<br />

Default Value : ’all’<br />

Value List : Select ¾’all’, ’first’, ’last’<br />

º RowEdge (output control) ...........................................point.y-array Htuple . double *<br />

Row coordinate of the center of the edge.<br />

º ColumnEdge (output control) .......................................point.x-array Htuple . double *<br />

Column coordinate of the center of the edge.<br />

º Amplitude (output control) ...........................................real-array Htuple . double *<br />

Edge amplitude of found edges (with sign).<br />

º Distance (output control) ............................................real-array Htuple . double *<br />

Distance between consecutive edges.<br />

Result<br />

If the parameter values are correct the operator T measure pos returns the value H MSG TRUE. Otherwise an<br />

exception handling is raised.<br />

Parallelization Information<br />

T measure pos is reentrant and processed without parallelization.<br />

gen measure rectangle2<br />

close measure<br />

edges sub pix, T measure pairs<br />

Sub-pixel operators<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

Module<br />

T measure projection ( Hobject Image, Htuple MeasureHandle,<br />

Htuple *GrayValues )<br />

Extract a gray value profile perpendicular to a rectangle.<br />

T measure projection extracts a one-dimensional gray value profile perpendicular to a rectangle. This is<br />

done by averaging the gray values in “slices” perpendicular to the major axis of the rectangle. The sampling is<br />

done at subpixel positions in the image Image at integer row and column distances (in the coordinate frame of the<br />

rectangle) from the center of the rectangle. Since this involves some calculations which can be used repeatedly in<br />

several projections, the operator gen measure rectangle2 is used to perform these calculations only once,<br />

and thus to increase the speed of T measure projection significantly. Since there is a trade-off between<br />

accuracy and speed in the subpixel calculations of the gray values, different interpolation schemes can be selected<br />

in gen measure rectangle2 (the interpolation only influences rectangles not aligned with the image axes).<br />

The measure object generated with gen measure rectangle2 is passed in MeasureHandle.<br />

Parameter<br />

º Image (input object) ...........................................singlechannel-image Hobject : byte<br />

Input image.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.11. MEASURE 777<br />

º MeasureHandle (input control) .........................................measure id Htuple . long<br />

Measure object handle.<br />

º GrayValues (output control) ......................................number-array Htuple . double *<br />

Gray value profile.<br />

Result<br />

If the parameter values are correct the operator T measure projection returns the value H MSG TRUE.<br />

Otherwise an exception handling is raised.<br />

Parallelization Information<br />

T measure projection is reentrant and processed without parallelization.<br />

gen measure rectangle2<br />

close measure<br />

gray projections<br />

Sub-pixel operators<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

Module<br />

T measure thresh ( Hobject Image, Htuple MeasureHandle, Htuple Sigma,<br />

Htuple Threshold, Htuple Select, Htuple *RowThresh, Htuple *ColumnThresh,<br />

Htuple *Distance )<br />

Extracting points with a particular grey value along a rectangle.<br />

T measure thresh extracts points for which the gray value within an one-dimensional gray value profile is<br />

equal to the specified threshold Threshold. The gray value profile is projected onto the major axis of the measure<br />

rectangle which is passed with the parameter MeasureHandle, so the threshold points calculated within the gray<br />

value profile correspond to certain image coordinates on the rectangle’s major axis. These coordinates are returned<br />

as the operator results in RowThresh and ColumnThresh.<br />

If the gray value profile intersects the threshold line for several times, the parameter Select determines which<br />

values to return. Possible settings are ’first’, ’last’, ’first last’ (first and last) or ’all’. For the last two cases<br />

Distance returns the distances between the calculated points.<br />

The gray value profile is created by averaging the gray values along all line segments, which are defined by the<br />

measure rectangle as follows:<br />

1. The segments are perpendicular to the major axis of the rectangle,<br />

2. they have an integer distance to the center of the rectangle,<br />

3. the rectangle bounds the segments.<br />

For every line segment, the average of the gray values of all points with an integer distance to the major axis is<br />

calculated. Due to translation and rotation of the measure rectangle with respect to the image coordinates the input<br />

image Image is in general sampled at subpixel positions.<br />

Since this involves some calculations which can be used repeatedly in several projections, the operator<br />

gen measure rectangle2 is used to perform these calculations only once in advance. Here, the measure<br />

object MeasureHandle is generated and different interpolation schemes can be selected.<br />

Attention<br />

T measure thresh only returns meaningful results if the assumptions that the edges are straight and perpendicular<br />

to the major axis of the rectangle are fulfilled. Thus, it should not be used to extract edges from curved<br />

objects, for example. Furthermore, the user should ensure that the rectangle is as close to perpendicular as possible<br />

to the edges in the image.<br />

<strong>HALCON</strong> 6.0


778 CHAPTER 12. TOOLS<br />

Parameter<br />

º Image (input object) ...........................................singlechannel-image Hobject : byte<br />

Input image.<br />

º MeasureHandle (input control) .........................................measure id Htuple . long<br />

Measure object handle.<br />

º Sigma (input control) .....................................................number Htuple . double<br />

Sigma of gaussian smoothing.<br />

Default Value : 1.0<br />

Value Suggestions : Sigma ¾0.0, 0.4, 0.6, 0.8, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 7.0, 10.0<br />

Typical Range of Values : 0.4 Sigma 100 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Sigma 0.0<br />

º Threshold (input control) ................................................number Htuple . double<br />

Threshold.<br />

Default Value : 128.0<br />

Typical Range of Values : 0 Threshold 255 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 0.5<br />

º Select (input control) .................................................string Htuple . const char *<br />

Selection of points.<br />

Default Value : ’all’<br />

Value List : Select ¾’all’, ’first’, ’last’, ’first last’<br />

º RowThresh (output control) ........................................point.y-array Htuple . double *<br />

Row coordinates of points with threshold value.<br />

º ColumnThresh (output control) ....................................point.x-array Htuple . double *<br />

Column coordinates of points with threshold value.<br />

º Distance (output control) ............................................real-array Htuple . double *<br />

Distance between consecutive points.<br />

Result<br />

If the parameter values are correct the operator T measure thresh returns the value H MSG TRUE. Otherwise,<br />

an exception handling is raised.<br />

Parallelization Information<br />

T measure thresh is reentrant and processed without parallelization.<br />

gen measure rectangle2<br />

close measure<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Alternatives<br />

T measure pos, edges sub pix, T measure pairs<br />

Sub-pixel operators<br />

Module<br />

12.12 OCR<br />

append ocr trainf ( Hobject Character, Hobject Image,<br />

const char *Class, const char *FileName )<br />

T append ocr trainf ( Hobject Character, Hobject Image, Htuple Class,<br />

Htuple FileName )<br />

Adding characters to a training file.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.12. OCR 779<br />

The operator (T )append ocr trainf serves to prepare the training with the operator<br />

(T )trainf ocr class box. Hereby regions, representing characters, including their grayvalues (region<br />

and pixel) and the corresponding classname will be written into a file. An arbitrary number of regions<br />

within one image is supported. For each character (region) in Character the corresponding class name must be<br />

specified in Class. The grayvalues are passed via the parameter Image. The file name can be chosen at will. In<br />

contrast to (T )write ocr trainf the characters are appended to the file. If the file does not exist a new file<br />

is generated.<br />

Parameter<br />

º Character (input object) ..................................................region(-array) Hobject<br />

Characters to be trained.<br />

º Image (input object) ..............................................................image Hobject<br />

Grayvalues of the characters.<br />

º Class (input control) ..........................................string(-array) (Htuple .) const char *<br />

Class (name) of the characters.<br />

º FileName (input control) ..........................................filename (Htuple .) const char *<br />

Name of the training file.<br />

Default Value : ”train ocr”<br />

Example<br />

char<br />

char<br />

name[128];<br />

class[128];<br />

read_image(&Image,"character.tiff");<br />

bin_threshold(Image,&Dark);<br />

connection(Dark,&Character);<br />

count_obj(Character,&num);<br />

create_tuple(&Class,num);<br />

open_window(0,0,-1,-1,0,"","",&WindowHandle);<br />

set_color(WindowHandle,"red");<br />

for (i=0; i


780 CHAPTER 12. TOOLS<br />

close all ocrs ( )<br />

Destroy all OCR classificators.<br />

close all ocrs deletes all OCR classificators and frees the used memory space. All the trained data will be<br />

lost.<br />

Attention<br />

Since all classificators are closed by close all ocrs all handles become invalid.<br />

Result<br />

If it is possible to close the OCR classificators the operator close all ocrs returns the value H MSG TRUE.<br />

Otherwise an exception handling is raised.<br />

Parallelization Information<br />

close all ocrs is processed completely exclusively without parallelization.<br />

close ocr<br />

Optical character recognition<br />

Alternatives<br />

Module<br />

close ocr ( long OcrHandle )<br />

Deallocation of the memory of an OCR classifier.<br />

The operator close ocr deallocates the memory of the classifier having the number OcrHandle. Hereby<br />

all corresponding data will be deleted. However, if necessary, they can be saved in advance using the operator<br />

write ocr. The number OcrHandle will be invalid after the call; but later the system can use it again for new<br />

classifiers.<br />

Attention<br />

All data of the classifier will be deleted in main memory (not on the hard disk).<br />

Parameter<br />

º OcrHandle (input control) ..............................................................ocr long<br />

ID of the OCR classifier to be deleted.<br />

Example<br />

HTuple<br />

long<br />

OcrHandle,Class,Confidence;<br />

orc_handle;<br />

read_ocr("testnet",&orc_handle);<br />

/* image processing */<br />

create_tuple(&OcrHandle,1);<br />

set_i(OcrHandle,orc_handle,0);<br />

T_do_ocr_multi(Character,Image,OcrHandle,&Class,&Confidence);<br />

close_ocr(orc_handle);<br />

Result<br />

If the parameter OcrHandle is valid, the operator close ocr returns the value H MSG TRUE. Otherwise an<br />

exception will be raised.<br />

Parallelization Information<br />

close ocr is reentrant and processed without parallelization.<br />

(T )write ocr trainf<br />

read ocr<br />

Optical character recognition<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.12. OCR 781<br />

T concat ocr trainf ( Htuple SingleFiles, Htuple ComposedFile )<br />

Concatenation of trainings files.<br />

The operator T concat ocr trainf stores all characters which are contained in the files SingleFiles into<br />

a new file with the name ComposedFile.<br />

Parameter<br />

º SingleFiles (input control) ..................................filename-array Htuple . const char *<br />

Name of the single training files.<br />

Default Value : ”<br />

º ComposedFile (input control) ......................................filename Htuple . const char *<br />

Name of the composed training file.<br />

Default Value : ’all characters’<br />

Result<br />

If the parameters are correct, the operator T concat ocr trainf returns the value H MSG TRUE. Otherwise<br />

an exception will be raised.<br />

Parallelization Information<br />

T concat ocr trainf is processed under mutual exclusion against itself and without parallelization.<br />

Possible Predecessor Functions<br />

(T )write ocr trainf, (T )append ocr trainf<br />

Possible Successor Functions<br />

(T )trainf ocr class box, T info ocr class box, write ocr, (T )do ocr multi,<br />

T do ocr single<br />

Module<br />

Optical character recognition<br />

T create ocr class box ( Htuple WidthPattern, Htuple HeightPattern,<br />

Htuple Interpolation, Htuple Features, Htuple Character,<br />

Htuple *OcrHandle )<br />

Creating a new OCR-classifier.<br />

The operator T create ocr class box creates a new OCR classifier. For a description of this classifier<br />

see operator learn class box. This classifier must then be trained with the help of the operators<br />

(T )traind ocr class box or (T )trainf ocr class box.<br />

The parameters WidthPattern and HeightPattern indicate the size of the input-layer of the network. This<br />

size is used for the features ’projection horizontal’, ’projection vertical’ and ’pixel’. The bigger it is, the more<br />

characters can be distinguished. Hereby the amount of time necessary for the training (as well as the number of<br />

training random samples) and the time necessary for the recognition, however, will increase as well. The larger<br />

the input level, the more specifical the training is for a certain font. The parameter Interpolation indicates<br />

the interpolation mode concerning the adaptation of characters in the image to the network. For more detailed<br />

information on this parameter see also affine trans image.<br />

The parameter Character determines all the characters which have to be recognized. Normally the transmitted<br />

strings consist of one character (e.g. alphabet). But also strings of any length can be learned. The number of<br />

distinguishable characters (number of strings in Character) is limited to 2048.<br />

The parameter Features helps to chose additional features besides grayvalues in order to recognize<br />

characters. By using ’default’ the features ’ratio’, ’projection horizontal’, ’projection vertical’, ’moments<br />

region 2nd invar’,and’moments region 2nd rel invar’ will be set.<br />

The following features are available:<br />

’ratio’ Ratio of the character.<br />

’width’ Width of the character (not invariant to scaling).<br />

’height’ Height of the character (not invariant to scaling).<br />

<strong>HALCON</strong> 6.0


782 CHAPTER 12. TOOLS<br />

’zoom factor’ Difference in size between the current character and the values of WidthPattern and<br />

HeightPattern (not invariant to scaling).<br />

’foreground’ Relative number of pixels in the foreground.<br />

’foreground grid 9’ Relative number of foreground pixels in a ¿ ¢ ¿ grid within the surrounding rectangle of the<br />

character.<br />

’foreground grid 16’ Relative number of foreground pixels in a ¢ grid within the surrounding rectangle of<br />

the character.<br />

’anisometry’ Form feature anisometry.<br />

’compactness’ Form feature compactness.<br />

’convexity’ Form feature convexity.<br />

’moments region 2nd invar’ Normed 2nd geometric moments of the region. See also<br />

moments region 2nd invar.<br />

’moments region 2nd rel invar’ Normed 2nd relativ geometric moments of the region. See also<br />

moments region 2nd rel invar.<br />

’moments region 3rd invar’ Normed 3rd geometric moments of the region. See also<br />

moments region 3rd invar.<br />

’moments central’ Normed central geometric moments of the region. See also moments region central.<br />

’phi’ Orientation (angle) of the character.<br />

’num connect’ Number of connecting components.<br />

’num holes’ Number of holes.<br />

’projection horizontal’ Horizontal projection of the grayvalues.<br />

’projection horizontal invar’ Horizontal projection of the grayvalues with are automatically scaled to maximum<br />

range.<br />

’projection vertical’ Vertical projection of the grayvalues.<br />

’projection vertical invar’ Vertical projection of the grayvalues with are automatically scaled to maximum<br />

range.<br />

’cooc’ Values of the binary cooccurrence matrix.<br />

’moments gray plane’ Normed grayvalue moments and the angles of the grayvalue level.<br />

’num runs’ Number of chords in the region normed to the area.<br />

’chord histo’ Frequency of the chords per row.<br />

’pixel’ Grayvalue of the character.<br />

’pixel invar’ Grayvalues of the character with automatic maximal scaling of the gray values.<br />

Parameter<br />

º WidthPattern (input control) ..............................................integer Htuple . long<br />

Width of the input layer of the network.<br />

Default Value : 8<br />

Value Suggestions : WidthPattern ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20<br />

Typical Range of Values : 1 WidthPattern 100<br />

º HeightPattern (input control) .............................................integer Htuple . long<br />

Height of the input layer of the network.<br />

Default Value : 10<br />

Value Suggestions : HeightPattern ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20<br />

Typical Range of Values : 1 HeightPattern 100<br />

º Interpolation (input control) .............................................integer Htuple . long<br />

Interpolation mode concerning scaling of characters.<br />

Default Value : 0<br />

Value List : Interpolation ¾0, 1, 2<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.12. OCR 783<br />

º Features (input control) .......................................string(-array) Htuple . const char *<br />

Additional features.<br />

Default Value : ’default’<br />

Value List : Features ¾’default’, ’zoom factor’, ’ratio’, ’width’, ’height’, ’foreground’,<br />

’foreground grid 9’, ’foreground grid 16’, ’anisometry’, ’compactness’, ’convexity’,<br />

’moments region 2nd invar’, ’moments region 2nd rel invar’, ’moments region 3rd invar’,<br />

’moments central’, ’phi’, ’num connect’, ’num holes’, ’projection horizontal’, ’projection vertical’,<br />

’projection horizontal invar’, ’projection vertical invar’, ’chord histo’, ’num runs’, ’pixel’, ’pixel invar’,<br />

’cooc’, ’moments gray plane’<br />

º Character (input control) .......................................string-array Htuple . const char *<br />

All characters of a set.<br />

Default Value : ’[’a’,’b’,’c’]’<br />

º OcrHandle (output control) ...................................................ocr Htuple . long *<br />

ID of the created OCR classifier.<br />

Example<br />

HTuple WidthPattern,HeightPattern,Interpolation,<br />

Features,OcrHandle;<br />

create_tuple(&WidthPattern,1);<br />

set_i(WidthPattern,8,0);<br />

create_tuple(&HeightPattern,1);<br />

set_i(HeightPattern,10,0);<br />

create_tuple(&Interpolation,1);<br />

set_i(Interpolation,1,0);<br />

create_tuple(&Features,1);<br />

set_s(Features,"default",0);<br />

create_tuple(&Character,26+26+10);<br />

set_s(Character,"a",0);<br />

set_s(Character,"b",1);<br />

/* ... */<br />

set_s(Character,"A",27);<br />

set_s(Character,"B",28);<br />

/* ... */<br />

set_s(Character,"1",53);<br />

set_s(Character,"2",54);<br />

/* ... */<br />

T_create_ocr_class_box(WidthPattern,HeightPattern,Interpolation,<br />

Features,Character,&OcrHandle);<br />

Result<br />

If the parameters are correct, the operator T create ocr class box returns the value H MSG TRUE. Otherwise<br />

an exception will be raised.<br />

Parallelization Information<br />

T create ocr class box is processed completely exclusively without parallelization.<br />

reset obj db<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

(T )traind ocr class box, (T )trainf ocr class box, T info ocr class box, write ocr,<br />

T ocr change char<br />

See Also<br />

affine trans image, T ocr change char, moments region 2nd invar,<br />

moments region 2nd rel invar, moments region 3rd invar, moments region central<br />

Optical character recognition<br />

Module<br />

<strong>HALCON</strong> 6.0


784 CHAPTER 12. TOOLS<br />

do ocr multi ( Hobject Character, Hobject Image, long OcrHandle,<br />

char *Class, double *Confidence )<br />

T do ocr multi ( Hobject Character, Hobject Image, Htuple OcrHandle,<br />

Htuple *Class, Htuple *Confidence )<br />

Classification of characters.<br />

The operator (T )do ocr multi assigns a class to every Character (character). For grayvalue features<br />

the grayvalues from the surrounding rectangles of the regions are used. The grayvalues will be taken from the<br />

parameter Image. For each character the corresponding class will be returned in Class and a confidence value<br />

will be returned in Confidence. The confidence value indicates the similarity between the input pattern and the<br />

assigned character.<br />

Parameter<br />

º Character (input object) ..................................................region(-array) Hobject<br />

Characters to be recognized.<br />

º Image (input object) ..............................................................image Hobject<br />

Grayvalues for the characters.<br />

º OcrHandle (input control) ....................................................ocr (Htuple .) long<br />

ID of the OCR classifier.<br />

º Class (output control) ..............................................string(-array) (Htuple .) char *<br />

Class (name) of the characters.<br />

Parameter Number : Class Character<br />

º Confidence (output control) .......................................real(-array) (Htuple .) double *<br />

Confidence values of the characters.<br />

Parameter Number : Confidence Character<br />

Example<br />

char Class[128];<br />

long orc_handle;<br />

read_ocr("testnet",&orc_handle);<br />

read_image(&Image,"character.tiff");<br />

bin_threshold(Image,&Dark);<br />

connection(Dark,&Character);<br />

count_obj(Character,&num);<br />

open_window(0,0,-1,-1,0,"","",&WindowHandle);<br />

for (i=0; i


12.12. OCR 785<br />

T do ocr single ( Hobject Character, Hobject Image, Htuple OcrHandle,<br />

Htuple *Classes, Htuple *Confidences )<br />

Classification of a character.<br />

The operator T do ocr single assigns classes to the Character (characters). For grayvalue features grayvalues<br />

of the surrounding rectangles of the regions will be used. The grayvalues will be taken from the paramter<br />

Image. For each character the two classes with the highest confidencenses will be returned in Classes. Thecorresponding<br />

confidences will be returned in Confidences. The confidence value indicates the similarity between<br />

the input pattern and the assigned character.<br />

Parameter<br />

º Character (input object) .........................................................region Hobject<br />

Character to be recognized.<br />

º Image (input object) ..............................................................image Hobject<br />

Grayvalues of the characters.<br />

º OcrHandle (input control) ......................................................ocr Htuple . long<br />

ID of the OCR classifier.<br />

º Classes (output control) ..............................................string-array Htuple . char *<br />

Classes (names) of the characters.<br />

Parameter Number : 2<br />

º Confidences (output control) ........................................real-array Htuple . double *<br />

Confidence values of the characters.<br />

Parameter Number : 2<br />

Example<br />

HTuple<br />

long<br />

HTuple<br />

Classes,Confidences;<br />

orc_handle;<br />

OcrHandle;<br />

read_ocr("testnet",&orc_handle);<br />

create_tuple(&OcrHandle,1);<br />

set_i(OcrHandle,orc_handle,0);<br />

read_image(&Image,"character.tiff");<br />

bin_threshold(Image,&Dark);<br />

connection(Dark,&Character);<br />

count_obj(Character,&num);<br />

open_window(0,0,-1,-1,0,"","",&WindowHandle);<br />

for (i=0; i


786 CHAPTER 12. TOOLS<br />

write ocr<br />

Optical character recognition<br />

See Also<br />

Module<br />

T info ocr class box ( Htuple OcrHandle, Htuple *WidthPattern,<br />

Htuple *HeightPattern, Htuple *Interpolation, Htuple *WidthMaxChar,<br />

Htuple *HeightMaxChar, Htuple *Features, Htuple *Characters )<br />

Information about an OCR classifier.<br />

The operator T info ocr class box returns some information about an OCR classifier. The parameters are<br />

equivalent to those of T create ocr class box. The parameters WidthMaxChar and HeightMaxChar<br />

indicate the extension of the largest trained character. These values can be used to control the segmentation.<br />

Parameter<br />

º OcrHandle (input control) ......................................................ocr Htuple . long<br />

ID of the OCR classifier.<br />

º WidthPattern (output control) ............................................integer Htuple . long *<br />

Width of the scaled characters.<br />

º HeightPattern (output control) ..........................................integer Htuple . long *<br />

Height of the scaled characters.<br />

º Interpolation (output control) ..........................................integer Htuple . long *<br />

Interpolation mode for scaling the characters.<br />

º WidthMaxChar (output control) ............................................integer Htuple . long *<br />

Width of the largest trained character.<br />

º HeightMaxChar (output control) ..........................................integer Htuple . long *<br />

Height of the largest trained character.<br />

º Features (output control) .............................................string-array Htuple . char *<br />

Used features.<br />

º Characters (output control) ..........................................string-array Htuple . char *<br />

All characters of the set.<br />

Example<br />

HTuple<br />

OcrHandle,WidthPattern,HeightPattern,Interpolation,<br />

WidthMaxChar,HeightMaxChar,Features,Characters;<br />

T_info_ocr_class_box(OcrHandle,&WidthPattern,&HeightPattern,&Interpolation,<br />

&WidthMaxChar,&HeightMaxChar,&Features,&Characters);<br />

printf("NetSize: %d x %d\n",get_i(WidthPattern,0),get_i(HeightPattern,0));<br />

printf("MaxChar: %d x %d\n",get_i(WidthMaxChar,0),get_i(HeightMaxChar,0));<br />

printf("Interpolation: %d\n",get_i(Interpolation,0));<br />

printf("Features: ");<br />

for (i=0; i


12.12. OCR 787<br />

write ocr<br />

Optical character recognition<br />

Possible Successor Functions<br />

Module<br />

T ocr change char ( Htuple OcrHandle, Htuple Character )<br />

Defining a new conversion table for the characters.<br />

The operator T ocr change char establishes a new look-up table for the characters. Hereby the number of<br />

strings of Character must be the same as of the classifier OcrHandle. In order to enlarge the font, the<br />

operator T ocr change char may be used as follows: More characters than actually needed will be indicated<br />

when creating a network using (T create ocr class box). The last Ò characters will not be used so far. If<br />

more characters are needed at a later stage, these unused characters will be allocated and then trained with the help<br />

of the operator T ocr change char.<br />

Parameter<br />

º OcrHandle (input control) ......................................................ocr Htuple . long<br />

ID of the OCR-network to be changed.<br />

º Character (input control) .......................................string-array Htuple . const char *<br />

New assign of characters.<br />

Default Value : ’[’a’,’b’,’c’]’<br />

Example<br />

HTuple Character1, Character2, OcrHandle;<br />

create_tuple(&Character1,26);<br />

set_s(Character1,"a",0);<br />

set_s(Character1,"b",1);<br />

/* set parameter values */<br />

T_create_ocr_net(WidthPattern,HeightPattern,Interpolation,<br />

Features,HiddenLayer,Init,Character1,&OcrHandle);<br />

/* later... */<br />

create_tuple(&Character2,26);<br />

set_s(Character2,"alpha",0);<br />

set_s(Character2,"beta",1);<br />

T_ocr_change_char(OcrHandle,Character2);<br />

Result<br />

If the number of characters in Character is identical with the number of the characters of the network, the<br />

operator T ocr change char returns the value H MSG TRUE. Otherwise an exception will be raised.<br />

Parallelization Information<br />

T ocr change char is processed completely exclusively without parallelization.<br />

read ocr<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

(T )do ocr multi, T do ocr single, write ocr<br />

Optical character recognition<br />

Module<br />

T ocr get features ( Hobject Character, Htuple OcrHandle,<br />

Htuple *FeatureVector )<br />

Access the features which correspond to a character.<br />

<strong>HALCON</strong> 6.0


788 CHAPTER 12. TOOLS<br />

The operator T ocr get features calculates the features for the given Character. The type and number of<br />

features is determined by the classifier OcrHandle. FeatureVector contains the same values which are used<br />

inside operators like (T )traind ocr class box or (T )trainf ocr class box.<br />

Parameter<br />

º Character (input object) .........................................................image Hobject<br />

Characters to be trained.<br />

º OcrHandle (input control) ......................................................ocr Htuple . long<br />

ID of the desired OCR-classifier.<br />

º FeatureVector (output control) ......................................real-array Htuple . double *<br />

Feature vector.<br />

Result<br />

If the parameters are correct, the operator T ocr get features returns the value H MSG TRUE. Otherwise<br />

an exception will be raised.<br />

Parallelization Information<br />

T ocr get features is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

T create ocr class box, read ocr, reduce domain, threshold, connection<br />

learn class box<br />

Possible Successor Functions<br />

See Also<br />

(T )trainf ocr class box, (T )traind ocr class box<br />

Optical character recognition<br />

Module<br />

read ocr ( const char *FileName, long *OcrHandle )<br />

Reading of an OCR classifier from a file.<br />

The operator read ocr reads an OCR classifier from a file FileName. This file will hereby be searched in<br />

the directory ($<strong>HALCON</strong>ROOT/ocr/) as well as in the currently used directory. If too many classifiers have been<br />

loaded, an error message will be displayed.<br />

Parameter<br />

º FileName (input control) ...................................................filename const char *<br />

Name of the OCR classifier file.<br />

Default Value : ’testnet’<br />

º OcrHandle (output control) ...........................................................ocr long *<br />

ID of the read OCR classifier.<br />

Result<br />

If the indicated file is available and the format is correct, the operator read ocr returns the value H MSG TRUE.<br />

Otherwise an exception will be raised.<br />

Parallelization Information<br />

read ocr is processed completely exclusively without parallelization.<br />

reset obj db<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

(T )do ocr multi, T do ocr single, (T )traind ocr class box, (T )trainf ocr class box<br />

See Also<br />

write ocr, (T )do ocr multi, (T )traind ocr class box, (T )trainf ocr class box<br />

Optical character recognition<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.12. OCR 789<br />

T read ocr trainf ( Hobject *Characters, Htuple TrainFileNames,<br />

Htuple *CharacterNames )<br />

Read training characters from files and convert to images.<br />

T read ocr trainf reads all characters from the specified file names and converts them into images. The<br />

domain is defined according to the foreground of the characters (as specified in (T )write ocr trainf). The<br />

names of the characters are returned in CharacterNames. If more than one file name is given the files are<br />

processed in the order the file names.<br />

Parameter<br />

º Characters (output object) .........................................image-array Hobject * : byte<br />

Images read from file.<br />

º TrainFileNames (input control) ......................filename.named(-array) Htuple . const char *<br />

Names of the training files.<br />

Default Value : ”<br />

º CharacterNames (output control) .....................................string-array Htuple . char *<br />

Names of the read characters.<br />

Result<br />

If the parameter values are correct the operator T read ocr trainf returns the value H MSG TRUE. Otherwise<br />

an exception handling is raised.<br />

Parallelization Information<br />

T read ocr trainf is reentrant and processed without parallelization.<br />

(T )write ocr trainf<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

disp image, select obj, zoom image size<br />

(T )read ocr trainf select<br />

(T )trainf ocr class box<br />

Optical character recognition<br />

Alternatives<br />

See Also<br />

Module<br />

read ocr trainf names ( const char *TrainFileNames,<br />

char *CharacterNames, long *CharacterCount )<br />

T read ocr trainf names ( Htuple TrainFileNames,<br />

Htuple *CharacterNames, Htuple *CharacterCount )<br />

Query which characters are stored in a training file.<br />

(T )read ocr trainf names extracts the names and frequency of all characters in the specified training files.<br />

Parameter<br />

º TrainFileNames (input control) ....................filename.named(-array) (Htuple .) const char *<br />

Names of the training files.<br />

Default Value : ”<br />

º CharacterNames (output control) ..................................string(-array) (Htuple .) char *<br />

Names of the read characters.<br />

º CharacterCount (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Number of the characters.<br />

Result<br />

If the parameter values are correct the operator (T )read ocr trainf names returns the value<br />

H MSG TRUE. Otherwise an exception handling is raised.<br />

<strong>HALCON</strong> 6.0


790 CHAPTER 12. TOOLS<br />

Parallelization Information<br />

(T )read ocr trainf names is reentrant and processed without parallelization.<br />

(T )write ocr trainf<br />

(T )trainf ocr class box<br />

Optical character recognition<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

read ocr trainf select ( Hobject *Characters,<br />

const char *TrainFileNames, const char *SearchNames, char *FoundNames )<br />

T read ocr trainf select ( Hobject *Characters, Htuple TrainFileNames,<br />

Htuple SearchNames, Htuple *FoundNames )<br />

Read training specific characters from files and convert to images.<br />

(T )read ocr trainf select reads the characters given in SearchNames from the specified files and<br />

converts them into images. It works simimalr to T read ocr trainf but here the characters which are extracted<br />

can be specified.<br />

Parameter<br />

º Characters (output object) .........................................image-array Hobject * : byte<br />

Images read from file.<br />

º TrainFileNames (input control) ....................filename.named(-array) (Htuple .) const char *<br />

Names of the training files.<br />

Default Value : ”<br />

º SearchNames (input control) ..................................string(-array) (Htuple .) const char *<br />

Names of the characters to be extracted.<br />

Default Value : ’0’<br />

º FoundNames (output control) .......................................string(-array) (Htuple .) char *<br />

Names of the read characters.<br />

Result<br />

If the parameter values are correct the operator (T )read ocr trainf select returns the value<br />

H MSG TRUE. Otherwise an exception handling is raised.<br />

Parallelization Information<br />

(T )read ocr trainf select is reentrant and processed without parallelization.<br />

(T )write ocr trainf<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

disp image, select obj, zoom image size<br />

T read ocr trainf<br />

(T )trainf ocr class box<br />

Optical character recognition<br />

Alternatives<br />

See Also<br />

Module<br />

testd ocr class box ( Hobject Character, Hobject Image, long OcrHandle,<br />

const char *Class, double *Confidence )<br />

T testd ocr class box ( Hobject Character, Hobject Image,<br />

Htuple OcrHandle, Htuple Class, Htuple *Confidence )<br />

Training of an OCR classifier by the input of regions.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.12. OCR 791<br />

The operator (T )testd ocr class box tests the confidence with which a character belongs to a given class.<br />

Any number of regions of an image can be passed. For each character (region) in Character the corresponding<br />

name (class) Class must be specified. The grayvalues are passed in Image. When the operator has finished the<br />

parameter Confidence provides information about how sure a character belongs to the (arbitrary chosen) class.<br />

Parameter<br />

º Character (input object) ..................................................region(-array) Hobject<br />

Characters to be trained.<br />

º Image (input object) ..............................................................image Hobject<br />

Grayvalues for the characters.<br />

º OcrHandle (input control) ....................................................ocr (Htuple .) long<br />

ID of the desired OCR-classifier.<br />

º Class (input control) ..........................................string(-array) (Htuple .) const char *<br />

Class (name) of the characters.<br />

Default Value : ”a”<br />

º Confidence (output control) .......................................real(-array) (Htuple .) double *<br />

Confidence for the character to belong to the class.<br />

Result<br />

If the parameters are correct, the operator (T )testd ocr class box returns the value H MSG TRUE. Otherwise<br />

an exception will be raised.<br />

Parallelization Information<br />

(T )testd ocr class box is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

read ocr, (T )trainf ocr class box, (T )traind ocr class box<br />

Optical character recognition<br />

Module<br />

traind ocr class box ( Hobject Character, Hobject Image,<br />

long OcrHandle, const char *Class, double *AvgConfidence )<br />

T traind ocr class box ( Hobject Character, Hobject Image,<br />

Htuple OcrHandle, Htuple Class, Htuple *AvgConfidence )<br />

Training of an OCR classifier by the input of regions.<br />

The operator (T )traind ocr class box trains the classifier directly via the input of regions in an image.<br />

Any number of regions of an image can be passed. For each character (region) in Character the corresponding<br />

name (class) Class must be specified. The grayvalues are passed in Image. When the procedure has finished<br />

the parameter AvgConfidence provides information about the success of the training: It contains the average<br />

confidence of the trained characters measured by a re-classification. The confidence of mismatched characters is<br />

set to 0 (thus, the average confidence will be decreased significantly).<br />

Parameter<br />

º Character (input object) ..................................................region(-array) Hobject<br />

Characters to be trained.<br />

º Image (input object) ..............................................................image Hobject<br />

Grayvalues for the characters.<br />

º OcrHandle (input control) ....................................................ocr (Htuple .) long<br />

ID of the desired OCR-classifier.<br />

º Class (input control) ..........................................string(-array) (Htuple .) const char *<br />

Class (name) of the characters.<br />

Default Value : ”a”<br />

º AvgConfidence (output control) .........................................real (Htuple .) double *<br />

Average confidence during a re-classification of the trained characters.<br />

Example<br />

<strong>HALCON</strong> 6.0


792 CHAPTER 12. TOOLS<br />

char name[128];<br />

long orc_handle;<br />

read_ocr("testnet",&orc_handle);<br />

read_image(&Image,"character.tiff");<br />

bin_threshold(Image,&Dark);<br />

connection(Dark,&Character);<br />

count_obj(Character,&num);<br />

open_window(0,0,-1,-1,0,"","",&WindowHandle);<br />

set_color(WindowHandle,"red");<br />

for (i=0; i


12.12. OCR 793<br />

Example<br />

HTuple FileName, OcrHandle, AvgConfidence;<br />

T_create_ocr_class_box(WidthPattern,HeightPattern,Interpolation,<br />

Features,\Character,&OcrHandle);<br />

create_tuple(&FileName,2);<br />

set_s(FileName,"data1",0);<br />

set_s(FileName,"data2",1);<br />

T_trainf_ocr_class_box(OcrHandle,FileName,&AvgConfidence);<br />

Result<br />

If the file name is correct and the data fit the network, the operator (T )trainf ocr class box returns the<br />

value H MSG TRUE. Otherwise an exception will be raised.<br />

Parallelization Information<br />

(T )trainf ocr class box is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

T create ocr class box, read ocr<br />

Possible Successor Functions<br />

(T )traind ocr class box, write ocr, (T )do ocr multi, T do ocr single<br />

(T )traind ocr class box<br />

Optical character recognition<br />

Alternatives<br />

Module<br />

write ocr ( long OcrHandle, const char *FileName )<br />

Writing an OCR classifier into a file.<br />

The operator write ocr writes the OCR classifier OcrHandle into the file FileName. Since the data of the<br />

classifier will be lost when the program is finished, they have to be stored after the training if the user wants to use<br />

them again at a later execution of the program. The data can then be read with the help of the operator read ocr.<br />

The extension will be added automatically to the parameter FileName.<br />

Attention<br />

The output file FileName must be given without extension.<br />

Parameter<br />

º OcrHandle (input control) ..............................................................ocr long<br />

ID of the OCR classifier.<br />

º FileName (input control) ...................................................filename const char *<br />

Name of the file for the OCR classifier (without extension).<br />

Default Value : ’my ocr’<br />

Result<br />

If the parameter OcrHandle is valid and the indicated file can be written, the operator write ocr returns the<br />

value H MSG TRUE. Otherwise an exception will be raised.<br />

Parallelization Information<br />

write ocr is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

(T )traind ocr class box, (T )trainf ocr class box<br />

Possible Successor Functions<br />

(T )do ocr multi, T do ocr single<br />

See Also<br />

read ocr, (T )do ocr multi, (T )traind ocr class box, (T )trainf ocr class box<br />

Optical character recognition<br />

Module<br />

<strong>HALCON</strong> 6.0


794 CHAPTER 12. TOOLS<br />

write ocr trainf ( Hobject Character, Hobject Image, const char *Class,<br />

const char *FileName )<br />

T write ocr trainf ( Hobject Character, Hobject Image, Htuple Class,<br />

Htuple FileName )<br />

Storing of trained characters into a file.<br />

The operator (T )write ocr trainf serves to prepare the training with the operator<br />

(T )trainf ocr class box. Hereby regions, representing characters, including their grayvalues (region<br />

and pixel) and the corresponding classname will be written into a file. An arbitrary number of regions<br />

within one image is supported. For each character (region) in Character the corresponding class name must be<br />

specified in Class. The grayvalues are passed via the parameter Image. The file name can be chosen at will.<br />

Parameter<br />

º Character (input object) ..................................................region(-array) Hobject<br />

Characters to be trained.<br />

º Image (input object) ..............................................................image Hobject<br />

Grayvalues of the characters.<br />

º Class (input control) ..........................................string(-array) (Htuple .) const char *<br />

Class (name) of the characters.<br />

º FileName (input control) ..........................................filename (Htuple .) const char *<br />

Name of the training file.<br />

Default Value : ”train ocr”<br />

Example<br />

char<br />

HTuple<br />

name[128];<br />

Class,Name;<br />

read_image(&Image,"character.tiff");<br />

bin_threshold(Image,&Dark);<br />

connection(Dark,&Character);<br />

count_obj(Character,&num);<br />

create_tuple(&Class,num);<br />

open_window(0,0,-1,-1,0,"","",&WindowHandle);<br />

set_color(WindowHandle,"red");<br />

for (i=0; i


12.13. OCV 795<br />

Optical character recognition<br />

Module<br />

write ocr trainf image ( Hobject Character, const char *Class,<br />

const char *FileName )<br />

T write ocr trainf image ( Hobject Character, Htuple Class,<br />

Htuple FileName )<br />

Write characters into a training file.<br />

The operator (T )write ocr trainf image is used to prepare the training with the operator<br />

(T )trainf ocr class box. Hereby regions, representing characters, including their grayvalues (region and<br />

pixel) and the corresponding classname will be written into a file. An arbitrary number of regions within one<br />

image is supported. For each character (region) in Character the corresponding class name must be specified in<br />

Class. The file name can be chosen at will. In contrast to (T )write ocr trainf one image per character<br />

is passed. The domain of this image defines the pixels which belong to the character.<br />

Parameter<br />

º Character (input object) ..................................................image(-array) Hobject<br />

Characters to be trained.<br />

º Class (input control) ..........................................string(-array) (Htuple .) const char *<br />

Class (name) of the characters.<br />

º FileName (input control) ..........................................filename (Htuple .) const char *<br />

Name of the training file.<br />

Default Value : ”train ocr”<br />

Result<br />

If the parameters are correct, the operator (T )write ocr trainf image returns the value H MSG TRUE.<br />

Otherwise an exception will be raised.<br />

Parallelization Information<br />

(T )write ocr trainf image is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

threshold, connection, T create ocr class box, read ocr<br />

Possible Successor Functions<br />

(T )trainf ocr class box, T info ocr class box, write ocr, (T )do ocr multi,<br />

T do ocr single<br />

Alternatives<br />

(T )write ocr trainf, (T )append ocr trainf<br />

Optical character recognition<br />

Module<br />

12.13 OCV<br />

close all ocvs ( )<br />

Clear all OCV tools.<br />

close all ocvs closes all OCV tools which have been opened using (T )create ocv proj or read ocv.<br />

All handles are invalid after this call.<br />

Attention<br />

This operator is only for internal use (like e.g. a reset program in HDevelop).<br />

Result<br />

close all ocvs returns always H MSG TRUE.<br />

<strong>HALCON</strong> 6.0


796 CHAPTER 12. TOOLS<br />

Parallelization Information<br />

close all ocvs is processed completely exclusively without parallelization.<br />

read ocv, (T )create ocv proj<br />

close ocv<br />

Optical character verification<br />

Possible Predecessor Functions<br />

Alternatives<br />

Module<br />

close ocv ( long OCVHandle )<br />

Clear an OCV tool.<br />

close ocv closes an open OCV tool and frees the memory. The OCV tool has been created using<br />

(T )create ocv proj or read ocv. The handle is after this call no longer valid.<br />

Parameter<br />

º OCVHandle (input control) ..............................................................ocv long<br />

Handle of the OCV tool which has to be freed.<br />

Example<br />

read_ocv("ocv_file",&ocv_handle);<br />

for (i=0; i


12.13. OCV 797<br />

The pattern comparison is based on the gray projections: For every traing pattern the horizontal and vertical gray<br />

projections are calculated by summing up the gray values along the rows and columns inside the region of the<br />

pattern. This operation is applied to the training patterns and the test patterns. For the training patterns the result<br />

is stored inside the OCV tool to save runtime while comparing patterns. The OCV is done by comparing the<br />

corresponding projections. The Quality is the similarity of the projections.<br />

Input for (T )create ocv proj are the names of the patterns (PatternNames) which have to be trained.<br />

The number and the names can be chosen arbitrary. In most case only one pattern will be trained, thus only one<br />

name has to be specified. The names will be used when doing the OCV ((T )do ocv simple). It is possible to<br />

specify more names than actually used. These might be trained later.<br />

To close the OCV tool, i.e. to free the memory, the operator close ocv is called.<br />

Parameter<br />

º PatternNames (input control) ................................string(-array) (Htuple .) const char *<br />

List of names for patterns to be trained.<br />

Default Value : ”a”<br />

º OCVHandle (output control) .................................................ocv (Htuple .) long *<br />

Handle of the created OCV tool.<br />

Example<br />

create_ocv_proj("A",&ocv_handle);<br />

draw_region(&ROI,window_handle);<br />

reduce_domain(Image,ROI,&Sample);<br />

traind_ocv_proj(Sample,ocv_handle,"A","single");<br />

Result<br />

(T )create ocv proj returns H MSG TRUE, if the parameters are correct. Otherwise, an exception handling<br />

is raised.<br />

Parallelization Information<br />

(T )create ocv proj is processed completely exclusively without parallelization.<br />

Possible Successor Functions<br />

(T )traind ocv proj, write ocv, close ocv<br />

read ocv<br />

T create ocr class box<br />

Optical character verification<br />

Alternatives<br />

See Also<br />

Module<br />

do ocv simple ( Hobject Pattern, long OCVHandle,<br />

const char *PatternName, const char *AdaptPos, const char *AdaptSize,<br />

const char *AdaptAngle, const char *AdaptGray, double Threshold,<br />

double *Quality )<br />

T do ocv simple ( Hobject Pattern, Htuple OCVHandle, Htuple PatternName,<br />

Htuple AdaptPos, Htuple AdaptSize, Htuple AdaptAngle, Htuple AdaptGray,<br />

Htuple Threshold, Htuple *Quality )<br />

Verification of a pattern using an OCV tool.<br />

(T )do ocv simple evaluates the pattern in (Pattern). Before the evaluation the good-pattern has be trained<br />

by using the operator (T )traind ocv proj. Both patterns should have roughly the same (relative) extent and<br />

shape. To specify which of the trained patterns is used as reference its name is specified in PatternName. The<br />

next four parameters influence the automatic adaption: AdaptPos and AdaptSize refer to the geometry of the<br />

pattern. AdaptPos specifies whether a shift of the position will be adapted automatically. AdaptSize is used<br />

to adapt to changes in the size of the pattern. AdaptAngle is not yet implemented. The parameter AdaptGray<br />

<strong>HALCON</strong> 6.0


798 CHAPTER 12. TOOLS<br />

controls the adaption to changes of the grayvalues. This comprises additive and multiplicative changes of the<br />

intensity.<br />

The parameter Threshold specifies the minimum difference of the gray values to be treated as an error. In this<br />

case the percentage of wrong pixels is returned. If the value is below 0 the sum of all errors normalized with<br />

respect to the size is returned.<br />

The result of the operator is the Quality of the pattern with a value between 0 and 1. The value 1 corresponds to<br />

a pattern with no faults. The value 0 corresponds to a very big fault.<br />

Parameter<br />

º Pattern (input object) .....................................................image(-array) Hobject<br />

Characters to be verified.<br />

º OCVHandle (input control) ....................................................ocv (Htuple .) long<br />

Handle of the OCV tool.<br />

º PatternName (input control) ..................................string(-array) (Htuple .) const char *<br />

Name of the character.<br />

Default Value : ”a”<br />

º AdaptPos (input control) .............................................string (Htuple .) const char *<br />

Adaption to vertical and horizontal translation.<br />

Default Value : ”true”<br />

Value List : AdaptPos ¾”true”, ”false”<br />

º AdaptSize (input control) ...........................................string (Htuple .) const char *<br />

Adaption to vertical and horizontal scaling of the size.<br />

Default Value : ”true”<br />

Value List : AdaptSize ¾”true”, ”false”<br />

º AdaptAngle (input control) ..........................................string (Htuple .) const char *<br />

Adaption to changes of the orientation (not yet implemented).<br />

Default Value : ”false”<br />

Value List : AdaptAngle ¾”false”<br />

º AdaptGray (input control) ...........................................string (Htuple .) const char *<br />

Adaption to additive and scaling gray value changes.<br />

Default Value : ”true”<br />

Value List : AdaptGray ¾”true”, ”false”<br />

º Threshold (input control) ..............................................number (Htuple .) double<br />

Minimum difference between objects.<br />

Default Value : 10<br />

Value Suggestions : Threshold ¾-1, 0, 1, 5, 10, 15, 20, 30, 40, 50, 60, 80, 100, 150<br />

º Quality (output control) ...........................................real(-array) (Htuple .) double *<br />

Evaluation of the character.<br />

Typical Range of Values : 0.0 Quality 1.0<br />

Result<br />

(T )do ocv simple returns H MSG TRUE, if the handle and the characters are correct. Otherwise, an exception<br />

handling is raised.<br />

Parallelization Information<br />

(T )do ocv simple is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

(T )traind ocr class box, (T )trainf ocr class box, read ocv, threshold, connection,<br />

select shape<br />

Possible Successor Functions<br />

close ocv<br />

See Also<br />

(T )create ocv proj<br />

Module<br />

Optical character verification<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.13. OCV 799<br />

read ocv ( const char *FileName, long *OCVHandle )<br />

Reading an OCV tool from file.<br />

read ocv reads an OCV tool from file. The tool will contain the same information that it contained when saving<br />

it with write ocv. After reading the tool the training can be completed for those patterns which have not been<br />

trained so far. Otherwise a pattern comparison can be applied directly by calling (T )do ocv simple.<br />

As extension ’.ocv’ is used. If this extension is not given with the file name it will be added automatically.<br />

Parameter<br />

º FileName (input control) ...................................................filename const char *<br />

Name of the file which has to be read.<br />

Default Value : ’test ocv’<br />

º OCVHandle (output control) ...........................................................ocv long *<br />

Handle of read OCV tool.<br />

Example<br />

read_ocv("ocv_file",&ocv_handle);<br />

for (i=0; i


800 CHAPTER 12. TOOLS<br />

If more than one pattern has to be trained this can be achieved by multiple calls (one for each pattern) or by calling<br />

(T )traind ocv proj once with all patterns and a tuple of the corresponding names. The result will be in<br />

both cases the same. However using multiple calls will normally result in a longer execution time than using one<br />

call with all patterns.<br />

Parameter<br />

º Pattern (input object) .....................................................image(-array) Hobject<br />

Pattern to be trained.<br />

º OCVHandle (input control) ....................................................ocv (Htuple .) long<br />

Handle of the OCV tool to be trained.<br />

º Name (input control) ...........................................string(-array) (Htuple .) const char *<br />

Name(s) of the object(s) to analyse.<br />

Default Value : ”a”<br />

º Mode (input control) ..................................................string (Htuple .) const char *<br />

Mode for training (only one mode implemented).<br />

Default Value : ’single’<br />

Value List : Mode ¾’single’<br />

Example<br />

create_ocv_proj("A",&ocv_handle);<br />

draw_region(&ROI,window_handle);<br />

reduce_domain(Image,ROI,&Sample);<br />

traind_ocv_proj(Sample,ocv_handle,"A","single");<br />

Result<br />

(T )traind ocv proj returns H MSG TRUE, if the handle and the training pattern(s) are correct. Otherwise,<br />

an exception handling is raised.<br />

Parallelization Information<br />

(T )traind ocv proj is processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

(T )write ocr trainf, (T )create ocv proj, read ocv, threshold, connection,<br />

select shape<br />

Possible Successor Functions<br />

close ocv<br />

See Also<br />

(T )traind ocr class box<br />

Module<br />

Optical character verification<br />

write ocv ( long OCVHandle, const char *FileName )<br />

Saving an OCV tool to file.<br />

write ocv writes an OCV tool to file. This can be used to save the result of a training<br />

((T )traind ocv proj). The whole information contained in the OCV tool is stored in the file. The file<br />

can be reloaded afterwards using the operator read ocv.<br />

As file extension ’.ocv’ is used. If this extension is not given with the file name, it will be added automatically.<br />

Parameter<br />

º OCVHandle (input control) ..............................................................ocv long<br />

Handle of the OCV tool to be written.<br />

º FileName (input control) ...................................................filename const char *<br />

Name of the file where the tool has to be saved.<br />

Default Value : ’test ocv’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.14. SHAPE-FROM 801<br />

Result<br />

write ocv returns H MSG TRUE, if the data is correct and the file can be written. Otherwise, an exception<br />

handling is raised.<br />

Parallelization Information<br />

write ocv is reentrant and processed without parallelization.<br />

(T )traind ocv proj<br />

close ocv<br />

write ocr<br />

Optical character verification<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

12.14 Shape-from<br />

depth from focus ( Hobject MultiFocusImage, Hobject *Depth,<br />

Hobject *Confidence, const char *Filter, const char *Selection )<br />

T depth from focus ( Hobject MultiFocusImage, Hobject *Depth,<br />

Hobject *Confidence, Htuple Filter, Htuple Selection )<br />

Extract depth using mutiple focus levels.<br />

The operator (T )depth from focus extracts the depth using a focus sequence. The images of the focus<br />

sequence have to passed as a multi channel image (MultiFocusImage). The depth for each pixel will be<br />

returned in Depth as the channel number. The parameter Confidence returns a confidence value for each<br />

depth estimation: The larger this value, the higher the confidence of the depth estimation is.<br />

(T )depth from focus selects the pixels with the best focus of all focus levels. The method used to extract<br />

these pixels is specified by the parameters Filter and Selection:<br />

’highpass’ The value of the focus is estimated by a highpass filter.<br />

’bandpass’ The value of the focus is estimated by a bandpass filter.<br />

’next maximum’ To decide which focus level has be selected, the pixel in the neighborhood with the best confidence<br />

is used to determine this value.<br />

’local’ The decision for a focus level is based only on the locally calculated focus values.<br />

Parameter<br />

º MultiFocusImage (input object) . . . . . . . . . . . . . . . . . . . . . . . multichannel-image(-array) Hobject : byte<br />

Multichannel gray image consisting of multiple focus levels.<br />

º Depth (output object) .................................singlechannel-image(-array) Hobject * : byte<br />

Depth image.<br />

º Confidence (output object) ..........................singlechannel-image(-array) Hobject * : byte<br />

Confidence of depth estimation.<br />

º Filter (input control) ........................................string(-array) (Htuple .) const char *<br />

Filter used to find sharp pixels.<br />

Default Value : ’highpass’<br />

Value List : Filter ¾’highpass’, ’bandpass’<br />

º Selection (input control) ....................................string(-array) (Htuple .) const char *<br />

Method used to find sharp pixels.<br />

Default Value : ’next maximum’<br />

Value List : Selection ¾’next maximum’, ’local’<br />

<strong>HALCON</strong> 6.0


802 CHAPTER 12. TOOLS<br />

Example<br />

compose3(Focus0,Focus1,Focus2,&MultiFocus);<br />

depth_from_focus(MultiFocus,&Depth,&Confidence,’highpass’,’next_maximum’);<br />

mean_image(Depth,&Smooth,15,15);<br />

select_grayvalues_from_channels(MultiChannel,Smooth,SharpImage);<br />

threshold(Confidence,HighConfidence,10,255);<br />

reduce_domain(SharpImage,HighConfidence,ConfidentSharp);<br />

Parallelization Information<br />

(T )depth from focus is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

compose2, compose3, compose4, add channels, read image, read sequence<br />

Possible Successor Functions<br />

select grayvalues from channels, mean image, gauss image, threshold<br />

count channels<br />

Tools<br />

See Also<br />

Module<br />

estimate al am ( Hobject Image, double *Albedo, double *Ambient )<br />

T estimate al am ( Hobject Image, Htuple *Albedo, Htuple *Ambient )<br />

Estimate the albedo of a surface and the amount of ambient light.<br />

(T )estimate al am estimates the Albedo of a surface, i.e. the percentage of light reflected by the surface,<br />

and the amount of ambient light Ambient by using the maximum and minimum gray values of the image.<br />

Attention<br />

It is assumed that the image contains at least one point for which the reflection function assumes its minimum, e.g.,<br />

points in shadows. Furthermore, it is assumed that the image contains at least one point for which the reflection<br />

function assumes its maximum. If this is not the case, wrong values will be estimated.<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Image for which albedo and ambient are to be estimated.<br />

º Albedo (output control) ............................................real(-array) (Htuple .) double *<br />

Amount of light reflected by the surface.<br />

º Ambient (output control) ...........................................real(-array) (Htuple .) double *<br />

Amount of ambient light.<br />

Result<br />

(T )estimate al am always returns the value H MSG TRUE.<br />

Parallelization Information<br />

(T )estimate al am is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

sfs mod lr, sfs orig lr, sfs pentland, T phot stereo, shade height field<br />

Tools<br />

Module<br />

estimate sl al lr ( Hobject Image, double *Slant, double *Albedo )<br />

T estimate sl al lr ( Hobject Image, Htuple *Slant, Htuple *Albedo )<br />

Estimate the slant of a light source and the albedo of a surface.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.14. SHAPE-FROM 803<br />

(T )estimate sl al lr estimates the Slant of a light source, i.e., the angle between the light source and<br />

the positive z-axis, and the albedo of the surface in the input image Image, i.e. the percentage of light reflected<br />

by the surface, using the algorithm of Lee and Rosenfeld.<br />

Attention<br />

The Albedo is assumed constant for the entire surface depicted in the image.<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Image for which slant and albedo are to be estimated.<br />

º Slant (output control) ........................................angle.deg(-array) (Htuple .) double *<br />

Angle between the light sources and the positive z-axis (in degrees).<br />

º Albedo (output control) ............................................real(-array) (Htuple .) double *<br />

Amount of light reflected by the surface.<br />

Result<br />

(T )estimate sl al lr always returns the value H MSG TRUE.<br />

Parallelization Information<br />

(T )estimate sl al lr is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

sfs mod lr, sfs orig lr, sfs pentland, T phot stereo, shade height field<br />

Tools<br />

Module<br />

estimate sl al zc ( Hobject Image, double *Slant, double *Albedo )<br />

T estimate sl al zc ( Hobject Image, Htuple *Slant, Htuple *Albedo )<br />

Estimate the slant of a light source and the albedo of a surface.<br />

(T )estimate sl al zc estimates the Slant of a light source, i.e. the angle between the light source and the<br />

positive z-axis, and the albedo of the surface in the input image Image, i.e. the percentage of light reflected by<br />

the surface, using the algorithm of Zheng and Chellappa.<br />

Attention<br />

The Albedo is assumed constant for the entire surface depicted in the image.<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Image for which slant and albedo are to be estimated.<br />

º Slant (output control) ........................................angle.deg(-array) (Htuple .) double *<br />

Angle of the light sources and the positive z-axis (in degrees).<br />

º Albedo (output control) ............................................real(-array) (Htuple .) double *<br />

Amount of light reflected by the surface.<br />

Result<br />

(T )estimate sl al zc always returns the value H MSG TRUE.<br />

Parallelization Information<br />

(T )estimate sl al zc is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

sfs mod lr, sfs orig lr, sfs pentland, T phot stereo, shade height field<br />

Tools<br />

Module<br />

<strong>HALCON</strong> 6.0


804 CHAPTER 12. TOOLS<br />

estimate tilt lr ( Hobject Image, double *Tilt )<br />

T estimate tilt lr ( Hobject Image, Htuple *Tilt )<br />

Estimate the tilt of a light source.<br />

(T )estimate tilt lr estimates the tilt of a light source, i.e. the angle between the light source and the<br />

x-axis after projection into the xy-plane, from the image Image using the algorithm of Lee and Rosenfeld.<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Image for which the tilt is to be estimated.<br />

º Tilt (output control) .........................................angle.deg(-array) (Htuple .) double *<br />

Angle between the light source and the x-axis after projection into the xy-plane (in degrees).<br />

Result<br />

(T )estimate tilt lr always returns the value H MSG TRUE.<br />

Parallelization Information<br />

(T )estimate tilt lr is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

sfs mod lr, sfs orig lr, sfs pentland, T phot stereo, shade height field<br />

Tools<br />

Module<br />

estimate tilt zc ( Hobject Image, double *Tilt )<br />

T estimate tilt zc ( Hobject Image, Htuple *Tilt )<br />

Estimate the tilt of a light source.<br />

(T )estimate tilt zc estimates the tilt of a light source, i.e. the angle between the light source and the<br />

x-axis after projection into the xy-plane, from the image Image using the algorithm of Zheng and Chellappa.<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Image for which the tilt is to be estimated.<br />

º Tilt (output control) .........................................angle.deg(-array) (Htuple .) double *<br />

Angle between the light source and the x-axis after projection into the xy-plane (in degrees).<br />

Result<br />

(T )estimate tilt zc always returns the value H MSG TRUE.<br />

Parallelization Information<br />

(T )estimate tilt zc is reentrant and automatically parallelized (on tuple level).<br />

Possible Successor Functions<br />

sfs mod lr, sfs orig lr, sfs pentland, T phot stereo, shade height field<br />

Tools<br />

Module<br />

T phot stereo ( Hobject Images, Hobject *Height, Htuple Slants,<br />

Htuple Tilts )<br />

Reconstruct a surface from at least three gray value images.<br />

T phot stereo reconstructs a surface (i.e., the relative height of each image point) using the algorithm of<br />

Woodham from at least three gray value images given by the multi-channel image Images. The light sources<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.14. SHAPE-FROM 805<br />

corresponding to the individual images are given by the parameters Slants and Tilts and are assumed to lie<br />

infinitely far away.<br />

Attention<br />

T phot stereo assumes that the heights are to be extracted on a lattice with step width 1. If this is not the<br />

case, the calculated heights must be multiplied by the step width after the call to T phot stereo. ACartesian<br />

coordinate system with the origin in the lower left corner of the image is used internally. Since the operator is<br />

based on the Fast Fourier Transform, only square images with an edge length being a power of 2 are accepted. All<br />

given images must be byte-images. At least three images must be given in a multi-channel image. Slants and<br />

Tilts must contain exactly as many light sources as the number of channels in Images. At least three of the<br />

light source directions must be linearly independent.<br />

Parameter<br />

º Images (input object) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (multichannel-)image Hobject<br />

Shaded input image with at least three channels.<br />

º Height (output object) ..........................................................image Hobject *<br />

Reconstructed height field.<br />

º Slants (input control) ......................................angle.deg-array Htuple . double / long<br />

Angle between the light sources and the positive z-axis (in degrees).<br />

Default Value : 45.0<br />

Value Suggestions : Slants ¾1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 90.0<br />

Typical Range of Values : 0.0 Slants 180.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 10.0<br />

º Tilts (input control) ........................................angle.deg-array Htuple . double / long<br />

Angle between the light source and the x-axis after projection into the xy-plane (in degrees).<br />

Default Value : 45.0<br />

Value Suggestions : Tilts ¾1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 90.0<br />

Typical Range of Values : 0.0 Tilts 360.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 10.0<br />

Result<br />

If all parameters are correct T phot stereo returns the value H MSG TRUE. Otherwise, an exception is raised.<br />

Parallelization Information<br />

T phot stereo is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

(T )estimate sl al lr, (T )estimate sl al zc, (T )estimate tilt lr,<br />

(T )estimate tilt zc<br />

Possible Successor Functions<br />

shade height field<br />

Module<br />

Tools<br />

select grayvalues from channels ( Hobject MultichannelImage,<br />

Hobject IndexImage, Hobject *Selected )<br />

Selection of gray values of a multi channel image using an index image.<br />

The operator select grayvalues from channels selects gray values from a MultichannelImage.<br />

The channel number for each pixel is determined by using IndexImage: The gray value in IndexImage is<br />

used as the channel number in MultichannelImage.<br />

Parameter<br />

º MultichannelImage (input object) . . . . . . . . . . . . . . . . . . . . . multichannel-image(-array) Hobject : byte<br />

Multichannel gray image.<br />

º IndexImage (input object) ..............................singlechannel-image(-array) Hobject : byte<br />

Image, where gray values are interpreted als indexes.<br />

<strong>HALCON</strong> 6.0


806 CHAPTER 12. TOOLS<br />

º Selected (output object) .............................singlechannel-image(-array) Hobject * : byte<br />

Depth image.<br />

Example<br />

compose3(Focus0,Focus1,Focus2,&MultiFocus);<br />

depth_from_focus(MultiFocus,&Depth,&Confidence,’highpass’,’next_maximum’);<br />

mean_image(Depth,&Smooth,15,15);<br />

select_grayvalues_from_channels(MultiChannel,Smooth,SharpImage);<br />

Parallelization Information<br />

select grayvalues from channels is reentrant and automatically parallelized (on tuple level, domain<br />

level).<br />

Possible Predecessor Functions<br />

(T )depth from focus, mean image<br />

disp image<br />

count channels<br />

Tools<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

sfs mod lr ( Hobject Image, Hobject *Height, double Slant, double Tilt,<br />

double Albedo, double Ambient )<br />

Reconstruct a surface from a gray value image.<br />

sfs mod lr reconstructs a surface (i.e. the relative height of each image point) using the modified algorithm of<br />

Lee and Rosenfeld. The surface is reconstructed from the input image Image, and the light source given by the<br />

parameters Slant, Tilt, Albedo and Ambient, and is assumed to lie infinitely far away in the direction given<br />

by Slant and Tilt. The parameter Albedo determines the albedo of the surface, i.e. the percentage of light<br />

reflected in all directions. Ambient determines the amount of ambient light falling onto the surface. It can be set<br />

to values greater than zero if, for example, the white balance of the camera was badly adjusted at the moment the<br />

image was taken.<br />

Attention<br />

sfs mod lr assumes that the heights are to be extracted on a lattice with step width 1. If this is not the case, the<br />

calculated heights must be multiplied with the step width after the call to sfs mod lr. A Cartesian coordinate<br />

system with the origin in the lower left corner of the image is used internally. Since the operator is based on the<br />

Fast Fourier Transform, only square images with the edge length being a power of 2 are accepted. sfs mod lr<br />

can only handle byte-images.<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Shaded input image.<br />

º Height (output object) ...................................................image(-array) Hobject *<br />

Reconstructed height field.<br />

º Slant (input control) .....................................................angle.deg double / long<br />

Angle between the light source and the positive z-axis (in degrees).<br />

Default Value : 45.0<br />

Value Suggestions : Slant ¾1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 90.0<br />

Typical Range of Values : 0.0 Slant 180.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 10.0<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.14. SHAPE-FROM 807<br />

º Tilt (input control) ......................................................angle.deg double / long<br />

Angle between the light source and the x-axis after projection into the xy-plane (in degrees).<br />

Default Value : 45.0<br />

Value Suggestions : Tilt ¾1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 90.0<br />

Typical Range of Values : 0.0 Tilt 360.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 10.0<br />

º Albedo (input control) .....................................................number double / long<br />

Amount of light reflected by the surface.<br />

Default Value : 1.0<br />

Value Suggestions : Albedo ¾0.1, 0.5, 1.0, 5.0<br />

Typical Range of Values : 0.0 Albedo 5.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Albedo 0.0<br />

º Ambient (input control) ....................................................number double / long<br />

Amount of ambient light.<br />

Default Value : 0.0<br />

Value Suggestions : Ambient ¾0.1, 0.5, 1.0<br />

Typical Range of Values : 0.0 Ambient 1.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Ambient 0.0<br />

Result<br />

If all parameters are correct sfs mod lr returns the value H MSG TRUE. Otherwise, an exception is raised.<br />

Parallelization Information<br />

sfs mod lr is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

(T )estimate al am, (T )estimate sl al lr, (T )estimate sl al zc,<br />

(T )estimate tilt lr, (T )estimate tilt zc<br />

shade height field<br />

Tools<br />

Possible Successor Functions<br />

Module<br />

sfs orig lr ( Hobject Image, Hobject *Height, double Slant, double Tilt,<br />

double Albedo, double Ambient )<br />

Reconstruct a surface from a gray value image.<br />

sfs orig lr reconstructs a surface (i.e. the relative height of each image point) using the original algorithm of<br />

Lee and Rosenfeld. The surface is reconstructed from the input image Image. The light source is to be given by<br />

the parameters Slant, Tilt, Albedo and Ambient, and is assumed to lie infinitely far away in the direction<br />

given by Slant and Tilt. The parameter Albedo determines the albedo of the surface, i.e. the percentage of<br />

light reflected in all directions. Ambient determines the amount of ambient light falling onto the surface. It can<br />

be set to values greater than zero if, for example, the white balance of the camera was badly adjusted at the moment<br />

the image was taken.<br />

Attention<br />

sfs orig lr assumes that the heights are to be extracted on a lattice with step width 1. If this is not the case, the<br />

calculated heights must be multiplied with the step width after the call to sfs orig lr. A Cartesian coordinate<br />

system with the origin in the lower left corner of the image is used internally. Since the operator is based on the<br />

Fast Fourier Transform, only square images with the edge length being a power of 2 are accepted. sfs orig lr<br />

can only handle byte-images.<br />

<strong>HALCON</strong> 6.0


808 CHAPTER 12. TOOLS<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Shaded input image.<br />

º Height (output object) ...................................................image(-array) Hobject *<br />

Reconstructed height field.<br />

º Slant (input control) .....................................................angle.deg double / long<br />

Angle between the light source and the positive z-axis (in degrees).<br />

Default Value : 45.0<br />

Value Suggestions : Slant ¾1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 90.0<br />

Typical Range of Values : 0.0 Slant 180.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 10.0<br />

º Tilt (input control) ......................................................angle.deg double / long<br />

Angle between the light source and the x-axis after projection into the xy-plane (in degrees).<br />

Default Value : 45.0<br />

Value Suggestions : Tilt ¾1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 90.0<br />

Typical Range of Values : 0.0 Tilt 360.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 10.0<br />

º Albedo (input control) .....................................................number double / long<br />

Amount of light reflected by the surface.<br />

Default Value : 1.0<br />

Value Suggestions : Albedo ¾0.1, 0.5, 1.0, 5.0<br />

Typical Range of Values : 0.0 Albedo 5.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Albedo 0.0<br />

º Ambient (input control) ....................................................number double / long<br />

Amount of ambient light.<br />

Default Value : 0.0<br />

Value Suggestions : Ambient ¾0.1, 0.5, 1.0<br />

Typical Range of Values : 0.0 Ambient 1.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Ambient 0.0<br />

Result<br />

If all parameters are correct sfs orig lr returns the value H MSG TRUE. Otherwise, an exception is raised.<br />

Parallelization Information<br />

sfs orig lr is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

(T )estimate al am, (T )estimate sl al lr, (T )estimate sl al zc,<br />

(T )estimate tilt lr, (T )estimate tilt zc<br />

shade height field<br />

Tools<br />

Possible Successor Functions<br />

Module<br />

sfs pentland ( Hobject Image, Hobject *Height, double Slant,<br />

double Tilt, double Albedo, double Ambient )<br />

Reconstruct a surface from a gray value image.<br />

sfs pentland reconstructs a surface (i.e. the relative height of each image point) using the algorithm of Pentland.<br />

The surface is reconstructed from the input image Image. The light source must be given by the parameters<br />

Slant, Tilt, Albedo and Ambient, and is assumed to lie infinitely far away in the direction given by Slant<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.14. SHAPE-FROM 809<br />

and Tilt. The parameter Albedo determines the albedo of the surface, i.e. the percentage of light reflected in<br />

all directions. Ambient determines the amount of ambient light falling onto the surface. It can be set to values<br />

greater than zero if, for example, the white balance of the camera was badly adjusted at the moment the image was<br />

taken.<br />

Attention<br />

sfs pentland assumes that the heights are to be extracted on a lattice with step width 1. If this is not the<br />

case, the calculated heights must be multiplied with the step width after the call to sfs pentland. ACartesian<br />

coordinate system with the origin in the lower left corner of the image is used internally. Since the operator is<br />

based on the Fast Fourier Transform, only square images with the edge length being a power of 2 are accepted.<br />

sfs pentland can only handle byte-images.<br />

Parameter<br />

º Image (input object) ........................................................image(-array) Hobject<br />

Shaded input image.<br />

º Height (output object) ...................................................image(-array) Hobject *<br />

Reconstructed height field.<br />

º Slant (input control) .....................................................angle.deg double / long<br />

Angle between the light source and the positive z-axis (in degrees).<br />

Default Value : 45.0<br />

Value Suggestions : Slant ¾1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 90.0<br />

Typical Range of Values : 0.0 Slant 180.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Tilt (input control) ......................................................angle.deg double / long<br />

Angle between the light source and the x-axis after projection into the xy-plane (in degrees).<br />

Default Value : 45.0<br />

Value Suggestions : Tilt ¾1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 90.0<br />

Typical Range of Values : 0.0 Tilt 360.0 (lin)<br />

Minimal Value Step : 1.0<br />

Recommended Value Step : 10.0<br />

º Albedo (input control) .....................................................number double / long<br />

Amount of light reflected by the surface.<br />

Default Value : 1.0<br />

Value Suggestions : Albedo ¾0.1, 0.5, 1.0, 5.0<br />

Typical Range of Values : 0.0 Albedo 5.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Albedo 0.0<br />

º Ambient (input control) ....................................................number double / long<br />

Amount of ambient light.<br />

Default Value : 0.0<br />

Value Suggestions : Ambient ¾0.1, 0.5, 1.0<br />

Typical Range of Values : 0.0 Ambient 1.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Ambient 0.0<br />

Result<br />

If all parameters are correct sfs pentland returns the value H MSG TRUE. Otherwise, an exception is raised.<br />

Parallelization Information<br />

sfs pentland is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

(T )estimate al am, (T )estimate sl al lr, (T )estimate sl al zc,<br />

(T )estimate tilt lr, (T )estimate tilt zc<br />

shade height field<br />

Tools<br />

Possible Successor Functions<br />

Module<br />

<strong>HALCON</strong> 6.0


810 CHAPTER 12. TOOLS<br />

shade height field ( Hobject ImageHeight, Hobject *ImageShade,<br />

double Slant, double Tilt, double Albedo, double Ambient,<br />

const char *Shadows )<br />

Shade a height field.<br />

shade height field computes a shaded image from the height field ImageHeight as if the image were<br />

illuminated by an infinitely far away light source. It is assumed that the surface described by the height field has<br />

Lambertian reflection properties determined by Albedo and Ambient. The parameter Shadows determines<br />

whether shadows are to be calculated.<br />

Attention<br />

shade height field assumes that the heights are given on a lattice with step width 1. If this is not the case, the<br />

heights must be divided by the step width before the call to shade height field. Otherwise, the derivatives<br />

used internally to compute the orientation of the surface will be estimated to steep or too flat. Example: The height<br />

field is given on 100*100 points on the square [0,1]*[0,1]. Then the heights must be divided by 1/100 first. A<br />

Cartesian coordinate system with the origin in the lower left corner of the image is used internally.<br />

Parameter<br />

º ImageHeight (input object) ...............................................image(-array) Hobject<br />

Height field to be shaded.<br />

º ImageShade (output object) ..............................................image(-array) Hobject *<br />

Shaded image.<br />

º Slant (input control) .....................................................angle.deg double / long<br />

Angle between the light source and the positive z-axis (in degrees).<br />

Default Value : 0.0<br />

Value Suggestions : Slant ¾1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 90.0<br />

Typical Range of Values : 0.0 Slant 180.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 10.0<br />

º Tilt (input control) ......................................................angle.deg double / long<br />

Angle between the light source and the x-axis after projection into the xy-plane (in degrees).<br />

Default Value : 0.0<br />

Value Suggestions : Tilt ¾1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 90.0<br />

Typical Range of Values : 0.0 Tilt 360.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 10.0<br />

º Albedo (input control) .....................................................number double / long<br />

Amount of light reflected by the surface.<br />

Default Value : 1.0<br />

Value Suggestions : Albedo ¾0.1, 0.5, 1.0, 5.0<br />

Typical Range of Values : 0.0 Albedo 5.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Albedo 0.0<br />

º Ambient (input control) ....................................................number double / long<br />

Amount of ambient light.<br />

Default Value : 0.0<br />

Value Suggestions : Ambient ¾0.1, 0.5, 1.0<br />

Typical Range of Values : 0.0 Ambient 1.0 (lin)<br />

Minimal Value Step : 0.01<br />

Recommended Value Step : 0.1<br />

Restriction : Ambient 0.0<br />

º Shadows (input control) .......................................................string const char *<br />

Should shadows be calculated?<br />

Default Value : ’false’<br />

Value Suggestions : Shadows ¾’true’, ’false’<br />

Result<br />

If all parameters are correct shade height field returns the value H MSG TRUE. Otherwise, an exception<br />

is raised.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


12.14. SHAPE-FROM 811<br />

Parallelization Information<br />

shade height field is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

sfs mod lr, sfs orig lr, sfs pentland, T phot stereo<br />

Tools<br />

Module<br />

<strong>HALCON</strong> 6.0


812 CHAPTER 12. TOOLS<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Chapter 13<br />

Tuple<br />

13.1 Arithmetic<br />

tuple abs ( double T, double *Abs )<br />

T tuple abs ( Htuple T, Htuple *Abs )<br />

Compute the absolute value of a tuple.<br />

(T )tuple abs computes the absolute value of the input tuple T. The absolute value of an integer number is<br />

again an integer number. The absolute value of a floating point number is a floating point number. The absolute<br />

value of a string is not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Abs (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double * / long *<br />

Absolute value of the input tuple.<br />

Parallelization Information<br />

(T )tuple abs is reentrant and processed without parallelization.<br />

(T )tuple fabs<br />

Operators not requiring licensing<br />

Alternatives<br />

Module<br />

tuple acos ( double T, double *ACos )<br />

T tuple acos ( Htuple T, Htuple *ACos )<br />

Compute the arccosine of a tuple.<br />

(T )tuple acos computes the arccosine of the input tuple T. The arccosine is always returned as a floating<br />

point number. The arccosine of a string is not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

Restriction : ´-1 Tµ 1<br />

º ACos (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Arccosine of the input tuple.<br />

813


814 CHAPTER 13. TUPLE<br />

Parallelization Information<br />

(T )tuple acos is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple asin, (T )tuple atan, (T )tuple atan2<br />

(T )tuple cos<br />

Operators not requiring licensing<br />

See Also<br />

Module<br />

tuple add ( double S1, double S2, double *Sum )<br />

T tuple add ( Htuple S1, Htuple S2, Htuple *Sum )<br />

Add two tuples.<br />

(T )tuple add computes the sum of the input tuples S1 and S2. If both tuples have the same length the<br />

corresponding elements of both tuples are added. Otherwise, either S1 or S2 must have length 1. In this case, the<br />

addition is performed for each element of the longer tuple with the single element of the other tuple. If two integer<br />

numbers are added, the result is again an integer number. If a floating point number is added to another number,<br />

the result is a floating point number. If two strings are added, the addition corresponds to a string concatenation. If<br />

a number and a string are added, the number is converted to a string first. Thus, the addition also corresponds to a<br />

string concatenation in this case.<br />

Parameter<br />

º S1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long / const char *<br />

Input tuple 1.<br />

º S2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long / const char *<br />

Input tuple 2.<br />

º Sum (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double * / long * / char *<br />

Sum of the input tuples.<br />

Parallelization Information<br />

(T )tuple add is reentrant and processed without parallelization.<br />

(T )tuple sub<br />

Operators not requiring licensing<br />

Alternatives<br />

Module<br />

tuple asin ( double T, double *ASin )<br />

T tuple asin ( Htuple T, Htuple *ASin )<br />

Compute the arcsine of a tuple.<br />

(T )tuple asin computes the arcsine of the input tuple T. The arcsine is always returned as a floating point<br />

number. The arcsine of a string is not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

Restriction : ´-1 Tµ 1<br />

º ASin (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Arcsine of the input tuple.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.1. ARITHMETIC 815<br />

Parallelization Information<br />

(T )tuple asin is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple acos, (T )tuple atan, (T )tuple atan2<br />

(T )tuple sin<br />

Operators not requiring licensing<br />

See Also<br />

Module<br />

tuple atan ( double T, double *ATan )<br />

T tuple atan ( Htuple T, Htuple *ATan )<br />

Compute the arctangent of a tuple.<br />

(T )tuple atan computes the arctangent of the input tuple T. The arctangent is always returned as a floating<br />

point number. The arctangent of a string is not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º ATan (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Arctangent of the input tuple.<br />

Parallelization Information<br />

(T )tuple atan is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple atan2, (T )tuple asin, (T )tuple acos<br />

(T )tuple tan<br />

Operators not requiring licensing<br />

See Also<br />

Module<br />

tuple atan2 ( double Y, double X, double *ATan )<br />

T tuple atan2 ( Htuple Y, Htuple X, Htuple *ATan )<br />

Compute the arctangent of a tuple for all four quadrants.<br />

(T )tuple atan2 computes the arctangent of the input tuples while treating all four quadrants correctly.<br />

The arctangent is always returned as a floating point number. The arctangent of a string is not allowed.<br />

Parameter<br />

º Y (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple of the y-values.<br />

º X (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple of the x-values.<br />

º ATan (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Arctangent of the input tuple.<br />

Parallelization Information<br />

(T )tuple atan2 is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple atan, (T )tuple asin, (T )tuple acos<br />

<strong>HALCON</strong> 6.0


816 CHAPTER 13. TUPLE<br />

(T )tuple tan<br />

Operators not requiring licensing<br />

See Also<br />

Module<br />

tuple cos ( double T, double *Cos )<br />

T tuple cos ( Htuple T, Htuple *Cos )<br />

Compute the cosine of a tuple.<br />

(T )tuple cos computes the cosine of the input tuple T. The cosine is always returned as a floating point<br />

number. The cosine of a string is not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Cos (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double *<br />

Cosine of the input tuple.<br />

Parallelization Information<br />

(T )tuple cos is reentrant and processed without parallelization.<br />

(T )tuple sin, (T )tuple tan<br />

(T )tuple acos<br />

Operators not requiring licensing<br />

Alternatives<br />

See Also<br />

Module<br />

tuple cosh ( double T, double *Cosh )<br />

T tuple cosh ( Htuple T, Htuple *Cosh )<br />

Compute the hyperbolic cosine of a tuple.<br />

(T )tuple cosh computes the hyperbolic cosine of the input tuple T. The hyperbolic cosine is always returned<br />

as a floating point number. The hyperbolic cosine of a string is not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Cosh (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Hyperbolic cosine of the input tuple.<br />

Parallelization Information<br />

(T )tuple cosh is reentrant and processed without parallelization.<br />

(T )tuple sinh, (T )tuple tanh<br />

Operators not requiring licensing<br />

Alternatives<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.1. ARITHMETIC 817<br />

tuple div ( double Q1, double Q2, double *Quot )<br />

T tuple div ( Htuple Q1, Htuple Q2, Htuple *Quot )<br />

Divide two tuples.<br />

(T )tuple div computes the quotient of the input tuples Q1 and Q2. If both tuples have the same length the<br />

corresponding elements of both tuples are divided. Otherwise, either Q1 or Q2 must have length 1. In this case, the<br />

division is performed for each element of the longer tuple with the single element of the other tuple. If two integer<br />

numbers are divided, the result is again an integer number. If one of the operands is a floating point number, the<br />

result is a floating point number. The division of strings is not allowed.<br />

Parameter<br />

º Q1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple 1.<br />

º Q2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple 2.<br />

Restriction : Q2 0<br />

º Quot (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double * / long *<br />

Quotient of the input tuples.<br />

Parallelization Information<br />

(T )tuple div is reentrant and processed without parallelization.<br />

(T )tuple mult<br />

Operators not requiring licensing<br />

Alternatives<br />

Module<br />

tuple exp ( double T, double *Exp )<br />

T tuple exp ( Htuple T, Htuple *Exp )<br />

Compute the exponential of a tuple.<br />

(T )tuple exp computes the exponential of the input tuple T. The exponential is always returned as a floating<br />

point number. The exponential of a string is not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Exp (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double *<br />

Exponential of the input tuple.<br />

Parallelization Information<br />

(T )tuple exp is reentrant and processed without parallelization.<br />

(T )tuple pow<br />

(T )tuple log, (T )tuple log10<br />

Operators not requiring licensing<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


818 CHAPTER 13. TUPLE<br />

tuple fabs ( double T, double *Abs )<br />

T tuple fabs ( Htuple T, Htuple *Abs )<br />

Compute the absolute value of a tuple (as floating point numbers).<br />

(T )tuple fabs computes the absolute value of the input tuple T. In contrast to (T )tuple abs, the absolute<br />

value is always returned as a floating point number by (T )tuple fabs. The absolute value of a string is not<br />

allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Abs (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double *<br />

Absolute value of the input tuple.<br />

Parallelization Information<br />

(T )tuple fabs is reentrant and processed without parallelization.<br />

(T )tuple abs<br />

Operators not requiring licensing<br />

Alternatives<br />

Module<br />

tuple fmod ( double T1, double T2, double *Fmod )<br />

T tuple fmod ( Htuple T1, Htuple T2, Htuple *Fmod )<br />

Calculate the remainder of the floating point division of two tuples.<br />

(T )tuple fmod computes the remainder of the floating point division of the input tuples ̽̾. If both tuples<br />

have the same length the division is performed for the corresponding elements of both tuples. Otherwise, either<br />

T1 or T2 must have length 1. In this case, the division is performed for each element of the longer tuple with<br />

the single element of the other tuple. The result is always a floating point number. The division of strings is not<br />

allowed.<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple 2.<br />

Restriction : T2 0.0<br />

º Fmod (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Remainder of the division of the input tuples.<br />

Parallelization Information<br />

(T )tuple fmod is reentrant and processed without parallelization.<br />

(T )tuple floor, (T )tuple ceil<br />

Operators not requiring licensing<br />

See Also<br />

Module<br />

tuple ldexp ( double T1, double T2, double *Ldexp )<br />

T tuple ldexp ( Htuple T1, Htuple T2, Htuple *Ldexp )<br />

Calculate the ldexp function of two tuples.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.1. ARITHMETIC 819<br />

(T )tuple ldexp computes the ldexp function of the input tuples, i.e., ̽ £ ¾ ̾ . If both tuples have the same<br />

length the operation is performed for the corresponding elements of both tuples. Otherwise, either T1 or T2 must<br />

have length 1. In this case, the operation is performed for each element of the longer tuple with the single element<br />

of the other tuple. The result is always a floating point number. The ldexp function of strings is not allowed.<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple 2.<br />

º Ldexp (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Ldexp function of the input tuples.<br />

Parallelization Information<br />

(T )tuple ldexp is reentrant and processed without parallelization.<br />

(T )tuple exp<br />

Operators not requiring licensing<br />

See Also<br />

Module<br />

tuple log ( double T, double *Log )<br />

T tuple log ( Htuple T, Htuple *Log )<br />

Compute the natural logarithm of a tuple.<br />

(T )tuple log computes the natural logarithm of the input tuple T. The natural logarithm is always returned as<br />

a floating point number. The natural logarithm of a string is not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

Restriction : T 0<br />

º Log (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double *<br />

Natural logarithm of the input tuple.<br />

Parallelization Information<br />

(T )tuple log is reentrant and processed without parallelization.<br />

(T )tuple log10<br />

(T )tuple exp, (T )tuple pow<br />

Operators not requiring licensing<br />

Alternatives<br />

See Also<br />

Module<br />

tuple log10 ( double T, double *Log )<br />

T tuple log10 ( Htuple T, Htuple *Log )<br />

Compute the base 10 logarithm of a tuple.<br />

(T )tuple log10 computes the base 10 logarithm of the input tuple T. The logarithm is always returned as a<br />

floating point number. The logarithm of a string is not allowed.<br />

<strong>HALCON</strong> 6.0


820 CHAPTER 13. TUPLE<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

Restriction : T 0<br />

º Log (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double *<br />

Base 10 logarithm of the input tuple.<br />

Parallelization Information<br />

(T )tuple log10 is reentrant and processed without parallelization.<br />

(T )tuple log<br />

(T )tuple exp, (T )tuple pow<br />

Operators not requiring licensing<br />

Alternatives<br />

See Also<br />

Module<br />

tuple mult ( double P1, double P2, double *Prod )<br />

T tuple mult ( Htuple P1, Htuple P2, Htuple *Prod )<br />

Multiply two tuples.<br />

(T )tuple mult computes the product of the input tuples P1 and P2. If both tuples have the same length the<br />

corresponding elements of both tuples are subtracted. Otherwise, either P1 or P2 must have length 1. In this case,<br />

the multiplication is performed for each element of the longer tuple with the single element of the other tuple. If<br />

two integer numbers are multiplied, the result is again an integer number. If one of the operands is a floating point<br />

number, the result is a floating point number. The multiplication of strings is not allowed.<br />

Parameter<br />

º P1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple 1.<br />

º P2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple 2.<br />

º Prod (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double * / long *<br />

Product of the input tuples.<br />

Parallelization Information<br />

(T )tuple mult is reentrant and processed without parallelization.<br />

(T )tuple div<br />

Operators not requiring licensing<br />

Alternatives<br />

Module<br />

tuple neg ( double T, double *Neg )<br />

T tuple neg ( Htuple T, Htuple *Neg )<br />

Negate a tuple.<br />

(T )tuple neg computes the negation of the input tuple T, i.e., Æ Ì. The negation of an integer number<br />

is again an integer number. The negation of a floating point number is a floating point number. The negation of a<br />

string is not allowed. The negation of an empty input tuple results in an empty output tuple.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.1. ARITHMETIC 821<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Neg (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double * / long *<br />

Negation of the input tuple.<br />

Parallelization Information<br />

(T )tuple neg is reentrant and processed without parallelization.<br />

Operators not requiring licensing<br />

Module<br />

tuple pow ( double T1, double T2, double *Pow )<br />

T tuple pow ( Htuple T1, Htuple T2, Htuple *Pow )<br />

Calculate the power function two tuples.<br />

(T )tuple pow computes the power function of the input tuples ̽ ̾ . If both tuples have the same length the<br />

power function is applied to the corresponding elements of both tuples. Otherwise, either T1 or T2 must have<br />

length 1. In this case, the power function is performed for each element of the longer tuple with the single element<br />

of the other tuple. The result is always a floating point number. The power function of strings is not allowed.<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple 2.<br />

º Pow (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double * / long *<br />

Power function of the input tuples.<br />

Parallelization Information<br />

(T )tuple pow is reentrant and processed without parallelization.<br />

(T )tuple exp<br />

(T )tuple log, (T )tuple log10<br />

Operators not requiring licensing<br />

Alternatives<br />

See Also<br />

Module<br />

tuple rad ( double Deg, double *Rad )<br />

T tuple rad ( Htuple Deg, Htuple *Rad )<br />

Convert a tuple from degrees to radians.<br />

(T )tuple rad converts the input tuple Deg from degrees to radians. The result is always returned as a floating<br />

point number. The conversion of a string is not allowed.<br />

Parameter<br />

º Deg (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Rad (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double *<br />

Input tuple in radians.<br />

<strong>HALCON</strong> 6.0


822 CHAPTER 13. TUPLE<br />

Parallelization Information<br />

(T )tuple rad is reentrant and processed without parallelization.<br />

(T )tuple deg<br />

Operators not requiring licensing<br />

See Also<br />

Module<br />

tuple sin ( double T, double *Sin )<br />

T tuple sin ( Htuple T, Htuple *Sin )<br />

Compute the sine of a tuple.<br />

(T )tuple sin computes the sine of the input tuple T. The sine is always returned as a floating point number.<br />

The sine of a string is not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Sin (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double *<br />

Sine of the input tuple.<br />

Parallelization Information<br />

(T )tuple sin is reentrant and processed without parallelization.<br />

(T )tuple cos, (T )tuple tan<br />

(T )tuple asin<br />

Operators not requiring licensing<br />

Alternatives<br />

See Also<br />

Module<br />

tuple sinh ( double T, double *Sinh )<br />

T tuple sinh ( Htuple T, Htuple *Sinh )<br />

Compute the hyperbolic sine of a tuple.<br />

(T )tuple sin computes the hyperbolic sine of the input tuple T. The hyperbolic sine is always returned as a<br />

floating point number. The hyperbolic sine of a string is not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Sinh (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Hyperbolic sine of the input tuple.<br />

Parallelization Information<br />

(T )tuple sinh is reentrant and processed without parallelization.<br />

(T )tuple cosh, (T )tuple tanh<br />

Operators not requiring licensing<br />

Alternatives<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.1. ARITHMETIC 823<br />

tuple sqrt ( double T, double *Sqrt )<br />

T tuple sqrt ( Htuple T, Htuple *Sqrt )<br />

Compute the square root of a tuple.<br />

(T )tuple sqrt computes the square root of the input tuple T. The square root is always returned as a floating<br />

point number. The square root of a string is not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

Restriction : T 0<br />

º Sqrt (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Square root of the input tuple.<br />

Parallelization Information<br />

(T )tuple sqrt is reentrant and processed without parallelization.<br />

Operators not requiring licensing<br />

Module<br />

tuple sub ( double D1, double D2, double *Diff )<br />

T tuple sub ( Htuple D1, Htuple D2, Htuple *Diff )<br />

Subtract two tuples.<br />

(T )tuple sub computes the difference of the input tuples D1 and D2. If both tuples have the same length the<br />

corresponding elements of both tuples are subtracted. Otherwise, either D1 or D2 must have length 1. In this case,<br />

the subtraction is performed for each element of the longer tuple with the single element of the other tuple. If two<br />

integer numbers are subtracted, the result is again an integer number. If one of the operands is a floating point<br />

number, the result is a floating point number. The subtraction of strings is not allowed.<br />

Parameter<br />

º D1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple 1.<br />

º D2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple 2.<br />

º Diff (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double * / long *<br />

Difference of the input tuples.<br />

Parallelization Information<br />

(T )tuple sub is reentrant and processed without parallelization.<br />

(T )tuple add<br />

Operators not requiring licensing<br />

Alternatives<br />

Module<br />

tuple tan ( double T, double *Tan )<br />

T tuple tan ( Htuple T, Htuple *Tan )<br />

Compute the tangent of a tuple.<br />

(T )tuple tan computes the tangent of the input tuple T. The tangent is always returned as a floating point<br />

number. The tangent of a string is not allowed.<br />

<strong>HALCON</strong> 6.0


824 CHAPTER 13. TUPLE<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Tan (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double *<br />

Tangent of the input tuple.<br />

Parallelization Information<br />

(T )tuple tan is reentrant and processed without parallelization.<br />

(T )tuple sin, (T )tuple cos<br />

(T )tuple atan, (T )tuple atan2<br />

Operators not requiring licensing<br />

Alternatives<br />

See Also<br />

Module<br />

tuple tanh ( double T, double *Tanh )<br />

T tuple tanh ( Htuple T, Htuple *Tanh )<br />

Compute the hyperbolic tangent of a tuple.<br />

(T )tuple tanh computes the hyperbolic tangent of the input tuple T. The hyperbolic tangent is always returned<br />

as a floating point number. The hyperbolic tangent of a string is not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Tanh (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Hyperbolic tangent of the input tuple.<br />

Parallelization Information<br />

(T )tuple tanh is reentrant, local, and processed without parallelization.<br />

(T )tuple sinh, (T )tuple cosh<br />

Operators not requiring licensing<br />

Alternatives<br />

Module<br />

13.2 Bit-Operations<br />

tuple band ( long T1, long T2, long *BAnd )<br />

T tuple band ( Htuple T1, Htuple T2, Htuple *BAnd )<br />

Compute the bitwise and of two tuples.<br />

(T )tuple band computes the bitwise and of the input tuples T1 and T2. If both tuples have the same length<br />

the operation is performed on the corresponding elements of both tuples. Otherwise, either T1 or T2 must have<br />

length 1. In this case, the operation is performed for each element of the longer tuple with the single element of<br />

the other tuple. The input tuples must contain only integer numbers.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.2. BIT-OPERATIONS 825<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long<br />

Input tuple 2.<br />

º BAnd (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Binary and of the input tuples.<br />

Parallelization Information<br />

(T )tuple band is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple bor, (T )tuple bxor, (T )tuple bnot<br />

See Also<br />

(T )tuple and, (T )tuple or, (T )tuple xor, (T )tuple not<br />

Operators not requiring licensing<br />

Module<br />

tuple bnot ( long T, long *BNot )<br />

T tuple bnot ( Htuple T, Htuple *BNot )<br />

Compute the bitwise not of two tuples.<br />

(T )tuple bnot computes the bitwise not of the input tuple T. The input tuple must contain only integer<br />

numbers.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Input tuple.<br />

º BNot (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Binary not of the input tuple.<br />

Parallelization Information<br />

(T )tuple bnot is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple band, (T )tuple bor, (T )tuple bxor<br />

See Also<br />

(T )tuple and, (T )tuple or, (T )tuple xor, (T )tuple not<br />

Operators not requiring licensing<br />

Module<br />

tuple bor ( long T1, long T2, long *BOr )<br />

T tuple bor ( Htuple T1, Htuple T2, Htuple *BOr )<br />

Compute the bitwise or of two tuples.<br />

(T )tuple bor computes the bitwise or of the input tuples T1 and T2. If both tuples have the same length the<br />

operation is performed on the corresponding elements of both tuples. Otherwise, either T1 or T2 must have length<br />

1. In this case, the operation is performed for each element of the longer tuple with the single element of the other<br />

tuple. The input tuples must contain only integer numbers.<br />

<strong>HALCON</strong> 6.0


826 CHAPTER 13. TUPLE<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long<br />

Input tuple 2.<br />

º BOr (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Binary or of the input tuples.<br />

Parallelization Information<br />

(T )tuple bor is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple band, (T )tuple bxor, (T )tuple bnot<br />

See Also<br />

(T )tuple and, (T )tuple or, (T )tuple xor, (T )tuple not<br />

Operators not requiring licensing<br />

Module<br />

tuple bxor ( long T1, long T2, long *BXor )<br />

T tuple bxor ( Htuple T1, Htuple T2, Htuple *BXor )<br />

Compute the bitwise exclusive or of two tuples.<br />

(T )tuple bxor computes the bitwise exclusive or of the input tuples T1 and T2. If both tuples have the same<br />

length the operation is performed on the corresponding elements of both tuples. Otherwise, either T1 or T2 must<br />

have length 1. In this case, the operation is performed for each element of the longer tuple with the single element<br />

of the other tuple. The input tuples must contain only integer numbers.<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long<br />

Input tuple 2.<br />

º BXor (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Binary exclusive or of the input tuples.<br />

Parallelization Information<br />

(T )tuple bxor is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple band, (T )tuple bor, (T )tuple bnot<br />

See Also<br />

(T )tuple and, (T )tuple or, (T )tuple xor, (T )tuple not<br />

Operators not requiring licensing<br />

Module<br />

tuple lsh ( long T, long Shift, long *Lsh )<br />

T tuple lsh ( Htuple T, Htuple Shift, Htuple *Lsh )<br />

Shift a tuple bitwise to the left.<br />

(T )tuple lsh shifts the tuple T bitwise to the left by Shift places. If no overflow occurs, this operation is<br />

equivalent to a multiplication by ¾ ËØ .IfT is negative, the result depends on the hardware. If Shift is negative<br />

or larger than 32, the result is undefined. If both tuples have the same length the corresponding elements of both<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.2. BIT-OPERATIONS 827<br />

tuples are shifted. Otherwise, either T or Shift must have length 1. In this case, the operation is performed for<br />

each element of the longer tuple with the single element of the other tuple. The input tuples must contain only<br />

integer numbers.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Input tuple.<br />

º Shift (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long<br />

Number of places to shift the input tuple.<br />

º Lsh (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Shifted input tuple.<br />

Parallelization Information<br />

(T )tuple lsh is reentrant and processed without parallelization.<br />

(T )tuple mult<br />

(T )tuple rsh<br />

Operators not requiring licensing<br />

Alternatives<br />

See Also<br />

Module<br />

tuple rsh ( long T, long Shift, long *Rsh )<br />

T tuple rsh ( Htuple T, Htuple Shift, Htuple *Rsh )<br />

Shift a tuple bitwise to the right.<br />

(T )tuple rsh shifts the tuple T bitwise to the right by Shift places. This operation is equivalent to a division<br />

by ¾ ËØ .IfT is negative, the result depends on the hardware. If Shift is negative or larger than 32, the result is<br />

undefined. If both tuples have the same length the corresponding elements of both tuples are shifted. Otherwise,<br />

either T or Shift must have length 1. In this case, the operation is performed for each element of the longer tuple<br />

with the single element of the other tuple. The input tuples must contain only integer numbers.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Input tuple.<br />

º Shift (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long<br />

Number of places to shift the input tuple.<br />

º Rsh (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Shifted input tuple.<br />

Parallelization Information<br />

(T )tuple rsh is reentrant and processed without parallelization.<br />

(T )tuple div<br />

(T )tuple lsh<br />

Operators not requiring licensing<br />

Alternatives<br />

See Also<br />

Module<br />

<strong>HALCON</strong> 6.0


828 CHAPTER 13. TUPLE<br />

13.3 Comparison<br />

tuple equal ( long T1, long T2, long *Equal )<br />

T tuple equal ( Htuple T1, Htuple T2, Htuple *Equal )<br />

Test, whether two tuples are equal.<br />

(T )tuple equal tests whether the two input tuples T1 and T2 are equal by comparing the tuples elementwise.<br />

Two tuples are equal, if they have got the same number of elements and if their elements are equal. Two tuple<br />

elements are equal, if they are both (integer or floating point) numbers or both are strings and contain the same<br />

value.<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple 2.<br />

º Equal (output control) ....................................................integer (Htuple .) long *<br />

Result of the comparison of the input tuples.<br />

Parallelization Information<br />

(T )tuple equal is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple not equal, (T )tuple less, (T )tuple greater, (T )tuple less equal,<br />

(T )tuple greater equal<br />

Module<br />

Operators not requiring licensing<br />

tuple greater ( long T1, long T2, long *Greater )<br />

T tuple greater ( Htuple T1, Htuple T2, Htuple *Greater )<br />

Test, whether a tuple is greater than another tuple.<br />

(T )tuple greater tests whether the input tuple T1 is greater than T2. A tuple T1 is said to be greater than<br />

a tuple T2, ifT1 has been found to be greater when comparing it elementwise to T2 or (for the case that the<br />

elementwise comparison did not show that T1 is greater than T2) ifT1 has got more elements than T2. With the<br />

elementwise comparison the single elements of T1 and T2 are compared with each other one after another (i.e., the<br />

first element of T1 is compared to the first element of T2 and the second element of T1 is compared to the second<br />

element of T2 etc.). If an element of T1 is greater than its counterpart of T2, T1 is said to be greater than T2. As<br />

a precondition for comparing the tuples elementwise two corresponding elements must either both be (integer or<br />

floating point) numbers or both be strings. Otherwise (T )tuple greater returns an error.<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple 2.<br />

º Greater (output control) .................................................integer (Htuple .) long *<br />

Result of the comparison of the input tuples.<br />

Parallelization Information<br />

(T )tuple greater is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple greater equal, (T )tuple less, (T )tuple less equal, (T )tuple equal,<br />

(T )tuple not equal<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.3. COMPARISON 829<br />

Operators not requiring licensing<br />

Module<br />

tuple greater equal ( long T1, long T2, long *Greatereq )<br />

T tuple greater equal ( Htuple T1, Htuple T2, Htuple *Greatereq )<br />

Test, whether a tuple is greater or equal to another tuple.<br />

(T )tuple greater equal tests whether the input tuple T1 is greater or equal to T2. A tuple T1 is said to<br />

be greater or equal to a tuple T2,ifT1 is not less than T2. A tuple T1 is said to be less than a tuple T2, ifT1 has<br />

been found to be less when comparing it elementwise to T2 or (for the case that the elementwise comparison did<br />

not show that T1 is less than T2)ifT1 has got less elements than T2. With the elementwise comparison the single<br />

elements of T1 and T2 are compared with each other one after another (i.e., the first element of T1 is compared to<br />

the first element of T2 and the second element of T1 is compared to the second element of T2 etc.). If an element<br />

of T1 is less than its counterpart of T2, T1 is said to be less than T2. As a precondition for comparing the tuples<br />

elementwise two corresponding elements must either both be (integer or floating point) numbers or both be strings.<br />

Otherwise (T )tuple greater equal returns an error.<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple 2.<br />

º Greatereq (output control) ..............................................integer (Htuple .) long *<br />

Result of the comparison of the input tuples.<br />

Parallelization Information<br />

(T )tuple greater equal is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple greater, (T )tuple less, (T )tuple less equal, (T )tuple equal,<br />

(T )tuple not equal<br />

Module<br />

Operators not requiring licensing<br />

tuple less ( long T1, long T2, long *Less )<br />

T tuple less ( Htuple T1, Htuple T2, Htuple *Less )<br />

Test, whether a tuple is less than another tuple.<br />

(T )tuple less tests whether the input tuple T1 is less than T2. A tuple T1 is said to be less than a tuple T2,if<br />

T1 has been found to be less when comparing it elementwise to T2 or (for the case that the elementwise comparison<br />

did not show that T1 is less than T2) ifT1 has got less elements than T2. With the elementwise comparison the<br />

single elements of T1 and T2 are compared with each other one after another (i.e., the first element of T1 is<br />

compared to the first element of T2 and the second element of T1 is compared to the second element of T2 etc.). If<br />

an element of T1 is less than its counterpart of T2, T1 is said to be less than T2. As a precondition for comparing<br />

the tuples elementwise two corresponding elements must either both be (integer or floating point) numbers or both<br />

be strings. Otherwise (T )tuple less returns an error.<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple 2.<br />

<strong>HALCON</strong> 6.0


830 CHAPTER 13. TUPLE<br />

º Less (output control) .....................................................integer (Htuple .) long *<br />

Result of the comparison of the input tuples.<br />

Parallelization Information<br />

(T )tuple less is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple less equal, (T )tuple greater, (T )tuple greater equal, (T )tuple equal,<br />

(T )tuple not equal<br />

Module<br />

Operators not requiring licensing<br />

tuple less equal ( long T1, long T2, long *Lesseq )<br />

T tuple less equal ( Htuple T1, Htuple T2, Htuple *Lesseq )<br />

Test, whether a tuple is less or equal to another tuple.<br />

(T )tuple less equal tests whether the input tuple T1 is less or equal to T2. A tuple T1 is said to be less or<br />

equal to a tuple T2, ifT1 is not greater than T2. A tuple T1 is said to be greater than a tuple T2, ifT1 has been<br />

found to be greater when comparing it elementwise to T2 or (for the case that the elementwise comparison did not<br />

show that T1 is greater than T2)ifT1 has got more elements than T2. With the elementwise comparison the single<br />

elements of T1 and T2 are compared with each other one after another (i.e., the first element of T1 is compared to<br />

the first element of T2 and the second element of T1 is compared to the second element of T2 etc.). If an element<br />

of T1 is greater than its counterpart of T2, T1 is said to be greater than T2. As a precondition for comparing the<br />

tuples elementwise two corresponding elements must either both be (integer or floating point) numbers or both be<br />

strings. Otherwise (T )tuple less equal returns an error.<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple 2.<br />

º Lesseq (output control) ..................................................integer (Htuple .) long *<br />

Result of the comparison of the input tuples.<br />

Parallelization Information<br />

(T )tuple less equal is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple less, (T )tuple greater, (T )tuple greater equal, (T )tuple equal,<br />

(T )tuple not equal<br />

Module<br />

Operators not requiring licensing<br />

tuple not equal ( long T1, long T2, long *Nequal )<br />

T tuple not equal ( Htuple T1, Htuple T2, Htuple *Nequal )<br />

Test, whether two tuples are not equal.<br />

(T )tuple not equal tests whether the two input tuples T1 and T2 are not equal. Two tuples are not equal, if<br />

they consist of a different number of elements or if they differ when compared elementwise. Two tuple elements<br />

differ, if they are of types that may not be compared (e.g. one string and one integer) or if they differ in their values.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.4. CONVERSION 831<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple 2.<br />

º Nequal (output control) ..................................................integer (Htuple .) long *<br />

Result of the comparison of the input tuples.<br />

Parallelization Information<br />

(T )tuple not equal is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple equal, (T )tuple less, (T )tuple greater, (T )tuple less equal,<br />

(T )tuple greater equal<br />

Module<br />

Operators not requiring licensing<br />

13.4 Conversion<br />

tuple chr ( long T, char *Chr )<br />

T tuple chr ( Htuple T, Htuple *Chr )<br />

Convert a tuple of integers into strings with the corresponding ASCII codes.<br />

(T )tuple chr converts the input tuple T, consisting of integer numbers, into a tuple of strings of length 1, the<br />

characters of which have the ASCII code of the corresponding input number.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Input tuple.<br />

Restriction : ´0 Tµ 255<br />

º Chr (output control) .................................................string(-array) (Htuple .) char *<br />

Strings corresponding to the ASCII code of the input tuple.<br />

Parallelization Information<br />

(T )tuple chr is reentrant and processed without parallelization.<br />

(T )tuple chrt<br />

(T )tuple ord, (T )tuple ords<br />

Operators not requiring licensing<br />

Alternatives<br />

See Also<br />

Module<br />

tuple chrt ( long T, char *Chrt )<br />

T tuple chrt ( Htuple T, Htuple *Chrt )<br />

Convert a tuple of integers into strings with the corresponding ASCII codes.<br />

(T )tuple chrt converts the input tuple T, consisting of integer numbers, into a tuple of strings and integer<br />

numbers (where only the number 0 can occur in the output), the characters of which have the ASCII code of the<br />

corresponding input number. The operator tries to pack as many of the input numbers into one string as possible.<br />

Only if the value 0 occurs in T the current string is terminated at this point, the integer number 0 is inserted into<br />

<strong>HALCON</strong> 6.0


832 CHAPTER 13. TUPLE<br />

the output, and a new string with the remaining input values is started. This operator can be used to convert data<br />

read with read serial into strings. With this mechanism it is possible to read bytes with the value 0.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Input tuple.<br />

Restriction : ´0 Tµ 255<br />

º Chrt (output control) ........................................string(-array) (Htuple .) char * / long *<br />

Strings corresponding to the ASCII code of the input tuple.<br />

Example<br />

read_serial (SerialHandle, 100, Data)<br />

tuple_chrt (Data, Strings)<br />

Parallelization Information<br />

(T )tuple chrt is reentrant and processed without parallelization.<br />

(T )tuple chr<br />

Alternatives<br />

See Also<br />

(T )tuple ord, (T )tuple ords, read serial<br />

Operators not requiring licensing<br />

Module<br />

tuple deg ( double Rad, double *Deg )<br />

T tuple deg ( Htuple Rad, Htuple *Deg )<br />

Convert a tuple from radians to degrees.<br />

(T )tuple deg converts the input tuple Rad from radians to degrees. The result is always returned as a floating<br />

point number. The conversion of a string is not allowed.<br />

Parameter<br />

º Rad (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Deg (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double *<br />

Input tuple in degrees.<br />

Parallelization Information<br />

(T )tuple deg is reentrant and processed without parallelization.<br />

(T )tuple rad<br />

Operators not requiring licensing<br />

See Also<br />

Module<br />

tuple number ( double T, double *Number )<br />

T tuple number ( Htuple T, Htuple *Number )<br />

Convert a tuple (of strings) into a tuple of numbers.<br />

(T )tuple number converts the input tuple T into a tuple of numbers. If the input tuple contains numbers,<br />

they are simply copied into the output tuple. Strings are converted into the appropriate type of number (integer or<br />

floating point numbers) or are copied as strings if they do not represent a number.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.4. CONVERSION 833<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long / const char *<br />

Input tuple.<br />

º Number (output control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double * / long * / char *<br />

Input tuple as numbers.<br />

Parallelization Information<br />

(T )tuple number is reentrant and processed without parallelization.<br />

(T )tuple is number, (T )tuple string<br />

Operators not requiring licensing<br />

See Also<br />

Module<br />

tuple ord ( const char *T, long *Ord )<br />

T tuple ord ( Htuple T, Htuple *Ord )<br />

Convert a tuple of strings of length 1 into a tuple of their ASCII codes.<br />

(T )tuple ord converts the input tuple T, which may only contain strings of length 1, into a tuple of integer<br />

numbers that represent the ASCII code of the characters of the strings.<br />

Parameter<br />

º T (input control) ...............................................string(-array) (Htuple .) const char *<br />

Input tuple.<br />

º Ord (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

ASCII code of the input tuple.<br />

Parallelization Information<br />

(T )tuple ord is reentrant and processed without parallelization.<br />

(T )tuple ords<br />

(T )tuple chr, (T )tuple chrt<br />

Operators not requiring licensing<br />

Alternatives<br />

See Also<br />

Module<br />

tuple ords ( const char *T, long *Ords )<br />

T tuple ords ( Htuple T, Htuple *Ords )<br />

Convert a tuple of strings into a tuple of their ASCII codes.<br />

(T )tuple ords converts the input tuple T, which may only contain strings and integer numbers, into a tuple<br />

of integer numbers that represent the ASCII code of the characters of the strings. The characters of the individual<br />

strings are output according to their order within the string and within the tuple. Integer numbers are simply copied<br />

to an appropriate position in the output string. This operator can be used to prepare outputs with write serial.<br />

In particular, a byte with value 0 can be written by inserting the integer number 0 into T.<br />

Parameter<br />

º T (input control) .........................................string(-array) (Htuple .) const char * / long<br />

Input tuple.<br />

º Ords (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

ASCII code of the input tuple.<br />

<strong>HALCON</strong> 6.0


834 CHAPTER 13. TUPLE<br />

Example<br />

tuple_ords (["String 1", 0, "String 2", 0], Data)<br />

write_serial (SerialHandle, Data)<br />

Parallelization Information<br />

(T )tuple ords is reentrant and processed without parallelization.<br />

(T )tuple ord<br />

Alternatives<br />

See Also<br />

(T )tuple chr, (T )tuple chrt, write serial<br />

Operators not requiring licensing<br />

Module<br />

tuple real ( double T, double *Real )<br />

T tuple real ( Htuple T, Htuple *Real )<br />

Convert a tuple into a tuple of floating point numbers.<br />

(T )tuple real converts the input tuple T into a tuple of floating point numbers. The conversion of a string is<br />

not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Real (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Input tuple as floating point numbers.<br />

Parallelization Information<br />

(T )tuple real is reentrant and processed without parallelization.<br />

Operators not requiring licensing<br />

Module<br />

tuple round ( double T, long *Round )<br />

T tuple round ( Htuple T, Htuple *Round )<br />

Convert a tuple into a tuple of integer numbers.<br />

(T )tuple round converts the input tuple T into a tuple of integer numbers by rounding T to the nearest integer.<br />

The conversion of a string is not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Round (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long *<br />

Input tuple as integer numbers.<br />

Parallelization Information<br />

(T )tuple round is reentrant and processed without parallelization.<br />

Operators not requiring licensing<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.4. CONVERSION 835<br />

tuple string ( double T, const char *Format, char *String )<br />

T tuple string ( Htuple T, Htuple Format, Htuple *String )<br />

Convert a tuple into a tuple of strings.<br />

(T )tuple string converts numbers to strings or modifies strings. The operator has two parameters: T is the<br />

number or string that has to be converted. Format specifies the conversion. This format string consists of the<br />

following four parts<br />

<br />

So a conversion might look like<br />

tuple\_string(1332.4554, ’.6e’, String)<br />

flags Zero or more flags, in any order, which modify the meaning of the conversion specification. Flags may<br />

consist of the following characters:<br />

- The result of the conversion is left justified within the field.<br />

+ The result of a signed conversion always begins with a sign, + or -.<br />

space If the first character of a signed conversion is not a sign, a space character is prefixed to the<br />

result. This means that if the space flag and + flag both appear, the space flag is ignored.<br />

# The value is to be converted to an “alternate form”. For d and s conversions, this flag has no effect. For<br />

o conversion (see below), it increases the precision to force the first digit of the result to be a zero. For<br />

x or X conversion (see below), a non- zero result has 0x or 0X prefixed to it. For e, E, f, g, andG<br />

conversions, the result always contains a radix character, even if no digits follow the radix character. For<br />

g and G conversions, trailing zeros are not removed from the result, contrary to usual behavior.<br />

field width An optional string of decimal digits to specify a minimum field width. For an output field, if<br />

the converted value has fewer characters than the field width, it is padded on the left (or right, if the leftadjustment<br />

flag, - has been given) to the field width.<br />

precision The precision specifies the minimum number of digits to appear for the d, o, x, orX conversions<br />

(the field is padded with leading zeros), the number of digits to appear after the radix character for the e and<br />

f conversions, the maximum number of significant digits for the g conversion, or the maximum number of<br />

characters to be printed from a string in s conversion. The precision takes the form of a period . followed<br />

by a decimal digit string. A null digit string is treated as a zero.<br />

conversion characters A conversion character indicates the type of conversion to be applied:<br />

d,o,x,X The integer argument is printed in signed decimal (d), unsigned octal (o), or unsigned hexadecimal<br />

notation (x and X). The x conversion uses the numbers and letters 0123456789abcdef, and<br />

the X conversion uses the numbers and letters 0123456789ABCDEF. The precision component of the<br />

argument specifies the minimum number of digits to appear. If the value being converted can be represented<br />

in fewer digits than the specified minimum, it is expanded with leading zeroes. The default<br />

precision is 1. The result of converting a zero value with a precision of 0 is no characters.<br />

f The floating-point number argument is printed in decimal notation in the style [-]dddrddd, wherethe<br />

number of digits after the radix character, r, is equal to the precision specification. If the precision is<br />

omitted from the argument, six digits are output; if the precision is explicitly 0, no radix appears.<br />

e,E The floating-point-number argument is printed in the style [-]drddde¦dd, where there is one digit<br />

before the radix character, and the number of digits after it is equal to the precision. When the precision<br />

is missing, six digits are produced; if the precision is 0, no radix character appears. The E conversion<br />

character produces a number with E introducing the exponent instead of e. The exponent always contains<br />

at least two digits. However, if the value to be printed requires an exponent greater than two digits,<br />

additional exponent digits are printed as necessary.<br />

g,G The floating-point-number argument is printed in style f or e (or in style E in the case of a G conversion<br />

character), with the precision specifying the number of significant digits. The style used depends on the<br />

value converted; style e is used only if the exponent resulting from the conversion is less than -4 or<br />

greater than or equal to the precision. Trailing zeros are removed from the result. A radix character<br />

appears only if it is followed by a digit.<br />

<strong>HALCON</strong> 6.0


836 CHAPTER 13. TUPLE<br />

s The argument is taken to be a string, and characters from the string are printed until the end of the string<br />

or the number of characters indicated by the precision specification of the argument is reached. If the<br />

precision is omitted from the argument, it is interpreted as infinite and all characters up to the end of the<br />

string are printed.<br />

b Similar to the s conversion specifier, except that the string can contain backslash-escape sequences which<br />

are then converted to the characters they represent.<br />

In no case does a nonexistent or insufficient field width cause truncation of a field; if the result of a conversion<br />

is wider than the field width, the field is simply expanded to contain the conversion result.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long / const char *<br />

Input tuple.<br />

º Format (input control) ...............................................string (Htuple .) const char *<br />

Format string.<br />

º String (output control) .............................................string(-array) (Htuple .) char *<br />

Input tuple converted to strings.<br />

Parallelization Information<br />

(T )tuple string is reentrant and processed without parallelization.<br />

(T )tuple sub<br />

Operators not requiring licensing<br />

Alternatives<br />

Module<br />

13.5 Creation<br />

tuple concat ( long T1, long T2, long *Concat )<br />

T tuple concat ( Htuple T1, Htuple T2, Htuple *Concat )<br />

Concatenate two tuple to a new one.<br />

(T )tuple concat concatenates the input tuples T1 and T2 to a new tuple Concat. The first elements of<br />

Concat conform to the elements of T1 and the remaining elements of Concat conform to those of T2<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple 2.<br />

º Concat (output control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long * / double * / char *<br />

Concatentaion of input tuples.<br />

Parallelization Information<br />

(T )tuple concat is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple gen const, (T )tuple str bit select, (T )tuple select,<br />

(T )tuple str first n, (T )tuple str last n<br />

Operators not requiring licensing<br />

Module<br />

tuple gen const ( long Length, long Const, long *Newtuple )<br />

T tuple gen const ( Htuple Length, Htuple Const, Htuple *Newtuple )<br />

Generate a tuple of a specific length and initialize its elements.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.6. ELEMENT-ORDER 837<br />

(T )tuple gen const generates a new tuple in Newtuple. The input parameter Length determines the<br />

number of elements for the new tuple. Thus Length may only consist of a single number. If Length contains a<br />

floating point number, this may only represent an integer value (without fraction). The data type and value of each<br />

element of the new generated tuple is determined by the input parameter Const that may only consist of a single<br />

element. All elements in Newtuple have got the same data type and value as the single element in Const.<br />

Parameter<br />

º Length (input control) ............................................number (Htuple .) long / double<br />

Length of tuple to generate.<br />

º Const (input control) .................................number (Htuple .) long / double / const char *<br />

Konstante f”ur die Initialisierung der Tupelelemente.: description.english: Constant for initializing the tuple<br />

elements.<br />

º Newtuple (output control) . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long * / double * / char *<br />

New Tuple.<br />

Parallelization Information<br />

(T )tuple gen const is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple str bit select, (T )tuple select, (T )tuple str first n,<br />

(T )tuple str last n, (T )tuple concat<br />

Operators not requiring licensing<br />

Module<br />

13.6 Element-Order<br />

tuple inverse ( long Tuple, long *Inverted )<br />

T tuple inverse ( Htuple Tuple, Htuple *Inverted )<br />

Invert a tuple.<br />

(T )tuple inverse inverts the input tuple Tuple. Thus Inverted contains the same elements as Tuple<br />

but with the reverse order.<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long / double / const char *<br />

Input tuple.<br />

º Inverted (output control) . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long * / double * / char *<br />

Inverted input tuple.<br />

Parallelization Information<br />

(T )tuple inverse is reentrant and processed without parallelization.<br />

(T )tuple sort, (T )tuple sort index<br />

Operators not requiring licensing<br />

Alternatives<br />

Module<br />

tuple sort ( long Tuple, long *Sorted )<br />

T tuple sort ( Htuple Tuple, Htuple *Sorted )<br />

Sorts the elements of a tuple in ascending order.<br />

(T )tuple sort sorts all elements of Tuple in ascending order and returns the result with Sorted. As a<br />

precondition the single elements of Tuple must be comparable. Thus Tuple must either exclusively consist of<br />

<strong>HALCON</strong> 6.0


838 CHAPTER 13. TUPLE<br />

strings or it must only contain (integer or floating point) numbers. In the latter case integers and floating point<br />

numbers may be mixed.<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long / double / const char *<br />

Input tuple.<br />

º Sorted (output control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long * / double * / char *<br />

Sorted tuple.<br />

Parallelization Information<br />

(T )tuple sort is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple sort index, (T )tuple inverse<br />

Operators not requiring licensing<br />

Module<br />

tuple sort index ( long Tuple, long *Indices )<br />

T tuple sort index ( Htuple Tuple, Htuple *Indices )<br />

Sorts the elements of a tuple and returns the indices of the sorted tuple.<br />

(T )tuple sort index sorts all elements of Tuple in ascending order and returns the indices of the elements<br />

of the sorted tuple (in relation to the input tuple Tuple) with Indices. As a precondition the single elements<br />

of Tuple must be comparable. Thus Tuple must either exclusively consist of strings or it must only contain<br />

(integer or floating point) numbers. In the latter case integers and floating point numbers may be mixed.<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long / double / const char *<br />

Input tuple.<br />

º Indices (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long *<br />

Sorted tuple.<br />

Parallelization Information<br />

(T )tuple sort index is reentrant and processed without parallelization.<br />

(T )tuple sort, (T )tuple inverse<br />

Operators not requiring licensing<br />

Alternatives<br />

Module<br />

13.7 Features<br />

tuple ceil ( double T, double *Ceil )<br />

T tuple ceil ( Htuple T, Htuple *Ceil )<br />

Compute the ceiling function of a tuple.<br />

(T )tuple ceil computes the ceiling function of the input tuple T, i.e., the smallest integer greater than or<br />

equal to T. The ceiling function is always returned as a floating point number. The ceiling function of a string is<br />

not allowed.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.7. FEATURES 839<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Ceil (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Ceiling function of the input tuple.<br />

Parallelization Information<br />

(T )tuple ceil is reentrant and processed without parallelization.<br />

(T )tuple ceil<br />

Operators not requiring licensing<br />

Alternatives<br />

Module<br />

tuple deviation ( long Tuple, double *Deviation )<br />

T tuple deviation ( Htuple Tuple, Htuple *Deviation )<br />

Return the standard deviation of the elements of a tuple.<br />

(T )tuple deviation calculates the standard derivation of all elements of the input tuple Tuple. It returns<br />

the derivation as a floating point number in the output parameter Deviation. The input tuple may only consist<br />

of numbers (integer or floating point numbers).<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long / double / const char *<br />

Input tuple.<br />

º Deviation (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Standard deviation of tuple elements.<br />

Parallelization Information<br />

(T )tuple deviation is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple mean, (T )tuple sum, (T )tuple min, (T )tuple max, (T )tuple length<br />

Operators not requiring licensing<br />

Module<br />

tuple floor ( double T, double *Floor )<br />

T tuple floor ( Htuple T, Htuple *Floor )<br />

Compute the floor function of a tuple.<br />

(T )tuple floor computes the floor function of the input tuple T, i.e., the largest integer less than or equal to<br />

T. The floor function is always returned as a floating point number. The floor function of a string is not allowed.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long<br />

Input tuple.<br />

º Floor (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Floor function of the input tuple.<br />

Parallelization Information<br />

(T )tuple floor is reentrant and processed without parallelization.<br />

(T )tuple ceil<br />

Alternatives<br />

<strong>HALCON</strong> 6.0


840 CHAPTER 13. TUPLE<br />

Operators not requiring licensing<br />

Module<br />

tuple is number ( double T, long *IsNumber )<br />

T tuple is number ( Htuple T, Htuple *IsNumber )<br />

Check a tuple (of strings) whether it represents numbers.<br />

(T )tuple is number checks each element of the input tuple T whether it represents a number. If the element<br />

is a number (real or integer), 1 is returned for that element. If the element is a string, it is checked whether the<br />

string represents a number. If so, 1 is returned, otherwise 0.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double / long / const char *<br />

Input tuple.<br />

º IsNumber (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long *<br />

Tuple with boolean numbers.<br />

Parallelization Information<br />

(T )tuple is number is reentrant and processed without parallelization.<br />

(T )tuple number<br />

Operators not requiring licensing<br />

See Also<br />

Module<br />

tuple length ( long Tuple, double *Length )<br />

T tuple length ( Htuple Tuple, Htuple *Length )<br />

Returns the number of elements of a tuple.<br />

(T )tuple length returns the number of elements of the input tuple Tuple.<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long / double / const char *<br />

Input tuple.<br />

º Length (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double *<br />

Number of elements of input tuple.<br />

Parallelization Information<br />

(T )tuple length is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple min, (T )tuple max, (T )tuple mean, (T )tuple deviation, (T )tuple sum<br />

Operators not requiring licensing<br />

Module<br />

tuple max ( long Tuple, double *Max )<br />

T tuple max ( Htuple Tuple, Htuple *Max )<br />

Returns the maximal element of a tuple.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.7. FEATURES 841<br />

(T )tuple max returns the maximal element of all elements of the input tuple Tuple. All elements of Tuple<br />

either have to be strings or numbers (integer or floating point numbers). It is not allowed to mix strings with<br />

numerical values. The result parameter Max will contain a floating point number, if at least one element of Tuple<br />

is a floating point number. If all elements of Tuple are integer numbers the resulting sum will also be an integer<br />

number.<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long / double / const char *<br />

Input tuple.<br />

º Max (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double *<br />

Maximal element of the input tuple elements.<br />

Parallelization Information<br />

(T )tuple max is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple min, (T )tuple mean, (T )tuple deviation, (T )tuple sum, (T )tuple length<br />

Operators not requiring licensing<br />

Module<br />

tuple mean ( long Tuple, double *Mean )<br />

T tuple mean ( Htuple Tuple, Htuple *Mean )<br />

Return the mean value of a tuple of numbers.<br />

(T )tuple mean returns the mean value of all elements of the input tuple Tuple as a floating point number in<br />

the output parameter Mean. The input tuple may only consist of numbers (integer or floating point numbers).<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long / double / const char *<br />

Input tuple.<br />

º Mean (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Mean value of tuple elements.<br />

Parallelization Information<br />

(T )tuple mean is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple deviation, (T )tuple sum, (T )tuple min, (T )tuple max, (T )tuple length<br />

Operators not requiring licensing<br />

Module<br />

tuple min ( long Tuple, double *Min )<br />

T tuple min ( Htuple Tuple, Htuple *Min )<br />

Returns the minimal element of a tuple.<br />

(T )tuple min returns the minimal element of all elements of the input tuple Tuple. All elements of Tuple<br />

either have to be strings or numbers (integer or floating point numbers). It is not allowed to mix strings with<br />

numerical values. The result parameter Min will contain a floating point number, if at least one element of Tuple<br />

is a floating point number. If all elements of Tuple are integer numbers the resulting sum will also be an integer<br />

number.<br />

<strong>HALCON</strong> 6.0


842 CHAPTER 13. TUPLE<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long / double / const char *<br />

Input tuple.<br />

º Min (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double *<br />

Minimal element of the input tuple elements.<br />

Parallelization Information<br />

(T )tuple min is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple max, (T )tuple mean, (T )tuple deviation, (T )tuple sum, (T )tuple length<br />

Operators not requiring licensing<br />

Module<br />

tuple sum ( long Tuple, double *Sum )<br />

T tuple sum ( Htuple Tuple, Htuple *Sum )<br />

Return the sum of all elements of a tuple.<br />

(T )tuple sum returns the sum of all elements of the input tuple Tuple. All elements of Tuple either have<br />

to be strings or numbers (integer or floating point numbers). It is not allowed to mix strings with numerical values.<br />

The result parameter Sum will contain a floating point number, if at least one element of Tuple is a floating point<br />

number. If all elements of Tuple are integer numbers the resulting sum will also be an integer number. If Tuple<br />

contains strings, the concatenation will be used for building the sum.<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long / double / const char *<br />

Input tuple.<br />

º Sum (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) double *<br />

Sum of tuple elements.<br />

Parallelization Information<br />

(T )tuple sum is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple mean, (T )tuple deviation, (T )tuple min, (T )tuple max, (T )tuple length<br />

Operators not requiring licensing<br />

Module<br />

13.8 Logical-Operations<br />

tuple and ( long T1, long T2, long *And )<br />

T tuple and ( Htuple T1, Htuple T2, Htuple *And )<br />

Compute the logical and of two tuples.<br />

(T )tuple and computes the logical and of the input tuples T1 and T2. If both tuples have the same length the<br />

operation is performed on the corresponding elements of both tuples. Otherwise, either T1 or T2 must have length<br />

1. In this case, the operation is performed for each element of the longer tuple with the single element of the other<br />

tuple. The input tuples must contain only integer numbers.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.8. LOGICAL-OPERATIONS 843<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long<br />

Input tuple 2.<br />

º And (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Logical and of the input tuples.<br />

Parallelization Information<br />

(T )tuple and is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple or, (T )tuple xor, (T )tuple not<br />

See Also<br />

(T )tuple band, (T )tuple bor, (T )tuple bxor, (T )tuple bnot<br />

Operators not requiring licensing<br />

Module<br />

tuple not ( long T, long *Not )<br />

T tuple not ( Htuple T, Htuple *Not )<br />

Compute the logical not of two tuples.<br />

(T )tuple not computes the logical not of the input tuple T. The input tuple must contain only integer numbers.<br />

Parameter<br />

º T (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long<br />

Input tuple.<br />

º Not (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Binary not of the input tuple.<br />

Parallelization Information<br />

(T )tuple not is reentrant, local, and processed without parallelization.<br />

Alternatives<br />

(T )tuple and, (T )tuple or, (T )tuple xor<br />

See Also<br />

(T )tuple band, (T )tuple bor, (T )tuple bxor, (T )tuple bnot<br />

Operators not requiring licensing<br />

Module<br />

tuple or ( long T1, long T2, long *Or )<br />

T tuple or ( Htuple T1, Htuple T2, Htuple *Or )<br />

Compute the logical or of two tuples.<br />

(T )tuple or computes the logical or of the input tuples T1 and T2. If both tuples have the same length the<br />

operation is performed on the corresponding elements of both tuples. Otherwise, either T1 or T2 must have length<br />

1. In this case, the operation is performed for each element of the longer tuple with the single element of the other<br />

tuple. The input tuples must contain only integer numbers.<br />

<strong>HALCON</strong> 6.0


844 CHAPTER 13. TUPLE<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long<br />

Input tuple 2.<br />

º Or (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Logical or of the input tuples.<br />

Parallelization Information<br />

(T )tuple or is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple and, (T )tuple xor, (T )tuple not<br />

See Also<br />

(T )tuple band, (T )tuple bor, (T )tuple bxor, (T )tuple bnot<br />

Operators not requiring licensing<br />

Module<br />

tuple xor ( long T1, long T2, long *Xor )<br />

T tuple xor ( Htuple T1, Htuple T2, Htuple *Xor )<br />

Compute the logical exclusive or of two tuples.<br />

(T )tuple xor computes the logical exclusive or of the input tuples T1 and T2. If both tuples have the same<br />

length the operation is performed on the corresponding elements of both tuples. Otherwise, either T1 or T2 must<br />

have length 1. In this case, the operation is performed for each element of the longer tuple with the single element<br />

of the other tuple. The input tuples must contain only integer numbers.<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long<br />

Input tuple 2.<br />

º Xor (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Binary exclusive or of the input tuples.<br />

Parallelization Information<br />

(T )tuple xor is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple and, (T )tuple or, (T )tuple not<br />

See Also<br />

(T )tuple band, (T )tuple bor, (T )tuple bxor, (T )tuple bnot<br />

Operators not requiring licensing<br />

Module<br />

13.9 Selection<br />

tuple first n ( long Tuple, long Index, long *Selected )<br />

T tuple first n ( Htuple Tuple, Htuple Index, Htuple *Selected )<br />

Select the first elements of a tuple.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.9. SELECTION 845<br />

(T )tuple first n selects the first elements of Tuple and returns them with Selected. Thus Selected<br />

contains all elements of Tuple from the first element up to the “n-th” element of Tuple (including the “n-th”<br />

element). The index “n” is determined by the input parameter Index. Thus Index must contain a single integer<br />

value (if Index consists of a floating point number, this must represent an integer value without fraction). Indices<br />

of tuple elements start at 0, that means, the first tuple element has got the index 0.<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long / double / const char *<br />

Input tuple.<br />

º Index (input control) .............................................number (Htuple .) long / double<br />

Index of the first element to select.<br />

º Selected (output control) . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long * / double * / char *<br />

Selected tuple elements.<br />

Parallelization Information<br />

(T )tuple first n is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple last n, (T )tuple select, (T )tuple last n, (T )tuple str bit select,<br />

(T )tuple concat<br />

Module<br />

Operators not requiring licensing<br />

tuple last n ( long Tuple, long Index, long *Selected )<br />

T tuple last n ( Htuple Tuple, Htuple Index, Htuple *Selected )<br />

Select all elements from index “n” to the end of a tuple.<br />

Starting with the “n-th” element of the tuple Tuple, (T )tuple last n selects every element of Tuple and<br />

returns it with Selected. Thus Selected contains all elements of Tuple from index “n” up to the last element<br />

of Tuple (including the element at position “n”). The index “n” is determined by the input parameter Index.<br />

Thus Index must contain a single integer value (if Index consists of a floating point number, this must represent<br />

an integer value without fraction). Indices of tuple elements start at 0, that means, the first tuple element has got<br />

the index 0.<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long / double / const char *<br />

Input tuple.<br />

º Index (input control) .............................................number (Htuple .) long / double<br />

Index of the first element to select.<br />

º Selected (output control) . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long * / double * / char *<br />

Selected tuple elements.<br />

Parallelization Information<br />

(T )tuple last n is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple first n, (T )tuple select, (T )tuple str bit select, (T )tuple concat<br />

Operators not requiring licensing<br />

Module<br />

tuple select ( long Tuple, long Index, long *Selected )<br />

T tuple select ( Htuple Tuple, Htuple Index, Htuple *Selected )<br />

Select single elements of a tuple.<br />

<strong>HALCON</strong> 6.0


846 CHAPTER 13. TUPLE<br />

(T )tuple select selects one or more single elements of the tuple Tuple and returns them with Selected.<br />

At this, Index determines the indices of the elements to select. Thus Index may only contain integer values (any<br />

floating point number within Index must represent an integer value without fraction). Indices of tuple elements<br />

start at 0, that means, the first tuple element has got the index 0.<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long / double / const char *<br />

Input tuple.<br />

º Index (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double<br />

Indices of the elements to select.<br />

º Selected (output control) . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long * / double * / char *<br />

Selected tuple element.<br />

Parallelization Information<br />

(T )tuple select is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple first n, (T )tuple last n, (T )tuple str bit select, (T )tuple concat<br />

Operators not requiring licensing<br />

Module<br />

tuple select range ( long Tuple, long Leftindex, long Rightindex,<br />

long *Selected )<br />

T tuple select range ( Htuple Tuple, Htuple Leftindex,<br />

Htuple Rightindex, Htuple *Selected )<br />

Select several elements of a tuple.<br />

(T )tuple select range selects several consecutive elements of the input tuple Tuple and returns them<br />

with Selected. Atthis,Leftindex determines the index of the first element and Rightindex determines<br />

the index of the last element to select. Thus both parameters Leftindex and Rightindex must contain a<br />

single integer value (any floating point number must represent an integer value without fraction). Indices of tuple<br />

elements start at 0, that means, the first tuple element has got the index 0. The result tuple Selected contains<br />

every element from the tuple Tuple that has got an index between Leftindex and Rightindex (including<br />

the elements at position Leftindex and Rightindex). The index Rightindex must be greater or equal to<br />

Leftindex. If the parameters contain equal values, only one element is selected.<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long / double / const char *<br />

Input tuple.<br />

º Leftindex (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double<br />

Index of first element to select.<br />

º Rightindex (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) long / double<br />

Index of last element to select.<br />

º Selected (output control) . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long * / double * / char *<br />

Selected tuple elements.<br />

Parallelization Information<br />

(T )tuple select range is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple select, (T )tuple first n, (T )tuple last n, (T )tuple str bit select,<br />

(T )tuple concat<br />

Module<br />

Operators not requiring licensing<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.10. STRING-OPERATORS 847<br />

tuple str bit select ( const char *Tuple, long Index, char *Selected )<br />

T tuple str bit select ( Htuple Tuple, Htuple Index, Htuple *Selected )<br />

Select single character or bit from a tuple.<br />

(T )tuple str bit select selects a single character or bit from a tuple Tuple of integer numbers and/or<br />

strings. The input parameter Index determines the character or bit position to select. Index must contain a single<br />

number. If Index contains a floating point number, this may only represent an integer value (without fraction).<br />

The result tuple Selected contains a new element for each element of Tuple. LetIndex contain the number<br />

“n” then each element of Selected consists of the “n-th” character (for strings) or “n-th” bit (for integers) of the<br />

corresponding element of Tuple.<br />

Parameter<br />

º Tuple (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) const char * / long<br />

Input tuple.<br />

º Index (input control) .............................................number (Htuple .) long / double<br />

Position of character or bit to select.<br />

º Selected (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .number(-array) (Htuple .) char * / long *<br />

Tuple containing the selected characters and bits.<br />

Parallelization Information<br />

(T )tuple str bit select is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple str bit select, (T )tuple select, (T )tuple first n, (T )tuple last n,<br />

(T )tuple concat, (T )tuple strchr, (T )tuple strrchr, (T )tuple str first n,<br />

(T )tuple str last n, (T )tuple and, (T )tuple or, (T )tuple xor, (T )tuple not<br />

Operators not requiring licensing<br />

Module<br />

13.10 String-Operators<br />

tuple environment ( const char *Names, char *Values )<br />

T tuple environment ( Htuple Names, Htuple *Values )<br />

Read one or more environment variables.<br />

(T )tuple environment reads the content of all environment variables that are referenced by their names in<br />

the input tuple Names and returns the content with the output tuple Values. The input tuple may only contain<br />

strings. An empty string is returned for every name within Names that does not denote a valid environment<br />

variable.<br />

Parameter<br />

º Names (input control) ..........................................string(-array) (Htuple .) const char *<br />

Tuple containing name(s) of the environment variable(s).<br />

º Values (output control) .............................................string(-array) (Htuple .) char *<br />

Content of the environment variable(s).<br />

Parallelization Information<br />

(T )tuple environment is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple strstr, (T )tuple strrstr, (T )tuple strchr, (T )tuple strrchr,<br />

(T )tuple strlen, (T )tuple str first n, (T )tuple str last n, (T )tuple split<br />

Operators not requiring licensing<br />

Module<br />

<strong>HALCON</strong> 6.0


848 CHAPTER 13. TUPLE<br />

tuple split ( const char *T1, const char *T2, char *Splitted )<br />

T tuple split ( Htuple T1, Htuple T2, Htuple *Splitted )<br />

Split strings into substrings between predefined separator symbol(s).<br />

(T )tuple split searches within the strings of the input tuple T1 for one or more separators defined in the<br />

input tuple T2. (T )tuple split then splits the examined strings into the substrings between the separators.<br />

Both input tuples may only consist of strings. Otherwise (T )tuple split returns an error. If the elements of<br />

T2 contain more than one character, each character defines a separator. If T1 consists only of one string, this is split<br />

up several times according to the elements of T2. For example: If T1 consists of the string “data1;data2:7;data3”<br />

and T2 contains the strings “;” and “:;”, the output tuple Splitted will comprise the strings “data1”, “data2:7”,<br />

“data3” as the result of splitting the string of T1 according to the first element of T2 and “data1”, “data2”, “7” und<br />

“data3” as the result of splitting according to the second element of T2. If both input tuples show the same number<br />

of elements, the search is done elementwise. I.e., (T )tuple split will split the first string of T1 according to<br />

the separators in the first element of T2, the second string of T1 according to the separators in the second element<br />

of T2 and so on. If T2 only contains one string, the separators defined in this string will be used to split up all the<br />

strings of T1. If both input tuples contain more than one element and the number of elements differs for the input<br />

tuples, (T )tuple split returns an error.<br />

Parameter<br />

º T1 (input control) ..............................................string(-array) (Htuple .) const char *<br />

Input tuple 1.<br />

º T2 (input control) ..............................................string(-array) (Htuple .) const char *<br />

Input tuple 2.<br />

º Splitted (output control) ..........................................string(-array) (Htuple .) char *<br />

Substrings after splitting the input strings.<br />

Parallelization Information<br />

(T )tuple split is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple strstr, (T )tuple strrstr, (T )tuple strchr, (T )tuple strrchr,<br />

(T )tuple strlen, (T )tuple str first n, (T )tuple str last n, (T )tuple environment<br />

Operators not requiring licensing<br />

Module<br />

tuple str first n ( const char *T1, long T2, char *Substring )<br />

T tuple str first n ( Htuple T1, Htuple T2, Htuple *Substring )<br />

Cut the first characters up to position “n” out of string tuple.<br />

(T )tuple str first n cuts the first characters up to position “n” out of each string of the input tuple T1 and<br />

returns them as new strings in the output tuple Substring (remark: the position within strings starts with 0 for<br />

the first character of a string). The number “n” is determined by the second input tuple T2. IfT2 only contains<br />

one element, this element contains the number “n”. If T1 and T2 have got the same number of elements, the first<br />

element of T2 determines the number “n” of characters to cut out of the first string of T1, the second element of<br />

T2 does so for the second string of T1 andsoon. IfT2 contains more than one element and T1 contains only<br />

one string, (T )tuple str first n cuts more than one substrings out of this string. The elements of T2 then<br />

determine the lengths of these substrings. If both input tuples contain more than one element but differ in the<br />

number of elements, (T )tuple str first n returns an error.<br />

Parameter<br />

º T1 (input control) ..............................................string(-array) (Htuple .) const char *<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double<br />

Input tuple 2.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.10. STRING-OPERATORS 849<br />

º Substring (output control) ........................................string(-array) (Htuple .) char *<br />

The first characters up to position “n” of each string.<br />

Parallelization Information<br />

(T )tuple str first n is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple str last n, (T )tuple strstr, (T )tuple strrstr, (T )tuple strlen,<br />

(T )tuple strchr, (T )tuple strrchr, (T )tuple split, (T )tuple environment<br />

Operators not requiring licensing<br />

Module<br />

tuple str last n ( const char *T1, long T2, char *Substring )<br />

T tuple str last n ( Htuple T1, Htuple T2, Htuple *Substring )<br />

Cut all characters starting at position “n” out of string tuple.<br />

(T )tuple str last n cuts all characters from positiion “n” to the end of the string out of each string of the<br />

input tuple T1 and returns them as new strings in the output tuple Substring. The position “n” is determined<br />

by the second input tuple T2. IfT2 only contains one element, this element contains “n”. If T1 and T2 have got<br />

the same number of elements, the first element of T2 determines the start position for the first string of T1, the<br />

second element of T2 does so for the second string of T1 and so on. If T2 contains more than one element and T1<br />

contains only one string, (T )tuple str last n cuts more than one substrings out of this string. The elements<br />

of T2 then determine the start positions for these substrings. If both input tuples contain more than one element<br />

but differ in the number of elements, (T )tuple str last n returns an error.<br />

Parameter<br />

º T1 (input control) ..............................................string(-array) (Htuple .) const char *<br />

Input tuple 1.<br />

º T2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double<br />

Input tuple 2.<br />

º Substring (output control) ........................................string(-array) (Htuple .) char *<br />

The last characters starting at position “n”.<br />

Parallelization Information<br />

(T )tuple str last n is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple str last n, (T )tuple strstr, (T )tuple strrstr, (T )tuple strlen,<br />

(T )tuple strchr, (T )tuple strrchr, (T )tuple split, (T )tuple environment<br />

Operators not requiring licensing<br />

Module<br />

tuple strchr ( const char *T1, const char *T2, long *Position )<br />

T tuple strchr ( Htuple T1, Htuple T2, Htuple *Position )<br />

Forward search for a character within a string tuple.<br />

(T )tuple strchr searches within the strings of the input tuple T1 for the characters of the input tuple T2.<br />

Both input tuples may only consist of strings. Otherwise (T )tuple strchr returns an error. If the elements<br />

of T2 contain more than one character, only the first character of each element is considered for searching. If T1<br />

contains only one string, all the characters defined in T2 are searched in this string. Thus the output tuple consists<br />

of as many elements as T2. Whenever a searched character has been found, the position of its first occurence<br />

gets stored in the output tuple Position (remark: the position starts at 0 for the first character of a string). If a<br />

character can not be found, -1 will be returned instead of its position. If both input tuples show the same number<br />

<strong>HALCON</strong> 6.0


850 CHAPTER 13. TUPLE<br />

of elements, the search is done elementwise. I.e., the first character of the first element of T2 is searched within<br />

the first string of T1, the first character of the second element of T2 is searched within the second string of T1<br />

and so on. The results of the elementwise searches are returned with Position that contains as many elements<br />

as T1 and T2. IfT2 only contains one string, its first character is searched within all strings of T1. Thus in this<br />

case Position consists of as many elements as T1. If both input tuples contain more than one element and the<br />

number of elements differs for the input tuples, (T )tuple strchr returns an error.<br />

Parameter<br />

º T1 (input control) ..............................................string(-array) (Htuple .) const char *<br />

Input tuple 1.<br />

º T2 (input control) ..............................................string(-array) (Htuple .) const char *<br />

Input tuple 2.<br />

º Position (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long *<br />

Position of searched character(s) within the string(s).<br />

Parallelization Information<br />

(T )tuple strchr is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple strrchr, (T )tuple strstr, (T )tuple strrstr, (T )tuple strlen,<br />

(T )tuple str first n, (T )tuple str last n, (T )tuple split, (T )tuple environment<br />

Operators not requiring licensing<br />

Module<br />

tuple strlen ( long T1, long *Length )<br />

T tuple strlen ( Htuple T1, Htuple *Length )<br />

Length of every string within a tuple of strings.<br />

(T )tuple strlen checks the length of every string within the input tuple T1 and returns the length of<br />

each string with the output tuple Length. All elements of T1 may only consist of strings. Otherwise<br />

(T )tuple strlen returns an error.<br />

Parameter<br />

º T1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) long / double / const char *<br />

Input tuple.<br />

º Length (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . integer(-array) (Htuple .) long *<br />

Length of the single strings of the input tuple.<br />

Parallelization Information<br />

(T )tuple strlen is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple strstr, (T )tuple strrstr, (T )tuple strchr, (T )tuple strrchr,<br />

(T )tuple str first n, (T )tuple str last n, (T )tuple split, (T )tuple environment<br />

Operators not requiring licensing<br />

Module<br />

tuple strrchr ( const char *T1, const char *T2, long *Position )<br />

T tuple strrchr ( Htuple T1, Htuple T2, Htuple *Position )<br />

Backward search for a character within a string tuple.<br />

(T )tuple strrchr searches within the strings of the input tuple T1 for the characters of the input tuple<br />

T2. Both input tuples may only consist of strings. Otherwise (T )tuple strrchr returns an error. In any<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


13.10. STRING-OPERATORS 851<br />

case backward search is used, i.e., every string is examined from its last to its first character. If the elements of<br />

T2 contain more than one character, only the first character of each element is considered for searching. If T1<br />

contains only one string, all the characters defined in T2 are searched in this string. Thus the output tuple consists<br />

of as many elements as T2. Whenever a searched character has been found, the position of its first occurence gets<br />

stored in the output tuple Position . If a character can not be found, -1 will be returned instead of its position<br />

(remark: the position starts at 0 for the first character of a string). If both input tuples show the same number of<br />

elements, the search is done elementwise. I.e., the first character of the first element of T2 is searched within the<br />

first string of T1, the first character of the second element of T2 is searched within the second string of T1 and<br />

so on. The results of the elementwise searches are returned with Position that contains as many elements as<br />

T1 and T2. If T2 only contains one string, its first character is searched within all strings of T1. Thus in this<br />

case Position consists of as many elements as T1. If both input tuples contain more than one element and the<br />

number of elements differs for the input tuples, (T )tuple strrchr returns an error.<br />

Parameter<br />

º T1 (input control) ..............................................string(-array) (Htuple .) const char *<br />

Input tuple 1.<br />

º T2 (input control) ..............................................string(-array) (Htuple .) const char *<br />

Input tuple 2.<br />

º Position (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long *<br />

Position of searched character within the string.<br />

Parallelization Information<br />

(T )tuple strrchr is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple strchr, (T )tuple strstr, (T )tuple strrstr, (T )tuple strlen,<br />

(T )tuple str first n, (T )tuple str last n, (T )tuple split, (T )tuple environment<br />

Operators not requiring licensing<br />

Module<br />

tuple strrstr ( const char *T1, const char *T2, long *Position )<br />

T tuple strrstr ( Htuple T1, Htuple T2, Htuple *Position )<br />

Backward search for string(s) within a string tuple.<br />

(T )tuple strrstr searches within the strings of the input tuple T1 for the strings of the input tuple T2. Both<br />

input tuples may only consist of strings. Otherwise (T )tuple strrstr returns an error. In any case backward<br />

search is used, i.e., every string is examined from its last to its first character. If T1 contains only one string, all<br />

strings of T2 are searched in it. Thus the output tuple consists of as many elements as T2. Whenever a searched<br />

string has been found, the position of its first occurence gets stored in the output tuple Position (positions in<br />

strings are counted starting with 0). If a string can not be found, -1 will be returned instead of its position. If both<br />

input tuples show the same number of elements, the strings are searched elementwise. I.e., the first string of T2 is<br />

searched within the first string of T1, the second string of T2 is searched within the second string of T1 and so on.<br />

The results of the elementwise searches are returned with Position that contains as many elements as T1 and<br />

T2. IfT2 only contains one string, this is searched within all strings of T1. Thus in this case Position consists<br />

of as many elements as T1. If both input tuples contain more than one element and the number of elements differs<br />

for the input tuples, (T )tuple strrstr returns an error.<br />

Parameter<br />

º T1 (input control) ..............................................string(-array) (Htuple .) const char *<br />

Input tuple 1.<br />

º T2 (input control) ..............................................string(-array) (Htuple .) const char *<br />

Input tuple 2.<br />

º Position (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long *<br />

Position of searched string(s) within the examined string(s).<br />

Parallelization Information<br />

(T )tuple strrstr is reentrant and processed without parallelization.<br />

<strong>HALCON</strong> 6.0


852 CHAPTER 13. TUPLE<br />

Alternatives<br />

(T )tuple strstr, (T )tuple strlen, (T )tuple strchr, (T )tuple strrchr,<br />

(T )tuple str first n, (T )tuple str last n, (T )tuple split, (T )tuple environment<br />

Operators not requiring licensing<br />

Module<br />

tuple strstr ( const char *T1, const char *T2, long *Position )<br />

T tuple strstr ( Htuple T1, Htuple T2, Htuple *Position )<br />

Forward search for string(s) within a string tuple.<br />

(T )tuple strstr searches within the strings of the input tuple T1 for the strings of the input tuple T2. Both<br />

input tuples may only consist of strings. Otherwise (T )tuple strstr returns an error. If T1 contains only<br />

one string, all strings of T2 are searched in it. Thus the output tuple consists of as many elements as T2. Whenever<br />

a searched string has been found, the position of its first occurence gets stored in the output tuple Position<br />

(positions in strings are counted starting with 0). If a string can not be found, -1 will be returned instead of its<br />

position. If both input tuples show the same number of elements, the strings are searched elementwise. I.e., the<br />

first string of T2 is searched within the first string of T1, the second string of T2 is searched within the second<br />

string of T1 and so on. The results of the elementwise searches are returned with Position that contains as<br />

many elements as T1 and T2. IfT2 only contains one string, this is searched within all strings of T1. Thus in this<br />

case Position consists of as many elements as T1. If both input tuples contain more than one element and the<br />

number of elements differs for the input tuples, (T )tuple strstr returns an error.<br />

Parameter<br />

º T1 (input control) ..............................................string(-array) (Htuple .) const char *<br />

Input tuple 1.<br />

º T2 (input control) ..............................................string(-array) (Htuple .) const char *<br />

Input tuple 2.<br />

º Position (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .integer(-array) (Htuple .) long *<br />

Position of searched string(s) within the examined string(s).<br />

Parallelization Information<br />

(T )tuple strstr is reentrant and processed without parallelization.<br />

Alternatives<br />

(T )tuple strrstr, (T )tuple strlen, (T )tuple strchr, (T )tuple strrchr,<br />

(T )tuple str first n, (T )tuple str last n, (T )tuple split, (T )tuple environment<br />

Operators not requiring licensing<br />

Module<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Chapter 14<br />

XLD<br />

14.1 Access<br />

T get contour xld ( Hobject Contour, Htuple *Row, Htuple *Col )<br />

Return the coordinates of an XLD contour.<br />

T get contour xld returns the following values of the XLD contour Contour:<br />

Row Row coordinate of the contour’s points<br />

Col Column coordinate of the contour’s points<br />

Parameter<br />

º Contour (input object) ..........................................................xld cont Hobject<br />

Input XLD contour.<br />

º Row (output control) ................................................point.y-array Htuple . double *<br />

Row coordinate of the contour’s points.<br />

º Col (output control) ................................................point.x-array Htuple . double *<br />

Column coordinate of the contour’s points.<br />

Parallelization Information<br />

T get contour xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix<br />

See Also<br />

T get contour attrib xld, T query contour attribs xld,<br />

T get contour global attrib xld, T query contour global attribs xld<br />

Sub-pixel operators<br />

Module<br />

T get lines xld ( Hobject Polygon, Htuple *BeginRow, Htuple *BeginCol,<br />

Htuple *EndRow, Htuple *EndCol, Htuple *Length, Htuple *Phi )<br />

Return an XLD polygon’s data (as lines).<br />

T get lines xld returns the XLD polygon Polygon as a set of lines. The following values are returned:<br />

BeginRow: Rows coordinates of the lines’ start points<br />

BeginCol: Columns coordinates of the lines’ start points<br />

EndRow: Row coordinates of the lines’ end points<br />

EndCol: Column coordinates of the lines’ end points<br />

Length: Lengths of the line segments<br />

Phi: Angles of the line segments<br />

853


854 CHAPTER 14. XLD<br />

Parameter<br />

º Polygon (input object) ...................................................xld poly(-array) Hobject<br />

Input XLD polygons.<br />

º BeginRow (output control) .....................................line.begin.y-array Htuple . double *<br />

Row coordinates of the lines’ start points.<br />

º BeginCol (output control) .....................................line.begin.x-array Htuple . double *<br />

Column coordinates of the lines’ start points.<br />

º EndRow (output control) ..........................................line.end.y-array Htuple . double *<br />

Column coordinates of the lines’ end points.<br />

º EndCol (output control) ..........................................line.end.x-array Htuple . double *<br />

Column coordinates of the lines’ end points.<br />

º Length (output control) ...............................................real-array Htuple . double *<br />

Lengths of the line segments.<br />

º Phi (output control) ..............................................angle.rad-array Htuple . double *<br />

Angles of the line segments.<br />

Parallelization Information<br />

T get lines xld is reentrant and automatically parallelized (on tuple level).<br />

gen polygons xld<br />

T get polygon xld<br />

Sub-pixel operators<br />

Possible Predecessor Functions<br />

Alternatives<br />

Module<br />

T get parallels xld ( Hobject Parallels, Htuple *Row1, Htuple *Col1,<br />

Htuple *Length1, Htuple *Phi1, Htuple *Row2, Htuple *Col2,<br />

Htuple *Length2, Htuple *Phi2 )<br />

Return an XLD parallel’s data (as lines).<br />

T get parallels xld returns the following values of the XLD parallels Parallels:<br />

Row1: Row coordinates of the points on polygon P1<br />

Col1: Column coordinates of the points on polygon P1<br />

Length1: Lengths of the line segments on polygon P1<br />

Phi1: Angles of the line segments on polygon P1<br />

Row2: Row coordinates of the points on polygon P2<br />

Col2: Column coordinates of the points on polygon P2<br />

Length2: Lengths of the line segments on polygon P2<br />

Phi2: Angles of the line segments on polygon P2<br />

Parameter<br />

º Parallels (input object) ............................................................xld Hobject<br />

Input XLD parallels.<br />

º Row1 (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . polygon.y-array Htuple . long *<br />

Row coordinates of the points on polygon P1.<br />

º Col1 (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . polygon.x-array Htuple . long *<br />

Column coordinates of the points on polygon P1.<br />

º Length1 (output control) ..............................................real-array Htuple . double *<br />

Lengths of the line segments on polygon P1.<br />

º Phi1 (output control) .............................................angle.rad-array Htuple . double *<br />

Angles of the line segments on polygon P1.<br />

º Row2 (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . polygon.y-array Htuple . long *<br />

Row coordinates of the points on polygon P2.<br />

º Col2 (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . polygon.x-array Htuple . long *<br />

Column coordinates of the points on polygon P2.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.2. CREATION 855<br />

º Length2 (output control) ..............................................real-array Htuple . double *<br />

Lengths of the line segments on polygon P2.<br />

º Phi2 (output control) .............................................angle.rad-array Htuple . double *<br />

Angles of the line segments on polygon P2.<br />

Parallelization Information<br />

T get parallels xld is reentrant and processed without parallelization.<br />

gen parallels xld<br />

T get polygon xld, T get lines xld<br />

Sub-pixel operators<br />

Possible Predecessor Functions<br />

See Also<br />

Module<br />

T get polygon xld ( Hobject Polygon, Htuple *Row, Htuple *Col,<br />

Htuple *Length, Htuple *Phi )<br />

Return an XLD polygon’s data.<br />

T get polygon xld returns the following values of the XLD polygon Polygon:<br />

Row Row coordinates of the polygons’ points<br />

Col Column coordinates of the polygons’ points<br />

Length Lengths of the line segments between points and ·½, respectively<br />

Phi Angles of the line segments between points and ·½, respectively<br />

Parameter<br />

º Polygon (input object) ..........................................................xld poly Hobject<br />

Input XLD polygon.<br />

º Row (output control) ................................................point.y-array Htuple . double *<br />

Row coordinates of the polygons’ points.<br />

º Col (output control) ................................................point.x-array Htuple . double *<br />

Column coordinates of the polygons’ points.<br />

º Length (output control) ...............................................real-array Htuple . double *<br />

Lengths of the line segments.<br />

º Phi (output control) ..............................................angle.rad-array Htuple . double *<br />

Angles of the line segments.<br />

Parallelization Information<br />

T get polygon xld is reentrant and processed without parallelization.<br />

gen polygons xld<br />

T get lines xld<br />

Sub-pixel operators<br />

Possible Predecessor Functions<br />

Alternatives<br />

Module<br />

14.2 Creation<br />

T gen contour polygon xld ( Hobject *Contour, Htuple Row, Htuple Col )<br />

Generate an XLD contour from a polygon (given as tuples).<br />

T gen contour polygon xld generates an XLD contour Contour from a polygon given in the tuples Row<br />

and Col. This operator is useful if contours have been obtained from routines outside the core library, but higher<br />

level operators, e.g., polygon approximation and extraction of parallels, are to be performed on the contours.<br />

<strong>HALCON</strong> 6.0


856 CHAPTER 14. XLD<br />

Parameter<br />

º Contour (output object) .......................................................xld cont Hobject *<br />

Resulting contour.<br />

º Row (input control) ............................................number-array Htuple . double / long<br />

Row coordinates of the polygon.<br />

Default Value : ’[0,1,2,2,2]’<br />

Value Suggestions : Row ¾0, 1, 2, 3, 4, 5, 10, 20, 50, 100, 200, 500<br />

º Col (input control) ............................................number-array Htuple . double / long<br />

Column coordinates of the polygon.<br />

Default Value : ’[0,0,0,1,2]’<br />

Value Suggestions : Col ¾0, 1, 2, 3, 4, 5, 10, 20, 50, 100, 200, 500<br />

Parallelization Information<br />

T gen contour polygon xld is reentrant and processed without parallelization.<br />

get region contour<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

smooth contours xld, gen polygons xld<br />

gen contours skeleton xld<br />

Sub-pixel operators<br />

See Also<br />

Module<br />

gen contour region xld ( Hobject Regions, Hobject *Contours,<br />

const char *Mode )<br />

Generate XLD contours from regions.<br />

gen contour region xld generates XLD contours Contours from the regions given in Regions. This<br />

operator is useful if regions have been obtained from segmentation operations, but higher level operators, e.g.,<br />

polygon approximation and extraction of parallels, are to be performed on their boundaries. For each connected<br />

component of the input regions a closed contour of the boundary is generated. The parameter Mode can take on<br />

the following values:<br />

¯ ’center’: The centers of the border pixels are used as contour points.<br />

¯ ’border’: The outer border of the border pixels is used as contour points.<br />

The difference between the two modes can be seen by considering the following region:<br />

where ¾ symbolizes a single pixel.<br />

Then, computing the contour with ’border’ and ’center’ results in the following two contours, respectively:<br />

<br />

<br />

’border’<br />

’center’<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.2. CREATION 857<br />

This means, for example, that countours generated with ’border’ will in general have a much larger Euclidean<br />

length (see (T )length xld) than countours generated with ’center’. This results from the fact that for diagonal<br />

border elements ’border’ uses two contour segments of length 1 each, whereas ’center’ uses a single segment of<br />

length Ô ¾. Other features, e.g., the area (see (T )area center xld), will obviously also have different values.<br />

Parameter<br />

º Regions (input object) .....................................................region(-array) Hobject<br />

Input regions.<br />

º Contours (output object) ...............................................xld cont(-array) Hobject *<br />

Resulting contours.<br />

º Mode (input control) ............................................................string const char *<br />

Mode of contour generation.<br />

Default Value : ’border’<br />

Value List : Mode ¾’border’, ’center’<br />

Parallelization Information<br />

gen contour region xld is reentrant and processed without parallelization.<br />

Possible Successor Functions<br />

smooth contours xld, gen polygons xld<br />

Alternatives<br />

T gen contour polygon xld, get region contour<br />

gen contours skeleton xld<br />

Sub-pixel operators<br />

See Also<br />

Module<br />

gen contours skeleton xld ( Hobject Skeleton, Hobject *Contours,<br />

long Length, const char *Mode )<br />

Convert a skeleton into XLD contours.<br />

gen contours skeleton xld converts the input skeleton (e.g., edges) Skeleton, which is assumed to<br />

contain mostly one pixel wide regions (see skeleton), into XLD contours. The regions are first transformed<br />

to contain only line segments in 8-neighborhood. In the process 12 special configurations are taken into account:<br />

Points for which there is a junction of three or more lines in 8-neighborhood are preserved (in all four rotations):<br />

¼ ¼ ½<br />

½ ½ ¼<br />

¼ ½ ¼<br />

¼ ½ ¼<br />

¼ ½ ½<br />

¼ ½ ¼<br />

¼ ½ ¼<br />

½ ½ ½<br />

¼ ½ ¼<br />

In a second step, all junction points are labelled, taking six different characteristic configurations of all four possible<br />

rotations into account:<br />

½ ¼ ½<br />

¼ ¾ ¼<br />

¼ ¼ ½<br />

½ ¼ ½<br />

¼ ¾ ¼<br />

½ ¼ ½<br />

½ ¼ ¼<br />

¼ ¾ ½<br />

¼ ½ ¼<br />

½ ¼ ¼<br />

¼ ¾ ½<br />

½ ¼ ¼<br />

¼ ½ ¼<br />

¼ ¾ ½<br />

¼ ½ ¼<br />

¼ ½ ¼<br />

½ ¾ ½<br />

¼ ½ ¼<br />

where 0 = background, 1 = foreground, and 2 = junction point.<br />

After this, all contours having at least Length points are returned. The contours generated by<br />

gen contours skeleton xld always end in junction or end points. For closed contours the first point lies in<br />

the 8-neighborhood of the last point of the contour. Therefore, in order to determine the adjacency of contours it is<br />

sufficient to just take the end points into account.<br />

Since contours are split at junction points, possibly long contours may be split into several short segments because<br />

of short adjacent lines, even if they are longer than Length points, if Mode = ’filter’ was selected. This can be<br />

avoided by setting Mode = ’generalize1’. In this case, the contours are generated as if the segments shorter than<br />

Length were not contained in the input region. In order to preserve line segments, which are split into very short<br />

<strong>HALCON</strong> 6.0


858 CHAPTER 14. XLD<br />

segments by the crossing of short lines, Mode = ’generalize2’ can be selected. In this case, line segments are<br />

preserved if they end in two junction points, even if they are shorter than Length.<br />

Parameter<br />

º Skeleton (input object) ..........................................................region Hobject<br />

Skeleton of which the contours are to be determined.<br />

º Contours (output object) ................................................xld cont-array Hobject *<br />

Resulting contours.<br />

º Length (input control) ...............................................................integer long<br />

Minimum number of points a contour has to have.<br />

Default Value : 1<br />

Value Suggestions : Length ¾1, 2, 3, 5, 10, 20<br />

º Mode (input control) ............................................................string const char *<br />

Contour filter mode.<br />

Default Value : ’filter’<br />

Value List : Mode ¾’filter’, ’generalize1’, ’generalize2’<br />

Parallelization Information<br />

gen contours skeleton xld is reentrant and processed without parallelization.<br />

skeleton<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

smooth contours xld, T get contour xld, gen polygons xld<br />

See Also<br />

edges image, threshold, get region contour<br />

Sub-pixel operators<br />

Module<br />

gen ellipse contour xld ( Hobject *ContEllipse, double Row,<br />

double Column, double Phi, double Radius1, double Radius2,<br />

double StartPhi, double EndPhi, const char *PointOrder,<br />

double Resolution )<br />

T gen ellipse contour xld ( Hobject *ContEllipse, Htuple Row,<br />

Htuple Column, Htuple Phi, Htuple Radius1, Htuple Radius2,<br />

Htuple StartPhi, Htuple EndPhi, Htuple PointOrder, Htuple Resolution )<br />

Creation of an XLD contour corresponding to an elliptic arc.<br />

(T )gen ellipse contour xld creates one or more elliptic arcs or closed ellipses. Ellipses are specified by<br />

their center (Row, Column), the orientation of the main axis Phi, the length of the larger half axis Radius1,<br />

and the length of the smaller half axis Radius2. In addition to that, elliptic arcs are characterized by the angle<br />

of the start point StartPhi, the angle of the end point EndPhi, and the point order PointOrder along the<br />

boundary. The angles in the interval ¼ ¾℄ are measured in the coordinate system of the ellipse relative to the<br />

main axis. Thus, the two main poles correspond to the angles ¼ and , the two other poles to the angles ¾ and<br />

¿¾. To create a closed ellipse the values ¼ and ¾ (with positive point order) have to be passed to the operator.<br />

The resolution of the resulting contours ContEllipse is controlled via Resolution containing the maximum<br />

Euclidean distance between neighboring contour points.<br />

Parameter<br />

º ContEllipse (output object) ..........................................xld cont(-array) Hobject *<br />

Resulting contour.<br />

º Row (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.y(-array) (Htuple .) double<br />

Row coordinate of the center of the ellipse.<br />

º Column (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.x(-array) (Htuple .) double<br />

Column coordinate of the center of the ellipse.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.2. CREATION 859<br />

º Phi (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ellipse.angle.rad(-array) (Htuple .) double<br />

Orientation of the main axis [rad].<br />

Restriction : ´Phi 0µ ´Phi 6.283185307µ<br />

º Radius1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius1(-array) (Htuple .) double<br />

Length of the larger half axis.<br />

Restriction : Radius1 0<br />

º Radius2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius2(-array) (Htuple .) double<br />

Length of the smaller half axis.<br />

Restriction : Radius2 0<br />

º StartPhi (input control) ............................................real(-array) (Htuple .) double<br />

Angle of the start point [rad].<br />

Restriction : ´StartPhi 0µ ´StartPhi 6.283185307µ<br />

º EndPhi (input control) ...............................................real(-array) (Htuple .) double<br />

Angle of the end point [rad].<br />

Restriction : ´EndPhi 0µ ´EndPhi 6.283185307µ<br />

º PointOrder (input control) ...................................string(-array) (Htuple .) const char *<br />

point order along the boundary.<br />

Value List : PointOrder ¾’positive’, ’negative’<br />

º Resolution (input control) ................................................real (Htuple .) double<br />

Resolution: Maximum distance bewteen neighboring contour points.<br />

Default Value : 1.5<br />

Restriction : Resolution 0<br />

Example<br />

draw_ellipse(WindowHandle,&Row,&Column,&Phi,&Radius1,&Radius2);<br />

gen_ellipse_contour_xld(&Ellipse,Row,Column,Phi,Radius1,Radius2,0,6.28319,<br />

"positive");<br />

length_xld(Ellipse,&Length);<br />

Result<br />

(T )gen ellipse contour xld returns H MSG TRUE if all parameter values are correct. If necessary, an<br />

exception is raised.<br />

Parallelization Information<br />

(T )gen ellipse contour xld is reentrant and processed without parallelization.<br />

draw ellipse<br />

disp xld, get points ellipse<br />

Sub-pixel operators<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

Module<br />

gen parallels xld ( Hobject Polygons, Hobject *Parallels, double Len,<br />

double Dist, double Alpha, const char *Merge )<br />

Extract parallel XLD polygons.<br />

gen parallels xld examines the XLD polygons passed in Polygons for parallelism. The resulting parallel<br />

polygons are returned in Parallels. If the parameter Merge is set to ’true’, adjacent parallel polygons are<br />

returned in a single parallel relation. Otherwise, one parallel relation is returned for each pair of parallel line<br />

segments. Whether two polygon segments are parallel depends on their distance (smaller than Dist), a maximum<br />

allowed angle difference (Alpha, in radians), and a minimum length of the two polygon segments. Furthermore,<br />

the two segments have to overlap. As a side effect, a quality factor is calculated for each pair of parallels. It is<br />

based on the normalized angular difference and the normalized length of the overlapping area:<br />

ÕÙÐØÝ Æ«<br />

¾<br />

¾ÓÚÖÐÔ<br />

with ¼ Õ ½<br />

ÐÒ ½ · ÐÒ ¾<br />

<strong>HALCON</strong> 6.0


860 CHAPTER 14. XLD<br />

Here, Æ« is the angle difference of the polygon segments, ÓÚÖÐÔ is the length of the overlap area, ÐÒ ½ and Ð ¾ the<br />

length of the polygon segments, and ÕÙÐØÝ the resulting quality factor.<br />

The quality factor is a measure of parallelism (the larger its value, the “more parallel” the polygons). Finally, the<br />

quality factors of all parallel polygon segments contained in a single polygon are added, weighted with their length<br />

of the overlapping area.<br />

Parameter<br />

º Polygons (input object) ...................................................xld poly-array Hobject<br />

Input polygons.<br />

º Parallels (output object) ...............................................xld para-array Hobject *<br />

Parallel polygons.<br />

º Len (input control) ..........................................................number double / long<br />

Mimimum length of the individual polygon segments.<br />

Default Value : 10.0<br />

Value Suggestions : Len ¾5.0, 10.0, 15.0, 20.0<br />

Restriction : Len 0.0<br />

º Dist (input control) ........................................................number double / long<br />

Maximum distance between the polygon segments.<br />

Default Value : 30.0<br />

Value Suggestions : Dist ¾20.0, 25.0, 30.0, 40.0, 50.0, 75.0<br />

Restriction : Dist 0.0<br />

º Alpha (input control) .......................................................number double / long<br />

Maximum angle difference of the polygon segments.<br />

Default Value : 0.15<br />

Value Suggestions : Alpha ¾0.05, 0.10, 0.15, 0.20, 0.30<br />

Restriction : ´0 Alphaµ ´Alpha ´pi2µµ<br />

º Merge (input control) ..........................................................string const char *<br />

Should adjacent parallel relations be merged?<br />

Default Value : ’true’<br />

Value List : Merge ¾’true’, ’false’<br />

Parallelization Information<br />

gen parallels xld is reentrant and processed without parallelization.<br />

gen polygons xld<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

mod parallels xld, T get parallels xld<br />

Sub-pixel operators<br />

Module<br />

gen polygons xld ( Hobject Contours, Hobject *Polygons,<br />

const char *Type, double Alpha )<br />

Approximate XLD contours by polygons.<br />

gen polygons xld approximates XLD contours (Contours) by polygons. The type of the approximation<br />

can be set by Type. The threshold for the approximation is set via Alpha. The procedure is able to process open<br />

as well as closed contours. The resulting approximating XLD polygons are returned in Polygons.<br />

Contours can be approximated by the algorithms of Ramer, Ray, and Sato. The algorithm of Ramer approximates<br />

contours such that the Euclidian distance of the approximating polygon to the contour is at most Alpha pixel units.<br />

The algorithm of Ray does not need a threshold, and hence Alpha is ignored. Here, the contour is approximated<br />

by maximizing the line length, while minimizing the sum of the distances of the line segment from the contour.<br />

The algorithm of Sato produces a polygon point at the point of the contour in which the distance to the end points<br />

of the contour is maximal. The total approximation error for each iteration is then given by ´Ä Ä ¼ µÄ, whereÄ<br />

is the Euclidian contour length, and Ä ¼ is the length of the approximating polygon.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.2. CREATION 861<br />

Parameter<br />

º Contours (input object) ...................................................xld cont-array Hobject<br />

Contours to be approximated.<br />

º Polygons (output object) ................................................xld poly-array Hobject *<br />

Approximating polygons.<br />

º Type (input control) ............................................................string const char *<br />

Type of approximation.<br />

Default Value : ’ramer’<br />

Value List : Type ¾’ramer’, ’ray’, ’sato’<br />

º Alpha (input control) .......................................................number double / long<br />

Threshold for the approximation.<br />

Default Value : 2.0<br />

Value Suggestions : Alpha ¾1.0, 1.5, 2.0, 3.0, 4.0<br />

Restriction : Alpha 0.0<br />

Parallelization Information<br />

gen polygons xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix<br />

gen parallels xld<br />

get region polygon<br />

Sub-pixel operators<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

mod parallels xld ( Hobject Parallels, Hobject Image,<br />

Hobject *ModParallels, Hobject *ExtParallels, double Quality,<br />

long MinGray, long MaxGray, double MaxStandard )<br />

Extract parallel XLD polygons enclosing a homogeneous area.<br />

mod parallels xld selects XLD parallels enclosing homogeneous areas from the input parallels<br />

Parallels. The parameter Image contains the corresponding gray value image.<br />

Only parallels having a quality factor larger than Quality are examined. The algorithm performs parallel cross<br />

sections one pixel apart, and parallel to the line segments in the area of overlap between two parallel line segments.<br />

In the first iteration, the mean gray value for each of the lines in the cross section is calculated. In the second<br />

iteration, the standard deviations of the gray values along each line are computed.<br />

If the mean gray value of an area between parallels lies in the interval [MinGray,MaxGray], and if the mean of all<br />

standard deviations is smaller than the upper threshold MaxStandard, the corresponding parallels are returned<br />

as modified parallels in ModParallels.<br />

In a second step, all polygon segments adjacent to parallels bordering homogeneous areas are checked for homogeneity.<br />

To do so, a rectangle having the witdth of the last area enclosed by a modified parallel is constructed,<br />

and checked for homogeneity using the algorithm described above. This process is continued as long as there are<br />

adjacent polygon segments. The polygons thus found are returned as extended parallels in ExtParallels.<br />

Parameter<br />

º Parallels (input object) ..................................................xld para-array Hobject<br />

Input XLD parallels.<br />

º Image (input object) ..............................................................image Hobject<br />

Corresponding gray value image.<br />

º ModParallels (output object) ......................................xld mod para-array Hobject *<br />

Modified XLD parallels.<br />

º ExtParallels (output object) .......................................xld ext para-array Hobject *<br />

Modified XLD parallels.<br />

<strong>HALCON</strong> 6.0


862 CHAPTER 14. XLD<br />

º Quality (input control) ....................................................number double / long<br />

Minimum quality factor (measure of parallelism).<br />

Default Value : 0.4<br />

Value Suggestions : Quality ¾0.1, 0.2, 0.3, 0.4, 0.5, 0.6<br />

Restriction : ´0.0 Qualityµ ´Quality 1.0µ<br />

º MinGray (input control) .............................................................integer long<br />

Minimum mean gray value.<br />

Default Value : 160<br />

Value Suggestions : MinGray ¾80, 100, 120, 140, 160, 180<br />

Restriction : ´0 MinGrayµ ´MinGray 255µ<br />

º MaxGray (input control) .............................................................integer long<br />

Maximum mean gray value.<br />

Default Value : 220<br />

Value Suggestions : MaxGray ¾140, 160, 180, 200, 220, 240<br />

Restriction : ´´0 MaxGrayµ ´MaxGray 255µµ ´MaxGray MinGrayµ<br />

º MaxStandard (input control) ...............................................number double / long<br />

Maximum allowed standard deviation.<br />

Default Value : 10.0<br />

Value Suggestions : MaxStandard ¾5.0, 10.0, 15.0, 20.0<br />

Restriction : MaxStandard 0.0<br />

Parallelization Information<br />

mod parallels xld is reentrant and processed without parallelization.<br />

gen parallels xld<br />

max parallels xld<br />

info parallels xld<br />

Sub-pixel operators<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

14.3 Features<br />

area center xld ( Hobject XLD, double *Area, double *Row,<br />

double *Column, char *PointOrder )<br />

T area center xld ( Hobject XLD, Htuple *Area, Htuple *Row,<br />

Htuple *Column, Htuple *PointOrder )<br />

Area and center of gravity (centroid) of contours and polygons.<br />

(T )area center xld calculates the area and center of gravity (centroid) of the region enclosed by the contours<br />

or polygons XLD as well as the order of the points along the boundary. The area and centroid are computed<br />

by applying Green’s theorem using only the points on the contour or polygon, i.e., no region is generated explicitly<br />

for the purpose of calculating the features. It is assumed that the contours or polygons are closed. If this is not the<br />

case (T )area center xld will add one point to artificially produce a closed shape. If more than one contour<br />

or polygon is passed the results are stored as tuples in which the index of a value corresponds to the index of the<br />

respective contour or polygon in XLD.<br />

Parameter<br />

º XLD (input object) .............................................................xld(-array) Hobject<br />

Contours or polygons to be examined.<br />

º Area (output control) ...............................................real(-array) (Htuple .) double *<br />

Area enclosed by the contour or polygon.<br />

º Row (output control) .............................................point.y(-array) (Htuple .) double *<br />

Row coordinate of the centroid.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.3. FEATURES 863<br />

º Column (output control) .........................................point.x(-array) (Htuple .) double *<br />

Column coordinate of the centroid.<br />

º PointOrder (output control) .......................................string(-array) (Htuple .) char *<br />

point order along the boundary (”positive”/”negative”).<br />

Complexity<br />

Let Ò be the number of points of the contour or polygon. Then the run time is Ç´Òµ.<br />

Result<br />

(T )area center xld returns H MSG TRUE if the input is not empty. If the input is empty the behaviour can<br />

be set via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

(T )area center xld is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, smooth contours xld, gen polygons xld<br />

See Also<br />

(T )moments xld, area center, moments region 2nd<br />

Sub-pixel operators<br />

Module<br />

contour point num xld ( Hobject Contour, long *Length )<br />

Return the number of points in an XLD contour.<br />

contour point num xld returns the length of the input contour Contour, i.e.<br />

Length.<br />

Parameter<br />

its number of points, in<br />

º Contour (input object) ..........................................................xld cont Hobject<br />

Input XLD contour.<br />

º Length (output control) ............................................................integer long *<br />

Number of contour points.<br />

Parallelization Information<br />

contour point num xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix<br />

Possible Successor Functions<br />

T get contour xld, T get contour attrib xld<br />

T get regress params xld<br />

T query contour attribs xld<br />

Sub-pixel operators<br />

Alternatives<br />

See Also<br />

Module<br />

dist ellipse contour xld ( Hobject Contours, const char *Mode,<br />

long MaxNumPoints, long ClippingEndPoints, double Row, double Column,<br />

double Phi, double Radius1, double Radius2, double *MinDist,<br />

double *MaxDist, double *AvgDist, double *SigmaDist )<br />

T dist ellipse contour xld ( Hobject Contours, Htuple Mode,<br />

Htuple MaxNumPoints, Htuple ClippingEndPoints, Htuple Row, Htuple Column,<br />

Htuple Phi, Htuple Radius1, Htuple Radius2, Htuple *MinDist,<br />

Htuple *MaxDist, Htuple *AvgDist, Htuple *SigmaDist )<br />

Distance of contours to an ellipse.<br />

<strong>HALCON</strong> 6.0


864 CHAPTER 14. XLD<br />

(T )dist ellipse contour xld determines the distance between the contours in Contours and an ellipse<br />

specified by the center (Row, Column), the orientation of the main axis Phi, the length of the larger half axis<br />

Radius1, and the length of the smaller half axis Radius2. Different measures for the distance of a contour<br />

point ´Ü Ý µ to the ellipse are available (Mode):<br />

’algebraic’ The distance is measured by the algebraic distance Ü ¾ · Ü Ý · Ý ¾ · Ü · Ý · ,wherethe<br />

parameters - describing the ellipse are normalized in order to obtain Radius2 as distance of the<br />

center of the ellipse. This measure shows a high curvature bias: Near points of high curvature on the<br />

ellipse (like the poles on the main axis) the distance is smaller than near points with low curvature.<br />

’geometric’ The distance is measured by the deviation ½ · ¾ ¾,where ½ , ¾ are the focal points and<br />

corresponds to Radius1. This measure shows a low curvature bias: Near points of high curvature<br />

on the ellipse (like the poles on the main axis) the distance is larger than near points with low curvature.<br />

’bisec’ The distance is measured by the distance between and the intersection of the angular bisector of the<br />

two lines through and the focal points with the ellipse. This is a very good approximation of the<br />

orthogonal distance from to the ellipse.<br />

The operator returns the minimum absolute distance MinDist, the maximum absolute distance MaxDist, the<br />

average absolute distance AvgDist, and the standard deviation of the absolute distances SigmaDist of all<br />

contour points.<br />

To reduce the computational load, the computation of the distances can be restricted to a subset of the contour<br />

points: If a value other than -1 is assigned to MaxNumPoints, only up to MaxNumPoints points - uniformly<br />

distributed over the contour - are used. Due to artefacts in the pre-processing the start and end points of a contour<br />

might be faulty. Therefore, it is possible to exclude ClippingEndPoints at the beginning and at the end of a<br />

contour from the computation.<br />

Parameter<br />

º Contours (input object) .................................................xld cont(-array) Hobject<br />

Input contours.<br />

º Mode (input control) ..................................................string (Htuple .) const char *<br />

Method for the determination of the distances.<br />

Default Value : ’bisec’<br />

Value List : Mode ¾’geometric’, ’algebraic’, ’bisec’<br />

º MaxNumPoints (input control) .............................................integer (Htuple .) long<br />

Maximum number of contour points used for the computation (-1 for all points).<br />

Default Value : -1<br />

Restriction : MaxNumPoints 3<br />

º ClippingEndPoints (input control) ......................................integer (Htuple .) long<br />

Number of points at the beginning and the end of the contours to be ignored for the computation of distances.<br />

Default Value : 0<br />

Restriction : ClippingEndPoints 0<br />

º Row (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.y (Htuple .) double<br />

Row coordinate of the center of the ellipse of the ellipse.<br />

º Column (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ellipse.center.x (Htuple .) double<br />

Column coordinate of the center of the ellipse.<br />

º Phi (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.angle.rad (Htuple .) double<br />

Orientation of the main axis [rad].<br />

Restriction : ´Phi 0µ ´Phi 6.283185307µ<br />

º Radius1 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius1 (Htuple .) double<br />

Length of the larger half axis.<br />

Restriction : Radius1 0<br />

º Radius2 (input control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius2 (Htuple .) double<br />

Length of the smaller half axis.<br />

Restriction : Radius2 0<br />

º MinDist (output control) ...........................................real(-array) (Htuple .) double *<br />

Minimaler Abstand.<br />

º MaxDist (output control) ...........................................real(-array) (Htuple .) double *<br />

Maximaler Abstand.<br />

º AvgDist (output control) ...........................................real(-array) (Htuple .) double *<br />

Mittlerer Abstand.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.3. FEATURES 865<br />

º SigmaDist (output control) ........................................real(-array) (Htuple .) double *<br />

Standardabweichung des Abstands.<br />

Example<br />

read_image (Image, "caltab");<br />

find_caltab (Image, &Caltab, "caltabBig.descr", 3, 112, 5)<br />

reduce_domain (Image, Caltab, &ImageReduced);<br />

edges_sub_pix (ImageReduced, &Edges, "lanser2", 0.5, 20, 40);<br />

select_contours_xld (Edges, &EdgesClosed, "closed", 0, 2.0, 0, 0);<br />

select_contours_xld (EdgesClosed, &EdgesMarks, "length", 20, 80, 0, 0);<br />

fit_ellipse_contour_xld (EdgesMarks, "fitzgibbon", -1, 2, 0, 200, 3, 2.0,<br />

&Row, &Column, &Phi, &Radius1, &Radius2, &StartPhi,<br />

&EndPhi, &PointOrder);<br />

Result<br />

(T )dist ellipse contour xld returns H MSG TRUE if all parameter values are correct. If necessary, an<br />

exception is raised.<br />

Parallelization Information<br />

(T )dist ellipse contour xld is local and processed completely exclusively without parallelization.<br />

(T )fit ellipse contour xld<br />

Sub-pixel operators<br />

Possible Predecessor Functions<br />

Module<br />

fit circle contour xld ( Hobject Contours, const char *Algorithm,<br />

long MaxNumPoints, double MaxClosureDist, long ClippingEndPoints,<br />

long Iterations, double ClippingFactor, double *Row, double *Column,<br />

double *Radius, double *StartPhi, double *EndPhi, char *PointOrder )<br />

T fit circle contour xld ( Hobject Contours, Htuple Algorithm,<br />

Htuple MaxNumPoints, Htuple MaxClosureDist, Htuple ClippingEndPoints,<br />

Htuple Iterations, Htuple ClippingFactor, Htuple *Row, Htuple *Column,<br />

Htuple *Radius, Htuple *StartPhi, Htuple *EndPhi, Htuple *PointOrder )<br />

Approximation of XLD contours by circles.<br />

(T )fit circle contour xld approximates the XLD contours Contours by circles. It does not perform<br />

a segmentation of the input contours. Thus, one has to make sure that each contour corresponds to one and only<br />

one circle. The operator returns for each contour the center (Row, Column), and the Radius.<br />

The algorithm used for the fitting of circles can be selected via Algorithm:<br />

’algebraic’ This approach minimizes the algebraic distance between the contour points and the resulting circle.<br />

’ahuber’ Similar to ’algebraic’. Here the contour points are weighted to decrease the impact of outliers based<br />

on the approach of Huber.<br />

’atukey’ Similar to ’algebraic’. Here the contour points are weighted to decrease the impact of outliers based<br />

on the approach of Tukey.<br />

For ’ahuber’ and ’atukey’ a robust error statistics is used to estimate the standard deviation of the distances from<br />

the contour points without outliers from the approximating circle. The parameter ClippingFactor (a scaling<br />

factor for the standard deviation) controls the amount of damping outliers: The smaller the value chosen for<br />

ClippingFactor the more outliers are detected. The detection of outliers and the least squares fitting is repeated.<br />

The parameter Iterations specifies the number of iterations.<br />

To reduce the computational load, the fitting of circles can be restricted to a subset of the contour points: If a value<br />

other than -1 is assigned to MaxNumPoints, only up to MaxNumPoints points - uniformly distributed over the<br />

contour - are used.<br />

For circular arcs, the points on the circle closest to the start points and end points of the original contours are chosen<br />

as start and end points. The corresponding angles refering to the X-axis are returned in StartPhi and EndPhi,<br />

<strong>HALCON</strong> 6.0


866 CHAPTER 14. XLD<br />

see also (T )gen ellipse contour xld. Contours, for which the distance between their start points and<br />

their end points is less or equal MaxClosureDist are considered to be closed. Thus, they are approximated by<br />

circles instead of circular arcs. Due to artefacts in the pre-processing the start and end points of a contour might be<br />

faulty. Therefore, it is possible to exclude ClippingEndPoints at the beginning and at the end of a contour<br />

from the fitting of circles. However, they are still used for the determination of StartPhi and EndPhi.<br />

Parameter<br />

º Contours (input object) .................................................xld cont(-array) Hobject<br />

Input contours.<br />

º Algorithm (input control) ...........................................string (Htuple .) const char *<br />

Algorithm for the fitting of circles.<br />

Default Value : ’algebraic’<br />

Value List : Algorithm ¾’algebraic’, ’ahuber’, ’atukey’<br />

º MaxNumPoints (input control) .............................................integer (Htuple .) long<br />

Maximum number of contour points used for the computation (-1 for all points).<br />

Default Value : -1<br />

Restriction : MaxNumPoints 3<br />

º MaxClosureDist (input control) ...........................................real (Htuple .) double<br />

Maximum distance between the end points of a contour to be considered as ’closed’.<br />

Default Value : 0.0<br />

Restriction : MaxClosureDist 0.0<br />

º ClippingEndPoints (input control) ......................................integer (Htuple .) long<br />

Number of points at the beginning and at the end of the contours to be ignored for the fitting.<br />

Default Value : 0<br />

Restriction : ClippingEndPoints 0<br />

º Iterations (input control) ................................................integer (Htuple .) long<br />

Maximum number of iterations.<br />

Default Value : 3<br />

Restriction : Iterations 0<br />

º ClippingFactor (input control) ...........................................real (Htuple .) double<br />

Clipping factor for the elimination of outliers (typical: 1.0 for Huber and 2.0 for Tukey).<br />

Default Value : 2.0<br />

Value List : ClippingFactor ¾1.0, 1.5, 2.0, 2.5, 3.0<br />

Restriction : ClippingFactor 0<br />

º Row (output control) .......................................circle.center.y(-array) (Htuple .) double *<br />

Row coordinate of the center of the circle.<br />

º Column (output control) ...................................circle.center.x(-array) (Htuple .) double *<br />

Column coordinate of the center of the circle.<br />

º Radius (output control) ....................................circle.radius(-array) (Htuple .) double *<br />

Radius of circle.<br />

º StartPhi (output control) .........................................real(-array) (Htuple .) double *<br />

Angle of the start point [rad].<br />

º EndPhi (output control) ............................................real(-array) (Htuple .) double *<br />

Angle of the end point [rad].<br />

º PointOrder (output control) .......................................string(-array) (Htuple .) char *<br />

Point order along the boundary.<br />

Value List : PointOrder ¾’positive’, ’negative’<br />

Result<br />

(T )fit circle contour xld returns H MSG TRUE if all parameter values are correct, and circles<br />

could be fitted to the input contours. If the input is empty the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

(T )fit circle contour xld is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix,<br />

smooth contours xld<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.3. FEATURES 867<br />

Possible Successor Functions<br />

(T )gen ellipse contour xld, disp circle, get points ellipse<br />

See Also<br />

(T )fit ellipse contour xld, (T )fit line contour xld<br />

Sub-pixel operators<br />

Module<br />

fit ellipse contour xld ( Hobject Contours, const char *Algorithm,<br />

long MaxNumPoints, double MaxClosureDist, long ClippingEndPoints,<br />

long VossTabSize, long Iterations, double ClippingFactor, double *Row,<br />

double *Column, double *Phi, double *Radius1, double *Radius2,<br />

double *StartPhi, double *EndPhi, char *PointOrder )<br />

T fit ellipse contour xld ( Hobject Contours, Htuple Algorithm,<br />

Htuple MaxNumPoints, Htuple MaxClosureDist, Htuple ClippingEndPoints,<br />

Htuple VossTabSize, Htuple Iterations, Htuple ClippingFactor, Htuple *Row,<br />

Htuple *Column, Htuple *Phi, Htuple *Radius1, Htuple *Radius2,<br />

Htuple *StartPhi, Htuple *EndPhi, Htuple *PointOrder )<br />

Approximation of XLD contours by ellipses or elliptic arcs.<br />

(T )fit ellipse contour xld approximates the XLD contours Contours by elliptic arcs or closed ellipses.<br />

It does not perform a segmentation of the input contours. Thus, one has to make sure that each contour corresponds<br />

to one and only one elliptic structure. The operator returns for each contour the center (Row, Column),<br />

the orientation of the main axis Phi, the length of the larger half axis Radius1, and the length of the smaller half<br />

axis Radius2 of the underlying ellipse. In addition to that, the angle corresponding to the start point and the end<br />

point StartPhi, EndPhi, and the point order along the boundary PointOrder is returned for elliptic arcs.<br />

These parameters are set to ¼, ¾, and ’positive’ for closed ellipses. The algorithm used for the fitting of ellipses<br />

can be selected via Algorithm:<br />

’fitzgibbon’ This approach minimizes the algebraic distance Ü ¾ · Ü Ý · Ý ¾ · Ü · Ý · between the<br />

contour points ´Ü Ý µ and the resulting ellipse. The constraint ¾ ½guarantees that the resulting<br />

polynom characterizes an ellipse (instead of a hyperbola or a parabola).<br />

’fhuber’ Similar to ’fitzgibbon’. Here the contour points are weighted to decrease the impact of outliers based<br />

on the approach of Huber.<br />

’ftukey’ Similar to ’fitzgibbon’. Here the contour points are weighted to decrease the impact of outliers based<br />

on the approach of Tukey.<br />

’voss’ Each input contour is transformed in an affine standard position. Based on the moments of the transformed<br />

contour (that is of the enclosed image region) the standard circular segment is choosen whose<br />

standard position matches best with the standard position of the contour. The ellipse corresponding to<br />

the standard position of the selected circular segment is re-transformed based on the affine transformation<br />

which produced the standard position of the contour resulting in the ellipse matching the original<br />

contour. VossTabSize standard circular segments are used for this computation. To speed up the<br />

process the corresponding moments and other data is stored in a table which is created during the first<br />

call (with a specific value for VossTabSize)to(T )fit ellipse contour xld.<br />

’focpoints’ Each point È on an ellipse satisfies the constraint that the sum of distances to the focal points ½ , ¾<br />

equals twice the length of the larger half axis . In this approach, the deviation È ½ · È ¾ ¾ is<br />

minimized for all contour points by a least squares optimization.<br />

’fphuber’ Similar to ’focpoints’. Here a weighted least squares optimization is done to decrease the impact of<br />

outliers based on the approach of Huber.<br />

’fptukey’ Similar to ’focpoints’. Here a weighted least squares optimization is done to decrease the impact of<br />

outliers based on the approach of Tukey.<br />

For ’*Huber’ and ’*Tukey’ a robust error statistics is used to estimate the standard deviation of the distances<br />

from the contour points without outliers from the approximating ellipse. The parameter ClippingFactor (a<br />

scaling factor for the standard deviation) controls the amount of damping outliers: The smaller the value chosen<br />

for ClippingFactor the more outliers are detected. The detection of outliers and the least squares fitting in the<br />

mode ’focpoints’ is repeated. The parameter Iterations specifies the number of iterations.<br />

<strong>HALCON</strong> 6.0


868 CHAPTER 14. XLD<br />

To reduce the computational load, the fitting of ellipses can be restricted to a subset of the contour points: If a<br />

value other than -1 is assigned to MaxNumPoints, only up to MaxNumPoints points - uniformly distributed<br />

over the contour - are used.<br />

For elliptic arcs, the points on the ellipse closest to the start points and end points of the original contours are<br />

chosen as start and end points. The corresponding angles refering to the main axis of the ellipse are returned<br />

in StartPhi and EndPhi, see also (T )gen ellipse contour xld. Contours, for which the distance<br />

between their start points and their end points is less or equal MaxClosureDist are considered to be closed.<br />

Thus, they are approximated by ellipses instead of elliptic arcs. Due to artefacts in the pre-processing the start<br />

and end points of a contour might be faulty. Therefore, it is possible to exclude ClippingEndPoints at the<br />

beginning and at the end of a contour from the fitting of ellipses. However, they are still used for the determination<br />

of StartPhi and EndPhi.<br />

Parameter<br />

º Contours (input object) .................................................xld cont(-array) Hobject<br />

Input contours.<br />

º Algorithm (input control) ...........................................string (Htuple .) const char *<br />

Algorithm for the fitting of ellipses.<br />

Default Value : ’fitzgibbon’<br />

Value List : Algorithm ¾’fitzgibbon’, ’fhuber’, ’ftukey’, ’voss’, ’focpoints’, ’fphuber’, ’fptukey’<br />

º MaxNumPoints (input control) .............................................integer (Htuple .) long<br />

Maximum number of contour points used for the computation (-1 for all points).<br />

Default Value : -1<br />

Restriction : MaxNumPoints 3<br />

º MaxClosureDist (input control) ...........................................real (Htuple .) double<br />

Maximum distance between the end points of a contour to be considered as ’closed’.<br />

Default Value : 0.0<br />

Restriction : MaxClosureDist 0.0<br />

º ClippingEndPoints (input control) ......................................integer (Htuple .) long<br />

Number of points at the beginning and at the end of the contours to be ignored for the fitting.<br />

Default Value : 0<br />

Restriction : ClippingEndPoints 0<br />

º VossTabSize (input control) ..............................................integer (Htuple .) long<br />

Number of circular segments used for the Voss approach.<br />

Default Value : 200<br />

Restriction : ´VossTabSize 25µ ´VossTabSize 5000µ<br />

º Iterations (input control) ................................................integer (Htuple .) long<br />

Maximum number of iterations (unused for ’fitzgibbon’ and ’voss’).<br />

Default Value : 3<br />

Restriction : Iterations 0<br />

º ClippingFactor (input control) ...........................................real (Htuple .) double<br />

Clipping factor for the elimination of outliers (typical: 1.0 for ’*Huber’ and 2.0 for ’*Tukey’).<br />

Default Value : 2.0<br />

Value List : ClippingFactor ¾1.0, 1.5, 2.0, 2.5, 3.0<br />

Restriction : ClippingFactor 0<br />

º Row (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.y(-array) (Htuple .) double *<br />

Row coordinate of the center of the ellipse.<br />

º Column (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.center.x(-array) (Htuple .) double *<br />

Column coordinate of the center of the ellipse.<br />

º Phi (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.angle.rad(-array) (Htuple .) double *<br />

Orientation of the main axis [rad].<br />

º Radius1 (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius1(-array) (Htuple .) double *<br />

Length of the larger half axis.<br />

º Radius2 (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ellipse.radius2(-array) (Htuple .) double *<br />

Length of the smaller half axis.<br />

º StartPhi (output control) .........................................real(-array) (Htuple .) double *<br />

Angle of the start point [rad].<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.3. FEATURES 869<br />

º EndPhi (output control) ............................................real(-array) (Htuple .) double *<br />

Angle of the end point [rad].<br />

º PointOrder (output control) .......................................string(-array) (Htuple .) char *<br />

point order along the boundary.<br />

Value List : PointOrder ¾’positive’, ’negative’<br />

Example<br />

read_image (Image, "caltab");<br />

find_caltab (Image, &Caltab, "caltabBig.descr", 3, 112, 5)<br />

reduce_domain (Image, Caltab, &ImageReduced);<br />

edges_sub_pix (ImageReduced, &Edges, "lanser2", 0.5, 20, 40);<br />

select_contours_xld (Edges, &EdgesClosed, "closed", 0, 2.0, 0, 0);<br />

select_contours_xld (EdgesClosed, &EdgesMarks, "length", 20, 80, 0, 0);<br />

fit_ellipse_contour_xld (EdgesMarks, "fitzgibbon", -1, 2, 0, 200, 3, 2.0,<br />

&Row, &Column, &Phi, &Radius1, &Radius2, &StartPhi,<br />

&EndPhi, &PointOrder);<br />

gen_ellipse_contour_xld (&EllMarks, Row, Column, Phi, Radius1, Radius2,<br />

StartPhi, EndPhi, PointOrder, 1.5);<br />

length_xld(EllMarks,&Length);<br />

Result<br />

(T )fit ellipse contour xld returns H MSG TRUE if all parameter values are correct, and ellipses<br />

could be fitted to the input contours. If the input is empty the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

(T )fit ellipse contour xld is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix,<br />

smooth contours xld<br />

Possible Successor Functions<br />

(T )gen ellipse contour xld, disp ellipse, get points ellipse<br />

(T )fit line contour xld<br />

Sub-pixel operators<br />

See Also<br />

Module<br />

fit line contour xld ( Hobject Contours, const char *Algorithm,<br />

long MaxNumPoints, long ClippingEndPoints, long Iterations,<br />

double ClippingFactor, double *RowBegin, double *ColBegin, double *RowEnd,<br />

double *ColEnd, double *Nr, double *Nc, double *Dist )<br />

T fit line contour xld ( Hobject Contours, Htuple Algorithm,<br />

Htuple MaxNumPoints, Htuple ClippingEndPoints, Htuple Iterations,<br />

Htuple ClippingFactor, Htuple *RowBegin, Htuple *ColBegin, Htuple *RowEnd,<br />

Htuple *ColEnd, Htuple *Nr, Htuple *Nc, Htuple *Dist )<br />

Approximation of XLD contours by line segments.<br />

(T )fit line contour xld approximates the XLD contours Contours by line segments. It does not perform<br />

a segmentation of the input contours. Thus, one has to make sure that each contour corresponds to one and<br />

only one line segment. The operator returns for each contour the start point (RowBegin, ColBegin), the end<br />

point (RowEnd, ColEnd), and the regression line to the contour given by the normal vector (Nr, Nc) oftheline<br />

and its distance Dist from the origin, i.e., the line equation is given by ÖÒ Ö · Ò ¼.<br />

The algorithm used for the fitting of lines can be selected via Algorithm:<br />

’regression’ Standard ’least squares’ line fitting.<br />

<strong>HALCON</strong> 6.0


870 CHAPTER 14. XLD<br />

’huber’ Weighted ’least squares’ line fitting, where the impact of outliers is decreased based on the approach<br />

of Huber.<br />

’tukey’ Weighted ’least squares’ line fitting, where the impact of outliers is decreased based on the approach of<br />

Tukey.<br />

’drop’ Weighted ’least squares’ line fitting, where outliers are eliminated.<br />

’gauss’ Weighted ’least squares’ line fitting, where the impact of outliers is decreased based on the mean value<br />

and the standard deviation of the distances of all contour points from the approximating line.<br />

For ’huber’, ’tukey’, and ’drop’ a robust error statistics is used to estimate the standard deviation of the distances<br />

from the contour points without outliers from the approximating line. The parameter ClippingFactor (a<br />

scaling factor for the standard deviation) controls the amount of damping outliers: The smaller the value chosen<br />

for ClippingFactor the more outliers are detected. The detection of outliers is repeated. The parameter<br />

Iterations specifies the number of iterations. In the modus ’regression’ this value is ignored.<br />

To reduce the computational load, the fitting of lines can be restricted to a subset of the contour points: If a value<br />

other than -1 is assigned to MaxNumPoints, only up to MaxNumPoints points - uniformly distributed over the<br />

contour - are used.<br />

The start point and the end point of a line segment is determined by projecting the first and the last point of the<br />

corresponding contour to the approximating line. Due to artefacts in the pre-processing the start and end points of<br />

a contour might be faulty. Therefore, it is possible to exclude ClippingEndPoints at the beginning and at the<br />

end of a contour from the line fitting. However, they are still used for the determination of the start point and the<br />

end point of the line segment.<br />

Parameter<br />

º Contours (input object) .................................................xld cont(-array) Hobject<br />

Input contours.<br />

º Algorithm (input control) ...........................................string (Htuple .) const char *<br />

Algorithm for the fitting of lines.<br />

Default Value : ’tukey’<br />

Value List : Algorithm ¾’regression’, ’huber’, ’tukey’, ’gauss’, ’drop’<br />

º MaxNumPoints (input control) .............................................integer (Htuple .) long<br />

Maximum number of contour points used for the computation (-1 for all points).<br />

Default Value : -1<br />

Restriction : MaxNumPoints 3<br />

º ClippingEndPoints (input control) ......................................integer (Htuple .) long<br />

Number of points at the beginning and at the end of the contours to be ignored for the fitting.<br />

Default Value : 0<br />

Restriction : ClippingEndPoints 0<br />

º Iterations (input control) ................................................integer (Htuple .) long<br />

Maximum number of iterations (unused for ’regression’).<br />

Default Value : 5<br />

Restriction : Iterations 0<br />

º ClippingFactor (input control) ...........................................real (Htuple .) double<br />

Clipping factor for the elimination of outliers (typical: 1.0 for ’huber’ and ’drop’ and 2.0 for ’tukey’).<br />

Default Value : 2.0<br />

Value List : ClippingFactor ¾1.0, 1.5, 2.0, 2.5, 3.0<br />

Restriction : ClippingFactor 0<br />

º RowBegin (output control) ..................................line.begin.y(-array) (Htuple .) double *<br />

Row coordinates of the starting points of the line segments.<br />

º ColBegin (output control) ..................................line.begin.x(-array) (Htuple .) double *<br />

Column coordinates of the starting points of the line segments.<br />

º RowEnd (output control) .......................................line.end.y(-array) (Htuple .) double *<br />

Row coordinates of the end points of the line segments.<br />

º ColEnd (output control) .......................................line.end.x(-array) (Htuple .) double *<br />

Column coordinates of the end points of the line segments.<br />

º Nr (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Line parameter: Row coordinate of the normal vector<br />

º Nc (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Line parameter: Column coordinate of the normal vector<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.3. FEATURES 871<br />

º Dist (output control) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . number(-array) (Htuple .) double *<br />

Line parameter: Distance of the line from the origin<br />

Example<br />

draw_ellipse(WindowHandle,Row,Column,Phi,Radius1,Radius2);<br />

read_image (Image, ’mreut’);<br />

edges_sub_pix (Image, Edges, ’lanser2’, 0.5, 20, 40);<br />

gen_polygons_xld (Edges, Polygons, ’ramer’, 2);<br />

split_contours_xld (Polygons, Contours, ’polygon’, 1, 5);<br />

fit_line_contour_xld (Contours, ’regression’, -1, 0, 5, 2, RowBegin, ColBegin,<br />

RowEnd, ColEnd, Nr, Nc);<br />

Result<br />

(T )fit line contour xld returns H MSG TRUE if all parameter values are correct, and line segments<br />

could be fitted to the input contours. If the input is empty the behaviour can be set via set system<br />

(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

(T )fit line contour xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix,<br />

smooth contours xld<br />

Possible Successor Functions<br />

disp line, select lines, line orientation<br />

See Also<br />

regress contours xld, T get regress params xld<br />

Sub-pixel operators<br />

Module<br />

T get contour angle xld ( Hobject Contour, Htuple AngleMode,<br />

Htuple CalcMode, Htuple Lookaround, Htuple *Angles )<br />

Calculate the direction of an XLD contour for each contour point.<br />

T get contour angle xld calculates for each point of the XLD contour Contour the direction of its tangent.<br />

Two modes for the output values can be chosen: By passing ’abs’ for AngleMode, the resulting angles<br />

are returned relative to the horizontal axis as angles between 0 and ¾ (counter-clockwise). By passing ’rel’, the<br />

absolute value of the difference of angles to the previous contour point is returned. In this case the range of values<br />

is between 0 and .<br />

There are three different ways of calculating the tangent direction (CalcMode) of the contour point using the<br />

contour points in the interval from Lookaround to · Lookaround. Byusing’range’, the angle of the<br />

line segment between the first and last point of the interval is used. For ’mean’, the average of all angles between<br />

consecutive points of the contour is used. Finally, for ’regress’, the direction of the regression line (the least<br />

squares fit of a line to the contour points in the interval) is used. Lookaround is a measure of how strongly the<br />

contour is smoothed. The angles are returned in Angles in radians.<br />

Parameter<br />

º Contour (input object) ..........................................................xld cont Hobject<br />

Input contour.<br />

º AngleMode (input control) .............................................string Htuple . const char *<br />

Return type of the angles.<br />

Default Value : ’abs’<br />

Value List : AngleMode ¾’abs’, ’rel’<br />

º CalcMode (input control) ..............................................string Htuple . const char *<br />

Method for computing the angles.<br />

Default Value : ’range’<br />

Value List : CalcMode ¾’range’, ’mean’, ’regress’<br />

<strong>HALCON</strong> 6.0


872 CHAPTER 14. XLD<br />

º Lookaround (input control) .................................................integer Htuple . long<br />

Number of points to take into account.<br />

Default Value : 3<br />

Restriction : Lookaround 0<br />

º Angles (output control) ...............................................real-array Htuple . double *<br />

Direction of the tangent to the contour points.<br />

Parallelization Information<br />

T get contour angle xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix<br />

See Also<br />

T get contour xld, T get contour attrib xld<br />

Sub-pixel operators<br />

Module<br />

T get contour attrib xld ( Hobject Contour, Htuple Name,<br />

Htuple *Attrib )<br />

Return point attribute values of an XLD contour.<br />

T get contour attrib xld returns the values of the attribute Name of the XLD contour Contour in<br />

Attrib. Attributes are additional values defined for each contour point, e.g. the direction perpendicular to<br />

the contour (’angle’). Operators which define this kind of attributes, e.g., lines gauss and edges sub pix,<br />

contain a description of the name and semantics of the defined values. T query contour attribs xld can<br />

be used to query which attributes are defined for a particular contour.<br />

Parameter<br />

º Contour (input object) ..........................................................xld cont Hobject<br />

Input XLD contour.<br />

º Name (input control) ....................................................string Htuple . const char *<br />

Name of the attribute.<br />

Default Value : ’angle’<br />

Value Suggestions : Name ¾’angle’, ’edge direction’, ’width right’, ’width left’, ’response’, ’contrast’,<br />

’asymmetry’<br />

º Attrib (output control) ...............................................real-array Htuple . double *<br />

Attribute values.<br />

Parallelization Information<br />

T get contour attrib xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

lines gauss, lines facet, edges sub pix<br />

See Also<br />

T query contour attribs xld, T get contour global attrib xld,<br />

T query contour global attribs xld<br />

Module<br />

Sub-pixel operators<br />

T get contour global attrib xld ( Hobject Contour, Htuple Name,<br />

Htuple *Attrib )<br />

Return global attributes values of an XLD contour.<br />

T get contour global attrib xld returns the values of the global attribute Name of the XLD contour<br />

Contour in Attrib. Global attributes are additional values defined for each contour, e.g., the<br />

normal vector of the regression line of a contour (’regr norm row’ and ’regr norm col’). Operators<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.3. FEATURES 873<br />

which define this kind of attributes contain a description of the name and semantics of the defined values.<br />

T query contour global attribs xld can be used to query which attributes are defined for a particular<br />

contour.<br />

Parameter<br />

º Contour (input object) ..........................................................xld cont Hobject<br />

Input XLD contour.<br />

º Name (input control) .............................................string(-array) Htuple . const char *<br />

Name of the attribute.<br />

Default Value : ’regr norm row’<br />

Value Suggestions : Name ¾’regr norm row’, ’regr norm col’, ’regr mean dist’, ’regr dev dist’,<br />

’cont approx’<br />

º Attrib (output control) ...............................................real-array Htuple . double *<br />

Attribute values.<br />

Parallelization Information<br />

T get contour global attrib xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

lines gauss, lines facet, edges sub pix<br />

See Also<br />

T query contour global attribs xld, T get contour attrib xld,<br />

T query contour attribs xld<br />

Module<br />

Sub-pixel operators<br />

T get regress params xld ( Hobject Contours, Htuple *Length,<br />

Htuple *Nx, Htuple *Ny, Htuple *Dist, Htuple *Fpx, Htuple *Fpy,<br />

Htuple *Lpx, Htuple *Lpy, Htuple *Mean, Htuple *Deviation )<br />

Return XLD contour parameters.<br />

T get regress params xld returns the following parameters for all XLD contours given in Contours:<br />

¯ the number of contour points Length,<br />

¯ the coordinates Nx and Ny of the normal vector of the regression line (i.e., least-squares approximating line),<br />

¯ the distance Dist of the regression line to the origin<br />

¯ the sub-pixel precise coordinates Fpx and Fpy of the perpendicular projection of the start point of the contour<br />

onto the regression line,<br />

¯ the sub-pixel precise coordinates Lpx and Lpy of the perpendicular projection of the end point of the contour<br />

onto the regression line,<br />

¯ the mean of the Euclidian distance of the contour points from the regression line,<br />

¯ the standard deviation of these distances.<br />

Attention<br />

Before the contour parameters can be returned by T get regress params xld, the parameters of the regression<br />

line to the contour must be calculated by calling regress contours xld.<br />

Parameter<br />

º Contours (input object) ...................................................xld cont-array Hobject<br />

Input XLD contours.<br />

º Length (output control) ..............................................integer-array Htuple . long *<br />

Number of contour points.<br />

º Nx (output control) ..................................................point.x-array Htuple . double *<br />

X-coordinate of the normal vector of the regression line.<br />

º Ny (output control) ..................................................point.y-array Htuple . double *<br />

Y-coordinate of the normal vector of the regression line.<br />

<strong>HALCON</strong> 6.0


874 CHAPTER 14. XLD<br />

º Dist (output control) ..............................................number-array Htuple . double *<br />

Distance of the regression line from the origin.<br />

º Fpx (output control) ................................................point.x-array Htuple . double *<br />

X-coordinate of the projection of the start point of the contour onto the regression line.<br />

º Fpy (output control) ................................................point.y-array Htuple . double *<br />

Y-coordinate of the projection of the start point of the contour onto the regression line.<br />

º Lpx (output control) ................................................point.x-array Htuple . double *<br />

X-coordinate of the projection of the end point of the contour onto the regression line.<br />

º Lpy (output control) ................................................point.y-array Htuple . double *<br />

Y-coordinate of the projection of the end point of the contour onto the regression line.<br />

º Mean (output control) ..................................................real-array Htuple . double *<br />

Mean distance of the contour points from the regression line.<br />

º Deviation (output control) ...........................................real-array Htuple . double *<br />

Standard deviation of the distances from the regression line.<br />

Parallelization Information<br />

T get regress params xld is reentrant and processed without parallelization.<br />

regress contours xld<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

disp line, select lines, line orientation<br />

See Also<br />

(T )fit line contour xld, T get contour global attrib xld,<br />

T query contour global attribs xld, T get contour xld, T get contour attrib xld,<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix<br />

Sub-pixel operators<br />

Module<br />

info parallels xld ( Hobject Parallels, Hobject Image,<br />

double *QualityMin, double *QualityMax, long *GrayMin, long *GrayMax,<br />

double *StandardMin, double *StandardMax )<br />

Return information about the gray values of the area enclosed by XLD parallels.<br />

info parallels xld calculates various gray value features of the area enclosed by the XLD parallels<br />

Parallels. The input image Image is used to get the gray values needed for this. The algorithm used in<br />

this operator is very similar to the one used in mod parallels xld. The operator returns ranges for the quality<br />

factor (QualityMin and QualityMax), the mean gray value (GrayMin and GrayMax), and the standard<br />

deviation with respect to the mean gray value (StandardMin and StandardMax).<br />

This operator serves to determine appropriate thresholds for mod parallels xld.<br />

Parameter<br />

º Parallels (input object) ..................................................xld para-array Hobject<br />

Input XLD Parallels.<br />

º Image (input object) ..............................................................image Hobject<br />

Corresponding gray value image.<br />

º QualityMin (output control) .......................................................real double *<br />

Minimum quality factor.<br />

º QualityMax (output control) .......................................................real double *<br />

Maximum quality factor.<br />

º GrayMin (output control) ..........................................................integer long *<br />

Minimum mean gray value.<br />

º GrayMax (output control) ..........................................................integer long *<br />

Maximum mean gray value.<br />

º StandardMin (output control) ......................................................real double *<br />

Minimum standard deviation.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.3. FEATURES 875<br />

º StandardMax (output control) ......................................................real double *<br />

Maximum standard deviation.<br />

Parallelization Information<br />

info parallels xld is reentrant and processed without parallelization.<br />

gen parallels xld<br />

mod parallels xld<br />

intensity, min max gray<br />

Sub-pixel operators<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

length xld ( Hobject XLD, double *Length )<br />

T length xld ( Hobject XLD, Htuple *Length )<br />

Length of contours or polygons.<br />

(T )length xld calculates the length of the contours or polygons XLD. The length is calculated as the sum<br />

of the euclidian distances of successive points on the contour or polygon. If more than one contour or polygon<br />

is passed the results are stored as tuples in which the index of a value corresponds to the index of the respective<br />

contour or polygon in XLD.<br />

Parameter<br />

º XLD (input object) .............................................................xld(-array) Hobject<br />

Contours or polygons to be examined.<br />

º Length (output control) ............................................real(-array) (Htuple .) double *<br />

Length of the contour or polygon.<br />

Assertion : Length 0<br />

Complexity<br />

Let Ò be the number of points of the contour or polygon. Then the run time is Ç´Òµ.<br />

Result<br />

(T )length xld returns H MSG TRUE if the input is not empty. If the input is empty the behaviour can be set<br />

via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

(T )length xld is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, smooth contours xld, gen polygons xld<br />

See Also<br />

(T )area center xld, (T )moments any xld, (T )moments xld, contlength<br />

Sub-pixel operators<br />

Module<br />

local max contours xld ( Hobject Contours, Hobject Image,<br />

Hobject *LocalMaxContours, long MinPercent, long MinDiff, long Distance )<br />

Select XLD contours with a local maximum of gray values.<br />

local max contours xld selects XLD contours from the contours passed in Contours, which have a local<br />

maximum in gray values across the direction of the contour. In order to be selected, at least MinPercent of the<br />

contour points must have a local maximum perpendicular to the direction of the contour. The contours’ direction<br />

is determined by fitting a regression line through five neighboring points of the contour. In order to decide whether<br />

<strong>HALCON</strong> 6.0


876 CHAPTER 14. XLD<br />

there is a local maximum for a contour point, a gray value profile that is Distance points wide and perpendicular<br />

to the contour is computed on both sides of the contour. If the gray value at the countour point is at least MinDiff<br />

larger than the gray value at at least one point on each side of the profile, the contour point is labeled as a local<br />

maximum. The selected contours are returned in LocalMaxContours.<br />

Parameter<br />

º Contours (input object) ...................................................xld cont-array Hobject<br />

XLD contours to be examined.<br />

º Image (input object) ..............................................................image Hobject<br />

Corresponding gray value image.<br />

º LocalMaxContours (output object) .....................................xld cont-array Hobject *<br />

Selected contours.<br />

º MinPercent (input control) ................................................number long / double<br />

Minumum percentage of maximum points.<br />

Default Value : 70<br />

Value Suggestions : MinPercent ¾60, 70, 75, 80, 85, 90, 95<br />

Restriction : ´0.0 MinPercentµ ´MinPercent 100.0µ<br />

º MinDiff (input control) .............................................................integer long<br />

Minimum amount by which the gray value at the maximum must be larger than in the profile.<br />

Default Value : 15<br />

Value Suggestions : MinDiff ¾5, 8, 10, 12, 15, 20<br />

Restriction : ´0 MinDiffµ ´MinDiff 255µ<br />

º Distance (input control) ............................................................integer long<br />

Maximum width of profile used to check for maxima.<br />

Default Value : 4<br />

Value Suggestions : Distance ¾2, 3, 4, 5, 6<br />

Restriction : Distance 1<br />

Parallelization Information<br />

local max contours xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix<br />

gen polygons xld<br />

smooth contours xld<br />

Sub-pixel operators<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

max parallels xld ( Hobject ExtParallels, Hobject *MaxPolygons )<br />

Join modified XLD parallels lying on the same polygon.<br />

max parallels xld joins all modified XLD parallels in ExtParallels into a polygon if they lie on the<br />

same original polygon segment. This means that polgons exhibiting parallelism and enclosing homogeneous areas<br />

in several places are joined into one long polygon (from the first parallel line to the last parallel line). The resulting<br />

polygons are returned in MaxPolygons.<br />

Parameter<br />

º ExtParallels (input object) ..........................................xld ext para-array Hobject<br />

Extended XLD parallels.<br />

º MaxPolygons (output object) ............................................xld poly-array Hobject *<br />

Maximally extended parallels.<br />

Parallelization Information<br />

max parallels xld is reentrant and processed without parallelization.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.3. FEATURES 877<br />

mod parallels xld<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

T get polygon xld, T get lines xld<br />

Sub-pixel operators<br />

Module<br />

moments any xld ( Hobject XLD, const char *Mode, const char *PointOrder,<br />

double Area, double CenterRow, double CenterCol, long P, long Q,<br />

double *M )<br />

T moments any xld ( Hobject XLD, Htuple Mode, Htuple PointOrder,<br />

Htuple Area, Htuple CenterRow, Htuple CenterCol, Htuple P, Htuple Q,<br />

Htuple *M )<br />

Arbitrary geometric moments of contours or polygons.<br />

(T )moments any xld calculates arbitrary moments M of the region enclosed by the contours or polygons XLD.<br />

The moments are computed by applying Green’s theorem using only the points on the contour or polygon, i.e.,<br />

no region is generated explicitly for the purpose of calculating the features. It is assumed that the contours or<br />

polygons are closed. If this is not the case (T )moments any xld will add one point to artificially produce a<br />

closed shape. The computed moments are normalized depending on the desired mode Mode:<br />

¯ ’unnormalized’: No normalization. Let Ê be the enclosed image region. Then the computed moment Å ÔÕ<br />

is equivalent to<br />

Å ÔÕ <br />

<br />

Ê<br />

Ö Ô Õ Ö <br />

¯ ’normalized’: Normalization by the area Area of the enclosed image region:<br />

Å ÔÕ ½ <br />

<br />

Ê<br />

Ö Ô Õ Ö <br />

¯ ’central’:Normalization by the area Area of the enclosed image region and a shift of the region by it’s<br />

centroid Ö ℄ [CenterRow, CenterCol]:<br />

Å ÔÕ ½ <br />

<br />

Ê<br />

´Ö Öµ Ô´ µ Õ Ö <br />

For the normalization of the moments three specific moments are used: The area Area of the enclosed image<br />

region and the coordinates CenterRow,CenterRow of it’s centroid, see (T )area center xld. In addition<br />

to that (T )moments any xld ecpects information about the point order of the input contours/polygons in<br />

PointOrder, see(T )area center xld again. If more than one contour or polygon is passed, M contains<br />

all desired moments of the first contour/polygon followed by all the moments of the second contour/polygon and<br />

so forth.<br />

Parameter<br />

º XLD (input object) .............................................................xld(-array) Hobject<br />

Contours or polygons to be examined.<br />

º Mode (input control) ..................................................string (Htuple .) const char *<br />

computation mode.<br />

Default Value : ’unnormalized’<br />

Value Suggestions : Mode ¾’unnormalized’, ’normalized’, ’central’<br />

º PointOrder (input control) ...................................string(-array) (Htuple .) const char *<br />

point order along the boundary.<br />

Default Value : ’positive’<br />

Value Suggestions : PointOrder ¾’positive’, ’negative’<br />

<strong>HALCON</strong> 6.0


878 CHAPTER 14. XLD<br />

º Area (input control) ..................................................real(-array) (Htuple .) double<br />

Area enclosed by the contour or polygon.<br />

º CenterRow (input control) ........................................point.y(-array) (Htuple .) double<br />

Row coordinate of the centroid.<br />

º CenterCol (input control) ........................................point.x(-array) (Htuple .) double<br />

Column coordinate of the centroid.<br />

º P (input control) .....................................................point.x(-array) (Htuple .) long<br />

first index of the desired moments M[P,Q].<br />

Default Value : 1<br />

º Q (input control) .....................................................point.x(-array) (Htuple .) long<br />

second index of the desired moments M[P,Q].<br />

Default Value : 1<br />

º M (output control) ...................................................real(-array) (Htuple .) double *<br />

the computed moments.<br />

Complexity<br />

Let Ò be the number of points of the contour or polygon. Then the run time is Ç´Òµ.<br />

Result<br />

(T )moments any xld returns H MSG TRUE if the input is not empty. If the input is empty the behaviour can<br />

be set via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

(T )moments any xld is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

(T )area center xld, gen contours skeleton xld, smooth contours xld,<br />

gen polygons xld<br />

Alternatives<br />

(T )moments xld<br />

See Also<br />

(T )moments xld, (T )area center xld, moments region 2nd, area center<br />

Sub-pixel operators<br />

Module<br />

moments xld ( Hobject XLD, double *M11, double *M20, double *M02 )<br />

T moments xld ( Hobject XLD, Htuple *M11, Htuple *M20, Htuple *M02 )<br />

Geometric moments M20, M02, and M11 of contours or polygons.<br />

(T )moments xld calculates the moments (M20, M02, andM11) of the region enclosed by the contours or<br />

polygons XLD. Seemoments region 2nd for the definition of these features. The moments are computed by<br />

applying Green’s theorem using only the points on the contour or polygon, i.e., no region is generated explicitly<br />

for the purpose of calculating the features. It is assumed that the contours or polygons are closed. If this is not<br />

the case (T )moments xld will add one point to artificially produce a closed shape. If more than one contour<br />

or polygon is passed the results are stored as tuples in which the index of a value corresponds to the index of the<br />

respective contour or polygon in XLD.<br />

Parameter<br />

º XLD (input object) .............................................................xld(-array) Hobject<br />

Contours or polygons to be examined.<br />

º M11 (output control) ................................................real(-array) (Htuple .) double *<br />

Mixed second order moment.<br />

º M20 (output control) ................................................real(-array) (Htuple .) double *<br />

Second order moment along the row axis.<br />

º M02 (output control) ................................................real(-array) (Htuple .) double *<br />

Second order moment along the column axis.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.3. FEATURES 879<br />

Complexity<br />

Let Ò be the number of points of the contour or polygon. Then the run time is Ç´Òµ.<br />

Result<br />

(T )moments xld returns H MSG TRUE if the input is not empty. If the input is empty the behaviour can be<br />

set via set system(’no object result’,). If necessary, an exception is raised.<br />

Parallelization Information<br />

(T )moments xld is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, smooth contours xld, gen polygons xld<br />

(T )moments any xld<br />

Alternatives<br />

See Also<br />

(T )moments any xld, (T )area center xld, moments region 2nd, area center<br />

Sub-pixel operators<br />

Module<br />

T query contour attribs xld ( Hobject Contour, Htuple *Attribs )<br />

Return the names of the defined attributes of an XLD contour.<br />

T query contour attribs xld returns the names of the defined attributes of an XLD contour Contour in<br />

Attribs. Attributes are additional values defined for each contour point, e.g. the direction perpendicular to the<br />

contour (’angle’). Operators which define this kind of attributes contain a description of the name and semantics<br />

of the defined values. T get contour attrib xld can be used to access the values of a particular attribute.<br />

Parameter<br />

º Contour (input object) ..........................................................xld cont Hobject<br />

Input contour.<br />

º Attribs (output control) ..............................................string-array Htuple . char *<br />

List of the defined contour attributes.<br />

Parallelization Information<br />

T query contour attribs xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

lines gauss, lines facet, edges sub pix<br />

See Also<br />

T get contour attrib xld, T get contour global attrib xld,<br />

T query contour global attribs xld<br />

Module<br />

Sub-pixel operators<br />

T query contour global attribs xld ( Hobject Contour,<br />

Htuple *Attribs )<br />

Return the names of the defined global attributes of an XLD contour.<br />

T query contour global attribs xld returns the names of the globally defined attributes of an XLD<br />

contour Contour in Attribs. Global attributes are additional values defined for each contour, e.g.,<br />

the normal vector of the regression line of a contour (’regr norm row’ and ’regr norm col’). Operators<br />

which define this kind of attributes contain a description of the name and semantics of the defined values.<br />

T get contour global attrib xld can be used to access the value of a particular attribute.<br />

<strong>HALCON</strong> 6.0


880 CHAPTER 14. XLD<br />

Parameter<br />

º Contour (input object) ..........................................................xld cont Hobject<br />

Input contour.<br />

º Attribs (output control) ..............................................string-array Htuple . char *<br />

List of the defined global contour attributes.<br />

Parallelization Information<br />

T query contour global attribs xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

lines gauss, lines facet, edges sub pix<br />

See Also<br />

T get contour global attrib xld, T get contour attrib xld,<br />

T query contour attribs xld<br />

Module<br />

Sub-pixel operators<br />

select contours xld ( Hobject Contours, Hobject *SelectedContours,<br />

const char *Feature, double Min1, double Max1, double Min2, double Max2 )<br />

Select XLD contours according to several features.<br />

select contours xld selects XLD contours from the input contours Contours according to the following<br />

features (parameter Feature):<br />

’length’ all contours whose maximum extent (as measured by their eight extremal points in row and column<br />

direction, according to Haralick und Shapiro: Computer and Robot Vision, Addison-Wesley 1992, chapter<br />

3.2) is smaller than Min1 or larger than Max1 are not returned (Min2 and Max2 have no influence<br />

here).<br />

’direction’ only contours for which the direction of the regression line is between Min1 and Max1 (in radians,<br />

counter-clockwise) are returned. Min1 and Max1 are mapped to the range of [0,2*PI[. (Min2 and<br />

Max2 have no influence here).<br />

’curvature’ only contours for which the mean distance from the regression line lies between Min1 and Max1,<br />

and for which the standard deviation of the distances is between Min2 and Max2 are returned.<br />

’closed’ only contours for which the distance between their start point and their end point is less or equal Max2<br />

pixels are returned.<br />

If Min1 = Max1 =0orMin2 = Max2 = 0 is used for the selection according to curvature, the respective feature<br />

has no influence on the selection.<br />

Attention<br />

Before contour can be filtered by select contours xld according to ’direction’ or ’curvature’, the parameters<br />

of the regression lines to the contours must be calculated by calling regress contours xld.<br />

Parameter<br />

º Contours (input object) ...................................................xld cont-array Hobject<br />

Input XLD contours.<br />

º SelectedContours (output object) .....................................xld cont-array Hobject *<br />

Output XLD contours.<br />

º Feature (input control) .......................................................string const char *<br />

Feature to select contours with.<br />

Default Value : ’length’<br />

Value List : Feature ¾’length’, ’direction’, ’curvature’, ’closed’<br />

º Min1 (input control) ..................................................................real double<br />

Lower threshold.<br />

Default Value : 0.5<br />

º Max1 (input control) ..................................................................real double<br />

Upper threshold.<br />

Default Value : 200.0<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.4. TRANSFORMATION 881<br />

º Min2 (input control) ..................................................................real double<br />

Lower threshold.<br />

Default Value : -0.5<br />

º Max2 (input control) ..................................................................real double<br />

Upper threshold.<br />

Default Value : 0.5<br />

Parallelization Information<br />

select contours xld is reentrant and processed without parallelization.<br />

regress contours xld<br />

Possible Predecessor Functions<br />

See Also<br />

T get contour xld, T get contour attrib xld, gen contours skeleton xld, lines gauss,<br />

lines facet, edges sub pix, T get regress params xld,<br />

T get contour global attrib xld, T query contour global attribs xld<br />

Bibliography<br />

R. Haralick, L. Shapiro: ”‘Computer and Robot Vision”’ Vol. 1; Kapitel 3.2, Addison-Wesley 1992<br />

Sub-pixel operators<br />

Module<br />

14.4 Transformation<br />

add noise white contour xld ( Hobject Contours,<br />

Hobject *NoisyContours, long NumRegrPoints, double Amp )<br />

Add noise to XLD contours.<br />

add noise white contour xld adds noise to the input XLD contours Contours and returns the noisy<br />

contours in NoisyContours. For each point along the original contours the local regression line (i.e. a leastsquares<br />

approximating line) based on NumRegrPoints neighboring points is determined. Then the point is<br />

shifted perpendicular to this line. The length of the shifts corresponds to white noise, equally distributed in the<br />

interval [-Amp,Amp] generated by using the C function “drand48” with an initial time dependent seed.<br />

Parameter<br />

º Contours (input object) .................................................xld cont(-array) Hobject<br />

Original contours.<br />

º NoisyContours (output object) ........................................xld cont(-array) Hobject *<br />

Noisy contours.<br />

º NumRegrPoints (input control) .....................................................integer long<br />

Number of points used to calculate the regression line.<br />

Default Value : 5<br />

Value Suggestions : NumRegrPoints ¾3, 5, 7, 9<br />

Restriction : ´NumRegrPoints 3µ odd´NumRegrPointsµ<br />

º Amp (input control) ...................................................................real double<br />

Maximum amplitude of the added noise (equally distributed in [-Amp,Amp]).<br />

Default Value : 1.0<br />

Value Suggestions : Amp ¾0.25, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 10.0<br />

Restriction : Amp 0<br />

Example<br />

draw_ellipse(WindowHandle,&Row,&Column,&Phi,&Radius1,&Radius2);<br />

gen_ellipse_contour_xld(&Ellipse,Row,Column,Phi,Radius1,Radius2,0,6.28319,<br />

"positive");<br />

add_noise_white_contour_xld(Ellipse,&NoisyEllipse,5,0.5);<br />

fit_ellipse_contour_xld (NoisyEllipse, "fitzgibbon", -1, 2, 0, 200, 3, 2.0,<br />

&ERow, &EColumn, &EPhi, &ERadius1, &ERadius2,<br />

&EStartPhi, &EEndPhi, &EPointOrder);<br />

<strong>HALCON</strong> 6.0


882 CHAPTER 14. XLD<br />

Result<br />

add noise white contour xld returns H MSG TRUE if all parameter values are correct. If the input is<br />

empty the behaviour can be set via set system(’no object result’,). If necessary, an exception<br />

is raised.<br />

Parallelization Information<br />

add noise white contour xld is reentrant, local, and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix,<br />

(T )gen ellipse contour xld<br />

Possible Successor Functions<br />

smooth contours xld<br />

See Also<br />

smooth contours xld, add noise white<br />

Sub-pixel operators<br />

Module<br />

T affine trans contour xld ( Hobject Contours,<br />

Hobject *ContoursAffinTrans, Htuple HomMat2D )<br />

Apply an arbitrary affine transformation to an XLD contour.<br />

T affine trans contour xld applies an arbitrary affine transformation, i.e., scaling, rotation, translation,<br />

and skewing, to an XLD contour. The affine map is described by the transformation matrix given in<br />

HomMat2D , which is built up by using hom mat2d identity, hom mat2d scale, hom mat2d rotate,<br />

and hom mat2d translate. The components of the homogeneous transformation matrix are interpreted as follows:<br />

the row coordinate of the image corresponds to the Ü coordinate of the matrix, while the column coordinate<br />

of the image corresponds to the Ý coordinate of the matrix. This is necessary to obtain a right-handed coordinate<br />

system, which is assumed for the homogeneous transformation matrices, also for the image. In particular, by doing<br />

so roatations are performed in the correct direction. Note that the (Ü,Ý) order of the matrices quite naturally<br />

corresponds to the usual (row,column) order for coordinates in the image.<br />

Attention<br />

The components of the homogeneous transformation matrix are interpreted as follows: the row coordinate of the<br />

image corresponds to the Ü coordinate of the matrix, while the column coordinate of the image corresponds to the<br />

Ý coordinate of the matrix. This is necessary to obtain a right-handed coordinate system, which is assumed for the<br />

homogeneous transformation matrices, also for the image. In particular, by doing so roatations are performed in<br />

the correct direction. Note that the (Ü,Ý) order of the matrices quite naturally corresponds to the usual (row,column)<br />

order for coordinates in the image.<br />

Parameter<br />

º Contours (input object) .................................................xld cont(-array) Hobject<br />

Input XLD contours.<br />

º ContoursAffinTrans (output object) .................................xld cont(-array) Hobject *<br />

Transformed XLD contours.<br />

º HomMat2D (input control) ...........................................affine2d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 6<br />

Result<br />

T affine trans contour xld returns H MSG TRUE if all parameter values are correct. If necessary, an<br />

exception is raised.<br />

Parallelization Information<br />

T affine trans contour xld is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

hom mat2d identity, hom mat2d translate, hom mat2d rotate, hom mat2d scale<br />

See Also<br />

affine trans image, affine trans region<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.4. TRANSFORMATION 883<br />

Sub-pixel operators<br />

Module<br />

T affine trans polygon xld ( Hobject Polygons,<br />

Hobject *PolygonsAffinTrans, Htuple HomMat2D )<br />

Apply an arbitrary affine transformation to an XLD polygon.<br />

T affine trans polygon xld applies an arbitrary affine transformation, i.e., scaling, rotation, translation,<br />

and skewing, to an XLD polygon. The affine map is described by the transformation matrix given in<br />

HomMat2D , which is built up by using hom mat2d identity, hom mat2d scale, hom mat2d rotate,<br />

and hom mat2d translate.<br />

Attention<br />

The components of the homogeneous transformation matrix are interpreted as follows: the row coordinate of the<br />

image corresponds to the Ü coordinate of the matrix, while the column coordinate of the image corresponds to the<br />

Ý coordinate of the matrix. This is necessary to obtain a right-handed coordinate system, which is assumed for the<br />

homogeneous transformation matrices, also for the image. In particular, by doing so rotations are performed in the<br />

correct direction. Note that the (Ü,Ý) order of the matrices quite naturally corresponds to the usual (row,column)<br />

order for coordinates in the image.<br />

The XLD contours that are possibly referenced by Polygons are neither transformed nor stored with the output<br />

polygons, since this is generally impossible without creating inconsistencies for the attributes of the XLD contours.<br />

Hence, operators that access the contours associated with a polygon, e.g., split contours xld will not work<br />

correctly.<br />

Parameter<br />

º Polygons (input object) .................................................xld poly(-array) Hobject<br />

Input XLD polygons.<br />

º PolygonsAffinTrans (output object) .................................xld poly(-array) Hobject *<br />

Transformed XLD polygons.<br />

º HomMat2D (input control) ...........................................affine2d-array Htuple . double<br />

Input transformation matrix.<br />

Parameter Number : 6<br />

Result<br />

T affine trans polygon xld returns H MSG TRUE if all parameter values are correct. If necessary, an<br />

exception is raised.<br />

Parallelization Information<br />

T affine trans polygon xld is reentrant and automatically parallelized (on tuple level).<br />

Possible Predecessor Functions<br />

hom mat2d identity, hom mat2d translate, hom mat2d rotate, hom mat2d scale<br />

See Also<br />

affine trans image, affine trans region, T affine trans contour xld<br />

Sub-pixel operators<br />

Module<br />

clip contours xld ( Hobject Contours, Hobject *ClippedContours,<br />

long Row1, long Column1, long Row2, long Column2 )<br />

Clip an XLD contour.<br />

clip contours xld clips all XLD contours given in Contours, i.e., only contour points contained in the<br />

rectangle given by Row1, Column1, Row2, andColumn2 are returned on output. If necessary, coutours are<br />

split, and several new contours are produced. The resulting contours are returned in ClippedContours.<br />

<strong>HALCON</strong> 6.0


884 CHAPTER 14. XLD<br />

Parameter<br />

º Contours (input object) ...................................................xld cont-array Hobject<br />

Contours to be clipped.<br />

º ClippedContours (output object) .....................................xld cont(-array) Hobject *<br />

Clipped contours.<br />

º Row1 (input control) ........................................................rectangle.origin.y long<br />

Row coordinate of the upper left corner of the clip rectangle.<br />

Default Value : 0<br />

Value Suggestions : Row1 ¾0, 500, 1000, 1500, 2000<br />

º Column1 (input control) ....................................................rectangle.origin.x long<br />

Column coordinate of the upper left corner of the clip rectangle.<br />

Default Value : 0<br />

Value Suggestions : Column1 ¾0, 500, 1000, 1500, 2000<br />

º Row2 (input control) .......................................................rectangle.corner.y long<br />

Row coordinate of the lower right corner of the clip rectangle.<br />

Default Value : 512<br />

Value Suggestions : Row2 ¾512, 1024, 1536, 2048<br />

º Column2 (input control) ...................................................rectangle.corner.x long<br />

Column coordinate of the lower right corner of the clip rectangle.<br />

Default Value : 512<br />

Value Suggestions : Column2 ¾512, 1024, 1536, 2048<br />

Parallelization Information<br />

clip contours xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix<br />

gen polygons xld<br />

clip region, crop part<br />

Sub-pixel operators<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

combine roads xld ( Hobject EdgePolygons, Hobject ModParallels,<br />

Hobject ExtParallels, Hobject CenterLines, Hobject *RoadSides,<br />

double MaxAngleParallel, double MaxAngleColinear,<br />

double MaxDistanceParallel, double MaxDistanceColinear )<br />

Combine road hypotheses from two resolution levels.<br />

combine roads xld combines road hypotheses obtained from two different resolution levels. The algorithm<br />

selects only those hypotheses which mutually support each other in both resolution levels. The parameters<br />

EdgePolygons, ModParallels and ExtParallels correspond to the road hypotheses from the highest<br />

resolution level. The parameter CenterLines is the result of road extraction in a lower resolution level.<br />

Those of the polygons EdgePolygons are returned for which evidence of being roadsides is found in both resolution<br />

levels. The parameters MaxAngleParallel and MaxAngleColinear determine the angle, that may<br />

be formed by two parallel collinear line segments, respectively. The parameters MaxDistanceParallel and<br />

MaxDistanceColinear determine the maximum allowed distance of two parallel or colliear line segments,<br />

respectively. The combination is done using a number of rules.<br />

Parameter<br />

º EdgePolygons (input object) .............................................xld poly-array Hobject<br />

XLD polygons to be examined.<br />

º ModParallels (input object) .........................................xld mod para-array Hobject<br />

Modified parallels obtained from EdgePolygons.<br />

º ExtParallels (input object) ..........................................xld ext para-array Hobject<br />

Extended parallels obtained from EdgePolygons.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.4. TRANSFORMATION 885<br />

º CenterLines (input object) ...............................................xld poly-array Hobject<br />

Road-center-line polygons to be examined.<br />

º RoadSides (output object) ...............................................xld poly-array Hobject *<br />

Roadsides found.<br />

º MaxAngleParallel (input control) ......................................angle.rad double / long<br />

Maximum angle between two parallel line segments.<br />

Default Value : 0.523598775598<br />

Value Suggestions : MaxAngleParallel ¾0.349065850399, 0.523598775598, 0.6981317008<br />

Restriction : ´0 MaxAngleParallelµ ´pi2µ<br />

º MaxAngleColinear (input control) ......................................angle.rad double / long<br />

Maximum angle between two collinear line segments.<br />

Default Value : 0.261799387799<br />

Value Suggestions : MaxAngleColinear ¾0.174532925199, 0.261799387799, 0.349065850399<br />

Restriction : ´0 MaxAngleColinearµ ´pi2µ<br />

º MaxDistanceParallel (input control) .......................................real double / long<br />

Maximum distance between two parallel line segments.<br />

Default Value : 40<br />

Value Suggestions : MaxDistanceParallel ¾20, 30, 40, 50, 60<br />

Restriction : MaxDistanceParallel 0<br />

º MaxDistanceColinear (input control) .......................................real double / long<br />

Maximum distance between two collinear line segments.<br />

Default Value : 40<br />

Value Suggestions : MaxDistanceColinear ¾20, 30, 40, 50, 60<br />

Restriction : MaxDistanceColinear 0<br />

Parallelization Information<br />

combine roads xld is processed under mutual exclusion against itself and without parallelization.<br />

Possible Predecessor Functions<br />

mod parallels xld, gen polygons xld, T affine trans contour xld<br />

Possible Successor Functions<br />

T get polygon xld, T get lines xld<br />

See Also<br />

lines gauss, lines facet, get channel info, edges sub pix<br />

Bibliography<br />

C. Steger, C. Glock, W. Eckstein, H. Mayer, B. Radig; ”‘Model-based Road Extraction from Images”’; in ”‘Automatic<br />

Extraction of Man-Made Objects from Aerial and Space Images”’; A. Gruen, O. Kuebler, P. Agouris<br />

(Editors); Birkh”auser Verlag (1995), pp. 275-284.<br />

C. Heipke, C. Steger, R. Multhammer; ”‘A Hierarchical Approach to Automatic Road Extraction from Aerial<br />

Imagery”’; in ”‘Integrating Photogrammetric Techniques with Scene Analysis and Machine Vision II”’; D. M.<br />

McKeown, Jr., I. J. Dowman (Editors); Proc. SPIE 2486 (1995), pp. 222-231.<br />

Module<br />

Sub-pixel operators<br />

gen parallel contour xld ( Hobject Contours,<br />

Hobject *ParallelContours, const char *Mode, double Distance )<br />

Compute the parallel contour of an XLD contour.<br />

gen parallel contour xld computes for each of the input contours Contours a parallel contour with<br />

distance Distance. The resulting contours are returned in ParallelContours. To calculate the parallel<br />

contour, the normal vector of the input contour is needed in every contour point. The parameter Mode detemines<br />

how these normal vectors are computed. If Mode = ’gradient’, it is assumed that the input contours are edges,<br />

and the normal information is obtained from the gradient direction of the edge (see edges sub pix). For<br />

this, the attribute ’edge direction’ must exist for the input contour. If Mode = ’contour normal’, a possibly<br />

existing normal information is used to determine the normals. For this, the contour attribute ’angle’ must exist<br />

(see lines gauss, lines facet,oredges sub pix). Finally, if Mode = ’regression normal’, the normal<br />

<strong>HALCON</strong> 6.0


886 CHAPTER 14. XLD<br />

vectors are determined from a local line fit to each contour point. Here, the normal vectors are oriented such that<br />

they point to the right side of the contour when the contour is traversed from start to end. In contrast to the first<br />

two modes, this mode can be used for all XLD contours, no matter how they were generated.<br />

Parameter<br />

º Contours (input object) ...................................................xld cont-array Hobject<br />

Contours to be transformed.<br />

º ParallelContours (output object) .....................................xld cont-array Hobject *<br />

Parallel contours.<br />

º Mode (input control) ............................................................string const char *<br />

Mode, with which the direction information is computed.<br />

Default Value : ’regression normal’<br />

Value Suggestions : Mode ¾’gradient’, ’contour normal’, ’regression normal’<br />

º Distance (input control) ...................................................number double / long<br />

Distance of the parallel contour.<br />

Default Value : 1<br />

Value List : Distance ¾0.2, 0.4, 0.6, 0.8, 1, 2, 3, 4, 5, 7, 10, 15, 20, 30, 40, 50<br />

Parallelization Information<br />

gen parallel contour xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix<br />

gen polygons xld<br />

T get contour xld<br />

Sub-pixel operators<br />

Possible Successor Functions<br />

See Also<br />

Module<br />

merge cont line scan xld ( Hobject CurrConts, Hobject PrevConts,<br />

Hobject *CurrMergedConts, Hobject *PrevMergedConts, long ImageHeight,<br />

double Margin, const char *MergeBorder, long MaxImagesCont )<br />

Merge XLD contours from successive line scan images.<br />

The operator merge cont line scan xld connects adjacent XLD contours, which were extracted from adjacent<br />

images with the height ImageHeight. This operator was especially designed to connect contours that were<br />

extracted from images grabbed by a line scan camera. CurrConts contains the contours from the current image<br />

and PrevConts the contours from the previous one.<br />

With the help of the parameter MergeBorder two cases can be distinguished: If the top (first) line of the current<br />

image touches the bottom (last) line of the previous image, MergeBorder must be set to ’top’, otherwise set<br />

MergeBorder to ’bottom’. MergeBorder defines a margin to the border. Only those end points of the<br />

contours which are inside this margin are considered for the following merging process.<br />

If the operator merge cont line scan xld is used recursivly, the parameter MaxImagesCont determines<br />

the maximum number of images which are covered by a merged contour. All points of the merged contour from<br />

an older image are removed.<br />

The operator merge cont line scan xld returns two contour arrays. PrevMergedConts contains all<br />

those contours from the previous input contours PrevConts, which could not be merged with a current contour.<br />

CurrMergedConts collects all current contours together with the merged parts from the previous<br />

images. Merged contours will exceed the original image, because the previous contours are moved upward<br />

(MergeBorder=’top’)ordownward(MergeBorder=’bottom’) according to the image height.<br />

Parameter<br />

º CurrConts (input object) ................................................xld cont(-array) Hobject<br />

Current input contours.<br />

º PrevConts (input object) ................................................xld cont(-array) Hobject<br />

Merged contours from the previous iteration.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.4. TRANSFORMATION 887<br />

º CurrMergedConts (output object) .....................................xld cont(-array) Hobject *<br />

Current contours, merged with old ones where applicable.<br />

º PrevMergedConts (output object) .....................................xld cont(-array) Hobject *<br />

Contours from the previous iteration which could not be merged with the current ones.<br />

º ImageHeight (input control) ........................................................integer long<br />

Height of the line scan images.<br />

Default Value : 512<br />

Value List : ImageHeight ¾240, 480, 512<br />

º Margin (input control) ...............................................................real double<br />

Maximum distance of contours from the image border.<br />

Default Value : 0<br />

Value List : Margin ¾0, 1, 2, 3, 4, 5<br />

º MergeBorder (input control) ..................................................string const char *<br />

Image line of the current image, which touches the previous image.<br />

Default Value : ”top”<br />

Value List : MergeBorder ¾”top”, ”bottom”<br />

º MaxImagesCont (input control) .....................................................integer long<br />

Maximum number of images covered by one contour.<br />

Default Value : 3<br />

Value Suggestions : MaxImagesCont ¾1, 2, 3, 4, 5<br />

Result<br />

The operator merge cont line scan xld returns the value H MSG TRUE if the given parameters are correct.<br />

Otherwise, an exception will be raised.<br />

Parallelization Information<br />

merge cont line scan xld is reentrant and processed without parallelization.<br />

Sub-pixel operators<br />

Module<br />

regress contours xld ( Hobject Contours, Hobject *RegressContours,<br />

const char *Mode, long Iterations )<br />

Calculate the parameters of a regression line to an XLD contour.<br />

regress contours xld calculates the following parameters for the input XLD contours Contours, and<br />

stores them with the resulting contours as global attributes:<br />

¯ the coordinates of the normal vector of the regression line, i.e., the least-squares approximating line, of all<br />

contour points; the normal vector always points from the origin to the line (attributes: ’regr norm row’,<br />

’regr norm col’),<br />

¯ the mean of the Euclidian distance of the contour points from the regression line (attribute:<br />

’regr mean dist’),<br />

¯ the standard deviation of these distances to the regression line (attribute: ’regr dev dist’).<br />

For Mode = ’no’, the parameters of the regression line are calculated for all points of the contour. In addition,<br />

three different kinds of outlier treatment can be applied. Outliers are contour points which do not lie on the general<br />

contour direction in an “obvious” manner, and thus “distort” the resulting regression line.<br />

Mode =<br />

¯ ’drop’: All contour points further away from the contour than the mean distance to the regression line are<br />

ignored for the calculation of the undistorted regression line.<br />

¯ ’gauss’: The distances of the contour points are weighted according to their probability of occurence in a<br />

Gaussian distribution around the normal regression line.<br />

¯ ’median’: Here, also a normal distribution is assumed for the distances to the normal regression line, however<br />

with the outlier-independent standard deviation ÑÒ´ÐÐ×ص . Again, the distances are weighted, and points<br />

¼<br />

further away than a certain distance are ignored for the undistorted regression line.<br />

<strong>HALCON</strong> 6.0


888 CHAPTER 14. XLD<br />

The calculation of the undistorted regression line can be iterated several times (Iterations).<br />

Parameter<br />

º Contours (input object) ...................................................xld cont-array Hobject<br />

Input XLD contours.<br />

º RegressContours (output object) .......................................xld cont-array Hobject *<br />

Resulting XLD contours.<br />

º Mode (input control) ............................................................string const char *<br />

Type of outlier treatment.<br />

Default Value : ’no’<br />

Value List : Mode ¾’no’, ’drop’, ’gauss’, ’median’<br />

º Iterations (input control) .........................................................integer long<br />

Number of iterations for the outlier treatment.<br />

Default Value : 1<br />

Value Suggestions : Iterations ¾1, 2, 3, 5, 10, 20<br />

Parallelization Information<br />

regress contours xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix<br />

T get regress params xld<br />

Possible Successor Functions<br />

See Also<br />

smooth contours xld, T get contour global attrib xld,<br />

T query contour global attribs xld<br />

Bibliography<br />

H. Suesse, K. Voss: ”‘Adaptive Ausgleichsrechnung und Ausrei”serproblematik f”ur die digitale Bildverarbeitung”’;<br />

Proc. 15. DAGM Symposium, Springer Verlag, L”ubeck 1993<br />

R. Haralick, L. Shapiro: ”‘Computer and Robot Vision”’ Vol. 2; Kapitel 14.9, Addison-Wesley 1992<br />

Module<br />

Sub-pixel operators<br />

segment contours xld ( Hobject Contours, Hobject *ContoursSplit,<br />

const char *Mode, long SmoothCont, double MaxLineDist1,<br />

double MaxLineDist2 )<br />

Segment XLD contours into line segments and circular or elliptic arcs.<br />

segment contours xld segments the input contours Contours into lines if Mode=’lines’, into lines and circular<br />

arcs if Mode=’lines circles’, or into lines and elliptic arcs if Mode=’lines ellipses’. The segmented contours<br />

are returned in ContoursSplit. The information on whether an output contour represents a line or a circular of<br />

elliptic arc is done via the global contour attribute ’cont approx’ (see T get contour global attrib xld).<br />

If ’cont approx’=-1, the coutour is best approximated by a line segment, if ’cont approx’=0, by an elliptic arc,<br />

and if ’cont approx’=1, by a circular arc.<br />

segment contours xld first approximates the input contours by polygons. With this, the contours are oversegmented<br />

in curved areas. After this, neighboring line segments are substituted by circular or elliptic arcs, respectively,<br />

if the contour can be approximated better by an arc. If SmoothCont is set to a value ¼, the input<br />

contours are first smoothed (see smooth contours xld). This can be necessary to prevent very short segments<br />

in the polygonal approximation and to achieve a more robust fit with circular or elliptic arcs, because the smoothing<br />

suppresses outliers on the contours.<br />

The initial polygonal approximation is done by using the Ramer algorithm (see gen polygons xld) with a<br />

maximum distance of MaxLineDist1. After this, circular or elliptic arcs are fit into neighboring line segments.<br />

If the maximum distance of the resulting arc to the contour is smaller than the maximum distance of the two line<br />

segments, the two line segments are replaced with the arc. This procedure is iterated until no more changes occur.<br />

After this, the parts of the contour that are still approximated by line segments are again segmented with a<br />

polygonal approximation with maximum distance MaxLineDist2, and the newly created line segments are<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.4. TRANSFORMATION 889<br />

merged to circular or elliptical arcs where possible. Obviously, this changes the output only if ÅÜÄÒ×ؾ <br />

ÅÜÄÒ×ؽ. This two-step approach is more efficient than a one-step approach with MaxLineDist2,since<br />

fewer line segments are generated in the first step, and hence the circle or ellipse fit has to be performed less often.<br />

Therefore, parts of the input contours that can be approximated by long arcs can be found more efficiently. In the<br />

second step, parts of the input contours that can be approximated by short arcs are found and the end parts of long<br />

arcs are refined.<br />

Parameter<br />

º Contours (input object) .................................................xld cont(-array) Hobject<br />

Contours to be segmented.<br />

º ContoursSplit (output object) .........................................xld cont-array Hobject *<br />

Segmented contours.<br />

º Mode (input control) ............................................................string const char *<br />

Mode for the segmentation of the contours.<br />

Default Value : ’lines circles’<br />

Value List : Mode ¾’lines’, ’lines circles’, ’lines ellipses’<br />

º SmoothCont (input control) .........................................................integer long<br />

Number of points used for smoothing the contours.<br />

Default Value : 5<br />

Value Suggestions : SmoothCont ¾0, 3, 5, 7, 9<br />

Restriction : ´SmoothCont 0µ ´´SmoothCont 3µ odd´SmoothContµµ<br />

º MaxLineDist1 (input control) .......................................................real double<br />

Maximum distance between a contour and the approximating line (first iteration).<br />

Default Value : 4.0<br />

Value Suggestions : MaxLineDist1 ¾1.0, 1.5, 2.0, 2.5, 3.0, 3.5<br />

Restriction : MaxLineDist1 0.0<br />

º MaxLineDist2 (input control) .......................................................real double<br />

Maximum distance between a contour and the approximating line (second iteration).<br />

Default Value : 2.0<br />

Value Suggestions : MaxLineDist2 ¾1.0, 1.5, 2.0, 2.5, 3.0, 3.5<br />

Restriction : MaxLineDist2 0.0<br />

Example<br />

read_image (Image, ’pumpe’)<br />

edges_sub_pix (Image, Edges, ’canny’, 1.5, 15, 40)<br />

segment_contours_xld (Edges, ContoursSplit, ’lines_circles’, 5, 4, 2)<br />

count_obj (ContoursSplit, Number)<br />

gen_empty_obj (Lines)<br />

gen_empty_obj (Circles)<br />

for I := 1 to Number by 1<br />

select_obj (ContoursSplit, Contour, I)<br />

get_contour_global_attrib_xld (Contour, ’cont_approx’, Type)<br />

if (Type = -1)<br />

concat_obj (Lines, Contour, Lines)<br />

else<br />

concat_obj (Circles, Contour, Circles)<br />

endif<br />

endfor<br />

fit_line_contour_xld (Lines, ’tukey’, -1, 0, 5, 2, RowBegin, ColBegin,<br />

RowEnd, ColEnd, Nr, Nc)<br />

fit_circle_contour_xld (Circles, ’atukey’, -1, 2, 0, 3, 2, Row, Column,<br />

Radius, StartPhi, EndPhi, PointOrder)<br />

Parallelization Information<br />

segment contours xld is local and processed completely exclusively without parallelization.<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, lines gauss, edges sub pix<br />

<strong>HALCON</strong> 6.0


890 CHAPTER 14. XLD<br />

Possible Successor Functions<br />

(T )fit line contour xld, (T )fit ellipse contour xld, (T )fit circle contour xld<br />

See Also<br />

split contours xld, T get contour global attrib xld, smooth contours xld,<br />

gen polygons xld<br />

Module<br />

Sub-pixel operators<br />

smooth contours xld ( Hobject Contours, Hobject *SmoothedContours,<br />

long NumRegrPoints )<br />

Smooth an XLD contour.<br />

smooth contours xld smooths the input XLD contours Contours and returns the smoothed contours in<br />

SmoothedContours. The smoothing is done by projecting the contours’ points onto a local regression line<br />

(i.e. a least-squares approximating line), which is computed from NumRegrPoints on each side of the current<br />

contour point. This operator should be called, for example, before contours are scaled.<br />

Parameter<br />

º Contours (input object) ...................................................xld cont-array Hobject<br />

Contour to be smoothed.<br />

º SmoothedContours (output object) .....................................xld cont-array Hobject *<br />

Smoothed contour.<br />

º NumRegrPoints (input control) .....................................................integer long<br />

Number of points used to calculate the regression line.<br />

Default Value : 5<br />

Value Suggestions : NumRegrPoints ¾3, 5, 7, 9<br />

Restriction : ´NumRegrPoints 3µ odd´NumRegrPointsµ<br />

Parallelization Information<br />

smooth contours xld is reentrant and processed without parallelization.<br />

Possible Predecessor Functions<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix<br />

Possible Successor Functions<br />

T affine trans contour xld, gen polygons xld, local max contours xld<br />

T get contour xld<br />

Sub-pixel operators<br />

See Also<br />

Module<br />

split contours xld ( Hobject Polygons, Hobject *Contours,<br />

const char *Mode, long Weight, long Smooth )<br />

Split XLD contours at dominant points.<br />

split contours xld splits the contours which were used to generate the polygons Polygons at prominent<br />

points. If the mode ’polygon’ is selected, the contours are split at the polygons’ control points. In mode ’dominant’,<br />

they are split at dominant points, i.e., at points for which the calculated change of direction is larger than<br />

the (empirically determined) threshold ¾Weightcontour length, and for which in the (empirically determined)<br />

neighborhood of Ô Smooth £ ÐÓ´contour lengthµ points no larger change of direction occurs. The contour direction<br />

is determined from the direction of the regression line (i.e. the least-squares approximating line) through all<br />

points in a neighborhood of Smooth points around a contour point. The directions thus determined are smoothed<br />

with a Gaussian of width Smooth. Weight is a weighting factor for the sensitiveness of the operator. The larger<br />

Weight is selected, the less dominant points are found.<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.4. TRANSFORMATION 891<br />

Parameter<br />

º Polygons (input object) .................................................xld poly(-array) Hobject<br />

Polygons for which the corresponding contours are to be split.<br />

º Contours (output object) ...............................................xld cont(-array) Hobject *<br />

Split contours.<br />

º Mode (input control) ............................................................string const char *<br />

Mode for the splitting of the contours.<br />

Default Value : ’polygon’<br />

Value List : Mode ¾’polygon’, ’dominant’<br />

º Weight (input control) ...............................................................integer long<br />

Weight for the sensitiveness.<br />

Default Value : 1<br />

º Smooth (input control) ...............................................................integer long<br />

Width of the smoothing mask.<br />

Default Value : 5<br />

Parallelization Information<br />

split contours xld is reentrant and processed without parallelization.<br />

gen polygons xld<br />

regress contours xld<br />

Possible Predecessor Functions<br />

Possible Successor Functions<br />

See Also<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix<br />

Sub-pixel operators<br />

Module<br />

T union straight contours histo xld ( Hobject Contours,<br />

Hobject *UnionContours, Hobject *SelectedContours, Htuple RefLineStartY,<br />

Htuple RefLineStartX, Htuple RefLineEndY, Htuple RefLineEndX,<br />

Htuple nWidth, Htuple MaxWidth, Htuple FilterSize, Htuple *HistoValues )<br />

Merge neighboring straight contours having a similar distance from a given line.<br />

T union straight contours histo xld merges neighboring XLD contours Contours if certain criteria<br />

are fulfilled.<br />

The maximum and minium distance of the contours to an given reference line are calculated. From this distances<br />

a histogram is created. If the histogram should be smoothed, FilterSize must be greater then one. Afterwards<br />

the resulting histogram is diveded into ranges.( from minima to minima) Contours which lie in the same range are<br />

concatenated to a new contour. If the width of Range is greater than MaxWidth, all contours in this range are<br />

ignored. (removed) Lies an contour in two ranges or more it is also ignored. In case there are parallel contours,<br />

there is a danger of merging neighboring contours.<br />

The parameters of the regression line are calculated new for merged contours.<br />

The resulting contours cannot be displayed.<br />

Attention<br />

Before the contour parameters can be returned by T union straight contours histo xld, the parameters<br />

of the regression line to the contour must be calculated by calling regress contours xld.<br />

Parameter<br />

º Contours (input object) ...................................................xld cont-array Hobject<br />

Input XLD contours.<br />

º UnionContours (output object) .........................................xld cont-array Hobject *<br />

Output XLD contours.<br />

º SelectedContours (output object) .....................................xld cont-array Hobject *<br />

Output XLD contours.<br />

<strong>HALCON</strong> 6.0


892 CHAPTER 14. XLD<br />

º RefLineStartY (input control) .............................................integer Htuple . long<br />

y coordinate of the starting point of the reference line.<br />

Default Value : 0<br />

º RefLineStartX (input control) .............................................integer Htuple . long<br />

x coordinate of the starting point of the reference line.<br />

Default Value : 0<br />

º RefLineEndY (input control) ................................................integer Htuple . long<br />

y coordinate of the endpoint of the reference line.<br />

Default Value : 0<br />

º RefLineEndX (input control) ................................................integer Htuple . long<br />

x coordinate of the endpoint of the reference line.<br />

Default Value : 0<br />

º nWidth (input control) .......................................................integer Htuple . long<br />

Maximum distance.<br />

Default Value : 1<br />

º MaxWidth (input control) ....................................................integer Htuple . long<br />

Maximum Width between two minimas.<br />

Default Value : 1<br />

º FilterSize (input control) .................................................integer Htuple . long<br />

Size of Smoothfilter<br />

Default Value : 1<br />

Typical Range of Values : 1 FilterSize 63<br />

º HistoValues (output control) ........................................integer-array Htuple . long *<br />

Output Values of Histogram.<br />

Parallelization Information<br />

T union straight contours histo xld is reentrant and processed without parallelization.<br />

regress contours xld<br />

Possible Predecessor Functions<br />

See Also<br />

(T )fit line contour xld, T get contour xld, T get contour attrib xld,<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix,<br />

T get regress params xld, T get contour global attrib xld,<br />

T query contour global attribs xld<br />

Module<br />

Sub-pixel operators<br />

union straight contours xld ( Hobject Contours,<br />

Hobject *UnionContours, double MaxDist, double MaxDiff, double Percent,<br />

const char *Mode, const char *Iterations )<br />

Merge neighboring straight contours having a similar direction.<br />

union straight contours xld merges neighboring XLD contours Contours if certain criteria are fulfilled.<br />

The merging is not done recursively, and only between two contours. The parameter Iterations controls<br />

how often this union step is executed.<br />

Two contours are merged if the shortest distance between their end points (end points are the projections of the<br />

contours’ first and last points onto its regression line) is smaller than MaxDist, and if the difference in direction<br />

(i.e. the regression lines’ direction) is smaller than MaxDiff (radians).<br />

If only one of the criteria is fulfilled, the decision on merging can be influenced by the weighting factor Percent,<br />

which allows the exceeding of one limit to be balanced by the other value remaining below the limit by the<br />

same amount. The end point distance is weighted by Percent, while the directional difference is weighted by<br />

½¼¼ Percent.<br />

If, for example, two contours have an end point distance of 5.0 and a directional difference of 0.5 (with the limits<br />

chosen being MaxDist = 4.0 und MaxDiff = 0.625), both values differ from the limits by 25%. By choosing<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


14.4. TRANSFORMATION 893<br />

Percent = 60%, the larger end point distance is weigthed more than the smaller directional difference, and thus<br />

the contours are not merged. Contrary, if Percent = 40% is chosen, the contours are merged.<br />

For Percent = 100%, only the end point distance is taken into account, while for Percent = 0% only the<br />

difference of direction is used. If Percent = 50% both criteria are equally valid.<br />

In case there are parallel contours, there is a danger of merging neighboring contours. If this is to be avoided, Mode<br />

= ’noparallel’ has to be chosen, while otherwise Mode = ’paralleltoo’ suffices. For Mode = ’every’, contours are<br />

merged unconditionally. All other parameters have no influence in this case.<br />

The parameters of the regression line are calculated anew for merged contours.<br />

Attention<br />

Before the contour parameters can be returned by T get regress params xld, the parameters of the regression<br />

line to the contour must be calculated by calling regress contours xld.<br />

Parameter<br />

º Contours (input object) ...................................................xld cont-array Hobject<br />

Input XLD contours.<br />

º UnionContours (output object) .........................................xld cont-array Hobject *<br />

Output XLD contours.<br />

º MaxDist (input control) ..............................................................real double<br />

Maximum distance of the contours’ endpoints.<br />

Default Value : 5.0<br />

º MaxDiff (input control) .........................................................angle.rad double<br />

Maximum difference in direction.<br />

Default Value : 0.5<br />

º Percent (input control) ..............................................................real double<br />

Weighting factor for the two selection criteria.<br />

Default Value : 50.0<br />

º Mode (input control) ............................................................string const char *<br />

Should parallel contours be taken into account?<br />

Default Value : ’noparallel’<br />

Value List : Mode ¾’noparallel’, ’paralleltoo’, ’every’<br />

º Iterations (input control) ..............................................string const char * / long<br />

Number of iterations or ’maximum’.<br />

Default Value : ’maximum’<br />

Value Suggestions : Iterations ¾1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ’maximum’<br />

Typical Range of Values : 1 Iterations 500 (lin)<br />

Minimal Value Step : 1<br />

Recommended Value Step : 1<br />

Parallelization Information<br />

union straight contours xld is reentrant and processed without parallelization.<br />

regress contours xld<br />

Possible Predecessor Functions<br />

See Also<br />

(T )fit line contour xld, T get contour xld, T get contour attrib xld,<br />

gen contours skeleton xld, lines gauss, lines facet, edges sub pix,<br />

T get regress params xld, T get contour global attrib xld,<br />

T query contour global attribs xld<br />

Module<br />

Sub-pixel operators<br />

<strong>HALCON</strong> 6.0


894 CHAPTER 14. XLD<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Index<br />

2D-Transformation, 15, 27, 449, 621, 623–629, 882,<br />

883<br />

3D-Projection, 696<br />

3D-Transformation, 622, 629, 631, 632, 634, 635<br />

3D-projection, 708<br />

abs funct 1d, 724<br />

abs image,33<br />

abs invar fourier coeff, 718<br />

Absolute-Value, 33, 724, 813, 818<br />

abstract, 589<br />

Access, 726<br />

access channel, 285<br />

Aceess, 726<br />

adapt template, 107<br />

add channels, 309<br />

add image,33<br />

add noise distribution, 136<br />

add noise white, 137<br />

add noise white contour xld, 881<br />

Addition, 33, 730, 814<br />

Affine-Map, 27, 29–32, 449, 623, 637–639, 882, 883<br />

Affine-Transformation, 451<br />

Affine-Transformation., 450, 453<br />

affine trans contour xld, 882<br />

affine trans image,27<br />

affine trans point 2d, 621<br />

affine trans point 3d, 622<br />

affine trans polygon xld, 883<br />

affine trans region, 449<br />

Albedo, 802, 803<br />

Ambient, 802<br />

and, 41<br />

angle ll, 734<br />

angle lx, 735<br />

Anisometry, 479, 500<br />

anisotrope diff, 140<br />

Anisotropy, 317, 330<br />

append channel, 286<br />

append ocr trainf, 778<br />

approx chain, 361<br />

approx chain simple, 364<br />

Approximation, 361, 364<br />

Arc, 205, 361<br />

Arccosine, 813<br />

Arcs, 364<br />

Arcsine, 814<br />

Arctangent, 815<br />

Area, 313, 473, 500, 506, 862<br />

area center, 473<br />

area center gray, 313<br />

area center xld, 862<br />

Arithmetic, 33, 35–40<br />

Arrow, 206<br />

assurance, 589, 591<br />

Attributes, 872, 879<br />

Ausgabe, 226<br />

auto threshold, 537<br />

Average, 308, 841, 861, 871, 873, 874, 880<br />

Background, 514, 519<br />

background, 640, 641, 644–647, 649<br />

background-estimation, 640, 641, 644–647, 649<br />

background seg, 514<br />

Band-Filter, 91<br />

Bandpass-Filter, 92, 97, 98, 103<br />

bandpass image, 103<br />

Barcode, 650, 652, 653, 657, 661, 662, 665<br />

Barcode-description, 661, 662<br />

Best-Match, 108–111, 113, 121, 122, 765<br />

best match, 108<br />

best match mg, 109<br />

best match pre mg, 110<br />

best match rot, 111<br />

best match rot mg, 113<br />

bin threshold, 538<br />

Binary-image, 16<br />

Bit, 41–46<br />

Bit-Operations, 824–827, 847<br />

bit and,41<br />

bit lshift,42<br />

bit mask,42<br />

bit not,43<br />

bit or, 44<br />

bit rshift,44<br />

bit slice,45<br />

bit xor,46<br />

Blurring, 162, 163, 165, 166<br />

BMP, 11, 14, 16, 266<br />

Border-Treatment, 129<br />

Bottom-Hat, 375, 382, 416<br />

bottom hat, 382<br />

Boundary, 383<br />

boundary, 383<br />

Branches, 425<br />

Buffer, 273, 277, 600, 603<br />

Bulkiness, 479<br />

C-procedure, 593<br />

Calibration, 622, 629, 631, 632, 635, 696<br />

895


896 Index<br />

calibration, 672, 673, 678–682, 685, 691, 692, 694,<br />

697, 698, 704–706, 708, 709, 711, 712,<br />

714, 716<br />

caltab points, 672<br />

camera calibration, 673<br />

Canny-Filter, 60, 63<br />

Ceiling-Function, 838<br />

Center, 313, 455, 473, 500, 506<br />

Center-of-Gravity, 368, 369<br />

Centroid, 862<br />

Chain-code, 445<br />

Chaincode, 361<br />

Chaincodes, 364<br />

change domain, 310<br />

change format, 333<br />

change radial distortion cam par, 678<br />

change radial distortion contours xld,<br />

679<br />

change radial distortion image, 680<br />

Channels, 581<br />

channels to image, 286<br />

Chapter, 588<br />

chapter, 589<br />

char threshold, 538<br />

Character, 795–797, 799, 800<br />

Character-sequence, 19<br />

Characters, 789, 790<br />

check difference, 539<br />

check par hw potential, 598<br />

Checkerboard, 454<br />

Choice-of-regions, 500<br />

Chord, 496, 497<br />

Chord-representation, 449<br />

Circle, 209, 385, 391, 399, 420, 455, 461, 486, 495,<br />

505, 888<br />

circle, 176, 252, 865<br />

circularity, 474<br />

Class, 436<br />

class 2dim sup, 541<br />

class 2dim unsup, 543<br />

class ndim box, 544<br />

class ndim norm, 545<br />

Classification, 135, 541, 543–545, 558, 559<br />

clear obj, 439<br />

clear rectangle, 262<br />

clear sampset,1<br />

clear serial, 608<br />

clear shape model, 763<br />

clear template, 114<br />

clear window, 263<br />

Clearing, 303, 439<br />

clip contours xld, 883<br />

clip region, 515<br />

clip region rel, 516<br />

Clipping, 515, 516, 518, 528, 883<br />

Close, 795, 796<br />

close all bg esti, 640<br />

close all class box,1<br />

close all files,17<br />

close all framegrabbers, 340<br />

close all ocrs, 780<br />

close all ocvs, 795<br />

close all serials, 608<br />

close bg esti, 640<br />

close class box,2<br />

close edges,55<br />

close edges length,56<br />

close file,18<br />

close framegrabber, 340<br />

close measure, 769<br />

close ocr, 780<br />

close ocv, 796<br />

close serial, 609<br />

close socket, 613<br />

close window, 263<br />

Closing, 263, 373, 375, 376, 382, 384, 385, 387, 403,<br />

404, 416<br />

closing, 384<br />

closing circle, 385<br />

closing golay, 387<br />

closing rectangle1, 388<br />

Clustering, 543–545, 558, 559<br />

Co-occurence-Matrix, 314, 315, 317, 322<br />

Coding, 497<br />

Coincidence, 461<br />

Color, 194, 196–198, 200<br />

color, 48, 52, 223, 228–231, 234, 235, 239, 250<br />

color-coding, 223, 239<br />

Color-Image, 210<br />

color-image, 47<br />

color-lookup-table, 228<br />

color-space, 48, 52<br />

color-space-transformation, 47, 48, 52<br />

Color-Table, 600, 603<br />

combine roads xld, 884<br />

Compactness, 474, 475, 500<br />

compactness, 475<br />

Comparison, 437, 797<br />

Comparison-Operators, 828–830<br />

Complement, 510<br />

complement, 510<br />

complex to real, 358<br />

Components, 435<br />

compose2, 286<br />

compose3, 287<br />

compose4, 287<br />

compose5, 288<br />

compose6, 289<br />

compose7, 289<br />

concat obj, 440<br />

concat ocr trainf, 781<br />

Concatenation, 440<br />

Configuration, 280<br />

configuration, 229–233, 256<br />

connect and holes, 475<br />

Connected-Components, 331, 332, 514, 517<br />

connection, 517<br />

Connection-component, 475, 481<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Index 897<br />

contlength, 476<br />

Contour, 445, 446, 448, 476, 741<br />

contour, 225, 237, 242<br />

Contour-Length, 875<br />

Contour-length, 475, 476, 500<br />

contour-output, 243<br />

contour point num xld, 863<br />

contour to world plane xld, 680<br />

Contours, 55, 56, 383, 853, 855–860, 863, 865, 867,<br />

869, 871–873, 875, 879–883, 885, 887,<br />

888, 890–892<br />

contours, 679<br />

Contrast, 87<br />

contrast, 82<br />

Contrast-enhancement, 83, 84<br />

Control, 583, 598–600, 603<br />

Control-Modes, 584<br />

control-parameter, 593<br />

Conversion, 831–835, 840<br />

convert image type, 358<br />

convert pose type, 681<br />

Convex, 446<br />

Convexity, 477, 500<br />

convexity, 477<br />

convol fft,85<br />

convol gabor,86<br />

convol image, 129<br />

Convolution, 85, 86, 93, 94, 129<br />

cooc feature image, 314<br />

cooc feature matrix, 315<br />

Coordinate-System, 271, 273, 277, 622, 629, 631,<br />

632, 635<br />

copy image, 295<br />

copy obj, 441<br />

copy rectangle, 264<br />

Copying, 295, 303, 355, 356, 440, 441, 443<br />

corner response, 114<br />

Corners, 114<br />

Correlation, 108–111, 113, 118, 120–122<br />

Cosine, 816<br />

count channels, 290<br />

count obj, 435<br />

count relation, 579<br />

count seconds, 596<br />

Create, 796<br />

create bg esti, 641<br />

create caltab, 682<br />

create class box,2<br />

create funct 1d array, 724<br />

create funct 1d pairs, 725<br />

create ocr class box, 781<br />

create ocv proj, 796<br />

create pose, 685<br />

create shape model, 763<br />

create template, 115<br />

create template rot, 117<br />

Creation, 836<br />

crop domain, 334<br />

crop domain rel, 518<br />

crop part, 334<br />

crop rectangle1, 335<br />

cross-reference, 589, 596<br />

Cursor, 203, 204<br />

cursor-position, 254<br />

Database, 295, 439–443, 579, 581<br />

Debugging, 583, 584<br />

Decode, 650, 652<br />

decode 1d bar code, 650<br />

decode 2d bar code, 651<br />

decompose2, 290<br />

decompose3, 291<br />

decompose4, 292<br />

decompose5, 292<br />

decompose6, 293<br />

decompose7, 293<br />

default-type, 591<br />

Degrees, 821, 832<br />

Delete, 438<br />

Deletion, 262, 263<br />

depth from focus, 801<br />

Deriche-Filter, 60, 63, 156<br />

derivate gauss,57<br />

descript class box,2<br />

Description-file, 11<br />

description-file, 757<br />

detect edge segments, 546<br />

Deviation, 326, 329, 330<br />

deviation image, 159<br />

Devicecontext, 281<br />

Diameter, 478<br />

diameter region, 478<br />

diff of gauss,59<br />

Difference, 511<br />

difference, 511<br />

Differential-Geometry, 57<br />

Diffusion-Filter, 140<br />

Dilatation, 742<br />

Dilation, 377, 382, 384, 385, 387, 389–392, 394,<br />

395, 411, 412, 416, 419, 420, 422–424,<br />

433<br />

dilation1, 389<br />

dilation2, 390<br />

dilation circle, 391<br />

dilation golay, 392<br />

dilation rectangle1, 394<br />

dilation seq, 395<br />

Direction, 853–855, 871, 873, 880, 881, 885, 890–<br />

892<br />

Direction-code, 445<br />

Discrete, 652<br />

discrete 1d bar code, 652<br />

disp arc, 205<br />

disp arrow, 206<br />

disp caltab, 691<br />

disp channel, 208<br />

disp circle, 209<br />

disp color, 210<br />

<strong>HALCON</strong> 6.0


898 Index<br />

disp distribution, 210<br />

disp ellipse, 211<br />

disp image, 213<br />

disp info, 587<br />

disp line, 214<br />

disp lut, 193<br />

disp obj, 215<br />

disp polygon, 216<br />

disp rectangle1, 217<br />

disp rectangle2, 219<br />

disp region, 220<br />

disp xld, 221<br />

Displacement-Vector-Field, 123, 126, 359<br />

DISPLAY, 273, 277<br />

Display, 221<br />

display, 224, 232, 241<br />

dist ellipse contour xld, 863<br />

Distance, 478, 519, 725, 741, 742, 863<br />

distance funct 1d, 725<br />

distance lr, 736<br />

distance pl, 737<br />

distance pp, 738<br />

distance pr, 739<br />

distance ps, 740<br />

distance rr min, 741<br />

distance rr min dil, 742<br />

distance sl, 742<br />

distance sr, 744<br />

distance ss, 744<br />

distance transform, 519<br />

Distribution, 317, 323, 325, 326, 496<br />

div image,35<br />

Division, 35, 817, 818<br />

do ocr multi, 784<br />

do ocr single, 785<br />

do ocv simple, 797<br />

Documentation, 600, 603<br />

Domain, 309–312<br />

drag region1, 173<br />

drag region2, 174<br />

drag region3, 175<br />

draw circle, 176<br />

draw circle mod, 176<br />

draw ellipse, 177<br />

draw ellipse mod, 178<br />

draw line, 180<br />

draw line mod, 181<br />

draw lut, 194<br />

draw point, 182<br />

draw point mod, 183<br />

draw polygon, 184<br />

draw rectangle1, 184<br />

draw rectangle1 mod, 186<br />

draw rectangle2, 187<br />

draw rectangle2 mod, 188<br />

draw region, 189<br />

drawing, 176, 180–184, 186–189<br />

dual rank, 373<br />

dual threshold, 548<br />

dump window, 266<br />

dvf to hom mat2d, 623<br />

dvf to int1, 359<br />

dyn threshold, 549<br />

Dynamic-Threshold, 539, 549<br />

eccentricity, 479<br />

Edge-Amplitude, 60, 63, 65, 66, 69, 70, 74, 75, 77–<br />

80<br />

Edge-Closing, 55, 56<br />

Edge-Detection, 55–57, 59, 60, 65–70, 72–80, 546,<br />

561, 562<br />

Edge-Direction, 60, 63, 66, 70, 75, 78, 80, 885<br />

Edge-Preservation, 140, 155<br />

Edge-Thinning, 60, 561, 562<br />

Edges, 55, 56, 546, 548, 561, 562, 575, 576, 769,<br />

771, 773, 775–777<br />

edges image,60<br />

edges sub pix,63<br />

Elements, 653<br />

eliminate min max, 141<br />

eliminate runs, 520<br />

eliminate sp, 143<br />

Ellipse, 211, 316, 457, 461, 479, 480, 746, 863, 888<br />

ellipse, 177, 178, 252, 858, 867<br />

elliptic axis, 480<br />

elliptic axis gray, 316<br />

emphasize,82<br />

End-Points, 526<br />

Energy, 87<br />

energy gabor,87<br />

enquire class box,3<br />

enquire reject class box,4<br />

Entropy, 160, 317, 320, 330<br />

entropy gray, 317<br />

entropy image, 160<br />

equ histo image,83<br />

Erosion, 378, 382, 384, 385, 387, 396, 397, 399–<br />

402, 408–410, 414–416, 419, 420, 422–<br />

424, 426–431, 433<br />

erosion1, 396<br />

erosion2, 397<br />

erosion circle, 399<br />

erosion golay, 400<br />

erosion rectangle1, 401<br />

erosion seq, 402<br />

Error-Control, 582<br />

Error-Message, 582<br />

Error-Text, 582<br />

Errors, 584<br />

estimate, 753, 757, 760<br />

estimate al am, 802<br />

estimate sl al lr, 802<br />

estimate sl al zc, 803<br />

estimate tilt lr, 804<br />

estimate tilt zc, 804<br />

Estimation, 802–804<br />

estimation, 753, 757, 760<br />

Euler-number, 481<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Index 899<br />

euler number, 481<br />

Evaluation, 795–797, 799, 800<br />

example, 589<br />

Exception, 582<br />

exhaustive match, 118<br />

exhaustive match mg, 120<br />

expand domain gray, 130<br />

expand gray, 551<br />

expand gray ref, 552<br />

expand line, 554<br />

expand region, 521<br />

Expansion, 521, 551, 552, 554<br />

Exponential, 817<br />

Extension, 11<br />

Extern, 271, 281<br />

fast match, 121<br />

fast match mg, 122<br />

fast threshold, 555<br />

Feature, 313–321, 326, 328, 329, 473–477, 480, 481,<br />

484–496, 499, 504–508, 840–842, 861,<br />

862, 874, 875, 877, 878<br />

Feature-Space, 541, 544, 545, 558, 559<br />

Features, 839, 841<br />

FFT, 85–92, 94, 96–102<br />

fft generic,88<br />

fft image,89<br />

fft image inv,90<br />

File, 600, 603<br />

file-access, 15<br />

File-Format, 16<br />

file exists,15<br />

File format, 14<br />

Fileheader, 12<br />

fill dvf, 123<br />

fill interlace, 144<br />

fill up, 522<br />

fill up shape, 523<br />

Filter, 85, 86, 93, 94, 114, 130, 284<br />

Filter-Mask, 129<br />

Filter-Width, 68, 146<br />

filter kalman, 753<br />

find 1d bar code, 653<br />

find 1d bar code region, 657<br />

find 2d bar code, 658<br />

find caltab, 692<br />

find marks and pose, 694<br />

find neighbors, 482<br />

find shape model, 765<br />

fit circle contour xld, 865<br />

fit ellipse contour xld, 867<br />

fit line contour xld, 869<br />

fit surface first order, 318<br />

fit surface second order, 319<br />

Fitting, 403, 404<br />

fitting, 403<br />

Floor-Function, 839<br />

fnew line,18<br />

Font, 600, 603<br />

font, 253, 256, 259<br />

font-size, 253<br />

Foreground, 519<br />

foreground, 640, 641, 644–647, 649<br />

Form, 500<br />

Form-feature, 488–493<br />

Fourier-Transformation, 88–92, 96–102<br />

fourier 1dim, 719<br />

fourier 1dim inv, 720<br />

Framegrabber, 340–346, 348, 350, 351<br />

fread char,19<br />

fread string,19<br />

Frei-Filter, 65, 66<br />

frei amp,65<br />

frei dir,66<br />

Frequency, 323, 325, 326<br />

Frequency-Domain, 85, 86, 88, 89, 91, 92, 94, 96–98<br />

full domain, 310<br />

funct 1d to pairs, 726<br />

Function, 725<br />

Functions, 724, 726–730, 732, 733<br />

Fuzzy-Sets, 320, 321<br />

fuzzy entropy, 320<br />

fuzzy perimeter, 321<br />

fwrite string,20<br />

Gabor-Filter, 86, 87, 94<br />

Gaps, 521, 551, 552<br />

Gauss-Filter, 145, 156<br />

Gauss-Pyramid, 124<br />

gauss distribution, 138<br />

gauss image, 145<br />

Gaussian, 57, 59, 72, 73, 79, 80, 98, 145, 156, 537,<br />

538, 556<br />

Gaussian-Function, 731<br />

gen 1d bar code descr, 661<br />

gen 1d bar code descr gen, 662<br />

gen 2d bar code descr, 663<br />

gen bandfilter,91<br />

gen bandpass,92<br />

gen checker region, 454<br />

gen circle, 455<br />

gen contour polygon xld, 855<br />

gen contour region xld, 856<br />

gen contours skeleton xld, 857<br />

gen cooc matrix, 322<br />

gen disc se, 374<br />

gen ellipse, 457<br />

gen ellipse contour xld, 858<br />

gen empty obj, 442<br />

gen empty region, 458<br />

gen filter mask,93<br />

gen gabor,94<br />

gen gauss pyramid, 124<br />

gen grid region, 459<br />

gen highpass,96<br />

gen image1, 295<br />

gen image1 extern, 296<br />

gen image1 rect, 298<br />

<strong>HALCON</strong> 6.0


900 Index<br />

gen image3, 299<br />

gen image const, 301<br />

gen image gray ramp, 302<br />

gen image proto, 303<br />

gen image surface second order, 304<br />

gen lowpass,96<br />

gen measure arc, 769<br />

gen measure rectangle2, 771<br />

gen parallel contour xld, 885<br />

gen parallels xld, 859<br />

gen polygons xld, 860<br />

gen psf defocus, 162<br />

gen psf motion, 163<br />

gen random region, 460<br />

gen random regions, 461<br />

gen rectangle1, 463<br />

gen rectangle2, 464<br />

gen region histo, 465<br />

gen region hline, 466<br />

gen region line, 467<br />

gen region points, 468<br />

gen region polygon, 469<br />

gen region polygon filled, 470<br />

gen region runs, 471<br />

gen sin bandpass,97<br />

gen std bandpass,98<br />

gen struct elements, 404<br />

generic, 662<br />

Geocoding, 15, 23–25<br />

Geometry, 734–740, 742, 744, 746–748<br />

get 1d bar code, 665<br />

get 2d bar code, 666<br />

get 2d bar code pos, 670<br />

get bg esti params, 644<br />

get channel info, 435<br />

get chapter info, 588<br />

get check, 582<br />

get class box param,4<br />

get comprise, 221<br />

get contour angle xld, 871<br />

get contour attrib xld, 872<br />

get contour global attrib xld, 872<br />

get contour xld, 853<br />

get domain, 311<br />

get draw, 222<br />

get error text, 582<br />

get fix, 222<br />

get fixed lut, 195<br />

get font, 253<br />

get framegrabber lut, 341<br />

get framegrabber param, 341<br />

get grayval, 351<br />

get hsi, 223<br />

get icon, 223<br />

get image pointer1, 352<br />

get image pointer1 rect, 353<br />

get image pointer3, 354<br />

get image time, 306<br />

get insert, 224<br />

get keywords, 589<br />

get line approx, 225<br />

get line of sight, 696<br />

get line style, 225<br />

get line width, 225<br />

get lines xld, 853<br />

get lut, 196<br />

get lut style, 196<br />

get mbutton, 202<br />

get modules, 580<br />

get mposition, 203<br />

get mshape, 203<br />

get next socket data type, 613<br />

get obj class, 436<br />

get operator info, 589<br />

get operator name, 590<br />

get paint, 226<br />

get pair funct 1d, 726<br />

get parallels xld, 854<br />

get param info, 591<br />

get param names, 593<br />

get param num, 593<br />

get param types, 594<br />

get part, 226<br />

get part style, 227<br />

get pixel, 228<br />

get points ellipse, 746<br />

get polygon xld, 855<br />

get pose type, 697<br />

get region chain, 445<br />

get region contour, 446<br />

get region convex, 446<br />

get region index, 483<br />

get region points, 447<br />

get region polygon, 448<br />

get region runs, 449<br />

get region thickness, 483<br />

get regress params xld, 873<br />

get rgb, 228<br />

get serial param, 609<br />

get shape, 229<br />

get spy, 583<br />

get string extents, 253<br />

get system, 600<br />

get tposition, 254<br />

get tshape, 255<br />

get window extents, 267<br />

get window pointer3, 268<br />

get window type, 268<br />

give bg esti, 645<br />

Gnuplot, 190–192<br />

gnuplot close, 190<br />

gnuplot open file, 190<br />

gnuplot open pipe, 191<br />

gnuplot plot ctrl, 191<br />

gnuplot plot funct 1d, 192<br />

gnuplot plot image, 192<br />

Golay-Alphabet, 387, 392, 395, 400, 402, 405, 409,<br />

410, 417, 418, 422, 427, 428, 430, 431<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Index 901<br />

golay elements, 405<br />

grab image, 342<br />

grab image async, 343<br />

grab image start, 344<br />

grab region, 345<br />

grab region async, 346<br />

Graphic, 600, 603<br />

graphic, 221, 224<br />

Graphics, 205, 206, 209, 211, 271, 273, 277, 281<br />

graphics, 232, 691<br />

Graphics-Software, 268<br />

Grauwert, 226<br />

Gray-Channels, 285–294<br />

Gray-Projections, 653, 657, 665<br />

gray-scale-image, 47<br />

Gray-surface, 304<br />

Gray-Value, 213, 215, 308<br />

Gray-Value-Feature, 313–321, 326, 328, 329, 861,<br />

874<br />

Gray-Value-Morphology, 377, 379, 380<br />

Gray-value-scaling, 85<br />

gray-value-spreading, 85<br />

Gray-Value-Threshold, 537–539, 549, 555, 556, 573<br />

Gray-Values, 132, 303, 314, 315, 317, 322, 326, 329,<br />

355–357, 374–381, 551, 552, 861, 874<br />

Gray-values, 323, 325, 326, 330, 351<br />

gray bothat, 375<br />

gray closing, 376<br />

gray dilation, 377<br />

gray dilation rect, 377<br />

gray erosion, 378<br />

gray erosion rect, 379<br />

gray histo, 323<br />

gray inside, 131<br />

gray opening, 379<br />

gray projections, 324<br />

gray range rect, 380<br />

gray skeleton, 132<br />

gray tophat, 381<br />

grayvalue, 221, 226, 228, 231, 233, 238, 244, 250<br />

grayvalue-interpolation, 227, 249<br />

Grayvalues, 114<br />

Half-axis, 316, 480<br />

Half-Images, 144<br />

Hammin-distance, 484, 485<br />

Hamming-Distance, 524<br />

hamming change region, 524<br />

hamming distance, 484<br />

hamming distance norm, 485<br />

hand eye calibration, 698<br />

Height-Field, 804, 806–808, 810<br />

height-plot, 244<br />

help, 587, 589, 591, 595<br />

Hesse, 466<br />

High-Pass-Filter, 67<br />

Highpass-Filter, 96<br />

highpass image,67<br />

Hilbert-Transform, 86, 87, 94<br />

histo 2dim, 325<br />

histo to thresh, 556<br />

Histogram, 323, 325, 326, 331, 332, 465, 537, 538,<br />

541, 543, 556<br />

histogram, 244<br />

Histogram-linearisation, 83<br />

Histogram-spreading, 83<br />

Hit-Or-Miss-Transformation, 405, 408–410, 426–<br />

431<br />

hit or miss, 408<br />

hit or miss golay, 409<br />

hit or miss seq, 410<br />

HNF, 750–752<br />

hole, 475, 481<br />

Holes, 522, 523<br />

hom mat2d compose, 623<br />

hom mat2d identity, 624<br />

hom mat2d invert, 624<br />

hom mat2d rotate, 625<br />

hom mat2d scale, 626<br />

hom mat2d slant, 627<br />

hom mat2d to affine par, 628<br />

hom mat2d translate, 629<br />

hom mat3d compose, 629<br />

hom mat3d identity, 631<br />

hom mat3d invert, 631<br />

hom mat3d rotate, 632<br />

hom mat3d scale, 634<br />

hom mat3d to pose, 704<br />

hom mat3d translate, 635<br />

Homogeneous-Coordinates, 15, 27, 449, 621–629,<br />

631, 632, 634, 635, 882, 883<br />

homogeneous-coordinates, 704, 706<br />

Hopfield, 484, 485<br />

Hough-Transform, 749–752<br />

hough circle trans, 749<br />

hough circles, 749<br />

hough line trans, 750<br />

hough lines, 751<br />

Hull, 446, 486, 505, 507<br />

hull, 252<br />

Hyper-Cube, 545, 559<br />

Hyper-Cuboid, 544, 558<br />

Hyper-Sphere, 545, 559<br />

Hyperbolic-Cosine, 816<br />

Hyperbolic-Sine, 822<br />

Hyperbolic-Tangent, 824<br />

Hysteresis, 557<br />

Hysteresis-Thresholding, 60, 63<br />

hysteresis threshold, 557<br />

Iconic-Object, 295, 439–443, 579<br />

illuminate,84<br />

Illumination, 84<br />

Image, 215, 295, 296, 298, 299, 301, 302, 304, 600,<br />

603, 616, 617<br />

image-clipping, 226, 227, 248, 249<br />

Image-directory, 11<br />

Image-Generation, 306, 307<br />

<strong>HALCON</strong> 6.0


902 Index<br />

Image-grabbing, 341–346, 351<br />

image-matrix, 236<br />

Image-Object, 213, 220, 600, 603<br />

Image-object, 11, 295, 296, 298, 299, 301, 302, 304,<br />

435–438<br />

image-object, 236<br />

Image-Part, 334, 335<br />

image-part, 226, 227, 248, 249<br />

Image-Plane, 318, 319, 328, 329<br />

Image-plane, 302<br />

image-repeat-memory, 241<br />

Image-Restoration, 167, 169<br />

image-sequences, 640, 641, 644–647, 649<br />

Image-Size, 333–338<br />

Image-Types, 358<br />

Image data, 12<br />

image points to world plane, 705<br />

image to channels, 294<br />

Images, 581<br />

info edges,68<br />

info framegrabber, 346<br />

info ocr class box, 786<br />

info parallels xld, 874<br />

info smooth, 146<br />

Information, 317, 346, 435–438<br />

information, 589<br />

Initialization, 581, 598–600, 603<br />

Inner-circle, 486, 500<br />

inner circle, 486<br />

input, 257, 258<br />

input-parameter, 593<br />

inquiry, 595<br />

Inside, 131<br />

inspect shape model, 767<br />

int1 to dvf, 359<br />

integer to obj, 442<br />

integrate funct 1d, 727<br />

intensity, 326<br />

Interaction, 202, 203, 284<br />

interaction, 173–178, 180–184, 186–189<br />

interjacent, 525<br />

Interlace, 144<br />

Interpolation, 27, 144, 882, 883<br />

interpolation, 227<br />

Intersection, 512, 515, 516, 518<br />

intersection, 512<br />

intersection ll, 747<br />

invar fourier coeff, 721<br />

Inversion, 36<br />

invert image,36<br />

Iteration, 140<br />

JPEG, 11, 14, 266<br />

Junctions, 526<br />

junctions skeleton, 526<br />

Kalman-filter, 640, 644–647, 649, 753, 757, 759, 760<br />

keyword, 589, 596<br />

Kirsch-Filter, 69, 70<br />

kirsch amp,69<br />

kirsch dir,70<br />

kKalmanfilter, 641<br />

Label-Image, 307, 472<br />

label to region, 472<br />

Lanser-Filter, 60, 63<br />

laplace,72<br />

Laplace-Filter, 57, 59, 72, 73<br />

Laplace-of-Gaussian, 57, 59, 73<br />

Laplace-Operator, 548<br />

laplace of gauss,73<br />

Laws-Filter, 161<br />

Ldexp, 818<br />

learn class box,5<br />

learn ndim box, 558<br />

learn ndim norm, 559<br />

learn sampset box,6<br />

Least-Squares-Adjustment, 727<br />

Length, 853–855<br />

length xld, 875<br />

Level-Crossings, 574<br />

Licence, 580<br />

Light-Source, 802–804, 806–808, 810<br />

Line, 214, 361, 869, 888<br />

line, 180<br />

Line-Extraction, 103, 105<br />

Line-feed, 18<br />

Line-Length, 368, 369<br />

Line-length, 370<br />

Line-segments, 869, 888<br />

line-width, 243<br />

line orientation, 366<br />

line position, 367<br />

Lines, 364, 366–370, 459, 461, 466, 467, 533, 535,<br />

546, 853<br />

lines facet, 103<br />

lines gauss, 105<br />

load par knowledge, 599<br />

Local-Maximum, 561, 562, 875<br />

Local-Threshold, 539, 549<br />

local max, 560<br />

local max contours xld, 875<br />

LoG, 57, 59, 73<br />

Logarithm, 819<br />

Logical-Operations, 842–844<br />

Look-Up-Table, 133, 193, 194, 196–198, 200, 201,<br />

222, 237<br />

Lowpass-Filter, 96<br />

LUT, 133, 193, 194, 196–198, 200, 201, 222, 237,<br />

341, 350, 600<br />

lut, 250<br />

lut trans, 133<br />

Main-axes-of-inertia, 487–493<br />

Main-radius, 500<br />

Manipulation, 837, 838<br />

<strong>Manual</strong>, 588<br />

manual, 587, 595<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Index 903<br />

Map, 27, 29–32, 449, 623, 637–639, 882, 883<br />

Mask, 42<br />

match fourier coeff, 722<br />

match funct 1d trans, 727<br />

Matching, 107–111, 113–115, 117, 118, 120–122,<br />

125, 127–129, 752, 763, 765, 767–769<br />

Matrices, 581<br />

max image,36<br />

max parallels xld, 876<br />

Maxima, 560, 563, 564<br />

Maximum, 36, 125, 132, 326, 330, 377, 733, 840<br />

Mean, 326, 330, 731<br />

Mean-Filter, 141, 143, 147, 148<br />

mean image, 147<br />

mean n, 148<br />

mean sp, 148<br />

measure pairs, 773<br />

measure pos, 775<br />

measure projection, 776<br />

measure thresh, 777<br />

Measurement, 769, 771, 773, 775–777<br />

measurements, 753, 757, 759, 760<br />

Medial-Axis, 532<br />

Median, 529<br />

Median-Filter, 141, 149, 151–154, 158, 373<br />

median image, 149<br />

median separate, 151<br />

median weighted, 152<br />

Memory, 600<br />

merge cont line scan xld, 886<br />

merge regions line scan, 527<br />

Metric, 519<br />

Mexican-Hat-Operator, 57, 59, 73<br />

Midrange-Filter, 153<br />

midrange image, 153<br />

min image,37<br />

min max gray, 326<br />

Minima, 537, 538, 556<br />

Minimum, 37, 125, 326, 330, 379, 733, 741, 742,<br />

841<br />

Minkowski-Addition, 411, 412, 419, 420, 422–424<br />

Minkowski-Subtraction, 384, 385, 387, 414, 415<br />

minkowski add1, 411<br />

minkowski add2, 412<br />

minkowski sub1, 414<br />

minkowski sub2, 415<br />

mirror image,29<br />

mirror region, 450<br />

mod parallels xld, 861<br />

Modules, 580, 652<br />

Moments, 316, 318, 319, 328, 479, 480, 487–493,<br />

877, 878<br />

moments any xld, 877<br />

moments gray plane, 328<br />

moments region 2nd, 487<br />

moments region 2nd invar, 488<br />

moments region 2nd rel invar, 489<br />

moments region 3rd, 490<br />

moments region 3rd invar, 491<br />

moments region central, 492<br />

moments region central invar, 493<br />

moments xld, 878<br />

Monotony, 125<br />

monotony, 125<br />

morph hat, 416<br />

morph skeleton, 417<br />

morph skiz, 418<br />

Morphology, 374–385, 387, 389–392, 394–397,<br />

399–405, 408–412, 414–420, 422–431,<br />

433, 452<br />

Motion-Blur, 163, 166, 167, 169<br />

Mouse, 202–204<br />

move contour orig, 723<br />

move rectangle, 269<br />

move region, 451<br />

movement, 173–175<br />

mult image,38<br />

multichannel, 208<br />

Multiplication, 38, 730, 820<br />

negate funct 1d, 728<br />

Negation, 728, 820<br />

Neighborhood, 123, 482<br />

neighborhood, 499, 508<br />

new extern window, 271<br />

new line, 255<br />

Noise, 136–139, 167, 169, 881<br />

noise, 141<br />

Noise-Distribution, 136–139, 210, 881<br />

Noise-Removal, 530<br />

noise distribution mean, 138<br />

Non-linear-Filter, 140<br />

Non-Maximum-Suppression, 60, 561, 562<br />

nonmax suppression amp, 561<br />

nonmax suppression dir, 562<br />

not, 43<br />

num points funct 1d, 729<br />

obj to integer, 443<br />

Object, 215, 438, 442<br />

object, 12<br />

Object-choice, 483, 498<br />

Object-comparison, 437, 438<br />

Object-Key, 442, 443<br />

Object-Selection, 330<br />

OCR, 789, 790<br />

ocr change char, 787<br />

ocr get features, 787<br />

online-text, 589, 595, 596<br />

open file,21<br />

open framegrabber, 348<br />

open serial, 610<br />

open socket accept, 614<br />

open socket connect, 615<br />

open textwindow, 273<br />

open window, 277<br />

Opening, 373, 379, 381, 403, 404, 416, 419, 420,<br />

422–424, 433<br />

<strong>HALCON</strong> 6.0


904 Index<br />

opening, 419<br />

opening circle, 420<br />

opening golay, 422<br />

opening rectangle1, 423<br />

opening seg, 424<br />

Optical-Flow, 126, 359<br />

optical flow match, 126<br />

or, 44<br />

Orientatio, 500<br />

Orientation, 316, 366–369, 457, 464, 480, 494, 507,<br />

653<br />

orientation region, 494<br />

Out-Of-Focus-Blur, 162, 165, 167, 169<br />

Outer-circle, 500<br />

Outliers, 887<br />

Output, 205, 206, 208–211, 213–215, 217, 219<br />

output, 221, 225, 226, 241, 260, 261, 691<br />

output-parameter, 593<br />

Overlap, 503<br />

paint, 184<br />

paint gray, 355<br />

paint region, 356<br />

Parallelization, 598–600<br />

Parallels, 854, 859, 861, 874, 876, 884<br />

parameter, 225, 589, 591, 593–595<br />

parameter-number, 593<br />

Partition, 528<br />

partition dynamic, 528<br />

partition lines, 368<br />

partition rectangle, 528<br />

Pattern, 454, 459, 795–797, 799, 800<br />

Perimeter, 321<br />

Phase, 99, 100<br />

phase deg,99<br />

phase rad, 100<br />

phot stereo, 804<br />

Photometric-Stereo, 804<br />

Pixel, 447, 468<br />

Pixel-Relations, 600, 603<br />

Pixel-Types, 358<br />

Pixel types, 12<br />

Pixels, 459, 461<br />

plane deviation, 329<br />

Plateaus, 563<br />

plateaus, 563<br />

plateaus center, 563<br />

plot, 244<br />

point, 182, 183<br />

Polar-Transformation, 29<br />

polar trans image,29<br />

Polygon, 216, 469, 470, 495<br />

polygon, 184<br />

Polygon-Approximation, 860<br />

Polygon-approximation, 448<br />

polygon-approximation, 242<br />

Polygon-Length, 875<br />

Polygons, 853–856, 860, 876, 883, 884, 890<br />

Polyline, 216<br />

Pose-relation, 499, 508<br />

pose to hom mat3d, 706<br />

PostScript, 266<br />

Pouring, 564<br />

pouring, 564<br />

Power-Function, 821<br />

Power-Spectrum, 99–102<br />

power byte, 100<br />

power ln, 101<br />

power real, 102<br />

prediction, 753, 757, 760<br />

prep contour fourier, 723<br />

Prewitt-Filter, 74, 75<br />

prewitt amp,74<br />

prewitt dir,75<br />

Principal-Components, 134<br />

principal comp, 134<br />

procedure, 593, 595<br />

Procedure-Chapters, 588<br />

procedure-name, 590<br />

Product-of-inertia, 487–493<br />

project 3d point, 708<br />

projection, 244<br />

projection pl, 748<br />

Pruning, 425<br />

pruning, 425<br />

Pyramid, 120<br />

query all colors, 229<br />

query color, 230<br />

query colored, 231<br />

query contour attribs xld, 879<br />

query contour global attribs xld, 879<br />

query font, 256<br />

query gray, 231<br />

query insert, 232<br />

query line width, 232<br />

query lut, 197<br />

query mshape, 204<br />

query operator info, 595<br />

query paint, 233<br />

query param info, 595<br />

query shape, 233<br />

query spy, 584<br />

query tshape, 257<br />

query window type, 280<br />

Radians, 821, 832<br />

Radius, 316, 455, 457, 480<br />

Random-pattern, 460<br />

Range, 326, 380<br />

Range-Filter, 153<br />

Rank-Filter, 149, 152–154, 158, 373<br />

Rank-Gray-Value, 149, 152–154, 158, 373<br />

Rank-Operator, 529<br />

rank image, 154<br />

rank region, 529<br />

read cam par, 709<br />

read char, 257<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Index 905<br />

read class box,7<br />

read contour xld arc info,23<br />

read funct 1d, 729<br />

read gray se, 381<br />

read image,11<br />

read kalman, 757<br />

read ocr, 788<br />

read ocr trainf, 789<br />

read ocr trainf names, 789<br />

read ocr trainf select, 790<br />

read ocv, 799<br />

read polygon xld arc info,24<br />

read pose, 711<br />

read region,16<br />

read sampset,7<br />

read sequence,12<br />

read serial, 610<br />

read shape model, 768<br />

read string, 258<br />

read template, 127<br />

read tuple,22<br />

read world file,15<br />

real to complex, 360<br />

receive image, 616<br />

receive region, 616<br />

receive tuple, 617<br />

receive xld, 617<br />

Rectangle, 217, 219, 394, 401, 423, 461, 463, 464,<br />

507, 515, 516, 518, 528<br />

rectangle, 181, 184, 186–188, 252<br />

rectangle1 domain, 311<br />

rectification, 678–680<br />

Recursive-Filter, 156<br />

reduce domain, 312<br />

reference, 589<br />

Reflection, 29, 450, 452<br />

Region, 16, 17, 215, 220, 435, 438, 445–449, 454,<br />

458, 459, 461, 466, 467, 519, 600, 603,<br />

856<br />

region, 173–175, 189, 222, 229, 233<br />

Region-choice, 503<br />

region to bin, 306<br />

region to label, 307<br />

region to mean, 308<br />

Regiongrowing, 566–568<br />

regiongrowing, 566<br />

regiongrowing mean, 567<br />

regiongrowing n, 568<br />

Regions, 306, 307, 382–385, 387, 389–392, 394–<br />

397, 399–405, 408–412, 414–420, 422–<br />

431, 433, 452, 510–513, 522, 523, 531,<br />

581, 616, 618, 857<br />

regress contours xld, 887<br />

Regression, 869, 871, 873, 875, 880, 881, 885, 887,<br />

890–892<br />

Rekursive-Filters, 60, 63<br />

Relation, 579<br />

Relations, 581<br />

Remainder, 818<br />

remove noise region, 530<br />

reset obj db, 581<br />

Resolution-Pyramid, 120<br />

Restoration, 162, 163, 165, 166<br />

return-value, 589<br />

RGB, 47, 48, 52<br />

rgb1 to gray,47<br />

rgb3 to gray,47<br />

Ridge, 125<br />

roberts,76<br />

Roberts-Filter, 76<br />

Robinson-Filter, 77, 78<br />

robinson amp,77<br />

robinson dir,78<br />

rotate image,30<br />

Rotation, 30, 625, 627, 628, 632<br />

Roundness, 474, 475<br />

roundness, 495<br />

Run, 496, 497, 520<br />

run bg esti, 646<br />

Runlength-Code, 603<br />

Runlength-Coding, 600<br />

Runlength-coding, 449, 471, 497<br />

runlength-encoding, 520<br />

runlength distribution, 496<br />

runlength features, 497<br />

Runtime, 596<br />

sample funct 1d, 730<br />

Save, 799, 800<br />

scale image,39<br />

scale image max,85<br />

scale y funct 1d, 730<br />

Scaling, 31, 32, 39, 626, 634<br />

scaling, 85<br />

search operator, 596<br />

Secondary-radius, 500<br />

segment contours xld, 888<br />

Segmentation, 308, 345, 346, 361, 364, 472, 514,<br />

541, 543–545, 564, 575, 888<br />

segmentation, 692<br />

select contours xld, 880<br />

select gray, 330<br />

select grayvalues from channels, 805<br />

select lines, 369<br />

select lines longest, 370<br />

select matching lines, 752<br />

select obj, 443<br />

select region point, 498<br />

select region spatial, 499<br />

select shape, 500<br />

select shape proto, 503<br />

select shape std, 504<br />

Selection, 441, 443, 844–847<br />

send image, 617<br />

send region, 618<br />

send tuple, 618<br />

send xld, 619<br />

sensor kalman, 759<br />

<strong>HALCON</strong> 6.0


906 Index<br />

Separating-Lines, 525<br />

Serial-Interface, 608–612<br />

set bg esti params, 647<br />

set check, 584<br />

set class box param,8<br />

set color, 234<br />

set colored, 235<br />

set comprise, 236<br />

set draw, 237<br />

set fix, 237<br />

set fixed lut, 197<br />

set font, 259<br />

set framegrabber lut, 350<br />

set framegrabber param, 351<br />

set gray, 238<br />

set grayval, 357<br />

set hsi, 239<br />

set icon, 240<br />

set insert, 241<br />

set line approx, 242<br />

set line style, 242<br />

set line width, 243<br />

set lut, 198<br />

set lut style, 200<br />

set mshape, 204<br />

set offset template, 128<br />

set origin pose, 712<br />

set paint, 244<br />

set part, 248<br />

set part style, 249<br />

set pixel, 250<br />

set reference template, 128<br />

set rgb, 251<br />

set serial param, 611<br />

set shape, 252<br />

set spy, 585<br />

set system, 603<br />

set tposition, 260<br />

set tshape, 260<br />

set window attr, 280<br />

set window dc, 281<br />

set window extents, 282<br />

set window type, 283<br />

sfs mod lr, 806<br />

sfs orig lr, 807<br />

sfs pentland, 808<br />

shade height field, 810<br />

Shading, 804, 806–808, 810<br />

Shadows, 810<br />

Shape, 503<br />

Shape-Feature, 875, 877, 878<br />

Shape-feature, 474, 475, 477, 479, 480, 484, 485,<br />

487, 494, 495, 504<br />

Shape-Features, 523<br />

Shape-from-Shading, 804, 806–808<br />

Shape-Transformation, 531<br />

shape histo all, 331<br />

shape histo point, 332<br />

shape trans, 531<br />

Sharpness, 82<br />

Shen-Filter, 60, 63, 156<br />

Shift, 42, 44<br />

Sigma-Filter, 155<br />

sigma image, 155<br />

sim caltab, 712<br />

Similarity, 504, 725<br />

simulate defocus, 165<br />

simulate motion, 166<br />

Sine, 97, 98, 822<br />

Skeleton, 417, 418, 425, 429–431, 532, 857<br />

skeleton, 532<br />

Slant, 802, 803<br />

slide image, 284<br />

Slope, 125<br />

smallest circle, 505<br />

smallest rectangle1, 506<br />

smallest rectangle2, 507<br />

smooth contours xld, 890<br />

smooth funct 1d gauss, 731<br />

smooth funct 1d mean, 731<br />

smooth image, 156<br />

Smoothing, 57, 140, 141, 143–149, 151–156, 158,<br />

373, 731, 890<br />

Sobel-Filter, 79, 80<br />

sobel amp,79<br />

sobel dir,80<br />

socket accept connect, 620<br />

Sockets, 613–620<br />

sort region, 533<br />

sp distribution, 139<br />

Spatial-Domain, 88, 90, 93<br />

spatial relation, 508<br />

Split-And-Merge, 533, 535<br />

split contours xld, 890<br />

split skeleton lines, 533<br />

split skeleton region, 535<br />

spreading, 85<br />

Square-Root, 823<br />

Standard-Deviation, 159, 839, 861, 873, 874, 880<br />

Store, 799, 800<br />

store par knowledge, 600<br />

Storing-Capacity, 603<br />

String, 19, 20<br />

String-Operators, 847–852<br />

Structure-factor, 479<br />

Structuring-Elements, 374, 381<br />

sub image,40<br />

Subtraction, 40, 823<br />

Sum, 842<br />

Surrogate, 438, 442, 443<br />

Surrounding-circle, 500, 505<br />

surrounding-circle, 252<br />

Surrounding-rectangle, 500, 506, 507<br />

Symmetry, 134<br />

symmetry, 134<br />

System-Call., 597<br />

System-Parameter, 600, 603<br />

system call, 597<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Index 907<br />

systems, 753, 757, 760<br />

T abs funct 1d, 724<br />

T abs invar fourier coeff, 718<br />

T add noise distribution, 136<br />

T affine trans contour xld, 882<br />

T affine trans image,27<br />

T affine trans point 2d, 621<br />

T affine trans point 3d, 622<br />

T affine trans polygon xld, 883<br />

T affine trans region, 449<br />

T angle ll, 734<br />

T angle lx, 735<br />

T append ocr trainf, 778<br />

T approx chain, 361<br />

T approx chain simple, 364<br />

T area center, 473<br />

T area center gray, 313<br />

T area center xld, 862<br />

T best match, 108<br />

T best match rot, 111<br />

T best match rot mg, 113<br />

T caltab points, 672<br />

T camera calibration, 673<br />

T change radial distortion cam par,<br />

678<br />

T change radial distortion contours xld,<br />

679<br />

T change radial distortion image, 680<br />

T char threshold, 538<br />

T circularity, 474<br />

T class ndim norm, 545<br />

T clear rectangle, 262<br />

T compactness, 475<br />

T concat ocr trainf, 781<br />

T connect and holes, 475<br />

T contlength, 476<br />

T contour to world plane xld, 680<br />

T convert pose type, 681<br />

T convexity, 477<br />

T cooc feature image, 314<br />

T copy rectangle, 264<br />

T count channels, 290<br />

T create funct 1d array, 724<br />

T create funct 1d pairs, 725<br />

T create ocr class box, 781<br />

T create ocv proj, 796<br />

T create pose, 685<br />

T decode 1d bar code, 650<br />

T decode 2d bar code, 651<br />

T depth from focus, 801<br />

T detect edge segments, 546<br />

T diameter region, 478<br />

T discrete 1d bar code, 652<br />

T disp arc, 205<br />

T disp arrow, 206<br />

T disp caltab, 691<br />

T disp channel, 208<br />

T disp circle, 209<br />

T disp distribution, 210<br />

T disp ellipse, 211<br />

T disp line, 214<br />

T disp polygon, 216<br />

T disp rectangle1, 217<br />

T disp rectangle2, 219<br />

T dist ellipse contour xld, 863<br />

T distance funct 1d, 725<br />

T distance lr, 736<br />

T distance pl, 737<br />

T distance pp, 738<br />

T distance pr, 739<br />

T distance ps, 740<br />

T distance rr min, 741<br />

T distance rr min dil, 742<br />

T distance sl, 742<br />

T distance sr, 744<br />

T distance ss, 744<br />

T do ocr multi, 784<br />

T do ocr single, 785<br />

T do ocv simple, 797<br />

T dump window, 266<br />

T dvf to hom mat2d, 623<br />

T eccentricity, 479<br />

T elliptic axis, 480<br />

T elliptic axis gray, 316<br />

T enquire class box,3<br />

T enquire reject class box,4<br />

T entropy gray, 317<br />

T estimate al am, 802<br />

T estimate sl al lr, 802<br />

T estimate sl al zc, 803<br />

T estimate tilt lr, 804<br />

T estimate tilt zc, 804<br />

T euler number, 481<br />

T expand gray, 551<br />

T expand gray ref, 552<br />

T fast match mg, 122<br />

T filter kalman, 753<br />

T find 1d bar code, 653<br />

T find 1d bar code region, 657<br />

T find 2d bar code, 658<br />

T find marks and pose, 694<br />

T find neighbors, 482<br />

T find shape model, 765<br />

T fit circle contour xld, 865<br />

T fit ellipse contour xld, 867<br />

T fit line contour xld, 869<br />

T fit surface first order, 318<br />

T fit surface second order, 319<br />

T fourier 1dim, 719<br />

T fourier 1dim inv, 720<br />

T funct 1d to pairs, 726<br />

T fuzzy entropy, 320<br />

T fuzzy perimeter, 321<br />

T fwrite string,20<br />

T gauss distribution, 138<br />

T gen 1d bar code descr, 661<br />

T gen 1d bar code descr gen, 662<br />

<strong>HALCON</strong> 6.0


908 Index<br />

T gen 2d bar code descr, 663<br />

T gen circle, 455<br />

T gen contour polygon xld, 855<br />

T gen ellipse, 457<br />

T gen ellipse contour xld, 858<br />

T gen rectangle1, 463<br />

T gen rectangle2, 464<br />

T gen region histo, 465<br />

T gen region hline, 466<br />

T gen region line, 467<br />

T gen region points, 468<br />

T gen region polygon, 469<br />

T gen region polygon filled, 470<br />

T gen region runs, 471<br />

T get 1d bar code, 665<br />

T get 2d bar code, 666<br />

T get 2d bar code pos, 670<br />

T get channel info, 435<br />

T get chapter info, 588<br />

T get check, 582<br />

T get contour angle xld, 871<br />

T get contour attrib xld, 872<br />

T get contour global attrib xld, 872<br />

T get contour xld, 853<br />

T get framegrabber lut, 341<br />

T get framegrabber param, 341<br />

T get grayval, 351<br />

T get hsi, 223<br />

T get keywords, 589<br />

T get line of sight, 696<br />

T get line style, 225<br />

T get lines xld, 853<br />

T get lut, 196<br />

T get modules, 580<br />

T get obj class, 436<br />

T get operator info, 589<br />

T get operator name, 590<br />

T get paint, 226<br />

T get pair funct 1d, 726<br />

T get parallels xld, 854<br />

T get param info, 591<br />

T get param names, 593<br />

T get param types, 594<br />

T get pixel, 228<br />

T get points ellipse, 746<br />

T get polygon xld, 855<br />

T get pose type, 697<br />

T get region chain, 445<br />

T get region contour, 446<br />

T get region convex, 446<br />

T get region index, 483<br />

T get region points, 447<br />

T get region polygon, 448<br />

T get region runs, 449<br />

T get region thickness, 483<br />

T get regress params xld, 873<br />

T get rgb, 228<br />

T get string extents, 253<br />

T get system, 600<br />

T gnuplot plot ctrl, 191<br />

T gnuplot plot funct 1d, 192<br />

T gray histo, 323<br />

T gray projections, 324<br />

T hamming distance, 484<br />

T hamming distance norm, 485<br />

T hand eye calibration, 698<br />

T histo to thresh, 556<br />

T hom mat2d compose, 623<br />

T hom mat2d identity, 624<br />

T hom mat2d invert, 624<br />

T hom mat2d rotate, 625<br />

T hom mat2d scale, 626<br />

T hom mat2d slant, 627<br />

T hom mat2d to affine par, 628<br />

T hom mat2d translate, 629<br />

T hom mat3d compose, 629<br />

T hom mat3d identity, 631<br />

T hom mat3d invert, 631<br />

T hom mat3d rotate, 632<br />

T hom mat3d scale, 634<br />

T hom mat3d to pose, 704<br />

T hom mat3d translate, 635<br />

T hough circle trans, 749<br />

T hough circles, 749<br />

T hough lines, 751<br />

T image points to world plane, 705<br />

T info edges,68<br />

T info framegrabber, 346<br />

T info ocr class box, 786<br />

T info smooth, 146<br />

T inner circle, 486<br />

T integer to obj, 442<br />

T integrate funct 1d, 727<br />

T intensity, 326<br />

T intersection ll, 747<br />

T invar fourier coeff, 721<br />

T learn class box,5<br />

T learn ndim norm, 559<br />

T length xld, 875<br />

T line orientation, 366<br />

T line position, 367<br />

T lut trans, 133<br />

T match fourier coeff, 722<br />

T match funct 1d trans, 727<br />

T measure pairs, 773<br />

T measure pos, 775<br />

T measure projection, 776<br />

T measure thresh, 777<br />

T min max gray, 326<br />

T moments any xld, 877<br />

T moments gray plane, 328<br />

T moments region 2nd, 487<br />

T moments region 2nd invar, 488<br />

T moments region 2nd rel invar, 489<br />

T moments region 3rd, 490<br />

T moments region 3rd invar, 491<br />

T moments region central, 492<br />

T moments region central invar, 493<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Index 909<br />

T moments xld, 878<br />

T move contour orig, 723<br />

T move rectangle, 269<br />

T negate funct 1d, 728<br />

T noise distribution mean, 138<br />

T num points funct 1d, 729<br />

T obj to integer, 443<br />

T ocr change char, 787<br />

T ocr get features, 787<br />

T open framegrabber, 348<br />

T optical flow match, 126<br />

T orientation region, 494<br />

T partition lines, 368<br />

T phot stereo, 804<br />

T plane deviation, 329<br />

T pose to hom mat3d, 706<br />

T prep contour fourier, 723<br />

T principal comp, 134<br />

T project 3d point, 708<br />

T projection pl, 748<br />

T query all colors, 229<br />

T query color, 230<br />

T query colored, 231<br />

T query contour attribs xld, 879<br />

T query contour global attribs xld,<br />

879<br />

T query font, 256<br />

T query gray, 231<br />

T query insert, 232<br />

T query lut, 197<br />

T query mshape, 204<br />

T query operator info, 595<br />

T query paint, 233<br />

T query param info, 595<br />

T query shape, 233<br />

T query spy, 584<br />

T query tshape, 257<br />

T query window type, 280<br />

T read cam par, 709<br />

T read funct 1d, 729<br />

T read image,11<br />

T read kalman, 757<br />

T read ocr trainf, 789<br />

T read ocr trainf names, 789<br />

T read ocr trainf select, 790<br />

T read pose, 711<br />

T read serial, 610<br />

T read tuple,22<br />

T read world file,15<br />

T regiongrowing mean, 567<br />

T roundness, 495<br />

T runlength distribution, 496<br />

T runlength features, 497<br />

T sample funct 1d, 730<br />

T scale y funct 1d, 730<br />

T search operator, 596<br />

T select gray, 330<br />

T select lines, 369<br />

T select lines longest, 370<br />

T select matching lines, 752<br />

T select region spatial, 499<br />

T select shape, 500<br />

T select shape proto, 503<br />

T sensor kalman, 759<br />

T set check, 584<br />

T set color, 234<br />

T set framegrabber lut, 350<br />

T set framegrabber param, 351<br />

T set gray, 238<br />

T set grayval, 357<br />

T set hsi, 239<br />

T set line style, 242<br />

T set lut, 198<br />

T set origin pose, 712<br />

T set paint, 244<br />

T set pixel, 250<br />

T set rgb, 251<br />

T set system, 603<br />

T shape histo all, 331<br />

T shape histo point, 332<br />

T sim caltab, 712<br />

T smallest circle, 505<br />

T smallest rectangle1, 506<br />

T smallest rectangle2, 507<br />

T smooth funct 1d gauss, 731<br />

T smooth funct 1d mean, 731<br />

T sp distribution, 139<br />

T spatial relation, 508<br />

T split skeleton lines, 533<br />

T testd ocr class box, 790<br />

T texture laws, 161<br />

T threshold, 573<br />

T tile images offset, 338<br />

T traind ocr class box, 791<br />

T traind ocv proj, 799<br />

T trainf ocr class box, 792<br />

T transform funct 1d, 732<br />

T tuple abs, 813<br />

T tuple acos, 813<br />

T tuple add, 814<br />

T tuple and, 842<br />

T tuple asin, 814<br />

T tuple atan, 815<br />

T tuple atan2, 815<br />

T tuple band, 824<br />

T tuple bnot, 825<br />

T tuple bor, 825<br />

T tuple bxor, 826<br />

T tuple ceil, 838<br />

T tuple chr, 831<br />

T tuple chrt, 831<br />

T tuple concat, 836<br />

T tuple cos, 816<br />

T tuple cosh, 816<br />

T tuple deg, 832<br />

T tuple deviation, 839<br />

T tuple div, 817<br />

T tuple environment, 847<br />

<strong>HALCON</strong> 6.0


910 Index<br />

T tuple equal, 828<br />

T tuple exp, 817<br />

T tuple fabs, 818<br />

T tuple first n, 844<br />

T tuple floor, 839<br />

T tuple fmod, 818<br />

T tuple gen const, 836<br />

T tuple greater, 828<br />

T tuple greater equal, 829<br />

T tuple inverse, 837<br />

T tuple is number, 840<br />

T tuple last n, 845<br />

T tuple ldexp, 818<br />

T tuple length, 840<br />

T tuple less, 829<br />

T tuple less equal, 830<br />

T tuple log, 819<br />

T tuple log10, 819<br />

T tuple lsh, 826<br />

T tuple max, 840<br />

T tuple mean, 841<br />

T tuple min, 841<br />

T tuple mult, 820<br />

T tuple neg, 820<br />

T tuple not, 843<br />

T tuple not equal, 830<br />

T tuple number, 832<br />

T tuple or, 843<br />

T tuple ord, 833<br />

T tuple ords, 833<br />

T tuple pow, 821<br />

T tuple rad, 821<br />

T tuple real, 834<br />

T tuple round, 834<br />

T tuple rsh, 827<br />

T tuple select, 845<br />

T tuple select range, 846<br />

T tuple sin, 822<br />

T tuple sinh, 822<br />

T tuple sort, 837<br />

T tuple sort index, 838<br />

T tuple split, 848<br />

T tuple sqrt, 823<br />

T tuple str bit select, 847<br />

T tuple str first n, 848<br />

T tuple str last n, 849<br />

T tuple strchr, 849<br />

T tuple string, 835<br />

T tuple strlen, 850<br />

T tuple strrchr, 850<br />

T tuple strrstr, 851<br />

T tuple strstr, 852<br />

T tuple sub, 823<br />

T tuple sum, 842<br />

T tuple tan, 823<br />

T tuple tanh, 824<br />

T tuple xor, 844<br />

T union straight contours histo xld,<br />

891<br />

T update kalman, 760<br />

T vector angle to rigid, 637<br />

T vector to hom mat2d, 638<br />

T vector to rigid, 639<br />

T vector to similarity, 639<br />

T write cam par, 714<br />

T write funct 1d, 732<br />

T write image,14<br />

T write ocr trainf, 794<br />

T write ocr trainf image, 795<br />

T write pose, 716<br />

T write serial, 612<br />

T write string, 261<br />

T write tuple,23<br />

T x range funct 1d, 733<br />

T y range funct 1d, 733<br />

Tangent, 823<br />

Test-pixel, 483, 498, 509<br />

test equal obj, 437<br />

test equal region, 438<br />

test obj def, 438<br />

test region point, 509<br />

test sampset box,9<br />

testd ocr class box, 790<br />

Text, 273<br />

text, 253–259, 261<br />

text-cursor, 255, 257, 260<br />

Text-file, 17–21<br />

text-position, 260<br />

text-size, 253<br />

Texture, 151, 159–161, 314, 315, 317, 322<br />

Texture-Transformation, 161<br />

texture laws, 161<br />

Thickening, 426–428<br />

thickening, 426<br />

thickening golay, 427<br />

thickening seq, 428<br />

Thinning, 132, 417, 418, 429–431, 532<br />

thinning, 429<br />

thinning golay, 430<br />

thinning seq, 431<br />

Threshold, 331, 332, 537–539, 548, 549, 555–557,<br />

573, 777<br />

threshold, 573<br />

threshold sub pix, 574<br />

Thresholding, 537, 538, 556<br />

TIFF, 11, 266<br />

Tiff, 14, 16<br />

tile channels, 336<br />

tile images, 337<br />

tile images offset, 338<br />

Tiling, 336–338<br />

Tilt, 804<br />

Time-Measure, 596<br />

Top-Hat, 381, 416, 433<br />

top hat, 433<br />

Topographic-Primal-Sketch, 135<br />

topographic sketch, 135<br />

Trace, 583<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Index 911<br />

traind ocr class box, 791<br />

traind ocv proj, 799<br />

trainf ocr class box, 792<br />

Training, 558, 559, 789, 790, 799<br />

trans from rgb,48<br />

trans to rgb,52<br />

transform funct 1d, 732<br />

Transformation, 27, 29–32, 133, 449, 519, 637–639,<br />

727, 730, 732, 882, 883<br />

transformation, 705<br />

Transformation-Matrix, 27, 449, 623, 637–639, 882,<br />

883<br />

Translation, 451, 629, 635<br />

transpose region, 452<br />

Transposition, 452<br />

trimmed mean, 158<br />

truecolor, 244<br />

Tuple, 442, 458, 813–852<br />

Tuple-Length, 840<br />

Tuple-length, 435<br />

tuple abs, 813<br />

tuple acos, 813<br />

tuple add, 814<br />

tuple and, 842<br />

tuple asin, 814<br />

tuple atan, 815<br />

tuple atan2, 815<br />

tuple band, 824<br />

tuple bnot, 825<br />

tuple bor, 825<br />

tuple bxor, 826<br />

tuple ceil, 838<br />

tuple chr, 831<br />

tuple chrt, 831<br />

tuple concat, 836<br />

tuple cos, 816<br />

tuple cosh, 816<br />

tuple deg, 832<br />

tuple deviation, 839<br />

tuple div, 817<br />

tuple environment, 847<br />

tuple equal, 828<br />

tuple exp, 817<br />

tuple fabs, 818<br />

tuple first n, 844<br />

tuple floor, 839<br />

tuple fmod, 818<br />

tuple gen const, 836<br />

tuple greater, 828<br />

tuple greater equal, 829<br />

tuple inverse, 837<br />

tuple is number, 840<br />

tuple last n, 845<br />

tuple ldexp, 818<br />

tuple length, 840<br />

tuple less, 829<br />

tuple less equal, 830<br />

tuple log, 819<br />

tuple log10, 819<br />

tuple lsh, 826<br />

tuple max, 840<br />

tuple mean, 841<br />

tuple min, 841<br />

tuple mult, 820<br />

tuple neg, 820<br />

tuple not, 843<br />

tuple not equal, 830<br />

tuple number, 832<br />

tuple or, 843<br />

tuple ord, 833<br />

tuple ords, 833<br />

tuple pow, 821<br />

tuple rad, 821<br />

tuple real, 834<br />

tuple round, 834<br />

tuple rsh, 827<br />

tuple select, 845<br />

tuple select range, 846<br />

tuple sin, 822<br />

tuple sinh, 822<br />

tuple sort, 837<br />

tuple sort index, 838<br />

tuple split, 848<br />

tuple sqrt, 823<br />

tuple str bit select, 847<br />

tuple str first n, 848<br />

tuple str last n, 849<br />

tuple strchr, 849<br />

tuple string, 835<br />

tuple strlen, 850<br />

tuple strrchr, 850<br />

tuple strrstr, 851<br />

tuple strstr, 852<br />

tuple sub, 823<br />

tuple sum, 842<br />

tuple tan, 823<br />

tuple tanh, 824<br />

tuple xor, 844<br />

type, 591<br />

Type-Conversion, 358–360<br />

types, 594<br />

Union, 513<br />

union1, 513<br />

union2, 513<br />

union straight contours histo xld, 891<br />

union straight contours xld, 892<br />

update-file, 760<br />

update bg esti, 649<br />

update kalman, 760<br />

vector angle to rigid, 637<br />

vector to hom mat2d, 638<br />

vector to rigid, 639<br />

vector to similarity, 639<br />

Verification, 795–797, 799, 800<br />

wait seconds, 597<br />

Watersheds, 131, 575<br />

<strong>HALCON</strong> 6.0


912 Index<br />

watersheds, 575<br />

Weighting, 152<br />

Wiener-Filter, 162, 163, 167, 169<br />

wiener filter, 167<br />

wiener filter ni, 169<br />

Window, 263, 271, 273, 277, 280, 281, 600, 603<br />

Window-Dump, 266<br />

Window-Position, 282<br />

Window-Size, 267, 282<br />

Window-Types, 280<br />

World-File, 15, 23–25<br />

write cam par, 714<br />

write class box,9<br />

write contour xld arc info,25<br />

write funct 1d, 732<br />

write image,14<br />

write lut, 201<br />

write ocr, 793<br />

write ocr trainf, 794<br />

write ocr trainf image, 795<br />

write ocv, 800<br />

write polygon xld arc info,25<br />

write pose, 716<br />

write region,17<br />

write serial, 612<br />

write shape model, 769<br />

write string, 261<br />

write template, 129<br />

write tuple,23<br />

X-Window, 600, 603<br />

x range funct 1d, 733<br />

XLD, 215, 221, 617, 619, 679, 853–861, 863, 865,<br />

867, 869, 871–876, 879–885, 887, 888,<br />

890–892<br />

XLD-Contours, 23, 25, 221, 617, 619, 853, 855–860,<br />

863, 865, 867, 869, 871–873, 875, 879–<br />

883, 885, 887, 888, 890–892<br />

XLD-contours, 679<br />

XLD-Parallels, 221, 617, 619, 854, 859, 861, 874,<br />

876, 884<br />

XLD-Polygons, 24, 25, 221, 617, 619, 853–855,<br />

860, 876, 883, 884, 890<br />

xor, 46<br />

y range funct 1d, 733<br />

Zero-Crossings, 548, 575, 576<br />

zero crossing, 575<br />

zero crossing sub pix, 576<br />

zoom image factor,31<br />

zoom image size,32<br />

zoom region, 453<br />

Zooming, 453<br />

<strong>HALCON</strong>/C <strong>Reference</strong> <strong>Manual</strong> / 2000-11-15


Index 913<br />

<strong>HALCON</strong> 6.0

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!