Code of Project Final
Code of Project Final
Image used :
Code :
import cv2
def click_event(event,x,y,flags,param):
if event==cv2.EVENT_LBUTTONDOWN:
font=cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(grayImage,coordinate1,(x,y),font,.5,(0,0,0),2)
cv2.putText(equaImage,coordinate2,(x,y),font,.5,(0,0,0),2)
grayImage=cv2.imread('image.png',0)
colorImage=cv2.imread('image.png')
cv2.imshow('grayImage',grayImage)
cv2.imshow('colorImage',colorImage)
cv2.imshow('equalizedImage',equaImage)
cv2.setMouseCallback('colorImage',click_event)
cv2.waitKey(0)
cv2.destroyAllWindows()
intensityCal.py : The code in this file serves as a helper to calculate the
intensity deposited by the ant at a point. In order to do so, various
operations like calculation of mean values, standard deviation, Gaussian
distribution function value are performed to assist the process of
intensity calculation.
x_array=[]
y_array=[]
for i in range(length):
x_array.append(sample[i][0])
y_array.append(sample[i][1])
mu_x=mean(x_array)
mu_y=mean(y_array)
mu=(mu_x,mu_y)
sigma_x=stdev(x_array)
sigma_y=stdev(y_array)
sigma=(sigma_x,sigma_y)
gaussian=gaussian_value(point,mu,sigma)
#Calculating pheromone intensity emitted by ant located
at point to target
pheromone_intensity=e**(-sqrt((point[0]-target[0])**2 + (point[1]-
target[1])**2))/(2*pow(gaussian,2))
return pheromone_intensity
import intensityCal
def intensity(colony,target):
pheromone_intensity=0
size=len(colony)
pheromone_intensity+=intensityCal.calculate(colony,point,target)
return pheromone_intensity