Package apple.metalperformanceshaders
Class MPSImageCanny
- java.lang.Object
-
- org.moe.natj.general.NativeObject
-
- org.moe.natj.objc.ObjCObject
-
- apple.NSObject
-
- apple.metalperformanceshaders.MPSKernel
-
- apple.metalperformanceshaders.MPSUnaryImageKernel
-
- apple.metalperformanceshaders.MPSImageCanny
-
- All Implemented Interfaces:
NSCoding,NSCopying,NSSecureCoding,NSObject
public class MPSImageCanny extends MPSUnaryImageKernel
MPSImageCanny The MPSImageCanny implements the Canny edge detection algorithm. When the color model of the source and destination textures match, the filter is applied to each channel seperately. If the destination is monochrome but source multichannel, the source will be converted to grayscale using the linear gray color transform vector (v). Luminance = v[0] * pixel.x + v[1] * pixel.y + v[2] * pixel.z; The canny edge detection algorithm consists of 5 steps: 1. Blur the source image using a Gaussian blur with a sigma parameter 2. Use horizontal and vertical Sobel filters to find a gradient magnitude and direction. G = sqrt(Sx^2 + Sy^2) G_ang = arctan(Sy / Sx) 3. Perform non-maximum suppression to thin edges to single pixel widths. A pixel is considered to be a maxium along the edge if it has the largest gradient magnitude along the positive and negatve gradient direction. That is, if the gradient direction is 90°, if the gradient magnitude of a pixel is greater than its neighbors at -90° and 90° it is the maximum. Any pixel which is not a maximum will have its value suppressed, by setting it's magnitude to 0. 4. Double thresholding is preformed with two values ht and lt with ht > lt to classify a pixel as part of a weak or strong edge. A pixel with gradient value G is classified as: Strong edge: G > ht Weak edge: ht >= G > lt Not an edge: lt >= G 5. Edge tracking is performed along all weak edges to determine if they are part of a strong edge. Any weak edges which are connected to a strong edge are labelled true edges, along with strong edges themselves. A pixel can be connected through any of its 8 neighbors. Any pixel marked as a true edge is output with a high value, and all others are considered background and output with a low value.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class apple.metalperformanceshaders.MPSUnaryImageKernel
MPSUnaryImageKernel.Block_encodeToCommandBufferInPlaceTextureFallbackCopyAllocator
-
Nested classes/interfaces inherited from class apple.NSObject
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMPSImageCanny(org.moe.natj.general.Pointer peer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean_supportsSecureCoding()This property must return YES on all classes that allow secure coding.static booleanaccessInstanceVariablesDirectly()static MPSImageCannyalloc()static java.lang.ObjectallocWithZone(org.moe.natj.general.ptr.VoidPtr zone)static booleanautomaticallyNotifiesObserversForKey(java.lang.String key)static voidcancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)static voidcancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget, org.moe.natj.objc.SEL aSelector, java.lang.Object anArgument)static NSArray<java.lang.String>classFallbacksForKeyedArchiver()static org.moe.natj.objc.ClassclassForKeyedUnarchiver()org.moe.natj.general.ptr.ConstFloatPtrcolorTransform()[@property] colorTransform Returns a pointer to the array of three floats used to convert RGBA, RGB or RG images to the destination format when the destination is monochrome.static java.lang.StringdebugDescription_static()static java.lang.Stringdescription_static()static longhash_static()floathighThreshold()[@property] highThreshold Read-write value used to set the high threshold for double thresholding, value is normalized.MPSImageCannyinit()MPSImageCannyinitWithCoder(NSCoder aDecoder)NS_DESIGNATED_INITIALIZERMPSImageCannyinitWithCoderDevice(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.MPSImageCannyinitWithDevice(java.lang.Object device)Initialize a Canny filter on a given device using the default color transform and default sigma value for Gaussian blur.MPSImageCannyinitWithDeviceLinearToGrayScaleTransformSigma(MTLDevice device, org.moe.natj.general.ptr.ConstFloatPtr transform, float sigma)Initialize a Canny filter on a given device with a non-default color transform and non-default sigma.static NSObject.Function_instanceMethodForSelector_retinstanceMethodForSelector(org.moe.natj.objc.SEL aSelector)static NSMethodSignatureinstanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)static booleaninstancesRespondToSelector(org.moe.natj.objc.SEL aSelector)static booleanisSubclassOfClass(org.moe.natj.objc.Class aClass)static NSSet<java.lang.String>keyPathsForValuesAffectingValueForKey(java.lang.String key)floatlowThreshold()[@property] lowThreshold Read-write value used to set the low threshold for double thresholding, value is normalized.static java.lang.Objectnew_objc()static booleanresolveClassMethod(org.moe.natj.objc.SEL sel)static booleanresolveInstanceMethod(org.moe.natj.objc.SEL sel)voidsetHighThreshold(float value)[@property] highThreshold Read-write value used to set the high threshold for double thresholding, value is normalized.voidsetLowThreshold(float value)[@property] lowThreshold Read-write value used to set the low threshold for double thresholding, value is normalized.voidsetUseFastMode(boolean value)[@property] useFastMode Read-write value used to change algorithm to an approximation of the true Canny Edge detection Algorithm.static voidsetVersion_static(long aVersion)floatsigma()[@property] sigma Read-only sigma value used in performing Gaussian blur of the imagestatic org.moe.natj.objc.Classsuperclass_static()static booleansupportsSecureCoding()booleanuseFastMode()[@property] useFastMode Read-write value used to change algorithm to an approximation of the true Canny Edge detection Algorithm.static longversion_static()-
Methods inherited from class apple.metalperformanceshaders.MPSUnaryImageKernel
clipRect, edgeMode, encodeToCommandBufferInPlaceTextureFallbackCopyAllocator, encodeToCommandBufferSourceImageDestinationImage, encodeToCommandBufferSourceTextureDestinationTexture, offset, setClipRect, setEdgeMode, setOffset, sourceRegionForDestinationSize
-
Methods inherited from class apple.metalperformanceshaders.MPSKernel
copyWithZone, copyWithZoneDevice, device, encodeWithCoder, label, options, setLabel, setOptions
-
Methods inherited from class apple.NSObject
accessibilityActivate, accessibilityActivationPoint, accessibilityAssistiveTechnologyFocusedIdentifiers, accessibilityAttributedHint, accessibilityAttributedLabel, accessibilityAttributedUserInputLabels, accessibilityAttributedValue, accessibilityContainerType, accessibilityCustomActions, accessibilityCustomRotors, accessibilityDecrement, accessibilityDragSourceDescriptors, accessibilityDropPointDescriptors, accessibilityElementAtIndex, accessibilityElementCount, accessibilityElementDidBecomeFocused, accessibilityElementDidLoseFocus, accessibilityElementIsFocused, accessibilityElements, accessibilityElementsHidden, accessibilityFrame, accessibilityHint, accessibilityIncrement, accessibilityLabel, accessibilityLanguage, accessibilityNavigationStyle, accessibilityPath, accessibilityPerformEscape, accessibilityPerformMagicTap, accessibilityRespondsToUserInteraction, accessibilityScroll, accessibilityTextualContext, accessibilityTraits, accessibilityUserInputLabels, accessibilityValue, accessibilityViewIsModal, addObserverForKeyPathOptionsContext, attemptRecoveryFromErrorOptionIndex, attemptRecoveryFromErrorOptionIndexDelegateDidRecoverSelectorContextInfo, autoContentAccessingProxy, awakeAfterUsingCoder, awakeFromNib, class_objc, classForCoder, classForKeyedArchiver, copy, dealloc, debugDescription, description, dictionaryWithValuesForKeys, didChangeValueForKey, didChangeValueForKeyWithSetMutationUsingObjects, didChangeValuesAtIndexesForKey, doesNotRecognizeSelector, fileManagerShouldProceedAfterError, fileManagerWillProcessPath, finalize_objc, forwardingTargetForSelector, forwardInvocation, hash, indexOfAccessibilityElement, isAccessibilityElement, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableArrayValueForKey, mutableArrayValueForKeyPath, mutableCopy, mutableOrderedSetValueForKey, mutableOrderedSetValueForKeyPath, mutableSetValueForKey, mutableSetValueForKeyPath, observationInfo, observeValueForKeyPathOfObjectChangeContext, performSelector, performSelectorInBackgroundWithObject, performSelectorOnMainThreadWithObjectWaitUntilDone, performSelectorOnMainThreadWithObjectWaitUntilDoneModes, performSelectorOnThreadWithObjectWaitUntilDone, performSelectorOnThreadWithObjectWaitUntilDoneModes, performSelectorWithObject, performSelectorWithObjectAfterDelay, performSelectorWithObjectAfterDelayInModes, performSelectorWithObjectWithObject, prepareForInterfaceBuilder, provideImageDataBytesPerRowOrigin_Size_UserInfo, removeObserverForKeyPath, removeObserverForKeyPathContext, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, self, setAccessibilityActivationPoint, setAccessibilityAttributedHint, setAccessibilityAttributedLabel, setAccessibilityAttributedUserInputLabels, setAccessibilityAttributedValue, setAccessibilityContainerType, setAccessibilityCustomActions, setAccessibilityCustomRotors, setAccessibilityDragSourceDescriptors, setAccessibilityDropPointDescriptors, setAccessibilityElements, setAccessibilityElementsHidden, setAccessibilityFrame, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLanguage, setAccessibilityNavigationStyle, setAccessibilityPath, setAccessibilityRespondsToUserInteraction, setAccessibilityTextualContext, setAccessibilityTraits, setAccessibilityUserInputLabels, setAccessibilityValue, setAccessibilityViewIsModal, setIsAccessibilityElement, setNilValueForKey, setObservationInfo, setShouldGroupAccessibilityChildren, setValueForKey, setValueForKeyPath, setValueForUndefinedKey, setValuesForKeysWithDictionary, shouldGroupAccessibilityChildren, superclass, validateValueForKeyError, validateValueForKeyPathError, valueForKey, valueForKeyPath, valueForUndefinedKey, willChangeValueForKey, willChangeValueForKeyWithSetMutationUsingObjects, willChangeValuesAtIndexesForKey
-
-
-
-
Method Detail
-
accessInstanceVariablesDirectly
public static boolean accessInstanceVariablesDirectly()
-
alloc
public static MPSImageCanny alloc()
-
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()
-
colorTransform
public org.moe.natj.general.ptr.ConstFloatPtr colorTransform()
[@property] colorTransform Returns a pointer to the array of three floats used to convert RGBA, RGB or RG images to the destination format when the destination is monochrome. Value is readonly and user should not modify or free.
-
debugDescription_static
public static java.lang.String debugDescription_static()
-
description_static
public static java.lang.String description_static()
-
hash_static
public static long hash_static()
-
highThreshold
public float highThreshold()
[@property] highThreshold Read-write value used to set the high threshold for double thresholding, value is normalized. Default is 0.4
-
init
public MPSImageCanny init()
- Overrides:
initin classMPSUnaryImageKernel
-
initWithCoder
public MPSImageCanny initWithCoder(NSCoder aDecoder)
Description copied from interface:NSCodingNS_DESIGNATED_INITIALIZER- Specified by:
initWithCoderin interfaceNSCoding- Overrides:
initWithCoderin classMPSUnaryImageKernel
-
initWithCoderDevice
public MPSImageCanny 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:
initWithCoderDevicein classMPSUnaryImageKernel- Parameters:
aDecoder- The NSCoder subclass with your serialized MPSKerneldevice- The MTLDevice on which to make the MPSKernel- Returns:
- A new MPSKernel object, or nil if failure.
-
initWithDevice
public MPSImageCanny initWithDevice(java.lang.Object device)
Initialize a Canny filter on a given device using the default color transform and default sigma value for Gaussian blur. Default transform: BT.601/JPEG {0.299f, 0.587f, 0.114f} Default sigma: sqrt(2) For non-default parameters, use -initWithDevice:linearGrayColorTransform:sigma:- Overrides:
initWithDevicein classMPSUnaryImageKernel- Parameters:
device- The device the filter will run on- Returns:
- A valid object or nil, if failure.
-
initWithDeviceLinearToGrayScaleTransformSigma
public MPSImageCanny initWithDeviceLinearToGrayScaleTransformSigma(MTLDevice device, org.moe.natj.general.ptr.ConstFloatPtr transform, float sigma)
Initialize a Canny filter on a given device with a non-default color transform and non-default sigma. [@code] Luminance = transform[0] * pixel.x + transform[1] * pixel.y + transform[2] * pixel.z; [@endcode] [@code] w(i) = 1/sqrt(2*pi*sigma) * exp(-n^2/2*sigma^2) [@endcode] If we take cut off at 1% of w(0) (max weight) beyond which weights are considered 0, we have [@code] ceil (sqrt(-log(0.01)*2)*sigma) ~ ceil(3.7*sigma) [@endcode] as rough estimate of filter width- Parameters:
device- The device the filter will run ontransform- Array of three floats describing the rgb to gray scale color transform.sigma- The standard deviation of gaussian blur filter. Gaussian weight, centered at 0, at integer grid n is given as- Returns:
- A valid object or nil, if failure.
-
instanceMethodForSelector
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
-
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)
-
keyPathsForValuesAffectingValueForKey
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
-
lowThreshold
public float lowThreshold()
[@property] lowThreshold Read-write value used to set the low threshold for double thresholding, value is normalized. Default is 0.2
-
new_objc
public static java.lang.Object new_objc()
-
resolveClassMethod
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
-
resolveInstanceMethod
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
-
setHighThreshold
public void setHighThreshold(float value)
[@property] highThreshold Read-write value used to set the high threshold for double thresholding, value is normalized. Default is 0.4
-
setLowThreshold
public void setLowThreshold(float value)
[@property] lowThreshold Read-write value used to set the low threshold for double thresholding, value is normalized. Default is 0.2
-
setUseFastMode
public void setUseFastMode(boolean value)
[@property] useFastMode Read-write value used to change algorithm to an approximation of the true Canny Edge detection Algorithm. When true, a limit is placed on how far a single strong edge can extend. The result will be similar to a true output but some edges may terminate early, resulting in minor differences for cases with long, weak edges. The performance for the approximate canny implementation is improved and should provide similar enough results for most cases. Extra tuning of the high and low thresholds as well as sigma may help achieve a more similar output in this mode. Default is YES
-
setVersion_static
public static void setVersion_static(long aVersion)
-
sigma
public float sigma()
[@property] sigma Read-only sigma value used in performing Gaussian blur of the image
-
superclass_static
public static org.moe.natj.objc.Class superclass_static()
-
supportsSecureCoding
public static boolean supportsSecureCoding()
-
_supportsSecureCoding
public boolean _supportsSecureCoding()
Description copied from interface:NSSecureCodingThis 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:
_supportsSecureCodingin interfaceNSSecureCoding- Overrides:
_supportsSecureCodingin classMPSUnaryImageKernel
-
useFastMode
public boolean useFastMode()
[@property] useFastMode Read-write value used to change algorithm to an approximation of the true Canny Edge detection Algorithm. When true, a limit is placed on how far a single strong edge can extend. The result will be similar to a true output but some edges may terminate early, resulting in minor differences for cases with long, weak edges. The performance for the approximate canny implementation is improved and should provide similar enough results for most cases. Extra tuning of the high and low thresholds as well as sigma may help achieve a more similar output in this mode. Default is YES
-
version_static
public static long version_static()
-
-