├── setup.py ├── requirements.txt ├── image_processing ├── __init__.py ├── utils │ ├── __init__.py │ ├── io.py │ └── plot.py └── processing │ ├── __init__.py │ ├── transformation.py │ └── combination.py └── README.md /setup.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /image_processing/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /image_processing/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /image_processing/processing/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /image_processing/utils/io.py: -------------------------------------------------------------------------------- 1 | from skimage.io import imread, imsave 2 | 3 | def read_image(path, is_gray = False): 4 | image = imread(path, as_gray = is_gray) 5 | return image 6 | 7 | def save_image(image, path): 8 | imsave(path, image) -------------------------------------------------------------------------------- /image_processing/processing/transformation.py: -------------------------------------------------------------------------------- 1 | from skimage.transform import resize 2 | 3 | def resize_image(image, proportion): 4 | assert 0 <= proportion <= 1, "Specify a valid proportion between 0 and 1." 5 | height = round(image.shape[0] * proportion) 6 | width = round(image.shape[1] * proportion) 7 | image_resized = resize(image, (height, width), anti_aliasing=True) 8 | return image_resized -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # package_name 2 | 3 | Description. 4 | The package package_name is used to: 5 | - 6 | - 7 | 8 | ## Installation 9 | 10 | Use the package manager [pip](https://pip.pypa.io/en/stable/) to install package_name 11 | 12 | ```bash 13 | pip install package_name 14 | ``` 15 | 16 | ## Usage 17 | 18 | ```python 19 | from package_name.module1_name import file1_name 20 | file1_name.my_function() 21 | ``` 22 | 23 | ## Author 24 | My_name 25 | 26 | ## License 27 | [MIT](https://choosealicense.com/licenses/mit/) -------------------------------------------------------------------------------- /image_processing/processing/combination.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from skimage.color import rgb2gray 3 | from skimage.exposure import match_histograms 4 | from skimage.metrics import structural_similarity 5 | 6 | def find_difference(image1, image2): 7 | assert image1.shape == image2.shape, "Specify 2 images with de same shape." 8 | gray_image1 = rgb2gray(image1) 9 | gray_image2 = rgb2gray(image2) 10 | (score, difference_image) = structural_similarity(gray_image1, gray_image2, full=True) 11 | print("Similarity of the images:", score) 12 | normalized_difference_image = (difference_image-np.min(difference_image))/(np.max(difference_image)-np.min(difference_image)) 13 | return normalized_difference_image 14 | 15 | def transfer_histogram(image1, image2): 16 | matched_image = match_histograms(image1, image2, multichannel=True) 17 | return matched_image -------------------------------------------------------------------------------- /image_processing/utils/plot.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | 3 | def plot_image(image): 4 | plt.figure(figsize=(12, 4)) 5 | plt.imshow(image, cmap='gray') 6 | plt.axis('off') 7 | plt.show() 8 | 9 | def plot_result(*args): 10 | number_images = len(args) 11 | fig, axis = plt.subplots(nrows=1, ncols = number_images, figsize=(12, 4)) 12 | names_lst = ['Image {}'.format(i) for i in range(1, number_images)] 13 | names_lst.append('Result') 14 | for ax, name, image in zip(axis, names_lst, args): 15 | ax.set_title(name) 16 | ax.imshow(image, cmap='gray') 17 | ax.axis('off') 18 | fig.tight_layout() 19 | plt.show() 20 | 21 | def plot_histogram(image): 22 | fig, axis = plt.subplots(nrows=1, ncols = 3, figsize=(12, 4), sharex=True, sharey=True) 23 | color_lst = ['red', 'green', 'blue'] 24 | for index, (ax, color) in enumerate(zip(axis, color_lst)): 25 | ax.set_title('{} histogram'.format(color.title())) 26 | ax.hist(image[:, :, index].ravel(), bins = 256, color = color, alpha = 0.8) 27 | fig.tight_layout() 28 | plt.show() --------------------------------------------------------------------------------