public AutoConfigureImgPointsParams() { MinPixelsForBaseDisc = 10; MinPixelsForBaseDiscEndOfEdge = 10; ResizeWidth = 500; ResizeHeight = 500; MarkerProcessingParams = new MarkerProcessingParams(); }
/// <summary> /// Gets the list of marker positions that satisfy the supplied conditions /// </summary> /// <param name="colorVariations"></param> /// <param name="params"></param> /// <param name="extraLeftPixels"></param> /// <returns></returns> public static List <double> GetAllMarkerPositions(List <double> colorVariations, MarkerProcessingParams @params, int extraLeftPixels) { var maxMarkerWidth = colorVariations.Count * @params.MarkerWidthPercent / 100.0; var validPositions = GetValidPositions(colorVariations, @params.MarkerColorVariationPercent, maxMarkerWidth); var positions = new List <double>(); for (var ctr = 0; ctr < validPositions.Count; ctr++) { var endValidPositionIndex = GetEndValidIndex(ctr, validPositions, maxMarkerWidth); if (endValidPositionIndex != null) { var startValidPosition = validPositions[ctr]; var endValidPosition = validPositions[endValidPositionIndex.Value]; var position = GetMiddlePosition(startValidPosition, endValidPosition); positions.Add(extraLeftPixels + position); //move the counter forward to avoid repetition ctr = endValidPositionIndex.Value; } } return(positions); }
/// <summary> /// returns the first markers to the left and right of the center of disc /// </summary> /// <param name="image"></param> /// <param name="discLeftEdgeX"></param> /// <param name="discRightEdgeX"></param> /// <param name="y"></param> /// <param name="params"></param> /// <returns></returns> public static List <double> GetLeftAndRightMarkerPositions(Bitmap image, int discLeftEdgeX, int discRightEdgeX, int y, MarkerProcessingParams @params) { var colorVariations = ColorVariationCalculator.GetColorVariationList(image, discLeftEdgeX, discRightEdgeX, y); var markerPositions = GetAllMarkerPositions(colorVariations, @params, discLeftEdgeX); var center = GetMiddlePosition(discLeftEdgeX, discRightEdgeX); for (var index = 0; index < markerPositions.Count; index++) { var potentialRightMarkerPosition = markerPositions[index]; if (potentialRightMarkerPosition >= center) { if (index > 0) { var leftMarkerPosition = markerPositions[index - 1]; return(new List <double> { leftMarkerPosition, potentialRightMarkerPosition }); } //left index could not be found. break and return null break; } } return(null); }