Class MPSImageGuidedFilter

  • All Implemented Interfaces:
    NSCoding, NSCopying, NSSecureCoding, NSObject

    public class MPSImageGuidedFilter
    extends MPSKernel
    MPSImageGuidedFilter Perform Guided Filter to produce a coefficients image The filter is broken into two stages: - Regression - Reconstruction The regression stage learns a 4-channel "coefficient" texture (typically at a very low resolution), and represents the per-pixel linear regression of the source texture to the guidance texture. The reconstruction stage upsamples the coefficeints to the same size as the final output and then at each pixel computes the inner product to produce the output. The filter is broken into two stages to allow coefficients to be filtered (such as for example - temporally filtering for video to prevent flicker). There is also support for an optional weight texture that can be used to discard values in the source data. Guided Filter is described at https://arxiv.org/pdf/1505.00996.pdf.
    • Constructor Detail

      • MPSImageGuidedFilter

        protected MPSImageGuidedFilter​(org.moe.natj.general.Pointer peer)
    • Method Detail

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • allocWithZone

        public static java.lang.Object allocWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
      • automaticallyNotifiesObserversForKey

        public static boolean automaticallyNotifiesObserversForKey​(java.lang.String key)
      • cancelPreviousPerformRequestsWithTarget

        public static void cancelPreviousPerformRequestsWithTarget​(java.lang.Object aTarget)
      • cancelPreviousPerformRequestsWithTargetSelectorObject

        public static void cancelPreviousPerformRequestsWithTargetSelectorObject​(java.lang.Object aTarget,
                                                                                 org.moe.natj.objc.SEL aSelector,
                                                                                 java.lang.Object anArgument)
      • classFallbacksForKeyedArchiver

        public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
      • classForKeyedUnarchiver

        public static org.moe.natj.objc.Class classForKeyedUnarchiver()
      • debugDescription_static

        public static java.lang.String debugDescription_static()
      • description_static

        public static java.lang.String description_static()
      • encodeReconstructionToCommandBufferGuidanceTextureCoefficientsTextureDestinationTexture

        public void encodeReconstructionToCommandBufferGuidanceTextureCoefficientsTextureDestinationTexture​(MTLCommandBuffer commandBuffer,
                                                                                                            MTLTexture guidanceTexture,
                                                                                                            MTLTexture coefficientsTexture,
                                                                                                            MTLTexture destinationTexture)
        Perform Guided Filter Reconstruction (inference) to produce the filtered output The filter will not begin to execute until after the command buffer has been enqueued and committed. [@pparam] sourceGuidanceTexture Input guidance pixel buffer. This should be a color (RGB) image. [@pparam] coefficientsTexture Input coefficients texture generated generated by a previous encodeRegressionToCommandBuffer
        Parameters:
        destinationTexture - Output texture Note: The coefficients are upsampled at the reconstruction of the filtered data. Reconstruct(guidance RGB) = a.r * R + a.g * G + a.b * B + b, where a and b are the coefficients learnt using encodeRegressionToCommandBuffer. Final reconstructed value = value * reconstructScale + reconstructOffset
      • encodeRegressionToCommandBufferSourceTextureGuidanceTextureWeightsTextureDestinationCoefficientsTexture

        public void encodeRegressionToCommandBufferSourceTextureGuidanceTextureWeightsTextureDestinationCoefficientsTexture​(MTLCommandBuffer commandBuffer,
                                                                                                                            MTLTexture sourceTexture,
                                                                                                                            MTLTexture guidanceTexture,
                                                                                                                            MTLTexture weightsTexture,
                                                                                                                            MTLTexture destinationCoefficientsTexture)
        Perform Guided Filter Regression (correlation) to produce a coefficients texture The filter will not begin to execute until after the command buffer has been enqueued and committed.
        Parameters:
        commandBuffer - A valid MTLCommandBuffer.
        sourceTexture - Input source texture to be filtered (typically a mask). This should be a single channel image.
        guidanceTexture - Input guidance texture. This should be a color (RGB) image.
        weightsTexture - Optional input confidence texture. This should also a single channel image.
        destinationCoefficientsTexture - Output texture with four coefficients that minimize the mean squared error between the source and an affine function of guidance R, G, B. Note: The destinationCoefficientsTexture computes the linear cofficients "a" and "b". The "a" coefficient is stored in the RGB channels of destinationCoefficientsTexture and the "b" coefficient in the alpha chnanel. Set the MPSKernelOptionsAllowReducedPrecision in the "options" property for this kernel to peform the computations using half-precision arithmetic. This can potentially improve performance and/or power usage.
      • epsilon

        public float epsilon()
        [@property] epsilon The regularization parameter The parameter used when computing the linear coefficients a and b.
      • hash_static

        public static long hash_static()
      • initWithCoderDevice

        public MPSImageGuidedFilter initWithCoderDevice​(NSCoder aDecoder,
                                                        java.lang.Object device)
        NSSecureCoding compatability While the standard NSSecureCoding/NSCoding method -initWithCoder: should work, since the file can't know which device your data is allocated on, we have to guess and may guess incorrectly. To avoid that problem, use initWithCoder:device instead.
        Overrides:
        initWithCoderDevice in class MPSKernel
        Parameters:
        aDecoder - The NSCoder subclass with your serialized MPSKernel
        device - The MTLDevice on which to make the MPSKernel
        Returns:
        A new MPSKernel object, or nil if failure.
      • initWithDevice

        public MPSImageGuidedFilter initWithDevice​(java.lang.Object device)
        Description copied from class: MPSKernel
        Standard init with default properties per filter type
        Overrides:
        initWithDevice in class MPSKernel
        Parameters:
        device - The device that the filter will be used on. May not be NULL.
        Returns:
        a pointer to the newly initialized object. This will fail, returning nil if the device is not supported. Devices must be MTLFeatureSet_iOS_GPUFamily2_v1 or later.
      • initWithDeviceKernelDiameter

        public MPSImageGuidedFilter initWithDeviceKernelDiameter​(MTLDevice device,
                                                                 long kernelDiameter)
        Specifies information to apply the guided filter regression.
        Parameters:
        device - The device the filter will run on
        kernelDiameter - The local window size
        Returns:
        A valid MPSImageGuidedFilterRegression object or nil, if failure.
      • instanceMethodSignatureForSelector

        public static NSMethodSignature instanceMethodSignatureForSelector​(org.moe.natj.objc.SEL aSelector)
      • instancesRespondToSelector

        public static boolean instancesRespondToSelector​(org.moe.natj.objc.SEL aSelector)
      • isSubclassOfClass

        public static boolean isSubclassOfClass​(org.moe.natj.objc.Class aClass)
      • kernelDiameter

        public long kernelDiameter()
        [@property] kernelDiameter The local window size The local window size.
      • keyPathsForValuesAffectingValueForKey

        public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey​(java.lang.String key)
      • new_objc

        public static java.lang.Object new_objc()
      • reconstructOffset

        public float reconstructOffset()
        [@property] reconstructOffset The offset parameter The offset parameter added to the result of the scaled reconstructed value. The default value is 0.0f.
      • reconstructScale

        public float reconstructScale()
        [@property] reconstructScale The scale parameter The parameter used to scale the result of the reconstruction operation. The default value is 1.0f.
      • resolveClassMethod

        public static boolean resolveClassMethod​(org.moe.natj.objc.SEL sel)
      • resolveInstanceMethod

        public static boolean resolveInstanceMethod​(org.moe.natj.objc.SEL sel)
      • setEpsilon

        public void setEpsilon​(float value)
        [@property] epsilon The regularization parameter The parameter used when computing the linear coefficients a and b.
      • setReconstructOffset

        public void setReconstructOffset​(float value)
        [@property] reconstructOffset The offset parameter The offset parameter added to the result of the scaled reconstructed value. The default value is 0.0f.
      • setReconstructScale

        public void setReconstructScale​(float value)
        [@property] reconstructScale The scale parameter The parameter used to scale the result of the reconstruction operation. The default value is 1.0f.
      • setVersion_static

        public static void setVersion_static​(long aVersion)
      • superclass_static

        public static org.moe.natj.objc.Class superclass_static()
      • supportsSecureCoding

        public static boolean supportsSecureCoding()
      • _supportsSecureCoding

        public boolean _supportsSecureCoding()
        Description copied from interface: NSSecureCoding
        This property must return YES on all classes that allow secure coding. Subclasses of classes that adopt NSSecureCoding and override initWithCoder: must also override this method and return YES. The Secure Coding Guide should be consulted when writing methods that decode data.
        Specified by:
        _supportsSecureCoding in interface NSSecureCoding
        Overrides:
        _supportsSecureCoding in class MPSKernel
      • version_static

        public static long version_static()
      • encodeReconstructionToCommandBufferGuidanceTextureCoefficientsTextureACoefficientsTextureBDestinationTexture

        public void encodeReconstructionToCommandBufferGuidanceTextureCoefficientsTextureACoefficientsTextureBDestinationTexture​(MTLCommandBuffer commandBuffer,
                                                                                                                                 MTLTexture guidanceTexture,
                                                                                                                                 MTLTexture coefficientsTextureA,
                                                                                                                                 MTLTexture coefficientsTextureB,
                                                                                                                                 MTLTexture destinationTexture)
        Perform Guided Filter Reconstruction (inference) to produce the filtered output The filter will not begin to execute until after the command buffer has been enqueued and committed.
        Parameters:
        commandBuffer - A valid MTLCommandBuffer.
        guidanceTexture - Input guidance pixel buffer.
        coefficientsTextureA - Input coefficients A texture generated generated by a previous encodeRegressionToCommandBuffer.
        coefficientsTextureB - Input coefficients B texture generated generated by a previous encodeRegressionToCommandBuffer.
        destinationTexture - Output texture
      • encodeRegressionToCommandBufferSourceTextureGuidanceTextureWeightsTextureDestinationCoefficientsTextureADestinationCoefficientsTextureB

        public void encodeRegressionToCommandBufferSourceTextureGuidanceTextureWeightsTextureDestinationCoefficientsTextureADestinationCoefficientsTextureB​(MTLCommandBuffer commandBuffer,
                                                                                                                                                            MTLTexture sourceTexture,
                                                                                                                                                            MTLTexture guidanceTexture,
                                                                                                                                                            MTLTexture weightsTexture,
                                                                                                                                                            MTLTexture destinationCoefficientsTextureA,
                                                                                                                                                            MTLTexture destinationCoefficientsTextureB)
        Perform per-channel (non-color correlated) Guided Filter Regression (correlation) to produce a coefficients texture The filter will not begin to execute until after the command buffer has been enqueued and committed. This encode call differs from the one above in that the correlations are not computed across channels and therefore this filter computes two coefficient textures: ai and bi.
        Parameters:
        commandBuffer - A valid MTLCommandBuffer.
        sourceTexture - Input source texture to be filtered.
        guidanceTexture - Input guidance texture. This should be a color (RGB) image.
        weightsTexture - Optional input confidence texture. This should be a single channel image.
        destinationCoefficientsTextureA - Output texture with four coefficients A that minimize the mean squared error between the source channels and an affine function of guidance channels.
        destinationCoefficientsTextureB - Output texture with four coefficients B that minimize the mean squared error between the source channels and an affine function of guidance channels. Set the MPSKernelOptionsAllowReducedPrecision in the "options" property for this kernel to peform the computations using half-precision arithmetic. This can potentially improve performance and/or power usage.