Giter Site home page Giter Site logo

metalpetal / surfaceblur Goto Github PK

View Code? Open in Web Editor NEW
20.0 3.0 6.0 669 KB

Surface Blur / Bilateral Filter for MetalPetal.

License: MIT License

Objective-C 67.99% Ruby 10.97% Metal 21.04%
bilateral-filter bilateral surface-blur gpu ios macos metal image-processing metalpetal

surfaceblur's Introduction

SurfaceBlur

Surface Blur / Bilateral Filter for MetalPetal.

Preview

Preview

Photo by Ben Scott on Unsplash. https://unsplash.com/photos/tWb7IsL9CnY

Usage

MTISurfaceBlurFilter *filter = [[MTISurfaceBlurFilter alloc] initWithRadius:...];
filter.threshold = ...;
filter.inputImage = inputImage;
MTIImage *outputImage = filter.outputImage;

Install

pod 'MetalPetalSurfaceBlur', :git => 'https://github.com/MetalPetal/SurfaceBlur.git'

# Optional
pod 'MetalPetal/Swift'

License

MIT.

surfaceblur's People

Contributors

yuao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

surfaceblur's Issues

Not working

When I execute, I get an error:

Error Domain=MTLLibraryErrorDomain Code=5 "Function mtiSurfaceBlur was not found in the library" UserInfo={NSLocalizedDescription=Function mtiSurfaceBlur was not found in the library}

My code is:
`
guard let cgImage = image.cgImage else { return }

    let filter = MTISurfaceBlurFilter(radius: radius)
    filter.threshold = threshold
    filter.inputImage = MTIImage(__cgImage: cgImage, options: nil, isOpaque: true)

    let options = MTIContextOptions()

    guard let device = MTLCreateSystemDefaultDevice(), let context = try? MTIContext(device: device, options: options), let outputImage = filter.outputImage else {
        return
    }

    do {
        let filteredImage = try context.makeCGImage(from: outputImage)

        filteredImg = UIImage(cgImage: filteredImage)
        importImage.image = filteredImg
    } catch {
        print(error)
    }`

Any help is appreciated! Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.