CoreImageData

petrophys.interpretation.core_analysis.CoreImageData

class CoreImageData(
depth,
grey_level=None,
grey_std=None,
r=None,
g=None,
b=None,
hue=None,
saturation=None,
value=None,
metadata=<factory>,
)[source]

Color measurements extracted from core slab photographs.

Parameters:
  • depth (np.ndarray) – Measured depth (m or ft).

  • grey_level (np.ndarray, optional) – Average grey level (0–255 or 0–1).

  • grey_std (np.ndarray, optional) – Standard deviation of grey level (texture proxy).

  • r (np.ndarray, optional) – Red channel (0–255).

  • g (np.ndarray, optional) – Green channel (0–255).

  • b (np.ndarray, optional) – Blue channel (0–255).

  • hue (np.ndarray, optional) – Hue (0–360°).

  • saturation (np.ndarray, optional) – Saturation (0–1).

  • value (np.ndarray, optional) – Value/brightness in HSV (0–1).

  • metadata (dict)

Examples

>>> img = CoreImageData.from_las("core_image.las")
>>> bi = img.brightness_index()
>>> ci = img.color_index()

Attributes

Methods

brightness_index

Brightness index scaled to [0, 1].

color_index

Color index: the HSV saturation, or (max - min) / max of RGB.

filter_by_depth

Return a new CoreImageData filtered to [top, bottom].

from_dataframe

Create CoreImageData from a pandas DataFrame.

from_las

Load color data from a LAS file.

lithology_from_color

Simple rule-based lithology classification from color.

rgb_to_hsv

Convert RGB (0–255) to HSV.

texture_index

Texture index from grey level standard deviation.

to_dataframe

Export all loaded channels to a pandas DataFrame.

depth: ndarray
grey_level: ndarray | None = None
grey_std: ndarray | None = None
r: ndarray | None = None
g: ndarray | None = None
b: ndarray | None = None
hue: ndarray | None = None
saturation: ndarray | None = None
value: ndarray | None = None
metadata: Dict[str, Any]
property n_samples: int
property top: float | None
property bottom: float | None
property has_rgb: bool
property has_hsv: bool
classmethod from_las(
filepath,
grey_mnemonic='E_MBWP',
grey_std_mnemonic='E_STDP',
r_mnemonic='E_MRPX',
g_mnemonic='E_MGPX',
b_mnemonic='E_MBPX',
hue_mnemonic='E_MHPX',
sat_mnemonic='E_MSPX',
val_mnemonic='E_MVPX',
null_value=-999.25,
)[source]

Load color data from a LAS file.

Defaults match the EpsLog/Stratum Reservoir Image_10.0mm_WL.las mnemonic convention (E_MBWP, E_MRPX, etc.).

EpsLog stores RGB, grey level, saturation, and value on a 0–255 scale and hue in degrees (0–360). This loader normalises saturation and value to 0–1 automatically when their stored maximum exceeds 1.5, so that color_index() and lithology_from_color() work correctly regardless of source scale.

Depth is read via lasio’s las.index property (always the first column, regardless of mnemonic name).

Parameters:
  • filepath (str or Path)

  • grey_mnemonic (str, optional) – Average grey level mnemonic (EpsLog: E_MBWP).

  • grey_std_mnemonic (str, optional) – Grey level standard deviation (EpsLog: E_STDP).

  • r_mnemonic (str, optional) – RGB channel mnemonics (EpsLog: E_MRPX, E_MGPX, E_MBPX).

  • g_mnemonic (str, optional) – RGB channel mnemonics (EpsLog: E_MRPX, E_MGPX, E_MBPX).

  • b_mnemonic (str, optional) – RGB channel mnemonics (EpsLog: E_MRPX, E_MGPX, E_MBPX).

  • hue_mnemonic (str, optional) – HSV channel mnemonics (EpsLog: E_MHPX, E_MSPX, E_MVPX). Hue is kept in degrees; saturation and value are normalised to 0–1.

  • sat_mnemonic (str, optional) – HSV channel mnemonics (EpsLog: E_MHPX, E_MSPX, E_MVPX). Hue is kept in degrees; saturation and value are normalised to 0–1.

  • val_mnemonic (str, optional) – HSV channel mnemonics (EpsLog: E_MHPX, E_MSPX, E_MVPX). Hue is kept in degrees; saturation and value are normalised to 0–1.

  • null_value (float)

Return type:

CoreImageData

classmethod from_dataframe(
df,
depth_col='DEPTH',
grey_col=None,
grey_std_col=None,
r_col=None,
g_col=None,
b_col=None,
hue_col=None,
sat_col=None,
val_col=None,
)[source]

Create CoreImageData from a pandas DataFrame.

Parameters:
  • df (DataFrame)

  • depth_col (str)

  • grey_col (str | None)

  • grey_std_col (str | None)

  • r_col (str | None)

  • g_col (str | None)

  • b_col (str | None)

  • hue_col (str | None)

  • sat_col (str | None)

  • val_col (str | None)

Return type:

CoreImageData

brightness_index()[source]

Brightness index scaled to [0, 1].

Uses grey_level if available, otherwise derives from RGB mean, or falls back to the HSV value channel. Grey level and RGB are divided by their maximum in the data, so 1 is the brightest sample loaded, not absolute white.

Returns:

Low = dark (organic-rich), high = light (clean carbonate/evaporite).

Return type:

np.ndarray

color_index()[source]

Color index: the HSV saturation, or (max - min) / max of RGB.

Highlights color-rich intervals (iron staining, chlorite, etc.) against grey/white intervals. Returns 0 for grey, 1 for maximum color.

Returns:

Higher values = more colorful / chromatic.

Return type:

np.ndarray

texture_index()[source]

Texture index from grey level standard deviation.

Higher values indicate heterogeneous textures (lamination, bioturbation, vugs). Returns NaN if grey_std is not available.

Return type:

ndarray

rgb_to_hsv()[source]

Convert RGB (0–255) to HSV.

Returns:

  • dict with keys “hue” (0–360), “saturation” (0–1), “value” (0–1).

  • Raises ValueError if RGB channels are not loaded.

Return type:

Dict[str, ndarray]

lithology_from_color()[source]

Simple rule-based lithology classification from color.

Returns:

One of: “dark_organic”, “red_iron”, “tan_sand”, “grey_carbonate”, “green_chlorite”, “unclassified”.

Return type:

np.ndarray of str

filter_by_depth(top, bottom)[source]

Return a new CoreImageData filtered to [top, bottom].

Parameters:
Return type:

CoreImageData

to_dataframe()[source]

Export all loaded channels to a pandas DataFrame.

Return type:

DataFrame