print path # Get SKY REGION MASK sky_region_mask = ImageProcess.getSkyRegion(path) # Get Sun Orbit among three-day image stream using SUN REGION MASK sun_orbit = [] sun_orbit = ImageProcess.getSunOrbit(path_1, path_2, path_3, sky_region_mask) # Get Centroid of all the Detected Sun in sun_orbit. centroid_list = [] centroid_list = ImageProcess.getCentroidList(sun_orbit) # Fit the centroid list sample to a quadratic equation(general parabola). theta, coeffs = ImageProcess.generalParabola(centroid_list) # Detect sun of test image img_centroid_radius = ImageProcess.sunDetect(filename, sky_region_mask) # percentage = 0.0 if img_centroid_radius is not None and ImageProcess.sunDetectUsingOrbit(img_centroid_radius, theta, coeffs): # Sun Detected! percentage = ImageProcess.calculateCloudCoverage(filename, sky_region_mask, img_centroid_radius) else: percentage = ImageProcess.calculateCloudCoverage(filename, sky_region_mask) print 'Cloud Coverage = ', percentage cv2.imshow('final result', sky_region_mask) cv2.waitKey(0)
l1, l2_1, l2_3, l3 = ImageProcess.findMatchingFilenameBetweenTwoDay(images_d1_filename_list, images_d2_filename_list, images_d3_filename_list) print ("l1 length = " , len(l1)) print ("l2_1 length = " , len(l2_1)) print ('l2_3 length =', len(l2_3)) print ('l3 length = ', len(l3)) print ("l3 = ", l3) # Get filtered file in each day images_d1_filter = images_d1.filter(lambda x: x[0] in l1) images_d21_filter = images_d2.filter(lambda x: x[0] in l2_1) images_d23_filter = images_d2.filter(lambda x: x[0] in l2_3) images_d3_filter = images_d3.filter(lambda x: x[0] in l3) # For each filtered file, apply Sun Detect Function images_d1_sunDetect = images_d1_filter.map(lambda x: ImageProcess.sunDetect(x[1], sky_region_mask.value)) images_d21_sunDetect = images_d21_filter.map(lambda x: ImageProcess.sunDetect(x[1], sky_region_mask.value)) images_d23_sunDetect = images_d23_filter.map(lambda x: ImageProcess.sunDetect(x[1], sky_region_mask.value)) images_d3_sunDetect = images_d3_filter.map(lambda x: ImageProcess.sunDetect(x[1], sky_region_mask.value)) # Sun Intersection Detect. (Note: coalesce to only ONE group to do this.) images_d12_intersect = images_d1_sunDetect.coalesce(1).zip(images_d21_sunDetect.coalesce(1)).filter(lambda x: x[0] is not None and x[1] is not None and ImageProcess.intersectionDetect(x[0], x[1])).collect() images_d23_intersect = images_d3_sunDetect.coalesce(1).zip(images_d23_sunDetect.coalesce(1)).filter(lambda x: x[0] is not None and x[1] is not None and ImageProcess.intersectionDetect(x[0], x[1])).collect() print (images_d12_intersect) print (images_d23_intersect) # Get intersection sun centroid list centroid_list = ImageProcess.getCentroidList(images_d12_intersect + images_d23_intersect) print (centroid_list)