Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- Created on Sat Jul 14 23:59:48 2018
- @author: Callmetorre
- """
- import cv2
- import numpy as np
- import matplotlib.pyplot as plt
- def getGreenImage(img):
- R = img[:, :, 0]
- G = img[:, :, 1]
- B = img[:, :, 2]
- return R * 0 + G * 1 + B * 0
- def printImage(img):
- f = plt.figure()
- f.add_subplot(1,2, 1)
- plt.imshow(img, cmap='gray')
- def getIntensities(img):
- intensities = []
- for x in range(0, img.shape[0]):
- for y in range(0, img.shape[1]):
- if img[x,y] > 100:
- temp = (x, y)
- intensities.append(temp)
- return intensities
- #def equalization(hist):
- # cdf = hist.cumsum()
- # cdf_m = np.ma.masked_equal(cdf,0)
- # cdf_m = (cdf_m - cdf_m.min())*255/(cdf_m.max()-cdf_m.min())
- # cdf = np.ma.filled(cdf_m,0).astype('uint8')
- # return cdf
- img = cv2.imread('/Users/Callmetorre/Desktop/image015.png')
- img_gray_green = getGreenImage(img)
- #hist = cv2.calcHist([img], [0], None, [256], [0, 256]).flatten()
- #algo = equalization(hist)
- filtered_img = cv2.medianBlur(img_gray_green, 49)
- intensities = getIntensities(img_gray_green)
- printImage(img_gray_green)
- printImage(filtered_img)
- #printImage(algo[img_gray_green])
Add Comment
Please, Sign In to add comment