예제 #1
0
         allGT[:, 1, total_count]] = interpolate.splev(np.linspace(0, 1, L),
                                                       tck)
        # Get DWT polygons
        num_points = np.int32(corners_dwt[0])
        poly = np.zeros([num_points, 2])
        for c in range(num_points):
            poly[c, 0] = np.float(corners_dwt[1 + 2 * c]) * out_size / im_size
            poly[c, 1] = np.float(corners_dwt[2 + 2 * c]) * out_size / im_size
        [tck, u] = interpolate.splprep([poly[:, 0], poly[:, 1]],
                                       s=2,
                                       k=1,
                                       per=1)
        [allDWT[:, 0, total_count],
         allDWT[:, 1,
                total_count]] = interpolate.splev(np.linspace(0, 1, L), tck)
        if polygon_area(allDWT[:, 0, total_count], allDWT[:, 1,
                                                          total_count]) < 0:
            allDWT[:, :, total_count] = allDWT[::-1, :, total_count]
        # Get image and GT mask
        all_building_names.append(tile_name + '_building_' +
                                  str(i + 1).zfill(4) + '.png')
        all_building_sizes.append((np.float32(bb[2]) + np.float32(bb[3])) / 2)
        i += 1
        total_count += 1

allGT = np.minimum(allGT, out_size - 1)
allGT = np.maximum(allGT, 0)
allDWT = np.minimum(allDWT, out_size - 1)
allDWT = np.maximum(allDWT, 0)

all_relative_sizes = np.stack(all_building_sizes) / min(
    np.stack(all_building_sizes))
예제 #2
0
                                       per=1)
        [GT[:, 0, i], GT[:, 1, i]] = interpolate.splev(np.linspace(0, 1, L),
                                                       tck)
        # Get DWT polygons
        num_points = np.int32(corners_dwt[0])
        poly = np.zeros([num_points, 2])
        for c in range(num_points):
            poly[c, 0] = np.float(corners_dwt[1 + 2 * c]) * out_size / im_size
            poly[c, 1] = np.float(corners_dwt[2 + 2 * c]) * out_size / im_size
        [tck, u] = interpolate.splprep([poly[:, 0], poly[:, 1]],
                                       s=2,
                                       k=1,
                                       per=1)
        [DWT[:, 0, i], DWT[:, 1,
                           i]] = interpolate.splev(np.linspace(0, 1, L), tck)
        if polygon_area(DWT[:, 0, i], DWT[:, 1, i]) < 0:
            DWT[:, :, i] = DWT[::-1, :, i]
        # Get image and GT mask
        this_im = scipy.misc.imread(images_path + tile_name + '_building_' +
                                    str(i + 1).zfill(4) + '.png')
        images[:, :, :, i] = scipy.misc.imresize(this_im, [im_size, im_size])
        this_mask = scipy.misc.imread(gt_path + tile_name + '_building_' +
                                      str(i + 1).zfill(4) + '.png')
        masks[:, :, 0,
              i] = scipy.misc.imresize(this_mask, [out_size, out_size],
                                       interp='nearest') > 0
        i += 1

GT = np.minimum(GT, out_size - 1)
GT = np.maximum(GT, 0)
DWT = np.minimum(DWT, out_size - 1)