SBSDKImageMetricsAnalyzer

@interface SBSDKImageMetricsAnalyzer : NSObject
  • Utility class to extract the metrics for each individual channel of an UIImage.
  • Metrics are min, max and mean values of each channel, the variance and standard deviation.
  • Along with the metrics this class also extracts histograms and cumulative histograms for each channel.
  • The number of channels of the input image. *

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSInteger numberOfChannels;

    Swift

    var numberOfChannels: Int { get }
  • An array of SBSDKImageChannelMetrics objects in the order of the images channels. *

    Declaration

    Objective-C

    @property (readonly, nonatomic)
        NSArray<SBSDKImageChannelMetrics *> *_Nonnull allChannelMetrics;

    Swift

    var allChannelMetrics: [SBSDKImageChannelMetrics] { get }
  • Designated initializer.

    Declaration

    Objective-C

    - (nonnull instancetype)init:(nonnull UIImage *)image
                    convertToHSV:(BOOL)convertToHSV;

    Swift

    init(_ image: UIImage, convertToHSV: Bool)

    Parameters

    image

    The image to extract metrics and histograms from.

    convertToHSV

    If set to YES, the image is converted to the hue-saturation-value system. So instead of R-, G- and B-channels the metrics are created for hue, saturation and value (brightness).

  • Not available.

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Returns the metrics for the channel with the given index.

    Declaration

    Objective-C

    - (nullable SBSDKImageChannelMetrics *)metricsAtChannel:(NSInteger)channelIndex;

    Swift

    func metrics(atChannel channelIndex: Int) -> SBSDKImageChannelMetrics?

    Parameters

    channelIndex

    The index for the channel. Passing an invalid index will return nil.

    Return Value

    The metrics object for the given channel or nil.

  • Returns the number of pixels for a given histogram bin and channel.

    Declaration

    Objective-C

    - (double)histogramValueAt:(NSInteger)index inChannel:(NSInteger)channelIndex;

    Swift

    func histogramValue(at index: Int, inChannel channelIndex: Int) -> Double

    Parameters

    index

    The index (0-255) of the histogram bin. Passing an invalid index will lead to crash.

    channelIndex

    The index for the channel. Passing an invalid index will lead to a crash.

    Return Value

    Number of pixels in the bin.

  • Returns an array with 256 entries, each containing a NSNumber object with the number of pixels being in the corresponding histogram bin.

    Declaration

    Objective-C

    - (nonnull NSArray<NSNumber *> *)histogramValuesInChannel:
        (NSInteger)channelIndex;

    Swift

    func histogramValues(inChannel channelIndex: Int) -> [NSNumber]

    Parameters

    channelIndex

    The index for the channel. Passing an invalid index will lead to a crash.

    Return Value

    An array of 256 NSNumber objects.

  • Returns the number of pixels for a given cumulative histogram bin and channel.

    Declaration

    Objective-C

    - (double)cumulativeHistogramValueAt:(NSInteger)index
                               inChannel:(NSInteger)channelIndex;

    Swift

    func cumulativeHistogramValue(at index: Int, inChannel channelIndex: Int) -> Double

    Parameters

    index

    The index (0-255) of the cumulative histogram bin. Passing an invalid index will lead to crash.

    channelIndex

    The index for the channel. Passing an invalid index will lead to a crash.

    Return Value

    Number of pixels in the bin.

  • Returns an array with 256 entries, each containing a NSNumber object with the number of pixels being in the corresponding cumulative histogram bin.

    Declaration

    Objective-C

    - (nonnull NSArray<NSNumber *> *)cumulativeHistogramValuesInChannel:
        (NSInteger)channelIndex;

    Swift

    func cumulativeHistogramValues(inChannel channelIndex: Int) -> [NSNumber]

    Parameters

    channelIndex

    The index for the channel. Passing an invalid index will lead to a crash.

    Return Value

    An array of 256 NSNumber objects.