def set_to(image_np, value):
    """Sets the image pixels to the given value."""
    if image_np is None or value is None:
        return None
    if isinstance(value, tuple):
        channels = 1 if image_np.ndim < 3 else image_np.shape[2]
        if len(value) < channels:
            raise ValueError(
                'Input value has less entries than image channels.')
        if channels == 1:
            image_np[:] = value[0]
        else:
            for ch in range(channels):
                image_np[:, :, (ch)] = value[ch]
    else:
        image_np[:] = value
    return image_np
