Created
April 24, 2018 07:05
-
-
Save nithikan/604decdfe82e160ba86693dbbb461002 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### Exercise 6 Create Voronoi diagram from UCF_CC annotations | |
##### | |
##### 24/04/2018 | |
##### Nithikan Srinakrung - Bam | |
##### DFL, FTSM, UKM | |
import cv2 | |
import numpy as np | |
import scipy.io as sio | |
im = cv2.imread("D:\\Coop\\UCF_CC_50\\50.jpg") | |
im_Black = np.zeros_like(im) | |
im_Black[10,10,2] = 255 | |
data = sio.loadmat("D:\\Coop\\UCF_CC_50\\50_ann.mat") | |
annPoints = data["annPoints"] | |
for ann in annPoints: | |
x = ann[0] | |
y = ann[1] | |
im_Black[y, x, 2] = 255 | |
print(x, y) | |
points = np.array(annPoints) | |
from scipy.spatial import Voronoi, voronoi_plot_2d | |
vor = Voronoi(points) | |
import matplotlib.pyplot as plt | |
voronoi_plot_2d(vor) | |
plt.show() | |
cv2.imshow("hey",im_Black) | |
cv2.waitKey(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment