From 2d059f7146e222667927993279ca192922caae4a Mon Sep 17 00:00:00 2001 From: Vinicius_Vidal Date: Sun, 29 Sep 2024 18:17:11 -0300 Subject: [PATCH 1/3] criando o projeto --- package_name/combination.py | 17 +++++++++++++++++ package_name/file1_name.py | 0 package_name/file2_name.py | 0 package_name/transformation.py | 6 ++++++ setup.py | 2 +- 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 package_name/combination.py delete mode 100644 package_name/file1_name.py delete mode 100644 package_name/file2_name.py create mode 100644 package_name/transformation.py diff --git a/package_name/combination.py b/package_name/combination.py new file mode 100644 index 0000000..cddbecc --- /dev/null +++ b/package_name/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 the same shape" + gray_image1 = rgb2gray(image1) + gray_image2 = rgb2gray(image2) + (score, difference_image) = structural_similarity(gray_image1, gray_image2, full=True) + print(f"Similarity of the images:", score) + normalized_difference_image =(difference_image-np.min(difference_image))/x(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/package_name/file1_name.py b/package_name/file1_name.py deleted file mode 100644 index e69de29..0000000 diff --git a/package_name/file2_name.py b/package_name/file2_name.py deleted file mode 100644 index e69de29..0000000 diff --git a/package_name/transformation.py b/package_name/transformation.py new file mode 100644 index 0000000..4dc00b7 --- /dev/null +++ b/package_name/transformation.py @@ -0,0 +1,6 @@ +from skimage.transform import resize + +def resize_image(image, proportion): + assert 0 <= proportion <= 1, "Specify a valid proportion between 0 and 1." + + \ No newline at end of file diff --git a/setup.py b/setup.py index 4b4dc95..09c86cf 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ description="My short description", long_description=page_description, long_description_content_type="text/markdown", - url="my_github_repository_project_link" + url="my_github_repository_project_link", #eu adicionei essa virgula, se der pau, remover packages=find_packages(), install_requires=requirements, python_requires='>=3.8', From b1846d53946f8e8c260c88a408fab1002972b3c0 Mon Sep 17 00:00:00 2001 From: Vinicius_Vidal Date: Sun, 29 Sep 2024 18:49:46 -0300 Subject: [PATCH 2/3] criando o projeto --- package_name/combination.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package_name/combination.py b/package_name/combination.py index cddbecc..170c3cf 100644 --- a/package_name/combination.py +++ b/package_name/combination.py @@ -9,7 +9,7 @@ def find_difference(image1, image2): gray_image2 = rgb2gray(image2) (score, difference_image) = structural_similarity(gray_image1, gray_image2, full=True) print(f"Similarity of the images:", score) - normalized_difference_image =(difference_image-np.min(difference_image))/x(np.max(difference_image)-np.min(difference_image)) + 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): From 998be89bffd014a076fc8fea99d9a9a6ce4dedb5 Mon Sep 17 00:00:00 2001 From: Vinicius_Vidal Date: Tue, 8 Oct 2024 20:56:45 -0300 Subject: [PATCH 3/3] projeto finalizado --- README.md | 13 +++++++--- package_name/transformation.py | 6 ----- {package_name => processing}/__init__.py | 0 {package_name => processing}/combination.py | 0 processing/transformation.py | 8 ++++++ requirements.txt | 3 +++ utils/__init__.py | 0 utils/io.py | 7 ++++++ utils/plot.py | 28 +++++++++++++++++++++ 9 files changed, 56 insertions(+), 9 deletions(-) delete mode 100644 package_name/transformation.py rename {package_name => processing}/__init__.py (100%) rename {package_name => processing}/combination.py (100%) create mode 100644 processing/transformation.py create mode 100644 utils/__init__.py create mode 100644 utils/io.py create mode 100644 utils/plot.py diff --git a/README.md b/README.md index 0912af1..4e026cd 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,15 @@ Description. The package package_name is used to: - - - - + - Processing + - Histogram matching + - Structural similaryty + - Utils: + - Read image + - Save image + - Plot image + - Plot result + - Plot histogram ## Installation @@ -21,7 +28,7 @@ file1_name.my_function() ``` ## Author -My_name +Vinicius ## License [MIT](https://choosealicense.com/licenses/mit/) \ No newline at end of file diff --git a/package_name/transformation.py b/package_name/transformation.py deleted file mode 100644 index 4dc00b7..0000000 --- a/package_name/transformation.py +++ /dev/null @@ -1,6 +0,0 @@ -from skimage.transform import resize - -def resize_image(image, proportion): - assert 0 <= proportion <= 1, "Specify a valid proportion between 0 and 1." - - \ No newline at end of file diff --git a/package_name/__init__.py b/processing/__init__.py similarity index 100% rename from package_name/__init__.py rename to processing/__init__.py diff --git a/package_name/combination.py b/processing/combination.py similarity index 100% rename from package_name/combination.py rename to processing/combination.py diff --git a/processing/transformation.py b/processing/transformation.py new file mode 100644 index 0000000..28bec14 --- /dev/null +++ b/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/requirements.txt b/requirements.txt index e69de29..8f4c470 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1,3 @@ +matplotlib +numpy +scikit-image >= 0.16.1 \ No newline at end of file diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/utils/io.py b/utils/io.py new file mode 100644 index 0000000..abfb0a4 --- /dev/null +++ b/utils/io.py @@ -0,0 +1,7 @@ +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/utils/plot.py b/utils/plot.py new file mode 100644 index 0000000..92be4e8 --- /dev/null +++ b/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.light_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