ImagePRO-Python 1.0.4__tar.gz → 1.1.0__tar.gz

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.
Files changed (35) hide show
  1. {imagepro_python-1.0.4/src/ImagePRO_Python.egg-info → imagepro_python-1.1.0}/PKG-INFO +2 -1
  2. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/pyproject.toml +2 -1
  3. imagepro_python-1.1.0/src/ImagePRO/pre_processing/histogram.py +84 -0
  4. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/utils/image.py +12 -3
  5. {imagepro_python-1.0.4 → imagepro_python-1.1.0/src/ImagePRO_Python.egg-info}/PKG-INFO +2 -1
  6. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO_Python.egg-info/SOURCES.txt +1 -0
  7. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO_Python.egg-info/requires.txt +1 -0
  8. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/LICENSE +0 -0
  9. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/setup.cfg +0 -0
  10. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/__init__.py +0 -0
  11. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/human_analysis/__init__.py +0 -0
  12. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/human_analysis/body_analysis/__init__.py +0 -0
  13. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/human_analysis/body_analysis/body_pose_estimation.py +0 -0
  14. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/human_analysis/body_analysis/hand_tracking.py +0 -0
  15. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/human_analysis/face_analysis/__init__.py +0 -0
  16. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/human_analysis/face_analysis/eye_status_analysis.py +0 -0
  17. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/human_analysis/face_analysis/face_comparison.py +0 -0
  18. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/human_analysis/face_analysis/face_detection.py +0 -0
  19. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/human_analysis/face_analysis/face_mesh_analysis.py +0 -0
  20. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/human_analysis/face_analysis/head_pose_estimation.py +0 -0
  21. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/object_analysis/__init__.py +0 -0
  22. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/object_analysis/object_detection.py +0 -0
  23. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/pre_processing/__init__.py +0 -0
  24. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/pre_processing/blur.py +0 -0
  25. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/pre_processing/contrast.py +0 -0
  26. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/pre_processing/crop.py +0 -0
  27. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/pre_processing/dataset_generator.py +0 -0
  28. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/pre_processing/grayscale.py +0 -0
  29. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/pre_processing/resize.py +0 -0
  30. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/pre_processing/rotate.py +0 -0
  31. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/pre_processing/sharpen.py +0 -0
  32. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/utils/__init__.py +0 -0
  33. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO/utils/result.py +0 -0
  34. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO_Python.egg-info/dependency_links.txt +0 -0
  35. {imagepro_python-1.0.4 → imagepro_python-1.1.0}/src/ImagePRO_Python.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ImagePRO-Python
3
- Version: 1.0.4
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
@@ -7,7 +7,7 @@ where = ["src"]
7
7
 
8
8
  [project]
9
9
  name = "ImagePRO-Python"
10
- version = "1.0.4"
10
+ version = "1.1.0"
11
11
  description = "Professional & modular image processing library with OpenCV, MediaPipe, and YOLO integration."
12
12
  readme = "README.md"
13
13
  requires-python = "==3.10.*"
@@ -30,6 +30,7 @@ classifiers = [
30
30
  dependencies = [
31
31
  "numpy>=1.24,<2.0",
32
32
  "opencv-python>=4.8,<5.0",
33
+ "matplotlib>=3.7.0,<3.9.0"
33
34
  ]
34
35
 
35
36
  [project.optional-dependencies]
@@ -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
+ )
@@ -33,7 +33,7 @@ class Image:
33
33
 
34
34
  Example:
35
35
  >>> # Load from file (default BGR)
36
- >>> img = Image.from_path('input.jpg')
36
+ >>> img = Image.from_path('input.jpg', colorspace="BGR")
37
37
  >>> print(img.shape) # (H, W, 3)
38
38
  >>>
39
39
  >>> # Or wrap a NumPy array
@@ -46,13 +46,19 @@ class Image:
46
46
  source_type: SourceType = "array"
47
47
 
48
48
  @classmethod
49
- def from_path(cls, path: str | Path) -> Image:
49
+ def from_path(
50
+ cls,
51
+ path: str | Path,
52
+ colorspace: Colorspace = "BGR"
53
+ ) -> Image:
50
54
  """
51
55
  Create an Image instance from a file path.
52
56
 
53
57
  Args:
54
58
  path (str | Path):
55
59
  Path to the image file.
60
+ colorspace (Colorspace, optional):
61
+ Colorspace of the image array in that path ("BGR", "RGB", or "GRAY"). Defaults to "BGR".
56
62
 
57
63
  Returns:
58
64
  Image: New Image instance loaded from disk.
@@ -60,13 +66,16 @@ class Image:
60
66
  Raises:
61
67
  TypeError: If path is not str or Path.
62
68
  ValueError: If image cannot be loaded.
69
+ ValueError: If colorspace is invalid.
63
70
  """
64
71
  if not isinstance(path, (str, Path)):
65
72
  raise TypeError("'path' must be a string or pathlib.Path.")
66
73
  np_image = cv2.imread(str(path))
67
74
  if np_image is None:
68
75
  raise ValueError(f"Failed to load image from {path}")
69
- return cls(_data=np_image, path=Path(path), colorspace="BGR", source_type="path")
76
+ if colorspace not in ("BGR", "RGB", "GRAY"):
77
+ raise ValueError("'colorspace' must be one of 'BGR', 'RGB', 'GRAY'.")
78
+ return cls(_data=np_image, path=Path(path), colorspace=colorspace, source_type="path")
70
79
 
71
80
  @classmethod
72
81
  def from_array(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ImagePRO-Python
3
- Version: 1.0.4
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
@@ -19,6 +19,7 @@ src/ImagePRO/pre_processing/contrast.py
19
19
  src/ImagePRO/pre_processing/crop.py
20
20
  src/ImagePRO/pre_processing/dataset_generator.py
21
21
  src/ImagePRO/pre_processing/grayscale.py
22
+ src/ImagePRO/pre_processing/histogram.py
22
23
  src/ImagePRO/pre_processing/resize.py
23
24
  src/ImagePRO/pre_processing/rotate.py
24
25
  src/ImagePRO/pre_processing/sharpen.py
@@ -1,5 +1,6 @@
1
1
  numpy<2.0,>=1.24
2
2
  opencv-python<5.0,>=4.8
3
+ matplotlib<3.9.0,>=3.7.0
3
4
 
4
5
  [insightface]
5
6
  insightface<1.0,>=0.7
File without changes