Ejemplo n.º 1
0
        public static void SortHorizontalsBelowThreshold(PixelWrapper Image, byte threshold)
        {
            List <Pixel> Unsorted = Image.GetPixels();

            Pixel[] Sorted = Unsorted.ToArray();

            for (int y = 0; y < Image.Height; y++)
            {
                List <Pixel> Row = new List <Pixel>();

                // NextOverThreshold returns -1 if no matching pixel is found
                // so set 'end' index to the first thresholded pixel if it's not -1,
                // otherwise set it to the end of the row (Image.Width)
                int i   = NextOverThreshold(Unsorted, (y * Image.Width), (y * Image.Width) + Image.Width, threshold);
                int end = (i >= 0) ? (i - (y * Image.Width)) : Image.Width;

                // Split out vertical column
                for (int x = 0; x < end; x++)
                {
                    Row.Add(Unsorted[(y * Image.Width) + x]);
                }
                Row.Sort();

                // Reconstruct
                for (int x = 0; x < Row.Count; x++)
                {
                    Sorted[(y * Image.Width) + x] = Row[x];
                }
            }

            Image.SetPixels(Sorted.ToList());
        }
Ejemplo n.º 2
0
        public static void SortWhole(PixelWrapper Image)
        {
            List <Pixel> Sorted = Image.GetPixels();

            Sorted.Sort();

            Image.SetPixels(Sorted);
        }
Ejemplo n.º 3
0
        private void openButton_Click(object sender, EventArgs e)
        {
            DialogResult result = openImageDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                ImagePath = previewBox.ImageLocation = openImageDialog.FileName;
                Image     = new PixelWrapper(ImagePath);

                previewBox.Update();
            }
        }
Ejemplo n.º 4
0
        private void resetButton_Click(object sender, EventArgs e)
        {
            if (Image == null)
            {
                return;
            }

            Image = new PixelWrapper(ImagePath);
            previewBox.ImageLocation = ImagePath;
            previewBox.Update();

            progressBar.Value = 0;
        }