image.pyi 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. from collections.abc import Callable, Sequence
  2. import os
  3. import pathlib
  4. from typing import Any, BinaryIO, Literal
  5. import numpy as np
  6. from numpy.typing import ArrayLike, NDArray
  7. import PIL.Image
  8. import matplotlib.artist as martist
  9. from matplotlib.axes import Axes
  10. from matplotlib import cm
  11. from matplotlib.backend_bases import RendererBase, MouseEvent
  12. from matplotlib.colors import Colormap, Normalize
  13. from matplotlib.figure import Figure
  14. from matplotlib.transforms import Affine2D, BboxBase, Bbox, Transform
  15. #
  16. # These names are re-exported from matplotlib._image.
  17. #
  18. BESSEL: int
  19. BICUBIC: int
  20. BILINEAR: int
  21. BLACKMAN: int
  22. CATROM: int
  23. GAUSSIAN: int
  24. HAMMING: int
  25. HANNING: int
  26. HERMITE: int
  27. KAISER: int
  28. LANCZOS: int
  29. MITCHELL: int
  30. NEAREST: int
  31. QUADRIC: int
  32. SINC: int
  33. SPLINE16: int
  34. SPLINE36: int
  35. def resample(
  36. input_array: NDArray[np.float32] | NDArray[np.float64] | NDArray[np.int8],
  37. output_array: NDArray[np.float32] | NDArray[np.float64] | NDArray[np.int8],
  38. transform: Transform,
  39. interpolation: int = ...,
  40. resample: bool = ...,
  41. alpha: float = ...,
  42. norm: bool = ...,
  43. radius: float = ...,
  44. ) -> None: ...
  45. #
  46. # END names re-exported from matplotlib._image.
  47. #
  48. interpolations_names: set[str]
  49. def composite_images(
  50. images: Sequence[_ImageBase], renderer: RendererBase, magnification: float = ...
  51. ) -> tuple[np.ndarray, float, float]: ...
  52. class _ImageBase(martist.Artist, cm.ScalarMappable):
  53. zorder: float
  54. origin: Literal["upper", "lower"]
  55. axes: Axes
  56. def __init__(
  57. self,
  58. ax: Axes,
  59. cmap: str | Colormap | None = ...,
  60. norm: str | Normalize | None = ...,
  61. interpolation: str | None = ...,
  62. origin: Literal["upper", "lower"] | None = ...,
  63. filternorm: bool = ...,
  64. filterrad: float = ...,
  65. resample: bool | None = ...,
  66. *,
  67. interpolation_stage: Literal["data", "rgba"] | None = ...,
  68. **kwargs
  69. ) -> None: ...
  70. def get_size(self) -> tuple[int, int]: ...
  71. def set_alpha(self, alpha: float | ArrayLike | None) -> None: ...
  72. def changed(self) -> None: ...
  73. def make_image(
  74. self, renderer: RendererBase, magnification: float = ..., unsampled: bool = ...
  75. ) -> tuple[np.ndarray, float, float, Affine2D]: ...
  76. def draw(self, renderer: RendererBase, *args, **kwargs) -> None: ...
  77. def write_png(self, fname: str | pathlib.Path | BinaryIO) -> None: ...
  78. def set_data(self, A: ArrayLike | None) -> None: ...
  79. def set_array(self, A: ArrayLike | None) -> None: ...
  80. def get_shape(self) -> tuple[int, int, int]: ...
  81. def get_interpolation(self) -> str: ...
  82. def set_interpolation(self, s: str | None) -> None: ...
  83. def set_interpolation_stage(self, s: Literal["data", "rgba"]) -> None: ...
  84. def can_composite(self) -> bool: ...
  85. def set_resample(self, v: bool | None) -> None: ...
  86. def get_resample(self) -> bool: ...
  87. def set_filternorm(self, filternorm: bool) -> None: ...
  88. def get_filternorm(self) -> bool: ...
  89. def set_filterrad(self, filterrad: float) -> None: ...
  90. def get_filterrad(self) -> float: ...
  91. class AxesImage(_ImageBase):
  92. def __init__(
  93. self,
  94. ax: Axes,
  95. *,
  96. cmap: str | Colormap | None = ...,
  97. norm: str | Normalize | None = ...,
  98. interpolation: str | None = ...,
  99. origin: Literal["upper", "lower"] | None = ...,
  100. extent: tuple[float, float, float, float] | None = ...,
  101. filternorm: bool = ...,
  102. filterrad: float = ...,
  103. resample: bool = ...,
  104. interpolation_stage: Literal["data", "rgba"] | None = ...,
  105. **kwargs
  106. ) -> None: ...
  107. def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox: ...
  108. def make_image(
  109. self, renderer: RendererBase, magnification: float = ..., unsampled: bool = ...
  110. ) -> tuple[np.ndarray, float, float, Affine2D]: ...
  111. def set_extent(
  112. self, extent: tuple[float, float, float, float], **kwargs
  113. ) -> None: ...
  114. def get_extent(self) -> tuple[float, float, float, float]: ...
  115. def get_cursor_data(self, event: MouseEvent) -> None | float: ...
  116. class NonUniformImage(AxesImage):
  117. mouseover: bool
  118. def __init__(
  119. self, ax: Axes, *, interpolation: Literal["nearest", "bilinear"] = ..., **kwargs
  120. ) -> None: ...
  121. def set_data(self, x: ArrayLike, y: ArrayLike, A: ArrayLike) -> None: ... # type: ignore[override]
  122. # more limited interpolation available here than base class
  123. def set_interpolation(self, s: Literal["nearest", "bilinear"]) -> None: ... # type: ignore[override]
  124. class PcolorImage(AxesImage):
  125. def __init__(
  126. self,
  127. ax: Axes,
  128. x: ArrayLike | None = ...,
  129. y: ArrayLike | None = ...,
  130. A: ArrayLike | None = ...,
  131. *,
  132. cmap: str | Colormap | None = ...,
  133. norm: str | Normalize | None = ...,
  134. **kwargs
  135. ) -> None: ...
  136. def set_data(self, x: ArrayLike, y: ArrayLike, A: ArrayLike) -> None: ... # type: ignore[override]
  137. class FigureImage(_ImageBase):
  138. zorder: float
  139. figure: Figure
  140. ox: float
  141. oy: float
  142. magnification: float
  143. def __init__(
  144. self,
  145. fig: Figure,
  146. *,
  147. cmap: str | Colormap | None = ...,
  148. norm: str | Normalize | None = ...,
  149. offsetx: int = ...,
  150. offsety: int = ...,
  151. origin: Literal["upper", "lower"] | None = ...,
  152. **kwargs
  153. ) -> None: ...
  154. def get_extent(self) -> tuple[float, float, float, float]: ...
  155. class BboxImage(_ImageBase):
  156. bbox: BboxBase
  157. def __init__(
  158. self,
  159. bbox: BboxBase | Callable[[RendererBase | None], Bbox],
  160. *,
  161. cmap: str | Colormap | None = ...,
  162. norm: str | Normalize | None = ...,
  163. interpolation: str | None = ...,
  164. origin: Literal["upper", "lower"] | None = ...,
  165. filternorm: bool = ...,
  166. filterrad: float = ...,
  167. resample: bool = ...,
  168. **kwargs
  169. ) -> None: ...
  170. def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox: ...
  171. def imread(
  172. fname: str | pathlib.Path | BinaryIO, format: str | None = ...
  173. ) -> np.ndarray: ...
  174. def imsave(
  175. fname: str | os.PathLike | BinaryIO,
  176. arr: ArrayLike,
  177. vmin: float | None = ...,
  178. vmax: float | None = ...,
  179. cmap: str | Colormap | None = ...,
  180. format: str | None = ...,
  181. origin: Literal["upper", "lower"] | None = ...,
  182. dpi: float = ...,
  183. *,
  184. metadata: dict[str, str] | None = ...,
  185. pil_kwargs: dict[str, Any] | None = ...
  186. ) -> None: ...
  187. def pil_to_array(pilImage: PIL.Image.Image) -> np.ndarray: ...
  188. def thumbnail(
  189. infile: str | BinaryIO,
  190. thumbfile: str | BinaryIO,
  191. scale: float = ...,
  192. interpolation: str = ...,
  193. preview: bool = ...,
  194. ) -> Figure: ...