U
U
Username2015-11-29 15:06:59
Programming
Username, 2015-11-29 15:06:59

How to remove stripe from pixels in bitmap?

Good afternoon. I write Seam Carving and everything is ready except for one thing, how to remove pixels and display this change on the pictureBox and eventually save.
There is an EnergyMat matrix, a dist (distance) sum matrix, and an array of the shortest path way.
If we reduce the image by n pixels, then in the loop we shift all subsequent pixels to the left from the current position.

for (int i = 0; i < height; i++)
            {
                for (int j = way[i]; j < width; j++)
                {
                    EnergyMat[i, j] = EnergyMat[i, j + 1];
                    dist[i, j] = dist[i, j + 1];
                    width--;
                }
            }

1. How to remove pixels from a bitmap and display in a pictureBox?
2. How to truncate the dist and EnergyMat matrices? width-- I think it will not work here
P. s. I'm cropping the image to fit.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Evseev, 2015-12-04
@alex1t

1. Either redraw the Bitmap in the old sizes, but simply paint over the unwanted pixels with the background, or create a new Bitmap of the required sizes and reassign it to PictureBox.Image
2. You can crop only by recreating new ones and copying the values, but this will be expensive. Probably easier width--

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question