Skip to content

Commit e97779d

Browse files
committed
Added plot_image function to sigmoidal
1 parent 2acda11 commit e97779d

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

sigmoidal/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from sigmoidal.utils.notebook import plot_image

sigmoidal/utils/__init__.py

Whitespace-only changes.

sigmoidal/utils/notebook.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from typing import List, Optional, Tuple
2+
3+
import cv2
4+
import matplotlib.pyplot as plt
5+
import numpy as np
6+
7+
8+
def plot_image(
9+
image: np.ndarray,
10+
size: Tuple[int, int] = (10, 10),
11+
cmap: Optional[str] = 'gray'
12+
) -> None:
13+
"""
14+
Exibe uma imagem carregada pelo OpenCV em um Jupyter notebook.
15+
16+
Parâmetros:
17+
image (np.ndarray): Imagem a ser exibida.
18+
size (tuple): Tamanho da figura na qual a imagem será exibida (largura, altura).
19+
cmap (str): Mapa de cores a ser usado se a imagem for em escala de cinza.
20+
21+
Retorno:
22+
None
23+
"""
24+
plt.figure(figsize=size)
25+
26+
if image.ndim == 2:
27+
plt.imshow(image, cmap=cmap)
28+
else:
29+
plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
30+
31+
plt.axis("off")
32+
plt.show()

0 commit comments

Comments
 (0)