public DifferencesExpansionConfiguraitonDialogBox(DifferencesExpansionConfiguration standardDEConfig,
                                                          DifferenceExpansionBruteForceConfiguration bruteForceDEConfig,
                                                          AlgorithmConfiguration currentConfiguration)
        {
            InitializeComponent();

            if (standardDEConfig != null)
            {
                this.threshold   = standardDEConfig.Threeshold;
                tbThreshold.Text = threshold.ToString();
                cbEmbeddingDirection.SelectedIndex = (int)standardDEConfig.EmbeddingDirection;
                cbR.IsChecked = standardDEConfig.EmbeddingChanels.Contains(EmbeddingChanel.R);
                cbG.IsChecked = standardDEConfig.EmbeddingChanels.Contains(EmbeddingChanel.G);
                cbB.IsChecked = standardDEConfig.EmbeddingChanels.Contains(EmbeddingChanel.B);
                ComboBoxItem standardComboBoxItem = new ComboBoxItem();
                standardComboBoxItem.Content    = "Standard";
                standardComboBoxItem.IsSelected = currentConfiguration is DifferencesExpansionConfiguration;
                cbConfigurationType.Items.Add(standardComboBoxItem);
            }

            if (bruteForceDEConfig != null)
            {
                cbHorizontal_BF.IsChecked = bruteForceDEConfig.EmbeddingDirections.Contains(Direction.Horizontal);
                cbVertical_BF.IsChecked   = bruteForceDEConfig.EmbeddingDirections.Contains(Direction.Vertical);
                cbR_BF.IsChecked          = bruteForceDEConfig.EmbeddingChanels.Contains(EmbeddingChanel.R);
                cbG_BF.IsChecked          = bruteForceDEConfig.EmbeddingChanels.Contains(EmbeddingChanel.G);
                cbB_BF.IsChecked          = bruteForceDEConfig.EmbeddingChanels.Contains(EmbeddingChanel.B);
                ComboBoxItem bruteForceItem = new ComboBoxItem();
                bruteForceItem.Content    = "Brute force";
                bruteForceItem.IsSelected = currentConfiguration is DifferenceExpansionBruteForceConfiguration;
                cbConfigurationType.Items.Add(bruteForceItem);
            }
        }
        public Tuple <Bitmap, string> Decode(Bitmap encodedImage, AlgorithmConfiguration configuration)
        {
            // Algorithm instances
            DifferencesExpansionAlgorithm de = new DifferencesExpansionAlgorithm();
            HistogramShiftingAlgorithm    hs = new HistogramShiftingAlgorithm();
            // Algorithm configs
            DifferenceExpansionBruteForceConfiguration deConfig = new DifferenceExpansionBruteForceConfiguration(
                new HashSet <EmbeddingChanel>()
            {
                EmbeddingChanel.R, EmbeddingChanel.G, EmbeddingChanel.B
            }, new HashSet <Direction>()
            {
                Direction.Horizontal, Direction.Vertical
            });
            HistogramShiftingConfiguration hsConfig = new HistogramShiftingConfiguration(true,
                                                                                         new HashSet <EmbeddingChanel>()
            {
                EmbeddingChanel.R, EmbeddingChanel.G, EmbeddingChanel.B
            });
            // Decoding
            var deResult = de.BruteforceDecode(encodedImage, deConfig);

            if (deResult != null)
            {
                return(deResult);
            }
            var hsResult = hs.Decode(encodedImage, hsConfig);

            if (hsResult != null)
            {
                return(hsResult);
            }
            return(null);
        }
        public Tuple <Bitmap, string> BruteforceDecode(Bitmap inputImage, DifferenceExpansionBruteForceConfiguration bruteForceConfiguration)
        {
            Bitmap        processedImage = inputImage;
            List <string> payloadChunks  = new List <string>();

            foreach (EmbeddingChanel embeddingChannel in Enum.GetValues(typeof(EmbeddingChanel)))
            {
                if (bruteForceConfiguration.EmbeddingChanels.Contains(embeddingChannel))
                {
                    // For each RGB channel specified in configuration algorithm tries to perform decoding
                    Tuple <Bitmap, string> imageAndPayload = TryDecodeImageForChannel(processedImage, embeddingChannel, bruteForceConfiguration);
                    if (isDecodingSuccessfull(imageAndPayload))
                    {
                        // If decoding was successfull then retrived chunk of payload from given channel is saved
                        // If there was no success next embedding channel is used
                        processedImage = imageAndPayload.Item1;
                        payloadChunks.Add(imageAndPayload.Item2);
                    }
                }
            }
            return(payloadChunks.Count > 0 ? new Tuple <Bitmap, string>(processedImage, String.Join("", payloadChunks)) : null);
        }
 private void BtnConfigDE_Click(object sender, RoutedEventArgs e)
 {
     if (isWatermarkingModeSelected())
     {
         DifferencesExpansionConfiguration config = (DifferencesExpansionConfiguration)standardEncodingDEConfig;
         var dialogBox = new ConfigurationDialogBox.DifferencesExpansionConfiguraitonDialogBox(config, null, activeEncodingDEConfig)
         {
             Owner = this,
         };
         dialogBox.ShowDialog();
         AlgorithmConfiguration newConfig = GetConfigurationBasedOnDialogBoxResult(dialogBox);
         if (newConfig != null)
         {
             standardEncodingDEConfig = newConfig;
             activeEncodingDEConfig   = standardEncodingDEConfig;
         }
     }
     if (isAnalyzingModeSelected())
     {
         DifferencesExpansionConfiguration          deConfig           = (DifferencesExpansionConfiguration)standardDecodingDEConfig;
         DifferenceExpansionBruteForceConfiguration deBruteForceConfig = (DifferenceExpansionBruteForceConfiguration)bruteForceDecodingDEConfig;
         var dialogBox = new ConfigurationDialogBox.DifferencesExpansionConfiguraitonDialogBox(deConfig, deBruteForceConfig, activeDecodingDEConfig)
         {
             Owner = this,
         };
         dialogBox.ShowDialog();
         AlgorithmConfiguration newConfig = GetConfigurationBasedOnDialogBoxResult(dialogBox);
         if (dialogBox.cbConfigurationType.Text == "Standard" && newConfig != null)
         {
             standardDecodingDEConfig = newConfig;
             activeDecodingDEConfig   = standardDecodingDEConfig;
         }
         else if (dialogBox.cbConfigurationType.Text == "Brute force" && newConfig != null)
         {
             bruteForceDecodingDEConfig = newConfig;
             activeDecodingDEConfig     = bruteForceDecodingDEConfig;
         }
     }
 }
 public Tuple <Bitmap, string> TryDecodeImageForChannel(Bitmap inputImage, EmbeddingChanel embeddingChanel, DifferenceExpansionBruteForceConfiguration bruteForceConfiguration)
 {
     foreach (Direction direction in Enum.GetValues(typeof(Direction)))
     {
         if (bruteForceConfiguration.EmbeddingDirections.Contains(direction))
         {
             // For given RGB channel algorith tries to decode payload with each embedding direction allowed in configuration
             Tuple <Bitmap, string> imageAndPayload = TryDecodeImageForDirectionAndChannel(inputImage, Direction.Horizontal, embeddingChanel);
             if (isDecodingSuccessfull(imageAndPayload))
             {
                 // If decoding with given embedding channel and direction was successfull then image and payload chunk is returned
                 // If there was no success other embedding direction for given channel is used
                 return(imageAndPayload);
             }
         }
     }
     return(null);
 }