Skip to content

Commit deb1c9c

Browse files
authored
Merge pull request #1945 from roboflow/docs/refactor_0.27.0
docs/refactor 0.27.0 missing commits
2 parents c7de70e + 6679b1f commit deb1c9c

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

docs/utils/image.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
comments: true
3+
status: new
34
---
45

56
# Image Utils

supervision/utils/image.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def crop_image(
4141
image.shape
4242
# (1080, 1920, 3)
4343
44-
xyxy = (200, 400, 600, 800)
44+
xyxy = (400, 400, 800, 800)
4545
cropped_image = sv.crop_image(image=image, xyxy=xyxy)
4646
cropped_image.shape
4747
# (400, 400, 3)
@@ -55,12 +55,14 @@ def crop_image(
5555
image.size
5656
# (1920, 1080)
5757
58-
xyxy = (200, 400, 600, 800)
58+
xyxy = (400, 400, 800, 800)
5959
cropped_image = sv.crop_image(image=image, xyxy=xyxy)
6060
cropped_image.size
6161
# (400, 400)
6262
```
63-
"""
63+
64+
![crop-image](https://media.roboflow.com/supervision-docs/supervision-docs-crop-image-2.png){ align=center width="1000" }
65+
""" # noqa E501 // docs
6466
if isinstance(xyxy, (list, tuple)):
6567
xyxy = np.array(xyxy)
6668
xyxy = np.round(xyxy).astype(int)
@@ -110,7 +112,9 @@ def scale_image(image: ImageType, scale_factor: float) -> ImageType:
110112
scaled_image.size
111113
# (960, 540)
112114
```
113-
"""
115+
116+
![scale-image](https://media.roboflow.com/supervision-docs/supervision-docs-scale-image-2.png){ align=center width="1000" }
117+
""" # noqa E501 // docs
114118
if scale_factor <= 0:
115119
raise ValueError("Scale factor must be positive.")
116120

@@ -170,7 +174,7 @@ def resize_image(
170174
# (1000, 562)
171175
```
172176
173-
![resize_image](https://media.roboflow.com/supervision-docs/resize-image.png){ align=center width="800" }
177+
![resize-image](https://media.roboflow.com/supervision-docs/supervision-docs-resize-image-2.png){ align=center width="1000" }
174178
""" # noqa E501 // docs
175179
if keep_aspect_ratio:
176180
image_ratio = image.shape[1] / image.shape[0]
@@ -238,7 +242,7 @@ def letterbox_image(
238242
# (1000, 1000)
239243
```
240244
241-
![letterbox_image](https://media.roboflow.com/supervision-docs/letterbox-image.png){ align=center width="800" }
245+
![letterbox-image](https://media.roboflow.com/supervision-docs/supervision-docs-letterbox-image-2.png){ align=center width="1000" }
242246
""" # noqa E501 // docs
243247
assert isinstance(image, np.ndarray)
244248
color = unify_to_bgr(color=color)
@@ -389,7 +393,7 @@ def tint_image(
389393
390394
image = cv2.imread("source.png")
391395
tinted_image = sv.tint_image(
392-
image=image, color=sv.Color.BLACK, opacity=0.5
396+
image=image, color=sv.Color.ROBOFLOW, opacity=0.5
393397
)
394398
cv2.imwrite("target.png", tinted_image)
395399
```
@@ -400,11 +404,13 @@ def tint_image(
400404
401405
image = Image.open("source.png")
402406
tinted_image = sv.tint_image(
403-
image=image, color=sv.Color.BLACK, opacity=0.5
407+
image=image, color=sv.Color.ROBOFLOW, opacity=0.5
404408
)
405409
tinted_image.save("target.png")
406410
```
407-
"""
411+
412+
![tint-image](https://media.roboflow.com/supervision-docs/supervision-docs-tint-image-2.png){ align=center width="1000" }
413+
""" # noqa E501 // docs
408414
if not 0.0 <= opacity <= 1.0:
409415
raise ValueError("opacity must be between 0.0 and 1.0")
410416

@@ -447,7 +453,9 @@ def grayscale_image(image: ImageType) -> ImageType:
447453
grayscale_image = sv.grayscale_image(image=image)
448454
grayscale_image.save("target.png")
449455
```
450-
"""
456+
457+
![grayscale-image](https://media.roboflow.com/supervision-docs/supervision-docs-grayscale-image-2.png){ align=center width="1000" }
458+
""" # noqa E501 // docs
451459
grayscaled = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
452460
return cv2.cvtColor(grayscaled, cv2.COLOR_GRAY2BGR)
453461

0 commit comments

Comments
 (0)