private void buttonDecode_Click(object sender, EventArgs e)
        {
            using (var encodedImageReader = new EncodedImageReader())
            {
                encodedImage = encodedImageReader.ReadEncodedImage(encodedFilePath);
            }

            decodedImage  = Decoder.GetDecodedImage(encodedImage);
            decodedBitmap = Decoder.Decode(encodedImage);

            predictorSettings = decodedImage.PredictorSettings;
            UpdateUiFromSettings();

            lastOperationWasEncode = false;
            this.decodedImagePanel.BackgroundImage           = decodedBitmap;
            this.toolStripStatusLabel.Text                   = "Image decoded.";
            this.groupBoxHistogram.Enabled                   = true;
            this.buttonSaveDecoded.Enabled                   = true;
            this.radioButtonQuantizedErrorPrediction.Enabled = true;
            this.radioButtonErrorPrediction.Enabled          = true;
            this.radioButtonDecoded.Enabled                  = true;

            RefreshErrorImage();
            RefreshHistogram();
        }
Esempio n. 2
0
 public PredictorProxyService(
     IHttpClientFactory httpClientFactory,
     IOptions <PredictorSettings> options)
 {
     _httpClientFactory = httpClientFactory;
     _settings          = options.Value;
 }
        public static EncodedImage Encode(Bitmap image, PredictorSettings predictorSettings)
        {
            var originalImageMatrix = ImageMapper.GetPixelMatrixFromImage(image);

            var predictionAlgorithm = new PredictionAlgorithm(originalImageMatrix, predictorSettings);

            return(predictionAlgorithm.GetEncodedImage());
        }
        public void Setup()
        {
            var predictorSettings = new PredictorSettings
            {
                Predictor     = predictor,
                AcceptedError = acceptedError,
                Range         = range
            };

            predictionAlgorithm = new PredictionAlgorithm(originalMatrix, predictorSettings);
        }
        private void SetDefaultPredictorSettings()
        {
            ((RadioButton)groupBoxPredictors.Controls[0]).Checked = true;

            predictorSettings = new PredictorSettings
            {
                Predictor     = predictors[0],
                AcceptedError = Convert.ToInt32(KValue.Value),
                Range         = 256
            };

            UpdateSaveMode();
        }
        public PredictionAlgorithm(int[,] original, PredictorSettings predictorSettings) : base(predictorSettings)
        {
            this.original = original;

            width  = original.GetLength(1);
            height = original.GetLength(0);

            prediction                          = new int[height, width];
            errorPrediction                     = new int[height, width];
            quantizedErrorPrediction            = new int[height, width];
            dequantizedQuantizedErrorPrediction = new int[height, width];
            predictionFromDecoded               = new int[height, width];
            decoded = new int[height, width];
        }
Esempio n. 7
0
        public void Setup()
        {
            var predictorSettings = new PredictorSettings
            {
                Predictor     = predictor,
                AcceptedError = acceptedError,
                Range         = range
            };

            var encodedImage = new EncodedImage
            {
                PredictorSettings = predictorSettings,
                QuantizedErrorPredictionMatrix = quantizedErrorPredictionMatrix
            };

            inversePredictionAlgorithm = new InversePredictionAlgorithm(encodedImage);
        }
Esempio n. 8
0
        public void Setup()
        {
            predictorMock            = new Mock <IPredictor>();
            firstRowPredictorMock    = new Mock <IPredictor>();
            firstColumnPredictorMock = new Mock <IPredictor>();

            var predictorSettings = new PredictorSettings
            {
                Predictor     = predictorMock.Object,
                AcceptedError = acceptedError,
                Range         = range
            };

            basePredictionAlgorithm = new BasePredictionAlgorithm(predictorSettings)
            {
                firstRowPredictor    = firstRowPredictorMock.Object,
                firstColumnPredictor = firstColumnPredictorMock.Object
            };
        }
Esempio n. 9
0
 public string GetEncodedFileExtension(PredictorSettings predictorSettings, SaveMode saveMode)
 {
     return($"k{predictorSettings.AcceptedError}p{predictorSettings.Predictor.Code}{saveMode.ToString()}.nlp");
 }
Esempio n. 10
0
 public string GetOutputPath(string originalImagePath, PredictorSettings predictorSettings, SaveMode saveMode)
 {
     return($"{originalImagePath}.{GetEncodedFileExtension(predictorSettings, saveMode)}");
 }
Esempio n. 11
0
 public void WritePredictorSettings(PredictorSettings predictorSettings, SaveMode saveMode)
 {
     bitWriter.WriteNBits(4, (uint)predictorSettings.Predictor.Code);
     bitWriter.WriteNBits(4, (uint)predictorSettings.AcceptedError);
     bitWriter.WriteNBits(3, (uint)Array.IndexOf(Enum.GetValues(typeof(SaveMode)), saveMode));
 }
 public BasePredictionAlgorithm(PredictorSettings predictorSettings)
 {
     this.predictorSettings = predictorSettings;
 }