Skip to content

Instantly share code, notes, and snippets.

@sriharsha0806
Created September 13, 2016 03:22
Show Gist options
  • Save sriharsha0806/bb4126b1c9556f275fff54f079453246 to your computer and use it in GitHub Desktop.
Save sriharsha0806/bb4126b1c9556f275fff54f079453246 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 10 21:51:12 2016
@author: sriharsha
"""
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('Fig0316(4)(bottom_left).tif')
# Image 1
cv2.imshow('Dark_image',img)
cv2.waitKey(100)
hist = cv2.calcHist([img],[0],None,[256],[0,256])
plt.hist(img.ravel(),256,[0,256])
plt.figure(1)
plt.title('Histogram of dark image')
plt.show()
# Image 2
img1 = cv2.imread('Fig0316(3)(third_from_top).tif')
cv2.imshow('contrast_image',img1)
cv2.waitKey(100)
hist = cv2.calcHist([img1],[0],None,[256],[0,256])
plt.figure(2)
plt.hist(img1.ravel(),256,[0,256])
plt.title('Histogram of contrast Image')
plt.show()
# Image 3
img2 = cv2.imread('Fig0316(2)(2nd_from_top).tif')
cv2.imshow('low contrast image',img2)
cv2.waitKey(100)
hist = cv2.calcHist([img2],[0],None,[256],[0,256])
plt.figure(3)
plt.hist(img2.ravel(),256,[0,256])
plt.title('Histogram of low contrast image')
plt.show()
# Image 4
img3 = cv2.imread('Fig0316(1)(top_left).tif')
cv2.imshow('light image',img3)
cv2.waitKey(100)
hist = cv2.calcHist([img3],[0],None,[256],[0,256])
plt.figure(4)
plt.hist(img3.ravel(),256,[0,256])
plt.title('histogram of light image')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment