ImagePRO-Python 1.0.5__py3-none-any.whl → 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ImagePRO/pre_processing/histogram.py +84 -0
- {imagepro_python-1.0.5.dist-info → imagepro_python-1.1.0.dist-info}/METADATA +2 -1
- {imagepro_python-1.0.5.dist-info → imagepro_python-1.1.0.dist-info}/RECORD +6 -5
- {imagepro_python-1.0.5.dist-info → imagepro_python-1.1.0.dist-info}/WHEEL +0 -0
- {imagepro_python-1.0.5.dist-info → imagepro_python-1.1.0.dist-info}/licenses/LICENSE +0 -0
- {imagepro_python-1.0.5.dist-info → imagepro_python-1.1.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import cv2
|
|
4
|
+
import matplotlib.pyplot as plt
|
|
5
|
+
|
|
6
|
+
from ImagePRO.utils.image import Image
|
|
7
|
+
from ImagePRO.utils.result import Result
|
|
8
|
+
|
|
9
|
+
def show_histogram(image: Image) -> Result:
|
|
10
|
+
"""
|
|
11
|
+
Displays the histogram of an image with customizable options.
|
|
12
|
+
|
|
13
|
+
This function visualizes the intensity distribution of an image. It handles both grayscale
|
|
14
|
+
and color images, with automatic detection of image type. For color images, it displays
|
|
15
|
+
histograms for each color channel (BGR or RGB) with appropriate colors.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
image (Image):
|
|
19
|
+
Input image to convert. Must be BGR, RGB or Grayscale format.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
Result: Result object with histogram plot.
|
|
23
|
+
- image (np.ndarray): None
|
|
24
|
+
- data (None): matplotlib.pyplot object
|
|
25
|
+
- meta (dict): Contains source object and operation info
|
|
26
|
+
|
|
27
|
+
Raises:
|
|
28
|
+
TypeError: If image is not an Image instance
|
|
29
|
+
ValueError: If image colorspace is not defined.
|
|
30
|
+
"""
|
|
31
|
+
if not isinstance(image, Image):
|
|
32
|
+
raise TypeError("'image' must be an Image instance.")
|
|
33
|
+
|
|
34
|
+
if image.colorspace == "BGR":
|
|
35
|
+
colors = ('blue', 'green', 'red')
|
|
36
|
+
plt.figure(figsize=(10, 6))
|
|
37
|
+
|
|
38
|
+
for i, color in enumerate(colors):
|
|
39
|
+
hist = cv2.calcHist([image._data], [i], None, [256], [0, 256])
|
|
40
|
+
plt.plot(hist, color=color)
|
|
41
|
+
plt.xlim([0, 256])
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
plt.title('Histogram of BGR Channels')
|
|
45
|
+
plt.xlabel('Pixel Intensity')
|
|
46
|
+
plt.ylabel('Frequency')
|
|
47
|
+
plt.legend(['Blue Channel', 'Green Channel', 'Red Channel'])
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
elif image.colorspace == "RGB":
|
|
51
|
+
colors = ('red', 'green', 'blue')
|
|
52
|
+
plt.figure(figsize=(10, 6))
|
|
53
|
+
|
|
54
|
+
for i, color in enumerate(colors):
|
|
55
|
+
hist = cv2.calcHist([image._data], [i], None, [256], [0, 256])
|
|
56
|
+
plt.plot(hist, color=color)
|
|
57
|
+
plt.xlim([0, 256])
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
plt.title('Histogram of RGB Channels')
|
|
61
|
+
plt.xlabel('Pixel Intensity')
|
|
62
|
+
plt.ylabel('Frequency')
|
|
63
|
+
plt.legend(['Red Channel', 'Green Channel', 'Blue Channel'])
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
elif image.colorspace == 'GRAY':
|
|
67
|
+
plt.figure(figsize=(10, 6))
|
|
68
|
+
|
|
69
|
+
hist = cv2.calcHist([image._data], [0], None, [256], [0, 256])
|
|
70
|
+
plt.plot(hist, color='black')
|
|
71
|
+
plt.xlim([0, 256])
|
|
72
|
+
|
|
73
|
+
else:
|
|
74
|
+
return ValueError('Unknown colorspace')
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
return Result(
|
|
78
|
+
image=None,
|
|
79
|
+
data=plt,
|
|
80
|
+
meta={
|
|
81
|
+
"source": image,
|
|
82
|
+
"operation": "show_histogram"
|
|
83
|
+
}
|
|
84
|
+
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ImagePRO-Python
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Professional & modular image processing library with OpenCV, MediaPipe, and YOLO integration.
|
|
5
5
|
Author-email: Parsa Safaie <parsasafaie.2568@proton.me>
|
|
6
6
|
License: MIT
|
|
@@ -24,6 +24,7 @@ Description-Content-Type: text/markdown
|
|
|
24
24
|
License-File: LICENSE
|
|
25
25
|
Requires-Dist: numpy<2.0,>=1.24
|
|
26
26
|
Requires-Dist: opencv-python<5.0,>=4.8
|
|
27
|
+
Requires-Dist: matplotlib<3.9.0,>=3.7.0
|
|
27
28
|
Provides-Extra: yolo
|
|
28
29
|
Requires-Dist: ultralytics<9.0,>=8.2.0; extra == "yolo"
|
|
29
30
|
Provides-Extra: mediapipe
|
|
@@ -17,14 +17,15 @@ ImagePRO/pre_processing/contrast.py,sha256=64PL626Gxe_y8ZK1vKH7WQXfr0dW2bTNTAOHT
|
|
|
17
17
|
ImagePRO/pre_processing/crop.py,sha256=qrx-Kl5LO3udGrZaAlNVaR-MuCXpsMZfR1pTSOOMbjk,2184
|
|
18
18
|
ImagePRO/pre_processing/dataset_generator.py,sha256=kvu0m71HHOEqviQ6tDpKK3lVCBORUUa6cHl7Bsitih8,6391
|
|
19
19
|
ImagePRO/pre_processing/grayscale.py,sha256=IjMCvH7z4q1NCS8pm7S8A4hVigbLQbsjwvjfDQWmthY,1522
|
|
20
|
+
ImagePRO/pre_processing/histogram.py,sha256=NyP9d8OV2q7s67x4oeb-T4UthICCImpRpEKLm32wUoM,2629
|
|
20
21
|
ImagePRO/pre_processing/resize.py,sha256=BGGLGao_1uc8B1kZFa5MVYcTzaeeP1qkjFei6M_eIZc,1501
|
|
21
22
|
ImagePRO/pre_processing/rotate.py,sha256=kdauqCpn71Yube351o1tmQFyxcj2cjTs0ZJflxsoet8,3926
|
|
22
23
|
ImagePRO/pre_processing/sharpen.py,sha256=kW9KVXvQ77qezBfUWH7loqstQqJ2QvK7s0gtwoxR4EI,3285
|
|
23
24
|
ImagePRO/utils/__init__.py,sha256=McVd-o9KtKOpAVYbLi19KxsatPPFFF-Qbt0gdgY3Ln8,170
|
|
24
25
|
ImagePRO/utils/image.py,sha256=x93cBNycNOgET20a__TxZ9ZQo_2G84uB7QjXjBo9f8M,3973
|
|
25
26
|
ImagePRO/utils/result.py,sha256=DAFaFZ5jZZ7C2YrhRs6h2PAei6Mbv1Mu8xX_2NQ7c6Y,5605
|
|
26
|
-
imagepro_python-1.0.
|
|
27
|
-
imagepro_python-1.0.
|
|
28
|
-
imagepro_python-1.0.
|
|
29
|
-
imagepro_python-1.0.
|
|
30
|
-
imagepro_python-1.0.
|
|
27
|
+
imagepro_python-1.1.0.dist-info/licenses/LICENSE,sha256=sehkHN7dbe5umrINZJyJjIf9VTemZSgTfJlq6iIsbJQ,1069
|
|
28
|
+
imagepro_python-1.1.0.dist-info/METADATA,sha256=DEzqs1EVVnaE4V5UmzrOkwZIYY3WJMw03nAd957i4yA,1658
|
|
29
|
+
imagepro_python-1.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
30
|
+
imagepro_python-1.1.0.dist-info/top_level.txt,sha256=UOuPzsoWrVKXgUupOSI96shJ6wE8Fhz-8bm8oMlLC3s,9
|
|
31
|
+
imagepro_python-1.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|