Skip to content

Pixels

siapy.entities.pixels

Coordinates

Bases: NamedTuple

U class-attribute instance-attribute

U: str = 'u'

V class-attribute instance-attribute

V: str = 'v'

H class-attribute instance-attribute

H: str = 'h'

Pixels dataclass

Pixels(_data: DataFrame)

coords class-attribute

df property

df: DataFrame

from_iterable classmethod

from_iterable(iterable: Iterable[tuple[int, int] | Sequence[int]]) -> Pixels
PARAMETER DESCRIPTION
iterable

TYPE: Iterable[tuple[int, int] | Sequence[int]]

Source code in siapy/entities/pixels.py
27
28
29
30
31
32
33
34
35
36
37
38
39
@classmethod
def from_iterable(
    cls,
    iterable: Iterable[
        tuple[
            Annotated[int, "u coordinate on the image"],
            Annotated[int, "v coordinate on the image"],
        ]
        | Sequence[int]
    ],
) -> "Pixels":
    df = pd.DataFrame(iterable, columns=[Pixels.coords.U, Pixels.coords.V])
    return cls(df)

load_from_parquet classmethod

load_from_parquet(filepath: str | Path) -> Pixels
PARAMETER DESCRIPTION
filepath

TYPE: str | Path

Source code in siapy/entities/pixels.py
41
42
43
44
@classmethod
def load_from_parquet(cls, filepath: str | Path) -> "Pixels":
    df = pd.read_parquet(filepath)
    return cls(df)

df_homogenious

df_homogenious() -> DataFrame
Source code in siapy/entities/pixels.py
50
51
52
53
def df_homogenious(self) -> pd.DataFrame:
    df_homo = self.df.copy()
    df_homo[Pixels.coords.H] = 1
    return df_homo

u

u() -> Series
Source code in siapy/entities/pixels.py
55
56
def u(self) -> pd.Series:
    return self.df[Pixels.coords.U]

v

v() -> Series
Source code in siapy/entities/pixels.py
58
59
def v(self) -> pd.Series:
    return self.df[Pixels.coords.V]

to_numpy

to_numpy() -> ndarray
Source code in siapy/entities/pixels.py
61
62
def to_numpy(self) -> np.ndarray:
    return self.df.to_numpy()

save_to_parquet

save_to_parquet(filepath: str | Path) -> None
PARAMETER DESCRIPTION
filepath

TYPE: str | Path

Source code in siapy/entities/pixels.py
64
65
def save_to_parquet(self, filepath: str | Path) -> None:
    self.df.to_parquet(filepath, index=True)