In this lesson, we are going to describe and implement two features that can be used to identify GAN samples. These features include the centroid and the slope. We will briefly describe what information about images these features provide, and we’ll also give an implementation.
Centroid
The centroid draws inspiration from the centroid or geometric center defined in mathematics and physics, whereby it represents the arithmetic mean position of all the points in the figure. In computer vision parlance, the centroid is an image moment: a weighted average (moment) of the image pixels’ intensities.
In our context, the centroid represents the arithmetic mean row in a column. For each column in an image, we transform the pixel values into row probabilities by normalizing them by the column sum, after which we take the expected row value, therefore obtaining the spectral centroid. Naturally, this can be extended to include columns only or both rows and columns.
It is inspired by the spectral centroid (Peeters, 2004), a feature commonly used in the audio domain, where it represents the barycenter of the spectrum. Although this feature has been derived from the audio domain, it can be applied to other domains. The following figure shows these features computed on MNIST:
Get hands-on with 1400+ tech skills courses.