source-emitter 0.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.
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: source-emitter
3
+ Version: 0.1.0
4
+ Summary: Prints a complete Python source example from one public function.
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
7
+
8
+ # source-emitter
9
+
10
+ `source-emitter` has one public function: `emit_code()`. Calling it prints the complete Python script included with the library.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ python -m pip install source-emitter
16
+ ```
17
+
18
+ ## Use
19
+
20
+ ```python
21
+ from source_emitter import emit_code
22
+
23
+ emit_code()
24
+ ```
25
+
26
+ The emitted script uses OpenCV, NumPy, and Matplotlib and reads `sample.jpg` from the current working directory. Install those dependencies and place an image at that path before running the emitted script.
@@ -0,0 +1,19 @@
1
+ # source-emitter
2
+
3
+ `source-emitter` has one public function: `emit_code()`. Calling it prints the complete Python script included with the library.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ python -m pip install source-emitter
9
+ ```
10
+
11
+ ## Use
12
+
13
+ ```python
14
+ from source_emitter import emit_code
15
+
16
+ emit_code()
17
+ ```
18
+
19
+ The emitted script uses OpenCV, NumPy, and Matplotlib and reads `sample.jpg` from the current working directory. Install those dependencies and place an image at that path before running the emitted script.
@@ -0,0 +1,13 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "source-emitter"
7
+ version = "0.1.0"
8
+ description = "Prints a complete Python source example from one public function."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+
12
+ [tool.setuptools.packages.find]
13
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,76 @@
1
+ """Emit the complete example script with one public function."""
2
+
3
+ __all__ = ["emit_code"]
4
+
5
+
6
+ _SOURCE = '''import cv2
7
+ import numpy as np
8
+ import matplotlib.pyplot as plt
9
+
10
+ def show(img, title="Image", cmap="gray"):
11
+ plt.figure(figsize=(5, 5))
12
+ plt.imshow(img, cmap=cmap)
13
+ plt.title(title)
14
+ plt.axis("off")
15
+ plt.show()
16
+
17
+ # 1.2 Log Transformations
18
+ img = cv2.imread("sample.jpg", 0).astype(np.float32)
19
+
20
+ c = 255 / np.log(1 + img.max())
21
+ log_img = np.uint8(c * np.log(1 + img))
22
+ # The log transformation enhances details in darker regions. The constant c scales
23
+ # pixel values to the range [0, 255].
24
+
25
+ show(img.astype(np.uint8), "Original")
26
+ show(log_img, "Log Transformed")
27
+
28
+ # 1.3 Power-Law (Gamma) Transformations
29
+ img = cv2.imread("sample.jpg", 0).astype(np.float32) / 255
30
+
31
+ for gamma in [0.4, 1.0, 2.5]: # brighter, no change, darker
32
+ corrected = np.uint8(img ** gamma * 255)
33
+ show(corrected, f"Gamma = {gamma}")
34
+ # If gamma < 1, the image becomes brighter; if gamma = 1, it is unchanged;
35
+ # if gamma > 1, the image becomes darker.
36
+
37
+ # 1.4 Piecewise-Linear Transformations
38
+ # 1.4.1 Contrast Stretching
39
+ img = cv2.imread("sample.jpg", 0)
40
+
41
+ stretched = cv2.normalize(img, None, 0, 255, cv2.NORM_MINMAX)
42
+ # Normalize pixel values to the range [0, 255].
43
+
44
+ show(img, "Original (low contrast)")
45
+ show(stretched, "Contrast Stretched")
46
+
47
+ # 1.4.2 Thresholding
48
+ img = cv2.imread("sample.jpg", 0)
49
+
50
+ _, binary = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)
51
+ # Values above 127 become 255; all other values become 0.
52
+
53
+ show(img, "Original")
54
+ show(binary, "Thresholded (T=127)")
55
+
56
+ # 1.4.3 Gray-Level Slicing
57
+ img = cv2.imread("sample.jpg", 0)
58
+
59
+ sliced = np.where((img >= 100) & (img <= 180), 255, img // 2)
60
+ # Values from 100 through 180 become 255; all other values are halved.
61
+
62
+ show(img, "Original")
63
+ show(sliced, "Gray-Level Sliced")
64
+
65
+ # 1.5 Bit-Plane Slicing
66
+ img = cv2.imread("sample.jpg", 0)
67
+
68
+ for i in range(8): # an 8-bit image has eight bit planes
69
+ show(((img >> i) & 1) * 255, f"Bit Plane {i + 1}")
70
+ # Shift right by i, keep the lowest bit, and scale it to 0 or 255 for display.
71
+ '''
72
+
73
+
74
+ def emit_code() -> None:
75
+ """Print the complete example script."""
76
+ print(_SOURCE, end="")
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: source-emitter
3
+ Version: 0.1.0
4
+ Summary: Prints a complete Python source example from one public function.
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
7
+
8
+ # source-emitter
9
+
10
+ `source-emitter` has one public function: `emit_code()`. Calling it prints the complete Python script included with the library.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ python -m pip install source-emitter
16
+ ```
17
+
18
+ ## Use
19
+
20
+ ```python
21
+ from source_emitter import emit_code
22
+
23
+ emit_code()
24
+ ```
25
+
26
+ The emitted script uses OpenCV, NumPy, and Matplotlib and reads `sample.jpg` from the current working directory. Install those dependencies and place an image at that path before running the emitted script.
@@ -0,0 +1,7 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/source_emitter/__init__.py
4
+ src/source_emitter.egg-info/PKG-INFO
5
+ src/source_emitter.egg-info/SOURCES.txt
6
+ src/source_emitter.egg-info/dependency_links.txt
7
+ src/source_emitter.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ source_emitter