def grid_coordinates(roi, x_divisions, y_divisions, position):
	"""
	Function that returns the grid coordinates of a given position.
	To do so it computes, for a given area and taking into account
	the number of x and y divisions which is the total amount of cells.
	After that it maps the given position to the cell it falls inside and
	returns the coordinates of that cell. Finally, it is assumed that 
	the position is always inside the grid
	:param roi: region of interest to be gridezied
	:param x_divisions:number of divisions in the x axis
	:param y_divisions:number of divisions in the y axis
	:param position: position to transform into grid coordinates 
	"""
	px_per_x_division = float(roi[0][1]-roi[0][0])/x_divisions
	px_per_y_division = float(roi[1][1]-roi[1][0])/y_divisions
	x_in_grid = position[0] - roi[0][0]
	y_in_grid = position[1] - roi[1][0]
	return (int(x_in_grid/px_per_x_division), int(y_in_grid/px_per_y_division))