Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Criando pacote de processamento de imagem no Pypi #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/package-template.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

134 changes: 134 additions & 0 deletions ProcessamentoImagem.ipynb

Large diffs are not rendered by default.

41 changes: 27 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
# package_name
# processador_imagem

Description.
The package package_name is used to:
-
-
The package processador_imagem is used to:
Processing:
- Histogram matching
- Structural similarity
-Resize image
Utils:
-Read image
-Save image
-Plot image
-Plot result
-Plot histogram

O pacote package processador_imagem é usado para:
Processing:
- Correspondência de histograma
- Semelhança estrutural
-Redimensionar imagem
Utils:
-Ler imagens
-Gravar imagens
-Plot imagem
-Plot resultado
-Plot histograma

## 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.module1_name import file1_name
file1_name.my_function()
pip install processador_imagem
```

## Author
My_name
Uiliam

## License
[MIT](https://choosealicense.com/licenses/mit/)
[MIT](https://choosealicense.com/licenses/mit/)
46 changes: 46 additions & 0 deletions Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"id": "b1bff931",
"metadata": {},
"outputs": [],
"source": [
"from image_processing.utils import io, plot\n",
"from image_processing.processing import combination, transformation"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3e8834a4",
"metadata": {},
"outputs": [],
"source": [
"io.read_image('/home/uiliam/Downloads/green-forest')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
File renamed without changes.
22 changes: 22 additions & 0 deletions image_processing/processing/combination.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from nis import match
from unicodedata import normalize
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("Similarity of the images:", score)
normalized_difference_image = (difference_image.np.min(difference_image)) / (
np.max(difference_image).npmin(difference_image))
return normalized_difference_image


def transfer_histogram(image1, image2):
matched_image = match_histograms(image1, image2, multichannel=True)
return matched_image
10 changes: 10 additions & 0 deletions image_processing/processing/transformation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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 = resized = resize(image, (height, width), anti_aliasing=True)
return image_resized

10 changes: 10 additions & 0 deletions image_processing/utils/io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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)
31 changes: 31 additions & 0 deletions image_processing/utils/plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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()
Empty file.
Empty file.
Empty file.
Empty file.
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
setuptools
scikit-image
numpy
matplotlib
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
requirements = f.read().splitlines()

setup(
name="package_name",
name="processador_imagem",
version="0.0.1",
author="my_name",
author_email="my_email",
description="My short description",
author="Uiliam bomfim",
author_email="[email protected]",
description="pacote de processamento de imagens",
long_description=page_description,
long_description_content_type="text/markdown",
url="my_github_repository_project_link"
url="https://github.com/UiliamBomfim/package-template",
packages=find_packages(),
install_requires=requirements,
python_requires='>=3.8',
Expand Down