- Practical Computer Vision
- Abhinav Dadhich
- 264字
- 2021-06-30 18:54:51
Histogram equalization


Code for the preceding photos is as follows:
def plot_gray(input_image, output_image):
"""
Converts an image from BGR to RGB and plots
"""
# change color channels order for matplotlib
fig, ax = plt.subplots(nrows=1, ncols=2)
ax[0].imshow(input_image, cmap='gray')
ax[0].set_title('Input Image')
ax[0].axis('off')
ax[1].imshow(output_image, cmap='gray')
ax[1].set_title('Histogram Equalized ')
ax[1].axis('off')
plt.savefig('../figures/03_histogram_equalized.png')
plt.show()
def main():
# read an image
img = cv2.imread('../figures/flower.png')
# grayscale image is used for equalization
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# following function performs equalization on input image
equ = cv2.equalizeHist(gray)
# for visualizing input and output side by side
plot_gray(gray, equ)
if __name__ == '__main__':
main()
推薦閱讀
- 玩轉智能機器人程小奔
- Cloud Analytics with Microsoft Azure
- 模型制作
- Google App Inventor
- Data Wrangling with Python
- WordPress Theme Development Beginner's Guide(Third Edition)
- 四向穿梭式自動化密集倉儲系統的設計與控制
- Ceph:Designing and Implementing Scalable Storage Systems
- MATLAB/Simulink權威指南:開發環境、程序設計、系統仿真與案例實戰
- 分數階系統分析與控制研究
- Machine Learning with the Elastic Stack
- Hands-On Dashboard Development with QlikView
- 青少年VEX IQ機器人實訓課程(初級)
- Mastering Predictive Analytics with scikit:learn and TensorFlow
- Oracle 11g Anti-hacker's Cookbook