def step(taskName, parameterByName, folderStore, options): # Get parameters classifierName = parameterByName['classifier name'] classifierPath = folderStore.getClassifierPath(classifierName) classifierInformation = folderStore.getClassifierInformation(classifierName) windowLengthInMeters = classifierInformation.getWindowLengthInMeters() scanRatio = parameterByName['scan ratio'] regionName = parameterByName['region name'] regionPath = folderStore.getRegionPath(regionName) regionInformation = folderStore.getRegionInformation(regionName) regionDataset = regionInformation.getRegionDataset() # Prepare imageName = regionInformation.getImageName() imagePath = folderStore.getImagePath(imageName) imageInformation = folderStore.getImageInformation(imageName) multispectralImagePath = imageInformation.getMultispectralImagePath() multispectralImage = image_store.load(multispectralImagePath) panchromaticImagePath = imageInformation.getPanchromaticImagePath() positiveLocationPath = imageInformation.getPositiveLocationPath() regionFrames = regionDataset.getRegionFrames() # Record targetProbabilityPath = folderStore.fillProbabilityPath(taskName) probabilityInformation = { 'classifier': { 'name': classifierName, 'path': classifierPath, }, 'parameters': { 'window length in meters': windowLengthInMeters, 'scan ratio': scanRatio, }, 'probability': { 'region name': regionName, 'region path': regionPath, 'image name': imageName, 'image path': imagePath, }, } store.saveInformation(targetProbabilityPath, probabilityInformation) # If this is not a test, if not options.is_test: # Scan info = classifier.scan(targetProbabilityPath, classifierPath, multispectralImagePath, panchromaticImagePath, scanRatio, regionFrames) # Save print 'Saving probability matrix as a shapefile...' probability_store.saveShapefile(targetProbabilityPath, targetProbabilityPath, image_store.load(multispectralImagePath), windowLengthInMeters) # Evaluate print 'Evaluating windows...' windowPerformance, wrongPixelCenters, actualPixelPointMachine = evaluation_process.evaluateWindows(targetProbabilityPath, positiveLocationPath, multispectralImagePath, windowLengthInMeters) probabilityInformation['performance'] = windowPerformance probabilityInformation['performance'].update(info) else: wrongPixelCenters = [] windowPixelWidth, windowPixelHeight = multispectralImage.convertGeoDimensionsToPixelDimensions(windowLengthInMeters, windowLengthInMeters) actualPixelPointMachine = point_process.PointMachine([], 'INTEGER', windowPixelWidth, windowPixelHeight) # Update store.saveInformation(targetProbabilityPath, probabilityInformation) # Build patch patch_process.buildPatchFromScan(wrongPixelCenters, folderStore, taskName, targetProbabilityPath, multispectralImagePath, panchromaticImagePath, actualPixelPointMachine, classifierInformation, options.is_test)
def step(taskName, parameterByName, folderStore, options): # Get parameters imageName = parameterByName['image name'] imagePath = folderStore.getImagePath(imageName) imageInformation = folderStore.getImageInformation(imageName) multispectralImagePath = imageInformation.getMultispectralImagePath() multispectralImage = image_store.load(multispectralImagePath) scanRatio = float(parameterByName['scan ratio']) classifierName = parameterByName['classifier name'] classifierPath = folderStore.getClassifierPath(classifierName) classifierInformation = folderStore.getClassifierInformation(classifierName) windowLengthInMeters = classifierInformation.getWindowLengthInMeters() panchromaticImagePath = imageInformation.getPanchromaticImagePath() positiveLocationPath = imageInformation.getPositiveLocationPath() coverageFraction = parameterByName.get('coverage fraction', 1) # Record targetProbabilityPath = folderStore.fillProbabilityPath(taskName) regionPath = targetProbabilityPath + '_region' probabilityInformation = { 'classifier': { 'name': classifierName, 'path': classifierPath, }, 'parameters': { 'window length in meters': windowLengthInMeters, 'scan ratio': scanRatio, 'coverage fraction': coverageFraction, }, 'probability': { 'region path': regionPath, 'image name': imageName, 'image path': imagePath, }, } # Run store.saveInformation(targetProbabilityPath, probabilityInformation) if not options.is_test: # Frame xMax = multispectralImage.width yMax = multispectralImage.height xMargin = int(xMax * (1 - coverageFraction) / 2) yMargin = int(yMax * (1 - coverageFraction) / 2) regionFrames = [(xMargin, yMargin, xMax - xMargin, yMax - yMargin)] regionDataset = region_store.save(regionPath, regionFrames) regionDataset.saveShapefile(regionPath, multispectralImage) # Scan info = classifier.scan(targetProbabilityPath, classifierPath, multispectralImagePath, panchromaticImagePath, scanRatio, regionFrames) # Save print 'Saving probability matrix as a shapefile...' probability_store.saveShapefile(targetProbabilityPath, targetProbabilityPath, multispectralImage, windowLengthInMeters) # Evaluate windows windowPerformance, wrongPixelCenters, actualPixelPointMachine = evaluation_process.evaluateWindows(targetProbabilityPath, positiveLocationPath, multispectralImagePath, windowLengthInMeters) probabilityInformation['performance'] = windowPerformance probabilityInformation['performance'].update(info) else: wrongPixelCenters = [] windowPixelWidth, windowPixelHeight = multispectralImage.convertGeoDimensionsToPixelDimensions(windowLengthInMeters, windowLengthInMeters) actualPixelPointMachine = point_process.PointMachine([], 'INTEGER', windowPixelWidth, windowPixelHeight) # Update store.saveInformation(targetProbabilityPath, probabilityInformation) # Save patch patch_process.buildPatchFromScan(wrongPixelCenters, folderStore, taskName, targetProbabilityPath, multispectralImagePath, panchromaticImagePath, actualPixelPointMachine, classifierInformation, options.is_test)