/** * Computes a score based on the match between a template profile and the * particle profile in the X direction. This method uses the the column * averages and the profile defined at the top of the sample to look for the * solid vertical edges with a hollow center. * * @param image The image to use, should be the image before the convex hull * is performed * @param report The Particle Analysis Report for the particle * * @return The X Edge Score (0-100) */ public static double scoreXEdge(BinaryImage image, ParticleAnalysisReport report) throws NIVisionException { double total = 0; LinearAverages averages; NIVision.Rect rect = new NIVision.Rect(report.boundingRectTop, report.boundingRectLeft, report.boundingRectHeight, report.boundingRectWidth); averages = NIVision.getLinearAverages(image.image, LinearAverages.LinearAveragesMode.IMAQ_COLUMN_AVERAGES, rect); float columnAverages[] = averages.getColumnAverages(); for (int i = 0; i < (columnAverages.length); i++) { if (xMin[(i * (XMINSIZE - 1) / columnAverages.length)] < columnAverages[i] && columnAverages[i] < xMax[i * (XMAXSIZE - 1) / columnAverages.length]) { total++; } } total = 100 * total / (columnAverages.length); return total; }
/** * Computes a score based on the match between a template profile and the * particle profile in the Y direction. This method uses the the row * averages and the profile defined at the top of the sample to look for the * solid horizontal edges with a hollow center * * @param image The image to use, should be the image before the convex hull * is performed * @param report The Particle Analysis Report for the particle * * @return The Y Edge score (0-100) * */ public static double scoreYEdge(BinaryImage image, ParticleAnalysisReport report) throws NIVisionException { double total = 0; LinearAverages averages; NIVision.Rect rect = new NIVision.Rect(report.boundingRectTop, report.boundingRectLeft, report.boundingRectHeight, report.boundingRectWidth); averages = NIVision.getLinearAverages(image.image, LinearAverages.LinearAveragesMode.IMAQ_ROW_AVERAGES, rect); float rowAverages[] = averages.getRowAverages(); for (int i = 0; i < (rowAverages.length); i++) { if (yMin[(i * (YMINSIZE - 1) / rowAverages.length)] < rowAverages[i] && rowAverages[i] < yMax[i * (YMAXSIZE - 1) / rowAverages.length]) { total++; } } total = 100 * total / (rowAverages.length); return total; }
/** * Computes a score based on the match between a template profile and the particle profile in the X direction. This method uses the * the column averages and the profile defined at the top of the sample to look for the solid vertical edges with * a hollow center. * * @param image The image to use, should be the image before the convex hull is performed * @param report The Particle Analysis Report for the particle * * @return The X Edge Score (0-100) */ public double scoreXEdge(BinaryImage image, ParticleAnalysisReport report) throws NIVisionException { double total = 0; LinearAverages averages; NIVision.Rect rect = new NIVision.Rect(report.boundingRectTop, report.boundingRectLeft, report.boundingRectHeight, report.boundingRectWidth); averages = NIVision.getLinearAverages(image.image, LinearAverages.LinearAveragesMode.IMAQ_COLUMN_AVERAGES, rect); float columnAverages[] = averages.getColumnAverages(); for(int i=0; i < (columnAverages.length); i++){ if(xMin[(i*(XMINSIZE-1)/columnAverages.length)] < columnAverages[i] && columnAverages[i] < xMax[i*(XMAXSIZE-1)/columnAverages.length]){ total++; } } total = 100*total/(columnAverages.length); return total; }
/** * Computes a score based on the match between a template profile and the particle profile in the Y direction. This method uses the * the row averages and the profile defined at the top of the sample to look for the solid horizontal edges with * a hollow center * * @param image The image to use, should be the image before the convex hull is performed * @param report The Particle Analysis Report for the particle * * @return The Y Edge score (0-100) * */ public double scoreYEdge(BinaryImage image, ParticleAnalysisReport report) throws NIVisionException { double total = 0; LinearAverages averages; NIVision.Rect rect = new NIVision.Rect(report.boundingRectTop, report.boundingRectLeft, report.boundingRectHeight, report.boundingRectWidth); averages = NIVision.getLinearAverages(image.image, LinearAverages.LinearAveragesMode.IMAQ_ROW_AVERAGES, rect); float rowAverages[] = averages.getRowAverages(); for(int i=0; i < (rowAverages.length); i++){ if(yMin[(i*(YMINSIZE-1)/rowAverages.length)] < rowAverages[i] && rowAverages[i] < yMax[i*(YMAXSIZE-1)/rowAverages.length]){ total++; } } total = 100*total/(rowAverages.length); return total; }