Merge pull request #1945 from roboflow/docs/refactor_0.27.0
docs/refactor 0.27.0 missing commits
This commit is contained in:
commit
deb1c9c4f4
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
comments: true
|
||||
status: new
|
||||
---
|
||||
|
||||
# Image Utils
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ def crop_image(
|
|||
image.shape
|
||||
# (1080, 1920, 3)
|
||||
|
||||
xyxy = (200, 400, 600, 800)
|
||||
xyxy = (400, 400, 800, 800)
|
||||
cropped_image = sv.crop_image(image=image, xyxy=xyxy)
|
||||
cropped_image.shape
|
||||
# (400, 400, 3)
|
||||
|
|
@ -55,12 +55,14 @@ def crop_image(
|
|||
image.size
|
||||
# (1920, 1080)
|
||||
|
||||
xyxy = (200, 400, 600, 800)
|
||||
xyxy = (400, 400, 800, 800)
|
||||
cropped_image = sv.crop_image(image=image, xyxy=xyxy)
|
||||
cropped_image.size
|
||||
# (400, 400)
|
||||
```
|
||||
"""
|
||||
|
||||
{ align=center width="1000" }
|
||||
""" # noqa E501 // docs
|
||||
if isinstance(xyxy, (list, tuple)):
|
||||
xyxy = np.array(xyxy)
|
||||
xyxy = np.round(xyxy).astype(int)
|
||||
|
|
@ -110,7 +112,9 @@ def scale_image(image: ImageType, scale_factor: float) -> ImageType:
|
|||
scaled_image.size
|
||||
# (960, 540)
|
||||
```
|
||||
"""
|
||||
|
||||
{ align=center width="1000" }
|
||||
""" # noqa E501 // docs
|
||||
if scale_factor <= 0:
|
||||
raise ValueError("Scale factor must be positive.")
|
||||
|
||||
|
|
@ -170,7 +174,7 @@ def resize_image(
|
|||
# (1000, 562)
|
||||
```
|
||||
|
||||
{ align=center width="800" }
|
||||
{ align=center width="1000" }
|
||||
""" # noqa E501 // docs
|
||||
if keep_aspect_ratio:
|
||||
image_ratio = image.shape[1] / image.shape[0]
|
||||
|
|
@ -238,7 +242,7 @@ def letterbox_image(
|
|||
# (1000, 1000)
|
||||
```
|
||||
|
||||
{ align=center width="800" }
|
||||
{ align=center width="1000" }
|
||||
""" # noqa E501 // docs
|
||||
assert isinstance(image, np.ndarray)
|
||||
color = unify_to_bgr(color=color)
|
||||
|
|
@ -389,7 +393,7 @@ def tint_image(
|
|||
|
||||
image = cv2.imread("source.png")
|
||||
tinted_image = sv.tint_image(
|
||||
image=image, color=sv.Color.BLACK, opacity=0.5
|
||||
image=image, color=sv.Color.ROBOFLOW, opacity=0.5
|
||||
)
|
||||
cv2.imwrite("target.png", tinted_image)
|
||||
```
|
||||
|
|
@ -400,11 +404,13 @@ def tint_image(
|
|||
|
||||
image = Image.open("source.png")
|
||||
tinted_image = sv.tint_image(
|
||||
image=image, color=sv.Color.BLACK, opacity=0.5
|
||||
image=image, color=sv.Color.ROBOFLOW, opacity=0.5
|
||||
)
|
||||
tinted_image.save("target.png")
|
||||
```
|
||||
"""
|
||||
|
||||
{ align=center width="1000" }
|
||||
""" # noqa E501 // docs
|
||||
if not 0.0 <= opacity <= 1.0:
|
||||
raise ValueError("opacity must be between 0.0 and 1.0")
|
||||
|
||||
|
|
@ -447,7 +453,9 @@ def grayscale_image(image: ImageType) -> ImageType:
|
|||
grayscale_image = sv.grayscale_image(image=image)
|
||||
grayscale_image.save("target.png")
|
||||
```
|
||||
"""
|
||||
|
||||
{ align=center width="1000" }
|
||||
""" # noqa E501 // docs
|
||||
grayscaled = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||
return cv2.cvtColor(grayscaled, cv2.COLOR_GRAY2BGR)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue