Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/machinevisiontoolbox/ImageIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os.path
import sys
from pathlib import Path
from typing import TYPE_CHECKING, Any, SupportsFloat, cast
from typing import Any, SupportsFloat, cast

if sys.version_info >= (3, 11):
from typing import Self
Expand All @@ -18,13 +18,11 @@
import matplotlib.pyplot as plt
import numpy as np
import PIL.Image
from matplotlib.axes import Axes
from matplotlib.colors import Colormap, LinearSegmentedColormap
from PIL.ExifTags import TAGS
from spatialmath.base import set_window_title

if TYPE_CHECKING:
pass

from machinevisiontoolbox._image_typing import ImageMixinBase
from machinevisiontoolbox.base.imageio import (
_pick_imagefile,
Expand All @@ -39,6 +37,10 @@


class ImageIOMixin(ImageMixinBase):
"""
Methods of :class:`Image` that read, write and display images
"""

# ======================= image i/io ================================== #

@classmethod
Expand Down Expand Up @@ -448,12 +450,11 @@ def showpixels(
plt.draw()
return ax

def showwindow(self, h, ax=None, **kwargs: Any) -> Any:
def showwindow(self, h: int, ax: Axes | None = None, **kwargs: Any) -> Any:
"""Superimpose a colored window on the image.

:param h: The half-width of the window, so the total window size is
(2h+1)x(2h+1)
:type h: int
:param ax: The axes on which to display the window, defaults to the
current axes
:return: The window instance
Expand Down Expand Up @@ -513,7 +514,13 @@ def showwindow(self, h, ax=None, **kwargs: Any) -> Any:
"""

class Window:
def __init__(self, h=1, ax=None, image=None, **kwargs: Any) -> None:
def __init__(
self,
h: int = 1,
ax: Axes | None = None,
image: ImageMixinBase | None = None,
**kwargs: Any,
) -> None:
self.h = h
self.image = image
self.args = kwargs
Expand Down Expand Up @@ -701,7 +708,7 @@ class Cursor:
A cross hair cursor.
"""

def __init__(self, ax, ax2):
def __init__(self, ax: Axes, ax2: Axes) -> None:
self.ax = ax
self.ax2 = ax2
self.horizontal_line = ax.axhline(color="k", lw=0.8)
Expand Down
Loading