public void Normalize() { if (Normalized) { return; } Bitmap colorImage = (Bitmap)GetBitmap().Clone(); Image = ThresholdedImage; PixelMap pixelMap = GetPixelMap(); _bestPiece = pixelMap.GetBestPiece(); colorImage = GetBestPieceInFullColor(colorImage, _bestPiece); ComputeStatisticBrightness(colorImage); ComputeStatisticContrast(colorImage); ComputeStatisticHue(colorImage); ComputeStatisticSaturation(colorImage); Image = _bestPiece.Render() ?? new Bitmap(1, 1, PixelFormat.Format8bppIndexed); PieceWidth = GetWidth(); PieceHeight = GetHeight(); NormalizeResizeOnly(); Normalized = true; }
private Bitmap GetBestPieceInFullColor(Bitmap colorImage, PixelMap.Piece piece) { if (piece.Width <= 0 || piece.Height <= 0) { return(colorImage); } return(colorImage.Clone(new Rectangle( piece.mostLeftPoint, piece.mostTopPoint, piece.Width, piece.Height), PixelFormat.Format8bppIndexed)); }