【问题标题】:How do I blend two images together in GPUImage2 using Swift syntax如何使用 Swift 语法在 GPUImage2 中将两个图像混合在一起
【发布时间】:2017-01-02 14:20:16
【问题描述】:

我熟悉以下语法,可以在 Swift 语法中使用类似这样的东西在 GPUImage2 中进行单个图像过滤:

input --> blur --> output

但是如何使用需要两张图像的图像处理操作呢? GPUImage2 中的一个示例表明您可以这样做:

input --> self.lookup1 --> self.alphaBlend --> self.lookup2 --> output
          self.lookup1 --> self.gaussianBlur --> self.alphaBlend

self.lookup1 和 self.lookup2 是 2 个不同的图像。但我不确定这种语法,在这种情况下,第二张图片是否应该放在 alphaBlend 过滤器之后?

【问题讨论】:

    标签: ios swift image-processing gpuimage


    【解决方案1】:

    发现我发布的上述示例通过分析链并使用操作中所需的输入数量来工作。所以 alphaBlend 将等待另一个输入被应用,这是一个工作示例:

          let alphaBlend = AlphaBlend()
    
          let input1 = PictureInput(image: image1)
          let input2 = PictureInput(image: image2)
          alphaBlend.mix = 0.5;
    
          let output = PictureOutput();
          output.encodedImageFormat = .JPEG
    
          output.imageAvailableCallback = {image in
            // Do something with the image
            UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
          }
    
          input1 -->  alphaBlend
          input2 --> alphaBlend --> output
    
          input1.processImage(synchronously: true)
          input2.processImage(synchronously: true)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多