I try to use MPSImageErode and MPSImageDilate in an app right now with SwiftUI and BigSur, Xcode 12.3
The code
Resulting in
when I use the filter with only Zero it actually works
But I want to try different filter values to see if I can improve the analytics on an image.
Any suggestions ?
The code
Code Block let edSize = 9 var erodedilateKernelValues:[Float] = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0, 0.0, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.0, 0.0, 0.2, 0.1, 0.0, 0.0, 0.0, 0.1, 0.2, 0.0, 0.0, 0.2, 0.1, 0.0, 0.0, 0.0, 0.1, 0.2, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0, 0.0, 0.1, 0.2, 0.0, 0.0, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.0, 0.0, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] let dilateShader = MPSImageDilate( device: self.metalDevice!, kernelWidth:edSize, kernelHeight:edSize, values:&erodedilateKernelValues) dilateShader.encode(commandBuffer: cmdBuf, sourceTexture: wipTexture!, destinationTexture: erodila) let erodeShader = MPSImageErode( device: self.metalDevice!, kernelWidth:edSize, kernelHeight:edSize, values:&erodedilateKernelValues) erodeShader.encode(commandBuffer: cmdBuf, sourceTexture: erodila, destinationTexture: erodila2) cmdBuf.commit() cmdBuf.waitUntilCompleted() wipTexture = erodila2
Resulting in
Code Block 2021-01-02 19:33:40.320954+0900 ***[5330:369599] /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MetalPerformanceShaders-124.2.1/MPSCore/Utility/MPSLibrary.mm, line 338: error 'MPSKernel MTLComputePipelineStateCache unable to load function DilateFilter4. Compiler encountered an internal error: (null) ' /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MetalPerformanceShaders-124.2.1/MPSCore/Utility/MPSLibrary.mm:338: failed assertion `MPSKernel MTLComputePipelineStateCache unable to load function DilateFilter4. Compiler encountered an internal error: (null) ' /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MetalPerformanceShaders-124.2.1/MPSCore/Utility/MPSLibrary.mm:338: failed assertion `MPSKernel MTLComputePipelineStateCache unable to load function DilateFilter4. Compiler encountered an internal error: (null) '
when I use the filter with only Zero it actually works
Code Block var erodedilateKernelValues = [Float].init(repeating: 0.0, count: edSize * edSize)
But I want to try different filter values to see if I can improve the analytics on an image.
Any suggestions ?