D
D
daydiff2013-05-31 21:22:17
Algorithms
daydiff, 2013-05-31 21:22:17

Removing white background from the edges of an image

Dear habravchan!

There is a photograph of the item, on a white background. You need to remove the white background around the subject, but do not touch the white pixels inside it. Tell me the processing algorithm, the relevant literature or in which direction to dig (in the direction of image processing, obviously, I would like to know a more accurate direction).

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexey Akulovich, 2013-05-31
@daydiff

Yes, even a wave filling algorithm with an error (if not a pure white background) from any corner of the image.

D
DancingOnWater, 2013-05-31
@DancingOnWater

If the object has all border pixels other than white, then everything is simple: select all non-white pixels, define them as border pixels from the bottom, and then delete all pixels to the border.
But if the border pixels can be white, then only the shape of the object will help us.

T
Turansky, 2013-05-31
@Turansky

We walk along the perimeter, if the pixel is white, then delete it and check the neighboring pixels (usually there are 8 of them, in the case of extreme pixels 5, for corner 3)
For newly checked pixels, we again organize a check of neighboring pixels.
ActionScript has a threshold function for clipping a single-color area , but its functionality is not limited to this. Perhaps other languages ​​have similar features.

S
SergeyGrigorev, 2013-06-01
@SergeyGrigorev

If the white background is the shape of a rectangle inside which the image fits, then you can calculate the dimensions of the white background in 3 places (middle of the image -> check the lines up and down, and also left and right), then 25% higher (left) and 25 % below (to the right) this middle (to get rid of the error that there may be a white part of the image in the middle). If the dimensions match there, then the faces are found. But if the size of the white line is smaller above or below, then we take that very short part for the middle and again take 25% above and 25% below this “middle”.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question