示例#1
0
def ndvi(band3, band4):
	def crunch():
		size = cv.GetSize(band3)
		assert size == cv.GetSize(band4)
		numerator = cv.CreateImage(size, cv.IPL_DEPTH_32F, 1)
		cv.Sub(band4, band3, numerator)
		denominator = cv.CreateImage(size, cv.IPL_DEPTH_32F, 1)
		cv.Add(band4, band3, denominator)
		ndvi_img = cv.CreateImage(size, cv.IPL_DEPTH_32F, 1)
		cv.Div(numerator, denominator, ndvi_img)

		# (NDVI + 1)
		cv.AddS(ndvi_img, 1, ndvi_img)
		return ndvi_img

	def convert(ndvi_img):
		img8 = cv.CreateImage(cv.GetSize(ndvi_img), cv.IPL_DEPTH_8U, 1)
		# scaling as suggested in:
		# http://academic.emporia.edu/aberjame/remote/landsat/landsat_proc.htm
		cv.ConvertScale(ndvi_img, img8, 100) # includes rounding
		return img8

	band3 = cv.LoadImage(band3, 0)
	band4 = cv.LoadImage(band4, 0)
	img = profile.evaluate(crunch, "NDVI crunching")
	return profile.evaluate(lambda: convert(img), "NDVI converting")
示例#2
0
	def _(self):
		ok ( profile.evaluate(lambda: 1, '  ') ) == 1
示例#3
0
def count_lawn_grass(img):
	""" Feed me with band 4 """
	return profile.evaluate(lambda: count(img,185, 175), "Counting")
示例#4
0
def count_dry_grass(img):
	""" Feed me with band 3 """
	return profile.evaluate(lambda: count(img, 102, 74), "Counting")