Esempio n. 1
0
        private void usersDisplay(string imagePath)
        {
            if (verticalSeamsText.Text.Equals(""))
            {
                verticalSeamsText.Text = "1";
            }
            if (horizontalSeamsText.Text.Equals(""))
            {
                horizontalSeamsText.Text = "1";
            }
            int numOfVerticalSeams   = int.Parse(verticalSeamsText.Text);
            int numOfHorizontalSeams = int.Parse(horizontalSeamsText.Text);

            ImageAwareResize IAR = new ImageAwareResize(imagePath);

            ImageUtils.DisplayImage(IAR.imageMatrix, originalPictureBox);
            int Width  = IAR.imageMatrix.GetLength(1);
            int Height = IAR.imageMatrix.GetLength(0);

            if (columnsWork)
            {
                Pixel[,] ResizedMatrix = ImageUtils.NormalResize(IAR.imageMatrix, Width - numOfVerticalSeams, Height);
                ImageUtils.DisplayImage(ResizedMatrix, resultedPictureBox);
                IAR.removeColumns(numOfVerticalSeams);
            }
            else
            {
                Pixel[,] ResizedMatrix = ImageUtils.NormalResize(IAR.imageMatrix, Width, Height - numOfHorizontalSeams);
                ImageUtils.DisplayImage(ResizedMatrix, resultedPictureBox);
                IAR.removeRows(numOfVerticalSeams);
            }
            resizeCurrentButton.Visible = true;
        }
Esempio n. 2
0
        private void developersDisplay(string imagePath)
        {
            if (verticalSeamsText.Text.Equals(""))
            {
                verticalSeamsText.Text = "1";
            }
            if (horizontalSeamsText.Text.Equals(""))
            {
                horizontalSeamsText.Text = "1";
            }
            int numOfVerticalSeams   = int.Parse(verticalSeamsText.Text);
            int numOfHorizontalSeams = int.Parse(horizontalSeamsText.Text);
            ImageAwareResize IAR     = new ImageAwareResize(imagePath);

            ImageUtils.DisplayImage(IAR.imageMatrix, originalPictureBox);

            // The seams with the original image
            int Width  = IAR.imageMatrix.GetLength(1);
            int Height = IAR.imageMatrix.GetLength(0);

            if (columnsWork)
            {
                IAR.calculateVertIndexMat(numOfVerticalSeams);
                ImageUtils.DisplayEnergy(IAR.vertIndexMat, resultedPictureBox);
                for (int i = 0; i < Height; i++)
                {
                    for (int j = 0; j < Width; j++)
                    {
                        if (IAR.vertIndexMat[i, j] != int.MaxValue)
                        {
                            IAR.imageMatrix[i, j].R = 0;
                            IAR.imageMatrix[i, j].G = 0;
                            IAR.imageMatrix[i, j].B = 0;
                        }
                    }
                }
            }
            else
            {
                IAR.calculateHorzIndexMat(numOfHorizontalSeams);
                ImageUtils.DisplayEnergy(IAR.horzIndexMat, resultedPictureBox);
                for (int i = 0; i < Height; i++)
                {
                    for (int j = 0; j < Width; j++)
                    {
                        if (IAR.horzIndexMat[i, j] != int.MaxValue)
                        {
                            IAR.imageMatrix[i, j].R = 0;
                            IAR.imageMatrix[i, j].G = 0;
                            IAR.imageMatrix[i, j].B = 0;
                        }
                    }
                }
            }

            ImageUtils.DisplayImage(IAR.imageMatrix, originalPictureBox);
        }