//  [python]
def measure(self, pixels, image_name, object_name, measurement_name, workspace, percentiles=None):
        """Perform measurements on an array of pixels
        pixels - image pixel data, masked to objects if applicable
        image_name - name of the current input image
        object_name - name of the current object set pixels are masked to
        measurement_name - group title to be used in data tables
        workspace - has all the details for current image set
        """
        pixel_count = numpy.prod(pixels.shape)
        percentile_measures = {}
        if pixel_count == 0:
            pixel_sum = 0
            pixel_mean = 0
            pixel_std = 0
            pixel_mad = 0
            pixel_median = 0
            pixel_min = 0
            pixel_max = 0
            pixel_pct_max = 0
            pixel_lower_qrt = 0
            pixel_upper_qrt = 0
            if percentiles:
                for percentile in percentiles:
                    percentile_measures[percentile] = 0
        else:
            pixels = pixels.flatten()
            pixels = pixels[
                numpy.nonzero(numpy.isfinite(pixels))[0]
            ]  # Ignore NaNs, Infs
            pixel_count = numpy.prod(pixels.shape)

            pixel_sum = numpy.sum(pixels)
            pixel_mean = pixel_sum / float(pixel_count)
            pixel_std = numpy.std(pixels)
            pixel_median = numpy.median(pixels)
            pixel_mad = numpy.median(numpy.abs(pixels - pixel_median))
            pixel_min = numpy.min(pixels)
            pixel_max = numpy.max(pixels)
            pixel_pct_max = (
                100.0 * float(numpy.sum(pixels == pixel_max)) / float(pixel_count)
            )
            pixel_lower_qrt, pixel_upper_qrt = numpy.percentile(pixels, [25, 75])

            if percentiles:
                percentile_results = numpy.percentile(pixels, percentiles)
                for percentile, res in zip(percentiles, percentile_results):
                    percentile_measures[percentile] = res


        m = workspace.measurements
        m.add_image_measurement(F_TOTAL_INTENSITY % measurement_name, pixel_sum)
        m.add_image_measurement(F_MEAN_INTENSITY % measurement_name, pixel_mean)
        m.add_image_measurement(F_MEDIAN_INTENSITY % measurement_name, pixel_median)
        m.add_image_measurement(F_STD_INTENSITY % measurement_name, pixel_std)
        m.add_image_measurement(F_MAD_INTENSITY % measurement_name, pixel_mad)
        m.add_image_measurement(F_MAX_INTENSITY % measurement_name, pixel_max)
        m.add_image_measurement(F_MIN_INTENSITY % measurement_name, pixel_min)
        m.add_image_measurement(F_TOTAL_AREA % measurement_name, pixel_count)
        m.add_image_measurement(F_PERCENT_MAXIMAL % measurement_name, pixel_pct_max)
        m.add_image_measurement(F_LOWER_QUARTILE % measurement_name, pixel_lower_qrt)
        m.add_image_measurement(F_UPPER_QUARTILE % measurement_name, pixel_upper_qrt)

        all_features = [
                ("Total intensity", pixel_sum),
                ("Mean intensity", pixel_mean),
                ("Median intensity", pixel_median),
                ("Std intensity", pixel_std),
                ("MAD intensity", pixel_mad),
                ("Min intensity", pixel_min),
                ("Max intensity", pixel_max),
                ("Pct maximal", pixel_pct_max),
                ("Lower quartile", pixel_lower_qrt),
                ("Upper quartile", pixel_upper_qrt),
                ("Total area", pixel_count),
        ]
        for percentile, value in percentile_measures.items():
            m.add_image_measurement(f"Intensity_Percentile_{percentile}_{measurement_name}", value)
            all_features.append((f"Percentile {percentile}", value))

        return [
            [
                image_name,
                object_name if self.wants_objects.value else "",
                feature_name,
                str(value),
            ]
            for feature_name, value in all_features
        ]