//delegate method for sorting triplets based on correlation private static int CompareTriplet(PointMatchTriplet p1, PointMatchTriplet p2) { if (p2.correlation > p1.correlation) { return(1); } else if (p2.correlation < p1.correlation) { return(-1); } else { return(0); } }
public static void ScanImage(bool[,] sampleMaskArray, int sampleMaskWidth, int sampleMaskHeight, int sampleXCenter, int sampleYCenter, PointMatchSettings settings, int[,] imageArray, int imageWidth, int imageHeight, List <PointMatchTriplet> pointsCreated) { // loop through image to first on-pixel for (int x = 0; x < imageWidth; x++) { for (int y = 0; y < imageHeight; y++) { bool firstMax = true; int onCount = 0, xSum = 0, ySum = 0; int xMin = imageWidth, xMax = 0; int yMin = imageHeight, yMax = 0; double correlationMax = 0.0; RecurseThroughOnRegion(sampleMaskArray, sampleMaskWidth, sampleMaskHeight, sampleXCenter, sampleYCenter, imageArray, imageWidth, imageHeight, x, y, ref firstMax, ref onCount, ref xSum, ref ySum, ref xMin, ref xMax, ref yMin, ref yMax, ref correlationMax); // save max if its correlation is positive and the point is not too big. a zero // correlation is would be expected from two uncorrelated sets of pixels, and // a negative correlation means the sets of pixels are inverses if (!firstMax && (correlationMax > 0) && (xMax - xMin < settings.pointSize) && (yMax - yMin < settings.pointSize)) { PointMatchTriplet p = new PointMatchTriplet(); if (onCount < 0) { onCount = 1; } p.x = (int)((double)xSum / (double)onCount + 0.5); p.y = (int)((double)ySum / (double)onCount + 0.5); p.correlation = correlationMax; pointsCreated.Add(p); } } } }
public static void ScanImage(bool[,] sampleMaskArray, int sampleMaskWidth, int sampleMaskHeight, int sampleXCenter, int sampleYCenter, PointMatchSettings settings, int[,] imageArray, int imageWidth, int imageHeight, List<PointMatchTriplet> pointsCreated) { // loop through image to first on-pixel for (int x = 0; x < imageWidth; x++) { for (int y = 0; y < imageHeight; y++) { bool firstMax = true; int onCount = 0, xSum = 0, ySum = 0; int xMin = imageWidth, xMax = 0; int yMin = imageHeight, yMax = 0; double correlationMax = 0.0; RecurseThroughOnRegion(sampleMaskArray, sampleMaskWidth, sampleMaskHeight, sampleXCenter, sampleYCenter, imageArray, imageWidth, imageHeight, x, y, ref firstMax, ref onCount, ref xSum, ref ySum, ref xMin, ref xMax, ref yMin, ref yMax, ref correlationMax); // save max if its correlation is positive and the point is not too big. a zero // correlation is would be expected from two uncorrelated sets of pixels, and // a negative correlation means the sets of pixels are inverses if (!firstMax && (correlationMax > 0) && (xMax - xMin < settings.pointSize) && (yMax - yMin < settings.pointSize)) { PointMatchTriplet p = new PointMatchTriplet(); if (onCount < 0) onCount = 1; p.x = (int)((double)xSum / (double)onCount + 0.5); p.y = (int)((double)ySum / (double)onCount + 0.5); p.correlation = correlationMax; pointsCreated.Add(p); } } } }
//delegate method for sorting triplets based on correlation private static int CompareTriplet(PointMatchTriplet p1, PointMatchTriplet p2) { if (p2.correlation > p1.correlation) return 1; else if (p2.correlation < p1.correlation) return -1; else return 0; }