Python 如何以逆灰度保存图像?

Python 如何以逆灰度保存图像?,python,image-processing,scipy,Python,Image Processing,Scipy,有人能告诉我如何使用scipy.misc.imsave以逆灰度保存图像吗?使用下面的代码,我只能以灰度模式保存图像,但我的分类任务需要逆灰度图像 data = next(generator_queues[j]) assert data.shape == target_shape, "Shape mismatch {} vs {}".format(data.shape, args.shape) file_name = os

有人能告诉我如何使用scipy.misc.imsave以逆灰度保存图像吗?使用下面的代码,我只能以灰度模式保存图像,但我的分类任务需要逆灰度图像

            data = next(generator_queues[j])

            assert data.shape == target_shape, "Shape mismatch {} vs {}".format(data.shape, args.shape)

            file_name = os.path.join(args.target, language, "{}.png".format(i))

            scipy.misc.imsave(file_name, np.squeeze(data))

试试看:
np.挤压(255-数据)


看一看标准化
1-array
else
255 array
    data = next(generator_queues[j])

    assert data.shape == target_shape, "Shape mismatch {} vs {}".format(data.shape, args.shape)

    file_name = os.path.join(args.target, language, "{}.png".format(i))

    scipy.misc.imsave(file_name, np.squeeze(255 - data)) # if not normalised else 1 - data