边缘检测和透明度 [英] Edge Detection and transparency

查看:179
本文介绍了边缘检测和透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用针对一致的背景拍摄的服装的图片,我想让图片中的所有像素透明,除了服装。什么是最好的办法呢?我已经研究了常见的算法和开源库 opencv 。除了滚动我自己或使用opencv有一个简单的方法来做到这一点?

Using images of articles of clothing taken against a consistent background, I would like to make all pixels in the image transparent except for the clothing. What is the best way to go about this? I have researched the algorithms that are common for this and the open source library opencv. Aside from rolling my own or using opencv is there an easy way to do this? I am open to any language or platform.

感谢

推荐答案

如果你的背景是一个图像,但不一致的图像可能会变得棘手,但这里是我会做的:

If your background is consistend in an image but inconsistent across images it could get tricky, but here is what I would do:


  1. 分离图像变成某种强度/颜色形式,例如YUV或Lab。

  2. 在颜色部分上制作直方图。找到最发生的颜色,这是(最可能的)你的背景(更新)也许一个更好的技巧是找到从图像的边缘一个或两个像素内的所有像素的最发生的颜色。

  3. 从图片的边缘开始,将具有该颜色并通过该颜色的像素连接到边缘的所有像素设置为透明。

  4. 这件衣服的边缘现在看起来有点丑,因为它包括从背景和衣服获得他们的颜色的像素。要解决这个问题,你需要做更多的工作:

  1. Separate the image into some intensity/colour form such as YUV or Lab.
  2. Make a histogram over the colour part. Find the most occuring colour, this is (most likely) your background (update) maybe a better trick here would be to find the most occuring colour of all pixels within one or two pixels from the edge of the image.
  3. Starting from the eddges of the image, set all pixels that have that colour and are connected to the edge through pixels of that colour to transparent.
  4. The edge of the piece of clothing is now going to look a bit ugly because it consist of pixels that gain their colour from both the background and the piece of clothing. To combat this you need to do a bit more work:


  1. a href =http://en.wikipedia.org/wiki/Edge_detection =nofollow noreferrer>边缘检测机制。

  2. 更换边缘的颜色像素与混合的颜色只是内部的边缘像素(即该地区的服装的颜色)和透明(如果您的输出图像格式支持)。

  3. 如果你想要得到真正的幻想,你增加透明度取决于背景颜色的像素的颜色多少像的颜色。

  1. Find the edge of the piece of clothing through some edge detection mechanism.
  2. Replace the colour of the edge pixels with a blend of the colour just "inside" the edge pixel (i.e. the colour of the clothing in that region) and transparent (if your output image format supports that).
  3. If you want to get really fancy, you increase the transparency depending on how much "like" the background colour the colour of that pixel is.


这篇关于边缘检测和透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆