public Image2DMatrix GetImageMatrix() { Image2DMatrix sourceMatrix = _imageLoader.GetImageMatrix(); if (Quadrilateral != null) { //Bilinear transformations have 8 Parameter. These parameter can be obtained //by solving two linear equation systems. This will be done in the following. Quadrilateral targetQuadrilateral = GetTargetQuadrilateral(); Matrix <double> m = GetmMatrix(); Vector <double> a = GetaVector(targetQuadrilateral, m); Vector <double> b = GetbVector(targetQuadrilateral, m); double a0 = a[0]; double a1 = a[1]; double a2 = a[2]; double a3 = a[3]; double b0 = b[0]; double b1 = b[1]; double b2 = b[2]; double b3 = b[3]; return(Image2DMatrix.Transform(sourceMatrix, (x, y) => { x = (int)(a0 * x + a1 * y + a2 * x * y + a3); y = (int)(b0 * x + b1 * y + b2 * x * y + b3); return (x, y); })); } return(sourceMatrix); }
public Image2DMatrix GetImageMatrix() { MatrixChanged = false; Image2DMatrix sourceMatrix = _imageLoader.GetImageMatrix(); if (OperationShouldBeExecuted()) { if (MatrixMustBeUpdated()) { MatrixChanged = true; _lastDx = Dx; _lastDy = Dy; TransformationMatrix shiftingMatrix = TransformationMatrix.UnitMatrix3x3.Shift2D(Dx, Dy); _cashedMatrix = Image2DMatrix.Transform(sourceMatrix, new Image2DMatrix(sourceMatrix.Height, sourceMatrix.Width, sourceMatrix.BytePerPixel), shiftingMatrix); } return(_cashedMatrix); } else { MatrixChanged = true; _lastDx = Dx; _lastDy = Dy; return(sourceMatrix); } }
/// <summary> /// Executes the image loading stack and applies transformations. /// Finally, the image matrix will be converted to a bitmap image. /// </summary> /// <returns></returns> public WriteableBitmap Build() { SetImageLoader(); Image2DMatrix imageMatrix = _imageLoader.GetImageMatrix(); TransformationMatrix transformationMatrix = GetTransformationMatrix(imageMatrix); imageMatrix = ApplyTransformationMatrix(imageMatrix, transformationMatrix); return(MatrixToBitmapImageConverter.GetImage(imageMatrix)); }
public Image2DMatrix GetImageMatrix() { MatrixChanged = false; Image2DMatrix sourceMatrix = _imageLoader.GetImageMatrix(); if (UseCustomBrightness) { AdjustBrightness(sourceMatrix, BrightnessFactor); } else { AdjustBrightness(sourceMatrix, MetaFileBrightnessFactor); } return(_cashedMatrix); }