(img, options)
return pixels[idx[:num_samples]]
Pick a fixed percentage of pixels in the image, returned in random
order.
Pick a fixed percentage of pixels in the image, returned in random
order.
Pick a fixed percentage of pixels in the image returned in random order .
def sample_pixels(img, options):
    '''Pick a fixed percentage of pixels in the image, returned in random
order.'''

    pixels = img.reshape((-1, 3))
    num_pixels = pixels.shape[0]
    num_samples = int(num_pixels * options.sample_fraction)

    idx = np.arange(num_pixels)
    np.random.shuffle(idx)

    return pixels[idx[:num_samples]]
def sample_pixels ( img , options ) : pixels = img . reshape ( ( - 1 , 3 ) ) num_pixels = pixels . shape [ 0 ] num_samples = int ( num_pixels * options . sample_fraction ) idx = np . arange ( num_pixels ) np . random . shuffle ( idx ) return pixels [ idx [ : num_samples ] ]