Beispiel #1
0
# %% Read and Format .png Files

# Get Image Files and Names
pngs = vs.search_files('.*\\.png$', top='./data/', recursive=False)
services = [int(re.sub(r'\D*([0-9]+).*', r'\1', png)) for png in pngs]

# Clean Service Number for Joining of Images and Target
targets = pdfs[['quoted_materials', 'service_number']]
targets.service_number = targets.service_number.apply(lambda x:
                                                      int(re.sub('\D', '', x)))
targets = targets.drop('quoted_materials', 1)
# Create Perimeter Target Variable
targets['perim'] = targets.quoted_materials.transform(lambda x: x / 1.54)

# Process Images
init_cad = io.call_plugin('imread', fname=pngs[0])
init_cad = color.rgb2gray(init_cad)
init_cad = transform.resize(init_cad, (612, 792)).ravel().reshape(1, -1)
cads = init_cad
i = 2
for png in pngs[1:]:
    print('Processing image {}/895: {:.2%}'.format(i, i / len(pngs)))
    i += 1
    cad = io.call_plugin('imread', fname=png)
    cad = color.rgb2gray(cad)
    cad = transform.resize(cad, (612, 792)).ravel().reshape(1, -1)
    cads = np.vstack((cads, cad))

# Save Data
# np.save('./data/cads_pixels', cads)
Beispiel #2
0
def download_image(url):
    logging.info("downloading {}".format(url))
    fd = urllib.urlopen(url)
    img = io.call_plugin('imread', fd, plugin='pil')
    return img
Beispiel #3
0
def download_image(url):
    fd = urllib.urlopen(url)
    img = io.call_plugin('imread', fd, plugin='pil')
    return img
Beispiel #4
0
def load_local_image(path):
    fd = open(path, "rb")
    img = io.call_plugin('imread', fd, plugin='pil')
    return img