18 Appendiks 18.9 Implementering 18.9.11.2 calculateCenterOfMass() Der lavet to udgaver <strong>af</strong> denne funktion. Dette er gjort, for at massemidtpunktsudregningen kan <strong>brug</strong>es flere steder selvom det, det ene sted er et dobbeltarray <strong>af</strong> koordinater, <strong>og</strong> det andet sted er et grayScale-objekt der arbejdes med: Coordinates Utilities::calculateCenterOfMass(unsigned char **ppBlob, int ySize, int xSize, int numberOfPixels) { Coordinates CM; CM = calculateCM(ppBlob, ySize, xSize, numberOfPixels); return CM; } Coordinates Utilities::calculateCenterOfMass(GrayScale &grayScale, int numberOfPixels) { Coordinates CM; unsigned char **ppBlob = grayScale.getPointer(); int xSize = grayScale.getWidth(); int ySize = grayScale.getHeight(); } CM = calculateCM(ppBlob, ySize, xSize, numberOfPixels); return CM; 18.9.11.3 calculateCM() calculateCM() er funktionen, der foretager den reelle massemidtpunktsudregning. Funktionen består <strong>af</strong> to for-løkker der traverserer alle x- <strong>og</strong> y-koordinater igennem <strong>og</strong> summerer deres værdier op. Når begge løkker er færdige, deles der med antallet <strong>af</strong> pixels for at få den gennemsnitlige x- <strong>og</strong> yværdi. Disse to værdier er koordinatsættet for massemidtpunktet: Coordinates Utilities::calculateCM(unsigned char **ppBlob, int ySize, int xSize, int numberOfPixels) { int i=0; float centerOfMassX = 0, centerOfMassY=0; } for(int y=0; y
18 Appendiks 18.10 Test <strong>af</strong> Binary 18.10 Test <strong>af</strong> Binary Her følger testdataene fra testen <strong>af</strong> Binary-klassen (7.3 Test s. 26): Billede Forgrund Baggrund Threshold Genereret hist<strong>og</strong>ram blandet1 173,413 19,4556 96 159,905 17,4753 89 157,364 17,1948 87 156,585 17,1149 87 blandet2 191,585 18,3187 105 182,818 17,3078 100 180,957 17,1288 99 180,61 17,0968 99 blandet3 198,586 19,5937 109 191,694 18,735 105 190,213 18,5756 104 189,832 18,536 104 Side 124 <strong>af</strong> 131