@@ -43,24 +43,24 @@ def read(path, raw_bytes=None, format=None, convert_to_array=True):
4343 """Read an image from a file using one of VTK's ``vtkFormatReader`` classes
4444 where ``Format`` is replaced by JPEG, PNG, BMP or TIFF.
4545
46- :param path: Filename or file handle or `` None` ` if using the **raw_bytes** argument.
46+ :param path: Filename or file handle or `None` if using the **raw_bytes** argument.
4747 :type path: str, os.PathLike, io.BytesIO
4848
49- :param raw_bytes: Image compressed binary data, defaults to ``None`` .
50- :type raw_bytes: bytes, optional
49+ :param raw_bytes: Image compressed binary data.
50+ :type raw_bytes: bytes
5151
52- :param format: Image format extension (e.g. jpg), not needed if format can be determined from **path**, defaults to ``None`` .
53- :type format: str, optional
52+ :param format: Image format extension (e.g. jpg). This should never be needed .
53+ :type format: str
5454
55- :param convert_to_array: If true, convert to numpy, otherwise leave as vtkImageData, defaults to ``True`` .
56- :type convert_to_array: bool, optional
55+ :param convert_to_array: If true, convert to ` numpy.ndarray` , otherwise leave as vtkImageData_ .
56+ :type convert_to_array: bool
5757
5858 :return: Read image.
59- :rtype: np .ndarray or `vtkImageData`_
59+ :rtype: `numpy .ndarray` or `vtkImageData`_
6060
6161 The file format can be determined automatically from the **path** suffix or the beginning
6262 of **raw_bytes**. **format** can be any of JPEG, PNG, TIFF, BMP. It is case
63- insensitive, tolerant to preceding '.'s e.g. ``format=".jpg"`` and
63+ insensitive, tolerant to preceding `` '.'`` e.g. ``format=".jpg"`` and
6464 understands the aliases JPG \u21d4 JPEG and TIF \u21d4 TIFF.
6565
6666 The following demonstrates how to use pseudo file objects to avoid temporary
@@ -70,7 +70,7 @@ def read(path, raw_bytes=None, format=None, convert_to_array=True):
7070
7171 import vtkplotlib as vpl
7272
73- # Link you're image url here
73+ # Link your image url here
7474 url = "https://raw.githubusercontent.com/bwoodsend/vtkplotlib/master/vtkplotlib/data/icons/Right.jpg"
7575
7676 # You can make the url request with either:
@@ -81,7 +81,7 @@ def read(path, raw_bytes=None, format=None, convert_to_array=True):
8181 # import requests
8282 # raw_bytes = requests.get(url).content
8383
84- # Pass the bytes to :meth: `read` using:
84+ # Pass the bytes to `read() ` using:
8585 image = vpl.image_io.read(path=None, raw_bytes=raw_bytes)
8686
8787 # Visualize using matplotlib.
@@ -190,22 +190,22 @@ def write(arr, path, format=None, quality=95):
190190 """Write an image from a file using one of VTK's ``vtkFormatWriter`` classes
191191 where ``Format`` is replaced by JPEG or PNG.
192192
193- :param arr: **arr** can be a `vtkImageData`_ or a numpy array.
194- :type arr: np .ndarray
193+ :param arr: An image array.
194+ :type arr: `numpy .ndarray` or `vtkImageData`_
195195
196196 :param path: File path to write to.
197- :type path: str, os.Pathlike, io.BytesIO,
197+ :type path: str or os.PathLike or io.BytesIO
198198
199- :param format: Image format extension (e.g. jpg), not needed if format can be determined from **path**, defaults to ``None`` .
200- :type format: str, optional
199+ :param format: Image format extension (e.g. jpg), not needed if format can be determined from **path**.
200+ :type format: str
201201
202- :param quality: Lossy compression quality, only applicable to JPEGs, defaults to 95 .
203- :type quality: int from 0 to 100, optional
202+ :param quality: Lossy compression quality ( only applicable to JPEGs) between 0 to 100 .
203+ :type quality: int
204204
205- :return: The raw image binary if ``path is None``, `` NotImplemented` ` if the filetype is unknown. Otherwise no return value.
205+ :return: The raw image binary if ``path is None``, `NotImplemented` if the filetype is unknown. Otherwise no return value.
206206 :rtype: bytes
207207
208- See :meth: `read` for more information.
208+ See `read` for more information.
209209
210210 .. note::
211211
@@ -247,7 +247,7 @@ def write(arr, path, format=None, quality=95):
247247def vtkimagedata_to_array (image_data ):
248248 """Convert a vtkImageData to numpy array.
249249
250- .. seealso:: :meth: `vtkimagedata_from_array` for the reverse.
250+ .. seealso:: `vtkimagedata_from_array` for the reverse.
251251
252252 """
253253 points = vtk_to_numpy (image_data .GetPointData ().GetScalars ())
@@ -265,11 +265,11 @@ def vtkimagedata_to_array(image_data):
265265def vtkimagedata_from_array (arr , image_data = None ):
266266 """Convert a numpy array to a vtkImageData.
267267
268- :param arr: Array of colors.
269- :type arr: np .ndarray with dtype ``np.uint8``
268+ :param arr: An ``uint8`` array of colors.
269+ :type arr: numpy .ndarray
270270
271- :param image_data: An image data to write into, a new one is created if not specified, defaults to ``None`` .
272- :type image_data: `vtkImageData`_, optional
271+ :param image_data: An image data to write into, a new one is created if not specified.
272+ :type image_data: `vtkImageData`_
273273
274274 :return: A VTK image.
275275 :rtype: `vtkImageData`_
@@ -278,9 +278,9 @@ def vtkimagedata_from_array(arr, image_data=None):
278278 ``(m, n, 1)`` for greyscale, ``(m, n, 3)`` for RGB, or ``(m, n, 4)`` for
279279 RGBA.
280280
281- .. seealso:: :meth: `vtkimagedata_to_array` for the reverse.
281+ .. seealso:: `vtkimagedata_to_array` for the reverse.
282282
283- .. seealso:: :meth: `as_vtkimagedata` for converting from other types.
283+ .. seealso:: `as_vtkimagedata` for converting from other types.
284284
285285 """
286286 assert arr .dtype == np .uint8
@@ -308,20 +308,20 @@ def trim_image(arr, background_color, crop_padding):
308308 background.
309309
310310 :param arr: An image array.
311- :type arr: 3D np .ndarray
311+ :type arr: numpy .ndarray
312312
313313 :param background_color: The color of the portions to crop away.
314- :type background_color: Strictly an (r, g, b) tuple.
314+ :type background_color: tuple
315315
316- :param crop_padding: Space to leave, in pixels if int, or relative to image size if float.
316+ :param crop_padding: Space to leave, in pixels if ` int` , or relative to image size if ` float` .
317317 :type crop_padding: int or float
318318
319- :return: Smaller image array.
320- :rtype: 3D np .ndarray
319+ :return: A smaller image array.
320+ :rtype: numpy .ndarray
321321
322322
323323 If you don't want your files smaller you can instead use
324- :meth: `vtkplotlib.zoom `.
324+ `vtkplotlib.zoom_to_contents `.
325325
326326 """
327327 if (crop_padding is None ) or crop_padding == 0 :
0 commit comments