简体   繁体   中英

How to save images in inverse gray-scale?

Can anyone tell how to save images in inverse gray-scale using scipy.misc.imsave.Using below code I'm able to save images in gray-scale mode only but I need inverse gray-scale images for my classification task

            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))

Try: np.squeeze(255 - data)

    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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM