<p>It's quite difficult. There is so little contrast, even the JPEG compression artifacts have more contrast than the object on the background.</p>

<p>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.</p>

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

<hr>

<p>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.</p>

<p>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 <code>8*n</code> or <code>8n+1</code> X or Y is most likely just a compression artifact and can be ignored.</p>

<p>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.</p>

CC BY-SA 4.0
2019-02-25T20:16:53.660Z
2019-02-25T22:01:47.733Z
2019-02-25T22:01:47.733Z
Ext3h
<p>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. </p>

<p>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.</p>

<p>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.</p>

<p>Here's one of the tricky example:</p>

<p><a href="https://i.sstatic.net/Obe5E.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Obe5E.jpg" alt="Original cloth"></a>
<a href="https://i.sstatic.net/1cm5M.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/1cm5M.png" alt="Canny getting the contour of the cloth but noisy"></a>
<a href="https://i.sstatic.net/TzYzJ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TzYzJ.png" alt="Canny not getting enough contour of the cloth"></a></p>

<p>Simple growing region for background detection also doesn't work well enough.</p>

<p>So how do you detect the contour of an object if it has nearly the same color as the background?</p>

CC BY-SA 4.0
2019-02-25T19:23:16.840Z
the object is a texture with opacity? if so, just use Shobel with opacity as source value
Nadir
CC BY-SA 4.0
2019-02-26T04:15:34.257Z
Are many of these images the same? (Same camera angle) If the topology is roughly consistent it would be pretty easy to simply fill in the details on the latter image with some template. Wouldn't help much with the graphics on the tshirts though.
Andrew Wilson
<edge-detection>
Which method for detecting edges of white object on white background?
Nicolas Scotto Di Perto
# Which method for detecting edges of white object on white background?

(Asked by: username_0 on 2019-02-25)

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:

[![Original cloth](https://i.sstatic.net/Obe5E.jpg)](https://i.sstatic.net/Obe5E.jpg)
[![Canny getting the contour of the cloth but noisy](https://i.sstatic.net/1cm5M.png)](https://i.sstatic.net/1cm5M.png)
[![Canny not getting enough contour of the cloth](https://i.sstatic.net/TzYzJ.png)](https://i.sstatic.net/TzYzJ.png)

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?

**Tags:** edge-detection

> **Comments:**
> **username_1**: the object is a texture with opacity? if so, just use Shobel with opacity as source value  
> **username_2**: Are many of these images the same? (Same camera angle) If the topology is roughly consistent it would be pretty easy to simply fill in the details on the latter image with some template. Wouldn't help much with the graphics on the tshirts though.  

---

## 1 answers

### Answer by username_3 on 2019-02-25. Score: 4 | Accepted answer

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.


---

