diff --git a/README.md b/README.md index 0912af1..5fb2d52 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,23 @@ Description. The package package_name is used to: - - - - + Processing: + - Histogram matching + - Sttructural similarity + - Resize image + Utils: + - Read image + - Save image + - Plot image + - Plot result + - Plot histogram ## Installation Use the package manager [pip](https://pip.pypa.io/en/stable/) to install package_name ```bash -pip install package_name -``` - -## Usage - -```python -from package_name import file1_name -file1_name.my_function() +pip install image-processing-package ``` ## Author diff --git a/package_name/__init__.py b/image-processing-package/__init__.py similarity index 100% rename from package_name/__init__.py rename to image-processing-package/__init__.py diff --git a/package_name/file1_name.py b/image-processing-package/image_processing/__init__.py similarity index 100% rename from package_name/file1_name.py rename to image-processing-package/image_processing/__init__.py diff --git a/image-processing-package/image_processing/combination.py b/image-processing-package/image_processing/combination.py new file mode 100644 index 0000000..a75ecbd --- /dev/null +++ b/image-processing-package/image_processing/combination.py @@ -0,0 +1,17 @@ +import numpy as np +from skimage.color import rgb2gray +from skimage.exposure import match_histograms +from skimage.metrics import structural_similarity + +def find_difference(image1, image2): + assert image1.shape == image2.shape, "Specify 2 images with de same shape." + gray_image1 = rgb2gray(image1) + gray_image2 = rgb2gray(image2) + (score, difference_image) = structural_similarity(gray_image1, gray_image2, full=True) + print("Similarity of the images:", score) + normalized_difference_image = (difference_image-np.min(difference_image))/(np.max(difference_image)-np.min(difference_image)) + return normalized_difference_image + +def transfer_histogram(image1, image2): + matched_image = match_histograms(image1, image2, multichannel=True) + return matched_image \ No newline at end of file diff --git a/image-processing-package/image_processing/transformation.py b/image-processing-package/image_processing/transformation.py new file mode 100644 index 0000000..a726ada --- /dev/null +++ b/image-processing-package/image_processing/transformation.py @@ -0,0 +1,8 @@ +from skimage.transform import resize + +def resize_image(image, proportion): + assert 0 <= proportion <= 1, "Specify a valid proportion between 0 and 1." + height = round(image.shape[0] * proportion) + width = round(image.shape[1] * proportion) + image_resized = resize(image, (height, width), anti_aliasing=True) + return image_resized \ No newline at end of file diff --git a/package_name/file2_name.py b/image-processing-package/utils/__init__.py similarity index 100% rename from package_name/file2_name.py rename to image-processing-package/utils/__init__.py diff --git a/image-processing-package/utils/io.py b/image-processing-package/utils/io.py new file mode 100644 index 0000000..12d396f --- /dev/null +++ b/image-processing-package/utils/io.py @@ -0,0 +1,8 @@ +from skimage.io import imread, imsave + +def read_image(path, is_gray = False): + image = imread(path, as_gray = is_gray) + return image + +def save_image(image, path): + imsave(path, image) \ No newline at end of file diff --git a/image-processing-package/utils/plot.py b/image-processing-package/utils/plot.py new file mode 100644 index 0000000..a59c556 --- /dev/null +++ b/image-processing-package/utils/plot.py @@ -0,0 +1,28 @@ +import matplotlib.pyplot as plt + +def plot_image(image): + plt.figure(figsize=(12, 4)) + plt.imshow(image, cmap='gray') + plt.axis('off') + plt.show() + +def plot_result(*args): + number_images = len(args) + fig, axis = plt.subplots(nrows=1, ncols = number_images, figsize=(12, 4)) + names_lst = ['Image {}'.format(i) for i in range(1, number_images)] + names_lst.append('Result') + for ax, name, image in zip(axis, names_lst, args): + ax.set_title(name) + ax.imshow(image, cmap='gray') + ax.axis('off') + fig.tight_layout() + plt.show() + +def plot_histogram(image): + fig, axis = plt.subplots(nrows=1, ncols = 3, figsize=(12, 4), sharex=True, sharey=True) + color_lst = ['red', 'green', 'blue'] + for index, (ax, color) in enumerate(zip(axis, color_lst)): + ax.set_title('{} histogram'.format(color.title())) + ax.hist(image[:, :, index].ravel(), bins = 256, color = color, alpha = 0.8) + fig.tight_layout() + plt.show() \ No newline at end of file diff --git a/setup.py b/setup.py index 4b4dc95..0b09ee2 100644 --- a/setup.py +++ b/setup.py @@ -7,14 +7,14 @@ requirements = f.read().splitlines() setup( - name="package_name", + name="image-processing-package", version="0.0.1", - author="my_name", - author_email="my_email", - description="My short description", + author="Heliton", + author_email="", + description="Processar Imagens", long_description=page_description, long_description_content_type="text/markdown", - url="my_github_repository_project_link" + url="https://github.com/hprimo/image-processing-package", packages=find_packages(), install_requires=requirements, python_requires='>=3.8',