or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

color.mddata.mddrawing.mdexposure.mdfeatures.mdfiltering.mdindex.mdio.mdmeasurement.mdmorphology.mdrestoration.mdsegmentation.mdtransform.mdutilities.md

utilities.mddocs/

0

# Utilities

1

2

Generic utility functions for data type conversion, array manipulation, noise generation, and common image processing operations.

3

4

## Capabilities

5

6

### Data Type Conversion

7

8

```python { .api }

9

def img_as_float(image, force_copy=False):

10

"""Convert image to floating point format."""

11

12

def img_as_float32(image, force_copy=False):

13

"""Convert image to 32-bit float."""

14

15

def img_as_float64(image, force_copy=False):

16

"""Convert image to 64-bit float."""

17

18

def img_as_uint(image, force_copy=False):

19

"""Convert image to unsigned integer."""

20

21

def img_as_int(image, force_copy=False):

22

"""Convert image to signed integer."""

23

24

def img_as_ubyte(image, force_copy=False):

25

"""Convert image to unsigned byte (0-255)."""

26

27

def img_as_bool(image, force_copy=False):

28

"""Convert image to boolean."""

29

30

def dtype_limits(dtype, clip_negative=True):

31

"""Get intensity limits for data type."""

32

```

33

34

### Array Manipulation

35

36

```python { .api }

37

def crop(ar, crop_width, copy=False, order='K'):

38

"""Crop array along each axis."""

39

40

def view_as_blocks(arr_in, block_shape):

41

"""View array as overlapping blocks."""

42

43

def view_as_windows(arr_in, window_shape, step=1):

44

"""View array as sliding windows."""

45

46

def montage(arr_in, padding_width=0, fill=0, grid_shape=None, multichannel=False, rescale_intensity=False, channel_axis=None):

47

"""Create image montage from array of images."""

48

```

49

50

### Noise Generation

51

52

```python { .api }

53

def random_noise(image, mode='gaussian', seed=None, clip=True, **kwargs):

54

"""Add various types of random noise to image."""

55

```

56

57

### Image Utilities

58

59

```python { .api }

60

def invert(image, signed_float=False):

61

"""Invert image intensities."""

62

63

def map_array(input_arr, input_vals, output_vals, out=None):

64

"""Map input array values to output values."""

65

66

def compare_images(image1, image2, method='diff'):

67

"""Compare two images using specified method."""

68

```

69

70

### Documentation

71

72

```python { .api }

73

def lookfor(what):

74

"""Search for keywords in function docstrings."""

75

```

76

77

## Types

78

79

```python { .api }

80

from typing import Union, Optional, Tuple

81

from numpy.typing import NDArray

82

import numpy as np

83

84

DataType = type

85

IntensityLimits = Tuple[float, float]

86

NoiseMode = str

87

ArrayWindow = NDArray[np.number]

88

```