python - how to save image to files while using matplotlib -


i using different filters skimage package & want save new image file instead of showing on screen. can please help. pretty new user of python . below code

import os = 'c:' a1 = 'users' a2 = 'ashay.chandra' b = 'downloads'  c = 'test.jpg' import matplotlib.pyplot plt  skimage import data,io skimage.color import rgb2hed matplotlib.colors import linearsegmentedcolormap  # create artificial color close orginal 1 cmap_hema = linearsegmentedcolormap.from_list('mycmap', ['white', 'navy']) cmap_dab = linearsegmentedcolormap.from_list('mycmap', ['white',                                              'saddlebrown']) cmap_eosin = linearsegmentedcolormap.from_list('mycmap', ['darkviolet',                                                'white']) filename = os.path.join (a + os.sep,a1,a2,b,c) #ihc_rgb = data.immunohistochemistry() img = io.imread(filename) #ihc_rgb = data.immunohistochemistry() ihc_hed = rgb2hed(img)  fig, axes = plt.subplots(2, 2, figsize=(7, 6), sharex=true, sharey=true,                          subplot_kw={'adjustable': 'box-forced'}) ax = axes.ravel() plt.savefig("'c:\users\ashay.chandra\documents\learning_python\test_orig.png") = ax[0].imshow(img) plt.savefig("'c:\users\ashay.chandra\documents\learning_python\4pnormc1p2_ad1_tz1_a0_v0_m0_l0_ix_h1_hematoxylin.png") = ax[1].imshow(ihc_hed[:, :, 0], cmap=cmap_hema) plt.savefig("'c:\users\ashay.chandra\documents\learning_python\test_eosin.png") = ax[2].imshow(ihc_hed[:, :, 1], cmap=cmap_eosin) plt.savefig("'c:\users\ashay.chandra\documents\learning_python\test_dab.png") = ax[3].imshow(ihc_hed[:, :, 2], cmap=cmap_dab) #ax[0].imshow(img) #ax[0].set_title("original image")  #ax[1].imshow(ihc_hed[:, :, 0], cmap=cmap_hema) #ax[1].set_title("hematoxylin")  #ax[2].imshow(ihc_hed[:, :, 1], cmap=cmap_eosin) #ax[2].set_title("eosin")  #ax[3].imshow(ihc_hed[:, :, 2], cmap=cmap_dab) #ax[3].set_title("dab")  in ax.ravel():     a.axis('off')  fig.tight_layout() 

can 1 please help

ashay


Comments