python 2.7 - vertical line in histogram with pyplot -


i've computed otsu's thresholding kinect depth image , want point out optimal thresholding value on histogram, using example axvline pyplot in opencv2. i'm beginner python , programming too, specific part of code:

fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(8, 2.5)) ax1.imshow(img) ax1.set_title('original') ax1.axis('off')  ax2.hist(img) ax2.set_title('histogram') plt.axvline(x=thresh, color='r', linestyle='dashed', linewidth=2)  ax3.imshow(binary, cmap=plt.cm.gray) ax3.set_title('thresholded') ax3.axis('off')  plt.show() 

but don't know why, obtain vertical line on thresholded plot

what doing wrong?? thanks

works me:

from scipy.misc import imread, imresize import matplotlib.pyplot plt f = r"c:\users\public\pictures\sample pictures\lighthouse.jpg" img = imread(f)[:, :, 0] fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(8, 2.5)) ax1.imshow(img) ax1.set_title('original') ax1.axis('off')  thresh = 100 ax2.hist(img) ax2.set_title('histogram') ax2.axvline(x=thresh, color='r', linestyle='dashed', linewidth=2)  ax3.imshow(img, cmap=plt.cm.gray) ax3.set_title('thresholded') ax3.axis('off')  plt.show() 

enter image description here


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -