Reputation: 554
I have two 16-bit grayscale images. One is a subimage of the bigger image. They are centred. bigger and the smaller notice, that the smaller looks slightly brighter.
When the two are displayed, the smaller looks brighter. Basically what I would like to do is them to keep the same grayscale value representation, i.e. I would like the smaller image have the same intensity appearance as the bigger one (since the GS intensity values in the respective pixels are the same). Any suggestions ?
for j in xrange(windows_a.shape[0]):
print j
pl.imshow(windows_a[j], interpolation='nearest')
pl.xticks(np.arange(0,window_size_1,1))
pl.yticks(np.arange(0,window_size_1,1))
pl.gray()
pl.grid( color = 'y' )
pl.savefig('./IW_small/IW_small_' + str("%05d" %i) + "_" + str("%05d" %j) + '.png')
pl.close()
pl.imshow(windows_b[j], interpolation='nearest')
pl.xticks(np.arange(0,window_size_2,1))
pl.yticks(np.arange(0,window_size_2,1))
pl.gray()
pl.grid( color = 'y' )
pl.savefig('./IW_big/IW_big_' + str("%05d" %i) + "_" + str("%05d" %j) + '.png')
pl.close()
Upvotes: 1
Views: 204
Reputation: 24298
You may set the intensity values yourself using the vmin
and vmax
arguments of the imshow
function:
for j in xrange(windows_a.shape[0]):
print j
vmin, vmax = windows_b[j].min(), windows_b[j].max()
pl.imshow(windows_a[j], vmin=vmin, vmax=vmax, interpolation='nearest')
pl.xticks(np.arange(0,window_size_1,1))
pl.yticks(np.arange(0,window_size_1,1))
pl.gray()
pl.grid( color = 'y' )
pl.savefig('./IW_small/IW_small_' + str("%05d" %i) + "_" + str("%05d" %j) + '.png')
pl.close()
pl.imshow(windows_b[j], vmin=vmin, vmax=vmax, interpolation='nearest')
pl.xticks(np.arange(0,window_size_2,1))
pl.yticks(np.arange(0,window_size_2,1))
pl.gray()
pl.grid( color = 'y' )
pl.savefig('./IW_big/IW_big_' + str("%05d" %i) + "_" + str("%05d" %j) + '.png')
pl.close()
Additionally, I would recommend to use the interpolation='none'
argument, since that usually works better with vector graphics. This doesn't make a difference for you PNG file, though.
Upvotes: 4