Exemplo n.º 1
0
        # we add noise to the original position of the data
        for j in range(numCuts):
            # rotate image with normally distributed angle with sigma = 10 degrees
            normalDistAngle = np.random.normal(0, config['angleStddev'])
            cut.rotate(normalDistAngle)

            # generate random image center point in range -12 - + 12 from the current ceiled center point
            randomRadius = random.uniform(0, config['displacement'])
            randomPhi = random.uniform(0, 360)  # in degrees

            images[i + j * numImages] = cut.cut_to(
                (randomRadius * math.cos(math.radians(randomPhi)),
                 randomRadius * math.sin(math.radians(randomPhi))))

            t = cut.targets_normalized()
            tmp = []
            for t_ in t:
                for t__ in t_:
                    tmp.append(t__)
            targets[i + j * numImages] = tmp

        if i % 10 == 0:
            print(f'\rcompleted input image {i} of {numImages} images')

    print('Writing images and target information to file...')

    # write the images and their corresponding head positions to hdf5
    if args.mode == 'range':
        h5_filename = cut[
            'HDF5Directory'] + f'{numCuts:02d}_{args.start:08d}-{args.stop:08d}_{args.step:d}'