public static ImageMatrices GetImageMatricesFromQuantizedErrorMatrix(int[,] quantizedErrors, NearLosslessOptions nearLosslessOptions)
        {
            var predictor     = NearLosslessPredictorSelector.GetPredictor(nearLosslessOptions.PredictorType);
            var imageMatrices = new ImageMatrices(quantizedErrors.GetLength(0), quantizedErrors.GetLength(1));

            CopyMatrix(quantizedErrors, imageMatrices.QuantizedErrors);

            HandleFirstPixel(imageMatrices, nearLosslessOptions);
            HandleFirstColumn(imageMatrices, nearLosslessOptions, predictor);
            HandleFirstRow(imageMatrices, nearLosslessOptions, predictor);

            for (var row = 1; row < imageMatrices.Width; row++)
            {
                for (var column = 1; column < imageMatrices.Height; column++)
                {
                    var a = imageMatrices.Decoded[row - 1, column];
                    var b = imageMatrices.Decoded[row, column - 1];
                    var c = imageMatrices.Decoded[row - 1, column - 1];

                    var prediction = predictor.PredictValue(nearLosslessOptions.PredictionLowerLimit, nearLosslessOptions.PredictionUpperLimit, a, b, c);

                    HandlePrediction(imageMatrices, nearLosslessOptions, row, column, prediction);
                }
            }

            return(imageMatrices);
        }
Beispiel #2
0
        public static void SetImageMatrices(ImageMatrices imageMatrices, NearLosslessOptions nearLosslessOptions)
        {
            var predictor = NearLosslessPredictorSelector.GetPredictor(nearLosslessOptions.PredictorType);

            HandleFirstPixel(imageMatrices, nearLosslessOptions);
            HandleFirstColumn(imageMatrices, nearLosslessOptions, predictor);
            HandleFirstRow(imageMatrices, nearLosslessOptions, predictor);

            for (var row = 1; row < imageMatrices.Width; row++)
            {
                for (var column = 1; column < imageMatrices.Height; column++)
                {
                    var a = imageMatrices.Decoded[row - 1, column];
                    var b = imageMatrices.Decoded[row, column - 1];
                    var c = imageMatrices.Decoded[row - 1, column - 1];

                    var prediction = predictor.PredictValue(nearLosslessOptions.PredictionLowerLimit, nearLosslessOptions.PredictionUpperLimit, a, b, c);

                    HandlePrediction(imageMatrices, nearLosslessOptions, row, column, prediction);
                }
            }
        }