def ex1(image_filename, encoded_filename): # image_filename = images.load(image_filename) rettangoli = vertici(image_filename) ordine = lista_ordine(rettangoli) enc = encodedimage(rettangoli) images.save(enc, encoded_filename) return boundingbox(rettangoli)
def saveFinalOverlay(settings,image,edge,image_name): ''' # Overlay unsmoothed edge on original image (grayscale) and save resulting image ''' bg = cv2.cvtColor(image,cv2.COLOR_RGB2GRAY) overlay = np.where(edge == 255,255,bg) filename = os.path.join(settings['out_directory'],'outlines','_'.join([settings['sampleID'],image_name,'final.tif'])) images.save(overlay,filename) # If save_intermediates is on, copy the final image into the intermediates # folder for easier comparison of image filter results if settings['save_intermediates']: shutil.copy2(filename,os.path.join(settings['out_directory'],'intermediates'))
def fetch_by_size(target_size): size, path = images.pick_by_size(target_size) url = images.BASE_URL + path octets = fetch(url) name = images.save(url, octets) return (size, name)
def final(orig_filename, box_list, run, plane_num, image=None): if image is None: image = images.load(orig_filename, run) image_size = np.shape(image) # [width, height] for box_num, box in enumerate(box_list): # crop expects [x1, y1, x2, y2], box is [y1, x1, y2, x2] crop_box = [box[1], box[0], box[3], box[2]] width = crop_box[2] - crop_box[0] height = crop_box[3] - crop_box[1] image_subsample = images.crop(image, crop_box) x_percent = float(crop_box[0]) / float(image_size[1]) * 100 y_percent = float(crop_box[1]) / float(image_size[0]) * 100 description = 'Object #%05d of %05d ( %d x %d pixels at slide position %05.2f x %05.2f )' \ % (box_num+1, len(box_list), width, height, x_percent, y_percent) labeled_image_subsample, label = images.label_image( image_subsample, orig_filename, description, run) object_directory = '%s%s%s_obj%05d' % (run['full_output'], os.sep, run['unique_id'], box_num + 1) if not os.path.exists(object_directory): os.makedirs(object_directory) print object_directory output_filename = '%s%s%s_obj%05d_plane%03d.%s' % ( object_directory, os.sep, run['unique_id'], box_num + 1, plane_num, run['output_ext']) tags = images.add_comment(output_filename, '. '.join(label)) print output_filename images.save(labeled_image_subsample, output_filename, tags=tags)
def final(orig_filename, box_list, run, plane_num, image=None): if image is None: image = images.load(orig_filename, run) image_size = np.shape(image) # [width, height] for box_num, box in enumerate(box_list): # crop expects [x1, y1, x2, y2], box is [y1, x1, y2, x2] crop_box = [box[1], box[0], box[3], box[2]] width = crop_box[2] - crop_box[0] height = crop_box[3] - crop_box[1] image_subsample = images.crop(image, crop_box) x_percent = float(crop_box[0]) / float(image_size[1]) * 100 y_percent = float(crop_box[1]) / float(image_size[0]) * 100 description = 'Object #%05d of %05d ( %d x %d pixels at slide position %05.2f x %05.2f )' \ % (box_num+1, len(box_list), width, height, x_percent, y_percent) labeled_image_subsample, label = images.label_image(image_subsample, orig_filename, description, run) object_directory = '%s%s%s_obj%05d' % (run['full_output'], os.sep, run['unique_id'], box_num+1) if not os.path.exists(object_directory): os.makedirs(object_directory) print object_directory output_filename = '%s%s%s_obj%05d_plane%03d.%s' % (object_directory, os.sep, run['unique_id'], box_num+1, plane_num, run['output_ext']) tags = images.add_comment(output_filename, '. '.join(label)) print output_filename images.save(labeled_image_subsample, output_filename, tags=tags)
def save(item, params, image, userId): if Item.validParams(params, image): item.name = params['name'] # item.categoryId = int(params['category']) item.category = db.getOne(Category, "id", params['category']) item.description = params['description'].strip() # item.userId = userId item.user = db.getOne(User, "email", userId) db.session.add(item) db.session.flush() url = images.save(image, item) if url: item.image = url db.session.commit() flash("%s has been saved" % item.name) return True return False
def ex1(image_filename, encoded_filename): rettangoli = vertici(image_filename) enc = encodedimage(rettangoli) images.save(enc, encoded_filename) return boundingbox(rettangoli)
def saveIntermediates(settings,image,image_name,tag): ''' Saves intermediate files (output of each individual image filter). ''' images.save(image,os.path.join(settings['out_directory'],'intermediates','_'.join([settings['sampleID'],image_name,tag])))