我遇到这种情况,我很难在谷歌上搜索并解释。
我们公司在铝上打印照片,我们给我们的客户两个选择。
我知道在织物JS中有这个removeWhite过滤器,它可以用透明的区域代替白色的区域。但这不是我需要的。我需要一个Fabric过滤器,ImageMagick的东西或任何其他的PHP或JS解决方案,可以使像素的“白色值”透明。我知道对你们来说这东西听起来很模糊,但让我来解释一下:
下面是我试图实现的过滤器/效果的前后示例:
在此之前:

之后:

如果你不明白我要什么,请不要犹豫。
发布于 2013-05-21 09:21:52
我让它开始工作了。通过使用来自YUV颜色空间的因素,我可以创建一个Fabric JS图像过滤器。
为了得到我想要的结果,我做了大量的尝试。因此,我没有(详细的)描述这是如何工作的。据我所知,我已经使用YUV的因素,以获得亮度的(RGB)颜色。
for (i = 0; i < iLen; i++) {
    for (j = 0; j < jLen; j++) {
      index = (i * 4) * jLen + (j * 4);
      var yuv = {};
      yuv.r = data[index] / 255 * 1 * 0.299;     
      yuv.g = data[index + 1] / 255 * 1 * 0.587; //we use the yuv formula constants
      yuv.b = data[index + 2] / 255 * 1 * 0.114; //to try to catch the Y (brightness)
      yuv.y = yuv.r + yuv.g + yuv.b;             //you can tweak this
      data[index + 3] = 350 - (yuv.y / 1 * 255); //by changing the first number after the "=" on this line!
    }
}通过在最后一行中修改350,您可以改变透明度系数。
很抱歉不能解释更多关于这种织物过滤器的工作原理。
发布于 2016-08-11 22:12:38
因此,在Fabric.js中有一个过滤器,它就是这样做的。
http://fabricjs.com/docs/fabric.Image.filters.RemoveWhite.html
var filter = new fabric.Image.filters.RemoveWhite({
  threshold: 40,
  distance: 140
});
image.filters.push(filter);
image.applyFilters(canvas.renderAll.bind(canvas));https://stackoverflow.com/questions/15380547
复制相似问题