lsst.scarlet.lite gee10cc3b42+772f6ae910
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
lsst.scarlet.lite.image.Image Class Reference

Public Member Functions

 __init__ (self, np.ndarray data, Sequence|None bands=None, tuple[int, int]|None yx0=None)
 
tuple[int,...] shape (self)
 
DTypeLike dtype (self)
 
tuple bands (self)
 
int n_bands (self)
 
bool is_multiband (self)
 
int height (self)
 
int width (self)
 
tuple[int, int] yx0 (self)
 
int y0 (self)
 
int x0 (self)
 
Box bbox (self)
 
np.ndarray data (self)
 
tuple[int,...]|slice spectral_indices (self, Sequence|slice bands)
 
tuple[tuple[int,...]|slice, tuple[int,...]|slice] matched_spectral_indices (self, Image other)
 
tuple[tuple[slice,...], tuple[slice,...]] matched_slices (self, Box bbox)
 
Image project (self, object|tuple[object]|None bands=None, Box|None bbox=None)
 
tuple[tuple[int,...]|slice, slice, slice] multiband_slices (self)
 
Image insert_into (self, Image image, Callable op=operator.add)
 
Image insert (self, Image image, Callable op=operator.add)
 
Image repeat (self, tuple bands)
 
Image copy (self, order=None)
 
 copy_with (self, np.ndarray|None data=None, str|None order=None, tuple[str,...]|None bands=None, tuple[int, int]|None yx0=None)
 
Image __eq__ (self, object other)
 
Image __ne__ (self, object other)
 
Image __ge__ (self, Image|ScalarLike other)
 
Image __le__ (self, Image|ScalarLike other)
 
Image __gt__ (self, Image|ScalarLike other)
 
Image __lt__ (self, Image|ScalarLike other)
 
 __neg__ (self)
 
 __pos__ (self)
 
 __invert__ (self)
 
Image __add__ (self, Image|ScalarLike other)
 
Image __iadd__ (self, Image|ScalarLike other)
 
Image __radd__ (self, Image|ScalarLike other)
 
Image __sub__ (self, Image|ScalarLike other)
 
Image __isub__ (self, Image|ScalarLike other)
 
Image __rsub__ (self, Image|ScalarLike other)
 
Image __mul__ (self, Image|ScalarLike other)
 
Image __imul__ (self, Image|ScalarLike other)
 
Image __rmul__ (self, Image|ScalarLike other)
 
Image __truediv__ (self, Image|ScalarLike other)
 
Image __itruediv__ (self, Image|ScalarLike other)
 
Image __rtruediv__ (self, Image|ScalarLike other)
 
Image __floordiv__ (self, Image|ScalarLike other)
 
Image __ifloordiv__ (self, Image|ScalarLike other)
 
Image __rfloordiv__ (self, Image|ScalarLike other)
 
Image __pow__ (self, Image|ScalarLike other)
 
Image __ipow__ (self, Image|ScalarLike other)
 
Image __rpow__ (self, Image|ScalarLike other)
 
Image __mod__ (self, Image|ScalarLike other)
 
Image __imod__ (self, Image|ScalarLike other)
 
Image __rmod__ (self, Image|ScalarLike other)
 
Image __and__ (self, Image|ScalarLike other)
 
Image __iand__ (self, Image|ScalarLike other)
 
Image __rand__ (self, Image|ScalarLike other)
 
Image __or__ (self, Image|ScalarLike other)
 
Image __ior__ (self, Image|ScalarLike other)
 
Image __ror__ (self, Image|ScalarLike other)
 
Image __xor__ (self, Image|ScalarLike other)
 
Image __ixor__ (self, Image|ScalarLike other)
 
Image __rxor__ (self, Image|ScalarLike other)
 
Image __lshift__ (self, ScalarLike other)
 
Image __ilshift__ (self, ScalarLike other)
 
Image __rlshift__ (self, ScalarLike other)
 
Image __rshift__ (self, ScalarLike other)
 
Image __irshift__ (self, ScalarLike other)
 
Image __rrshift__ (self, ScalarLike other)
 
 __str__ (self)
 
tuple[tuple[slice,...], tuple[slice,...]] overlapped_slices (self, Box bbox)
 
Image __getitem__ (self, Any indices)
 
Image __setitem__ (self, indices, Image value)
 

Static Public Member Functions

Image from_box (Box bbox, tuple|None bands=None, DTypeLike dtype=float)
 

Public Attributes

 bands
 
 n_bands
 
 bbox
 

Protected Member Functions

Image _i_update (self, Callable op, Image|ScalarLike other)
 
Image _check_equality (self, Image|ScalarLike other, Callable op)
 
bool _is_spectral_index (self, Any index)
 
tuple[slice, slice] _get_box_slices (self, Box bbox)
 
Image _get_sliced (self, Any indices, Image|None value=None)
 

Protected Attributes

 _data
 
 _yx0
 
 _bands
 

Detailed Description

A numpy array with an origin and (optional) bands

This class contains a 2D numpy array with the addition of an
origin (``yx0``) and an optional first index (``bands``) that
allows an immutable named index to be used.

Notes
-----
One of the main limitations of using numpy arrays to store image data
is the lack of an ``origin`` attribute that allows an array to retain
knowledge of it's location in a larger scene.
For example, if a numpy array ``x`` is sliced, eg. ``x[10:20, 30:40]``
the result will be a new ``10x10`` numpy array that has no meta
data to inform the user that it was sliced from a larger image.
In addition, astrophysical images are also multi-band data cubes,
with a 2D image in each band (in fact this is the simplifying
assumption that distinguishes scarlet lite from scarlet main).
However, the ordering of the bands during processing might differ from
the ordering of the bands to display multiband data.
So a mechanism was also desired to simplify the sorting and index of
an image by band name.

Thus, scarlet lite creates a numpy-array like class with the additional
``bands`` and ``yx0`` attributes to keep track of the bands contained
in an array and the origin of that array (we specify ``yx0`` as opposed
to ``xy0`` to be consistent with the default numpy/C++ ``(y, x)``
ordering of arrays as opposed to the traditional cartesian ``(x, y)``
ordering used in astronomy and other modules in the science pipelines.
While this may be a small source of confusion for the user,
it is consistent with the ordering in the original scarlet package and
ensures the consistency of scarlet lite images and python index slicing.

Examples
--------

The easiest way to create a new image is to use ``Image(numpy_array)``,
for example

>>> import numpy as np
>>> from lsst.scarlet.lite import Image
>>>
>>> x = np.arange(12).reshape(3, 4)
>>> image = Image(x)
>>> print(image)
Image:
 [[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]]
  bands=()
  bbox=Box(shape=(3, 4), origin=(0, 0))

This will create a single band :py:class:`~lsst.scarlet.lite.Image` with
origin ``(0, 0)``.
To create a multi-band image the input array must have 3 dimensions and
the ``bands`` property must be specified:

>>> x = np.arange(24).reshape(2, 3, 4)
>>> image = Image(x, bands=("i", "z"))
>>> print(image)
Image:
 [[[ 0  1  2  3]
  [ 4  5  6  7]
  [ 8  9 10 11]]
<BLANKLINE>
 [[12 13 14 15]
  [16 17 18 19]
  [20 21 22 23]]]
  bands=('i', 'z')
  bbox=Box(shape=(3, 4), origin=(0, 0))

It is also possible to create an empty single-band image using the
``from_box`` static method:

>>> from lsst.scarlet.lite import Box
>>> image = Image.from_box(Box((3, 4), (100, 120)))
>>> print(image)
Image:
 [[0. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]]
  bands=()
  bbox=Box(shape=(3, 4), origin=(100, 120))

Similarly, an empty multi-band image can be created by passing a tuple
of ``bands``:

>>> image = Image.from_box(Box((3, 4)), bands=("r", "i"))
>>> print(image)
Image:
 [[[0. 0. 0. 0.]
  [0. 0. 0. 0.]
  [0. 0. 0. 0.]]
<BLANKLINE>
 [[0. 0. 0. 0.]
  [0. 0. 0. 0.]
  [0. 0. 0. 0.]]]
  bands=('r', 'i')
  bbox=Box(shape=(3, 4), origin=(0, 0))

To select a sub-image use a ``Box`` to select a spatial region in either a
single-band or multi-band image:

>>> x = np.arange(60).reshape(3, 4, 5)
>>> image = Image(x, bands=("g", "r", "i"), yx0=(20, 30))
>>> bbox = Box((2, 2), (21, 32))
>>> print(image[bbox])
Image:
 [[[ 7  8]
  [12 13]]
<BLANKLINE>
 [[27 28]
  [32 33]]
<BLANKLINE>
 [[47 48]
  [52 53]]]
  bands=('g', 'r', 'i')
  bbox=Box(shape=(2, 2), origin=(21, 32))


To select a single-band image from a multi-band image,
pass the name of the band as an index:

>>> print(image["r"])
Image:
 [[20 21 22 23 24]
 [25 26 27 28 29]
 [30 31 32 33 34]
 [35 36 37 38 39]]
  bands=()
  bbox=Box(shape=(4, 5), origin=(20, 30))

Multi-band images can also be sliced in the spatial dimension, for example

>>> print(image["g":"r"])
Image:
 [[[ 0  1  2  3  4]
  [ 5  6  7  8  9]
  [10 11 12 13 14]
  [15 16 17 18 19]]
<BLANKLINE>
 [[20 21 22 23 24]
  [25 26 27 28 29]
  [30 31 32 33 34]
  [35 36 37 38 39]]]
  bands=('g', 'r')
  bbox=Box(shape=(4, 5), origin=(20, 30))

and

>>> print(image["r":"r"])
Image:
 [[[20 21 22 23 24]
  [25 26 27 28 29]
  [30 31 32 33 34]
  [35 36 37 38 39]]]
  bands=('r',)
  bbox=Box(shape=(4, 5), origin=(20, 30))

both extract a slice of a multi-band image.

.. warning::
    Unlike numerical indices, where ``slice(x, y)`` will select the
    subset of an array from ``x`` to ``y-1`` (excluding ``y``),
    a spectral slice of an ``Image`` will return the image slice
    including band ``y``.

It is also possible to change the order or index a subset of bands
in an image. For example:

>>> print(image[("r", "g", "i")])
Image:
 [[[20 21 22 23 24]
  [25 26 27 28 29]
  [30 31 32 33 34]
  [35 36 37 38 39]]
<BLANKLINE>
 [[ 0  1  2  3  4]
  [ 5  6  7  8  9]
  [10 11 12 13 14]
  [15 16 17 18 19]]
<BLANKLINE>
 [[40 41 42 43 44]
  [45 46 47 48 49]
  [50 51 52 53 54]
  [55 56 57 58 59]]]
  bands=('r', 'g', 'i')
  bbox=Box(shape=(4, 5), origin=(20, 30))


will return a new image with the bands re-ordered.

Images can be combined using the standard arithmetic operations similar to
numpy arrays, including ``+, -, *, /, **`` etc, however, if two images are
combined with different bounding boxes, the _union_ of the two
boxes is used for the result. For example:

>>> image1 = Image(np.ones((2, 3, 4)), bands=tuple("gr"))
>>> image2 = Image(np.ones((2, 3, 4)), bands=tuple("gr"), yx0=(2, 3))
>>> result = image1 + image2
>>> print(result)
Image:
 [[[1. 1. 1. 1. 0. 0. 0.]
  [1. 1. 1. 1. 0. 0. 0.]
  [1. 1. 1. 2. 1. 1. 1.]
  [0. 0. 0. 1. 1. 1. 1.]
  [0. 0. 0. 1. 1. 1. 1.]]
<BLANKLINE>
 [[1. 1. 1. 1. 0. 0. 0.]
  [1. 1. 1. 1. 0. 0. 0.]
  [1. 1. 1. 2. 1. 1. 1.]
  [0. 0. 0. 1. 1. 1. 1.]
  [0. 0. 0. 1. 1. 1. 1.]]]
  bands=('g', 'r')
  bbox=Box(shape=(5, 7), origin=(0, 0))

If instead you want to additively ``insert`` image 1 into image 2,
so that they have the same bounding box as image 2, use

>>> _ = image2.insert(image1)
>>> print(image2)
Image:
 [[[2. 1. 1. 1.]
  [1. 1. 1. 1.]
  [1. 1. 1. 1.]]
<BLANKLINE>
 [[2. 1. 1. 1.]
  [1. 1. 1. 1.]
  [1. 1. 1. 1.]]]
  bands=('g', 'r')
  bbox=Box(shape=(3, 4), origin=(2, 3))

To insert an image using a different operation use

>>> from operator import truediv
>>> _ = image2.insert(image1, truediv)
>>> print(image2)
Image:
 [[[2. 1. 1. 1.]
  [1. 1. 1. 1.]
  [1. 1. 1. 1.]]
<BLANKLINE>
 [[2. 1. 1. 1.]
  [1. 1. 1. 1.]
  [1. 1. 1. 1.]]]
  bands=('g', 'r')
  bbox=Box(shape=(3, 4), origin=(2, 3))


However, depending on the operation you may get unexpected results
since now there could be ``NaN`` and ``inf`` values due to the zeros
in the non-overlapping regions.
Instead, to select only the overlap region one can use

>>> result = image1 / image2
>>> print(result[image1.bbox & image2.bbox])
Image:
 [[[0.5]]
<BLANKLINE>
 [[0.5]]]
  bands=('g', 'r')
  bbox=Box(shape=(1, 1), origin=(2, 3))


Parameters
----------
data:
    The array data for the image.
bands:
    The bands coving the image.
yx0:
    The (y, x) offset for the lower left of the image.

Member Function Documentation

◆ __add__()

Image lsst.scarlet.lite.image.Image.__add__ ( self,
Image | ScalarLike other )
Combine this image and another image using addition.

◆ __and__()

Image lsst.scarlet.lite.image.Image.__and__ ( self,
Image | ScalarLike other )
Take the bitwise and of this and other.

◆ __eq__()

Image lsst.scarlet.lite.image.Image.__eq__ ( self,
object other )
Check if this image is equal to another.

◆ __floordiv__()

Image lsst.scarlet.lite.image.Image.__floordiv__ ( self,
Image | ScalarLike other )
Floor divide this image by `other` in place.

◆ __ge__()

Image lsst.scarlet.lite.image.Image.__ge__ ( self,
Image | ScalarLike other )
Check if this image is greater than or equal to another.

◆ __getitem__()

Image lsst.scarlet.lite.image.Image.__getitem__ ( self,
Any indices )
Get the subset of an image

Parameters
----------
indices:
    The indices to select a subsection of the image.

Returns
-------
result:
    The resulting image obtained by selecting subsets of the iamge
    based on the `indices`.

◆ __gt__()

Image lsst.scarlet.lite.image.Image.__gt__ ( self,
Image | ScalarLike other )
Check if this image is greater than or equal to another.

◆ __iadd__()

Image lsst.scarlet.lite.image.Image.__iadd__ ( self,
Image | ScalarLike other )
Combine this image and another image using addition and update
in place.

◆ __iand__()

Image lsst.scarlet.lite.image.Image.__iand__ ( self,
Image | ScalarLike other )
Take the bitwise and of this and other in place.

◆ __ifloordiv__()

Image lsst.scarlet.lite.image.Image.__ifloordiv__ ( self,
Image | ScalarLike other )
Floor divide this image by `other` in place.

◆ __ilshift__()

Image lsst.scarlet.lite.image.Image.__ilshift__ ( self,
ScalarLike other )
Shift this image to the left by other bits in place.

◆ __imod__()

Image lsst.scarlet.lite.image.Image.__imod__ ( self,
Image | ScalarLike other )
Take the modulus of this % other in place.

◆ __imul__()

Image lsst.scarlet.lite.image.Image.__imul__ ( self,
Image | ScalarLike other )
Combine this image and another image using multiplication,
with this image on the right.

◆ __invert__()

lsst.scarlet.lite.image.Image.__invert__ ( self)
Take the inverse (~) of the image.

◆ __ior__()

Image lsst.scarlet.lite.image.Image.__ior__ ( self,
Image | ScalarLike other )
Take the binary or of this or other in place.

◆ __ipow__()

Image lsst.scarlet.lite.image.Image.__ipow__ ( self,
Image | ScalarLike other )
Raise this image to the `other` power in place.

◆ __irshift__()

Image lsst.scarlet.lite.image.Image.__irshift__ ( self,
ScalarLike other )
Shift this image to the right by other bits in place.

◆ __isub__()

Image lsst.scarlet.lite.image.Image.__isub__ ( self,
Image | ScalarLike other )
Combine this image and another image using subtraction,
with this image on the right.

◆ __itruediv__()

Image lsst.scarlet.lite.image.Image.__itruediv__ ( self,
Image | ScalarLike other )
Divide this image by `other` in place.

◆ __ixor__()

Image lsst.scarlet.lite.image.Image.__ixor__ ( self,
Image | ScalarLike other )
Take the binary xor of this xor other in place.

◆ __le__()

Image lsst.scarlet.lite.image.Image.__le__ ( self,
Image | ScalarLike other )
Check if this image is less than or equal to another.

◆ __lshift__()

Image lsst.scarlet.lite.image.Image.__lshift__ ( self,
ScalarLike other )
Shift this image to the left by other bits.

◆ __lt__()

Image lsst.scarlet.lite.image.Image.__lt__ ( self,
Image | ScalarLike other )
Check if this image is less than or equal to another.

◆ __mod__()

Image lsst.scarlet.lite.image.Image.__mod__ ( self,
Image | ScalarLike other )
Take the modulus of this % other.

◆ __mul__()

Image lsst.scarlet.lite.image.Image.__mul__ ( self,
Image | ScalarLike other )
Combine this image and another image using multiplication.

◆ __ne__()

Image lsst.scarlet.lite.image.Image.__ne__ ( self,
object other )
Check if this image is not equal to another.

◆ __neg__()

lsst.scarlet.lite.image.Image.__neg__ ( self)
Take the negative of the image.

◆ __or__()

Image lsst.scarlet.lite.image.Image.__or__ ( self,
Image | ScalarLike other )
Take the binary or of this or other.

◆ __pos__()

lsst.scarlet.lite.image.Image.__pos__ ( self)
Make a copy using of the image.

◆ __pow__()

Image lsst.scarlet.lite.image.Image.__pow__ ( self,
Image | ScalarLike other )
Raise this image to the `other` power.

◆ __radd__()

Image lsst.scarlet.lite.image.Image.__radd__ ( self,
Image | ScalarLike other )
Combine this image and another image using addition,
with this image on the right.

◆ __rand__()

Image lsst.scarlet.lite.image.Image.__rand__ ( self,
Image | ScalarLike other )
Take the bitwise and of other and this.

◆ __rfloordiv__()

Image lsst.scarlet.lite.image.Image.__rfloordiv__ ( self,
Image | ScalarLike other )
Floor divide this image by `other` with this on the right.

◆ __rlshift__()

Image lsst.scarlet.lite.image.Image.__rlshift__ ( self,
ScalarLike other )
Shift other to the left by this image bits.

◆ __rmod__()

Image lsst.scarlet.lite.image.Image.__rmod__ ( self,
Image | ScalarLike other )
Take the modulus of other % this.

◆ __rmul__()

Image lsst.scarlet.lite.image.Image.__rmul__ ( self,
Image | ScalarLike other )
Combine this image and another image using multiplication,
with this image on the right.

◆ __ror__()

Image lsst.scarlet.lite.image.Image.__ror__ ( self,
Image | ScalarLike other )
Take the binary or of other or this.

◆ __rpow__()

Image lsst.scarlet.lite.image.Image.__rpow__ ( self,
Image | ScalarLike other )
Raise this other to the power of this image.

◆ __rrshift__()

Image lsst.scarlet.lite.image.Image.__rrshift__ ( self,
ScalarLike other )
Shift other to the right by this image bits.

◆ __rshift__()

Image lsst.scarlet.lite.image.Image.__rshift__ ( self,
ScalarLike other )
Shift this image to the right by other bits.

◆ __rsub__()

Image lsst.scarlet.lite.image.Image.__rsub__ ( self,
Image | ScalarLike other )
Combine this image and another image using subtraction,
with this image on the right.

◆ __rtruediv__()

Image lsst.scarlet.lite.image.Image.__rtruediv__ ( self,
Image | ScalarLike other )
Divide this image by `other` with this on the right.

◆ __rxor__()

Image lsst.scarlet.lite.image.Image.__rxor__ ( self,
Image | ScalarLike other )
Take the binary xor of other xor this.

◆ __setitem__()

Image lsst.scarlet.lite.image.Image.__setitem__ ( self,
indices,
Image value )
Set a subset of an image to a given value

Parameters
----------
indices:
    The indices to select a subsection of the image.
value:
    The value to use for the subset of the image.

Returns
-------
result:
    The resulting image obtained by selecting subsets of the image
    based on the `indices`.

◆ __str__()

lsst.scarlet.lite.image.Image.__str__ ( self)
Display the image array, bands, and bounding box.

◆ __sub__()

Image lsst.scarlet.lite.image.Image.__sub__ ( self,
Image | ScalarLike other )
Combine this image and another image using subtraction.

◆ __truediv__()

Image lsst.scarlet.lite.image.Image.__truediv__ ( self,
Image | ScalarLike other )
Divide this image by `other`.

◆ __xor__()

Image lsst.scarlet.lite.image.Image.__xor__ ( self,
Image | ScalarLike other )
Take the binary xor of this xor other.

◆ _check_equality()

Image lsst.scarlet.lite.image.Image._check_equality ( self,
Image | ScalarLike other,
Callable op )
protected
Compare this array to another.

This performs an element by element equality check.

Parameters
----------
other:
    The image to compare this image to.
op:
    The operator used for the comparision (==, !=, >=, <=).

Returns
-------
image: Image
    An image made by checking all of the elements in this array with
    another.

Raises
------
TypeError:
    If `other` is not an `Image`.
MismatchedBandsError:
    If `other` has different bands.
MismatchedBoxError:
    if `other` exists in a different bounding box.

◆ _get_box_slices()

tuple[slice, slice] lsst.scarlet.lite.image.Image._get_box_slices ( self,
Box bbox )
protected
Get the slices of the image to insert it into the overlapping
region with `bbox`.

◆ _get_sliced()

Image lsst.scarlet.lite.image.Image._get_sliced ( self,
Any indices,
Image | None value = None )
protected
Select a subset of an image

Parameters
----------
indices:
    The indices to select a subsection of the image.
    The spectral index can either be a tuple of indices,
    a slice of indices, or a single index used to select a
    single-band 2D image.
    The spatial index (if present) is a `Box`.

value:
    The value used to set this slice of the image.
    This allows the single `_get_sliced` method to be used for
    both getting a slice of an image and setting it.

Returns
-------
result: Image | np.ndarray
    The resulting image obtained by selecting subsets of the iamge
    based on the `indices`.

◆ _i_update()

Image lsst.scarlet.lite.image.Image._i_update ( self,
Callable op,
Image | ScalarLike other )
protected
Update the data array in place.

This is typically implemented by `__i<op>__` methods,
like `__iadd__`, to apply an operator and update this image
with the data in place.

Parameters
----------
op:
    Operator used to combine this image with the `other` image.
other:
    The other image that is combined with this one using the operator
    `op`.

Returns
-------
image: Image
    This image, after being updated by the operator

◆ _is_spectral_index()

bool lsst.scarlet.lite.image.Image._is_spectral_index ( self,
Any index )
protected
Check to see if an index is a spectral index.

Parameters
----------
index:
    Either a slice, a tuple, or an element in `Image.bands`.

Returns
-------
result:
    ``True`` if `index` is band or tuple of bands.

◆ bands()

tuple lsst.scarlet.lite.image.Image.bands ( self)
The bands used in the image.

◆ bbox()

Box lsst.scarlet.lite.image.Image.bbox ( self)
Bounding box for the special dimensions in the image.

◆ copy()

Image lsst.scarlet.lite.image.Image.copy ( self,
order = None )
Make a copy of this image.

Parameters
----------
order:
    The ordering to use for storing the bytes.
    This is unlikely to be needed, and just defaults to
    the numpy behavior (C) ordering.

Returns
-------
image: Image
    The copy of this image.

◆ copy_with()

lsst.scarlet.lite.image.Image.copy_with ( self,
np.ndarray | None data = None,
str | None order = None,
tuple[str, ...] | None bands = None,
tuple[int, int] | None yx0 = None )
Copy of this image with some parameters updated.

Any parameters not specified by the user will be copied from the
current image.

Parameters
----------
data:
    An update for the data in the image.
order:
    The ordering for stored bytes, from numpy.copy.
bands:
    The bands that the resulting image will have.
    The number of bands must be the same as the first dimension
    in the data array.
yx0:
    The lower-left of the image bounding box.

Returns
-------
image: Image
    The copied image.

◆ data()

np.ndarray lsst.scarlet.lite.image.Image.data ( self)
The image viewed as a numpy array.

◆ dtype()

DTypeLike lsst.scarlet.lite.image.Image.dtype ( self)
The numpy dtype of the image.

◆ from_box()

Image lsst.scarlet.lite.image.Image.from_box ( Box bbox,
tuple | None bands = None,
DTypeLike dtype = float )
static
Initialize an empty image from a bounding Box and optional bands

Parameters
----------
bbox:
    The bounding box that contains the image.
bands:
    The bands for the image.
    If bands is `None` then a 2D image is created.
dtype:
    The numpy dtype of the image.

Returns
-------
image:
    An empty image contained in ``bbox`` with ``bands`` bands.

◆ height()

int lsst.scarlet.lite.image.Image.height ( self)
Height of the image.

◆ insert()

Image lsst.scarlet.lite.image.Image.insert ( self,
Image image,
Callable op = operator.add )
Insert another image into this image in place.

Parameters
----------
image:
    The image to insert this image into.
op:
    The operator to use when combining the images.

Returns
-------
result:
    This instance with `image` inserted.

◆ insert_into()

Image lsst.scarlet.lite.image.Image.insert_into ( self,
Image image,
Callable op = operator.add )
Insert this image into another image in place.

Parameters
----------
image:
    The image to insert this image into.
op:
    The operator to use when combining the images.

Returns
-------
result:
    `image` updated by inserting this instance.

◆ is_multiband()

bool lsst.scarlet.lite.image.Image.is_multiband ( self)
Whether or not the image has a spectral dimension.

◆ matched_slices()

tuple[tuple[slice, ...], tuple[slice, ...]] lsst.scarlet.lite.image.Image.matched_slices ( self,
Box bbox )
Get the slices to match this image to a given bounding box

Parameters
----------
bbox:
    The bounding box to match this image to.

Returns
-------
result:
    Tuple of indices/slices to match this image to the given bbox.

◆ matched_spectral_indices()

tuple[tuple[int, ...] | slice, tuple[int, ...] | slice] lsst.scarlet.lite.image.Image.matched_spectral_indices ( self,
Image other )
Match bands between two images

Parameters
----------
other:
    The other image to match spectral indices to.

Returns
-------
result:
    A tuple with a tuple of indices/slices for each dimension,
    including the spectral dimension.

◆ multiband_slices()

tuple[tuple[int, ...] | slice, slice, slice] lsst.scarlet.lite.image.Image.multiband_slices ( self)
Return the slices required to slice a multiband image

◆ n_bands()

int lsst.scarlet.lite.image.Image.n_bands ( self)
Number of bands in the image.

If `n_bands == 0` then the image is 2D and does not have a spectral
dimension.

◆ overlapped_slices()

tuple[tuple[slice, ...], tuple[slice, ...]] lsst.scarlet.lite.image.Image.overlapped_slices ( self,
Box bbox )
Get the slices needed to insert this image into a bounding box.

Parameters
----------
bbox:
    The region to insert this image into.

Returns
-------
overlap:
    The slice of this image and the slice of the `bbox` required to
    insert the overlapping portion of this image.

◆ project()

Image lsst.scarlet.lite.image.Image.project ( self,
object | tuple[object] | None bands = None,
Box | None bbox = None )
Project this image into a different set of bands

 Parameters
 ----------
 bands:
    Spectral bands to project this image into.
    Not all bands have to be contained in the image, and not all
    bands contained in the image have to be used in the projection.
 bbox:
    A bounding box to project the image into.

Results
-------
image:
    A new image creating by projecting this image into
    `bbox` and `bands`.

◆ repeat()

Image lsst.scarlet.lite.image.Image.repeat ( self,
tuple bands )
Project a 2D image into the spectral dimension

Parameters
----------
bands:
    The bands in the projected image.

Returns
-------
result: Image
    The 2D image repeated in each band in the spectral dimension.

◆ shape()

tuple[int, ...] lsst.scarlet.lite.image.Image.shape ( self)
The shape of the image.

This includes the spectral dimension, if there is one.

◆ spectral_indices()

tuple[int, ...] | slice lsst.scarlet.lite.image.Image.spectral_indices ( self,
Sequence | slice bands )
The indices to extract each band in `bands` in order from the image

This converts a band name, or list of band names,
into numerical indices that can be used to slice the internal numpy
`data` array.

Parameters
---------
bands:
    If `bands` is a list of band names, then the result will be an
    index corresponding to each band, in order.
    If `bands` is a slice, then the ``start`` and ``stop`` properties
    should be band names, and the result will be a slice with the
    appropriate indices to start at `bands.start` and end at
    `bands.stop`.

Returns
-------
band_indices:
    Tuple of indices for each band in this image.

◆ width()

int lsst.scarlet.lite.image.Image.width ( self)
Width of the image.

◆ x0()

int lsst.scarlet.lite.image.Image.x0 ( self)
Location of the x-offset.

◆ y0()

int lsst.scarlet.lite.image.Image.y0 ( self)
location of the y-offset.

◆ yx0()

tuple[int, int] lsst.scarlet.lite.image.Image.yx0 ( self)
Origin of the image, in numpy/C++ y,x ordering.

The documentation for this class was generated from the following file: