public class MPSImageCanny extends MPSUnaryImageKernel
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.
MPSUnaryImageKernel.Block_encodeToCommandBufferInPlaceTextureFallbackCopyAllocatorNSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret| Modifier | Constructor and Description |
|---|---|
protected |
MPSImageCanny(org.moe.natj.general.Pointer peer) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
_supportsSecureCoding()
This property must return YES on all classes that allow secure coding.
|
static boolean |
accessInstanceVariablesDirectly() |
static MPSImageCanny |
alloc() |
static MPSImageCanny |
allocWithZone(org.moe.natj.general.ptr.VoidPtr zone) |
static boolean |
automaticallyNotifiesObserversForKey(java.lang.String key) |
static void |
cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget) |
static void |
cancelPreviousPerformRequestsWithTargetSelectorObject(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.Class |
classForKeyedUnarchiver() |
org.moe.natj.general.ptr.ConstFloatPtr |
colorTransform()
[@property] colorTransform
|
static java.lang.String |
debugDescription_static() |
static java.lang.String |
description_static() |
static long |
hash_static() |
float |
highThreshold()
[@property] highThreshold
|
MPSImageCanny |
init() |
MPSImageCanny |
initWithCoder(NSCoder aDecoder)
NS_DESIGNATED_INITIALIZER
|
MPSImageCanny |
initWithCoderDevice(NSCoder aDecoder,
java.lang.Object device)
NSSecureCoding compatability
|
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.
|
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.
|
static NSObject.Function_instanceMethodForSelector_ret |
instanceMethodForSelector(org.moe.natj.objc.SEL aSelector) |
static NSMethodSignature |
instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
instancesRespondToSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
isSubclassOfClass(org.moe.natj.objc.Class aClass) |
static NSSet<java.lang.String> |
keyPathsForValuesAffectingValueForKey(java.lang.String key) |
float |
lowThreshold()
[@property] lowThreshold
|
static MPSImageCanny |
new_objc() |
static boolean |
resolveClassMethod(org.moe.natj.objc.SEL sel) |
static boolean |
resolveInstanceMethod(org.moe.natj.objc.SEL sel) |
void |
setHighThreshold(float value)
[@property] highThreshold
|
void |
setLowThreshold(float value)
[@property] lowThreshold
|
void |
setUseFastMode(boolean value)
[@property] useFastMode
|
static void |
setVersion_static(long aVersion) |
float |
sigma()
[@property] sigma
|
static org.moe.natj.objc.Class |
superclass_static() |
static boolean |
supportsSecureCoding() |
boolean |
useFastMode()
[@property] useFastMode
|
static long |
version_static() |
clipRect, edgeMode, encodeToCommandBufferInPlaceTextureFallbackCopyAllocator, encodeToCommandBufferSourceImageDestinationImage, encodeToCommandBufferSourceTextureDestinationTexture, offset, setClipRect, setEdgeMode, setOffset, sourceRegionForDestinationSizecopyWithZone, copyWithZoneDevice, device, encodeWithCoder, label, options, setLabel, setOptionsaccessibilityActivate, 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, willChangeValuesAtIndexesForKeypublic static boolean accessInstanceVariablesDirectly()
public static MPSImageCanny alloc()
public static MPSImageCanny allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument)
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
public org.moe.natj.general.ptr.ConstFloatPtr 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.
public static java.lang.String debugDescription_static()
public static java.lang.String description_static()
public static long hash_static()
public float highThreshold()
Read-write value used to set the high threshold for double thresholding, value is normalized. Default is 0.4
public MPSImageCanny init()
init in class MPSUnaryImageKernelpublic MPSImageCanny initWithCoder(NSCoder aDecoder)
NSCodinginitWithCoder in interface NSCodinginitWithCoder in class MPSUnaryImageKernelpublic MPSImageCanny initWithCoderDevice(NSCoder aDecoder, java.lang.Object device)
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.
initWithCoderDevice in class MPSUnaryImageKernelaDecoder - The NSCoder subclass with your serialized MPSKerneldevice - The MTLDevice on which to make the MPSKernelpublic MPSImageCanny initWithDevice(java.lang.Object device)
For non-default parameters, use -initWithDevice:linearGrayColorTransform:sigma:
initWithDevice in class MPSUnaryImageKerneldevice - The device the filter will run onpublic MPSImageCanny initWithDeviceLinearToGrayScaleTransformSigma(MTLDevice device, org.moe.natj.general.ptr.ConstFloatPtr transform, float sigma)
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 aspublic static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
public float lowThreshold()
Read-write value used to set the low threshold for double thresholding, value is normalized. Default is 0.2
public static MPSImageCanny new_objc()
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
public void setHighThreshold(float value)
Read-write value used to set the high threshold for double thresholding, value is normalized. Default is 0.4
public void setLowThreshold(float value)
Read-write value used to set the low threshold for double thresholding, value is normalized. Default is 0.2
public void setUseFastMode(boolean value)
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
public static void setVersion_static(long aVersion)
public float sigma()
Read-only sigma value used in performing Gaussian blur of the image
public static org.moe.natj.objc.Class superclass_static()
public static boolean supportsSecureCoding()
public boolean _supportsSecureCoding()
NSSecureCoding_supportsSecureCoding in interface NSSecureCoding_supportsSecureCoding in class MPSUnaryImageKernelpublic boolean 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
public static long version_static()