'''======================Sky Region Detection Part======================'''

    # Get new RDD: Sky Region for each image
    images_sky_region = images_d2.map(lambda x: ImageProcess.checkSkyRegion(x[1]))

    # Combine sky_region_color and sky_region_edge
    skyRegionPixelCount = (np.zeros((HEIGHT, WIDTH), np.uint8), np.zeros((HEIGHT, WIDTH), np.uint8), 0)
    pixel = sc.accumulator(skyRegionPixelCount, MatrixAccumulatorParam())
    images_sky_region.foreach(lambda x: pixel.add(x))
    
    images_count = pixel.value[2]

    # Generate sky-region-binary-image
    beta1 = 0.75
    beta2 = 0.5
    resultPic = ImageProcess.getSkyRegionMask(pixel.value[0], pixel.value[1], images_count * beta1, images_count * beta2)

    # Erode the sky-region-binary-image and mark three largest (if any) contour area.
    kernel = np.ones((5, 5), np.uint8)
    mask, cnts_new = ImageProcess.markDisjointSkyRegion(resultPic, kernel)

    # If detect more than one disjoint contour area, calculate correlation coefficient of each area.
    contour_num = len(cnts_new)
    if contour_num > 1:
        mask_b = sc.broadcast(mask)
        images_coefficient = images_d2.flatMap(lambda x: ImageProcess.get_R_Minus_B_Value(x[1], mask_b.value))
        coef_list = images_coefficient.groupByKey().mapValues(list).take(3)
        print (coef_list)

        ImageProcess.disjointRegionProcess(coef_list, contour_num, mask)