def evaluateWindowsByLength(probabilityPath, geoLength): # Load information probabilityInformation = probability_store.Information(probabilityPath) multispectralImage, panchromaticImage = probabilityInformation.getImagePack() # Load regions regionGenerator = image_process.makeWindowGenerator(multispectralImage, panchromaticImage, geoLength, 1) regionPixelFrames = map(region_store.getMultispectralPixelFrame, regionGenerator) # Return return evaluateWindowsByRegions(probabilityPath, regionPixelFrames)
def scan(targetProbabilityPath, classifierPath, multispectralImagePath, panchromaticImagePath, scanRatio, regionFrames=None): # Initialize classify = load(classifierPath) classifierInformation = Information(classifierPath) windowLengthInMeters = classifierInformation.getWindowLengthInMeters() multispectralImage = image_store.load(multispectralImagePath) panchromaticImage = image_store.load(panchromaticImagePath) # If no regions are defined, if not regionFrames: # Use the entire image regionFrames = [(0, 0, multispectralImage.width, multispectralImage.height)] # Open probabilityFile probabilityFile = open(targetProbabilityPath, 'wt') # For each window, for regionIndex, regionFrame in enumerate(regionFrames): print 'Scanning region %s/%s...' % (regionIndex + 1, len(regionFrames)) for window in image_process.makeWindowGenerator(multispectralImage, panchromaticImage, windowLengthInMeters, scanRatio, regionFrame): # Classify classification_string = '%s %s' % classify(imageContent=window.extractImage()) windowLocation_string = '%s %s' % window.multispectralWindowLocation probabilityFile.write('%s %s\n' % (windowLocation_string, classification_string)) # Close probabilityFile probabilityFile.close()
def makeRegionGenerator(multispectralImage, panchromaticImage, regionLengthInWindows, windowLengthInMeters): return image_process.makeWindowGenerator(multispectralImage, panchromaticImage, regionLengthInWindows * windowLengthInMeters, 1)