def _updateSquareData(self, i, j): x0 = i * self._squareWidth x1 = x0 + self._squareWidth y0 = j * self._squareWidth y1 = y0 + self._squareWidth # Find the two dominant colors in the square. self._clusterer.fit( self._board[y0:y1, x0:x1].reshape( self._squareArea, 3)) # Find the proportion of the square's area that is # occupied by the less dominant color. freq = numpy.mean(self._clusterer.labels_) if freq > 0.5: freq = 1.0 - freq # Find the distance between the dominant colors. dist = ColorUtils.normColorDist( self._clusterer.cluster_centers_[0], self._clusterer.cluster_centers_[1]) self._squareFreqs[j, i] = freq self._squareDists[j, i] = dist
def _updateSquareData(self, i, j): x0 = i * self._squareWidth x1 = x0 + self._squareWidth y0 = j * self._squareWidth y1 = y0 + self._squareWidth # Find the two dominant colors in the square. self._clusterer.fit(self._board[y0:y1, x0:x1].reshape(self._squareArea, 3)) # Find the proportion of the square's area that is # occupied by the less dominant color. freq = numpy.mean(self._clusterer.labels_) if freq > 0.5: freq = 1.0 - freq # Find the distance between the dominant colors. dist = ColorUtils.normColorDist(self._clusterer.cluster_centers_[0], self._clusterer.cluster_centers_[1]) self._squareFreqs[j, i] = freq self._squareDists[j, i] = dist