def get_imgs_block(img_ids, img_dir_path): images = [] for img_id in img_ids: image = get_img_file_path(img_id, img_dir_path) if image is not None: cvimage = imread(image) cvimage = preprocess.scale_max(cvimage, 100, 100) images.append(cvimage) else: logging.error("Image %s is missing. Database and download folder are inconsistent.", img_id) images.append(np.ones((100, 100))) return images
def preprocess_canny(_image_files): processed_images = [] for image_file in _image_files: img = imread(image_file) img = preprocess.autocrop(img) img = preprocess.scale_max(img) img = preprocess.make_square(img) img = preprocess.grey(img) img = preprocess.canny(img) processed_images.append(img) mosaic_images = mosaic((len(processed_images)), processed_images) return mosaic_images
def get_imgs_block(img_ids, img_dir_path): images = [] for img_id in img_ids: image = get_img_file_path(img_id, img_dir_path) if image is not None: cvimage = imread(image) cvimage = preprocess.scale_max(cvimage, 100, 100) images.append(cvimage) else: logging.error( "Image %s is missing. Database and download folder are inconsistent.", img_id) images.append(np.ones((100, 100))) return images
def image_raw_preprocessing(img_stream): """Decode the raw data from url into an image, crops and makes square :param img_stream: raw data from url :return: processed img """ image_squared = None image_decoded = imdecode(np.fromstring(img_stream.content, np.uint8), flags=IMREAD_COLOR) if image_decoded is not None: try: image_autocropped = preprocess.autocrop(image_decoded) except AttributeError as e: LOGGER.error(e) return image_squared if image_autocropped is not None: image_scaled_max = preprocess.scale_max(image_autocropped) image_squared = preprocess.make_square(image_scaled_max) return image_squared
def preprocess_super_simple(_image_files): processed_images = [] for image_file in _image_files: img = imread(image_file) img = preprocess.autocrop(img) img = preprocess.scale_max(img) img = preprocess.make_square(img) img = preprocess.blur( img, gaussian_blur={"enabled": True, "ksize_width": 5, "ksize_height": 5, "sigmaX": 0} ) img = preprocess.grey(img) img = preprocess.bitwise(img) processed_images.append(img) mosaic_image = mosaic(len(processed_images), processed_images) return mosaic_image
def acquire_img(img_id, path): """Retrieve and process img from folder. Retrieve image from folder, scale it, applies grayscale, and reshape it to (1, 100, 100) Args: img_id (str): path (str): Returns: numpy.array: img array """ img_path = get_img_file_path(img_id, path) img = imread(img_path) img_gray = preprocess.grey(img) img_resized = preprocess.scale_max(img_gray, IMG_SIZE, IMG_SIZE) img_reshaped = np.reshape(img_resized, (1, 100, 100)) return img_reshaped
def preprocess_super_simple(_image_files): processed_images = [] for image_file in _image_files: img = imread(image_file) img = preprocess.autocrop(img) img = preprocess.scale_max(img) img = preprocess.make_square(img) img = preprocess.blur(img, gaussian_blur={ "enabled": True, "ksize_width": 5, "ksize_height": 5, "sigmaX": 0 }) img = preprocess.grey(img) img = preprocess.bitwise(img) processed_images.append(img) mosaic_image = mosaic(len(processed_images), processed_images) return mosaic_image