private void ComputeFilteredImage()
        {
            FilteredImage image = (FilteredImage)PreviousLayer.GetData();

            FilteredImageChannel[] newChannels = new FilteredImageChannel[image.NumberOfChannels];
            int size = image.Size;

            for (int i = 0; i < image.NumberOfChannels; i++)
            {
                double[,] newValues = new double[size, size];

                for (int valuesI = 0; valuesI < size; valuesI++)
                {
                    for (int valuesJ = 0; valuesJ < size; valuesJ++)
                    {
                        if (GlobalRandom.GetRandomDouble() < Rate)
                        {
                            newValues[valuesI, valuesJ] = 0;
                        }
                        else
                        {
                            newValues[valuesI, valuesJ] = image.Channels[i].Values[valuesI, valuesJ];
                        }
                    }
                }

                newChannels[i] = new FilteredImageChannel(size, newValues);
            }

            Output = new FilteredImage(image.NumberOfChannels, newChannels);
        }
 private void InitializeOutput()
 {
     if (Output == null)
     {
         LayerOutput previousData = PreviousLayer.GetData();
         if (previousData is FlattenedImage)
         {
             FlattenedImage previous = (FlattenedImage)previousData;
             Output = new FlattenedImage(previous.Size);
         }
         else
         {
             FilteredImage previous = (FilteredImage)previousData;
             Output = new FilteredImage(previous.NumberOfChannels, previous.Size);
         }
     }
 }
        private void ComputeFlattenedImage()
        {
            FlattenedImage previous = (FlattenedImage)PreviousLayer.GetData();

            double[] newValues = new double[previous.Size];

            for (int i = 0; i < previous.Size; i++)
            {
                if (GlobalRandom.GetRandomDouble() < Rate)
                {
                    newValues[i] = 0;
                }
                else
                {
                    newValues[i] = previous.Values[i];
                }
            }

            Output = new FlattenedImage(previous.Size, newValues);
        }