Which method for detecting edges of white object on white background? I would like to segment picture of cloths in order to remove the background. The pictures come from online retailers, they usually have an homogeneous white background. 

Using Canny edge detector works in most of the cases, but sometimes the cloths are nearly as white as the background making the edges hard to detect.

I tried to play with the min and max parameters in opencv (python), but I can't recover the clean edge, either I do not get the surrounding of the cloths (holes in the reigion) or the the edge is noisy around the cloth.

Here's one of the tricky example:





Simple growing region for background detection also doesn't work well enough.

So how do you detect the contour of an object if it has nearly the same color as the background?
It's quite difficult. There is so little contrast, even the JPEG compression artifacts have more contrast than the object on the background.

You would require a highly specialized deblock filter to eliminate the compression artifacts first. With knowledge about the block size of the used compression algorithm and the number of coefficients used per block you may be able to predict some of the edges.

For edges you could predict in the previous step, you may try to filter these from the detected edges.



All around the shirt in the photo, there are over-swings due to an excessively  lossy compression. At the edge of each block, the over-swings form a hard edge which you also successfully detected.

The block size is 8x8 pixels for JPEG (and hence also in this image), so every vertical or horizontal edge which falls directly onto position 8*n or 8n+1 X or Y is most likely just a compression artifact and can be ignored.

This approach can only work though if the image hasn't been re-sampled after compression, respectively hasn't been re-compressed multiple times with potentially different block sizes. At that point, isolating the compression artifacts becomes nearly impossible.