or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

tessl/pypi-scikit-image

Comprehensive image processing and computer vision library for Python with algorithms for filtering, morphology, segmentation, and feature detection

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/scikit-image@0.25.x

To install, run

npx @tessl/cli install tessl/pypi-scikit-image@0.25.0

0

# scikit-image

1

2

A comprehensive Python library for image processing and computer vision. scikit-image provides a collection of algorithms for image processing including color space conversion, filtering, morphology, segmentation, feature detection, geometric transformations, and measurement operations. It serves as the foundational image processing library for the Python scientific ecosystem.

3

4

## Package Information

5

6

- **Package Name**: scikit-image

7

- **Language**: Python

8

- **Installation**: `pip install scikit-image`

9

10

## Core Imports

11

12

```python

13

import skimage

14

```

15

16

Common submodule imports:

17

18

```python

19

from skimage import io, filters, morphology, segmentation

20

from skimage.feature import canny, corner_harris

21

from skimage.transform import resize, rotate

22

from skimage.measure import label, regionprops

23

```

24

25

## Basic Usage

26

27

```python

28

import numpy as np

29

from skimage import io, filters, morphology, measure

30

31

# Load an image

32

image = io.imread('path/to/image.jpg')

33

34

# Convert to grayscale if needed

35

from skimage.color import rgb2gray

36

gray_image = rgb2gray(image)

37

38

# Apply Gaussian filter for noise reduction

39

smooth = filters.gaussian(gray_image, sigma=1.0)

40

41

# Edge detection

42

edges = filters.sobel(smooth)

43

44

# Morphological operations

45

cleaned = morphology.remove_small_objects(edges > 0.1, min_size=100)

46

47

# Label connected components

48

labeled = measure.label(cleaned)

49

props = measure.regionprops(labeled)

50

51

# Basic measurements

52

for prop in props:

53

print(f"Area: {prop.area}, Centroid: {prop.centroid}")

54

55

# Save processed image

56

io.imsave('processed_image.jpg', cleaned)

57

```

58

59

## Architecture

60

61

scikit-image is organized into focused submodules, each targeting specific image processing domains:

62

63

- **Core Processing**: Filtering, morphology, and transformations for fundamental image operations

64

- **Analysis & Measurement**: Feature detection, region properties, and quantitative analysis

65

- **Color & Intensity**: Color space conversion and intensity adjustment operations

66

- **Segmentation**: Algorithms to partition images into meaningful regions

67

- **Input/Output**: Flexible image reading and writing with format support

68

- **Utilities**: Data type conversion, noise generation, and helper functions

69

70

This modular design enables selective imports and provides clear separation of concerns for different image processing workflows.

71

72

## Capabilities

73

74

### Color Space Conversion

75

76

Convert between different color representations including RGB, HSV, LAB, XYZ and specialized spaces for histological imaging and color analysis.

77

78

```python { .api }

79

def rgb2gray(rgb): ...

80

def rgb2hsv(rgb): ...

81

def rgb2lab(rgb, illuminant='D65', observer='2'): ...

82

def hsv2rgb(hsv): ...

83

def lab2rgb(lab, illuminant='D65', observer='2'): ...

84

def rgba2rgb(rgba, background=(1, 1, 1)): ...

85

```

86

87

[Color Processing](./color.md)

88

89

### Image Filtering and Enhancement

90

91

Apply filters for noise reduction, edge detection, sharpening, and enhancement. Includes Gaussian filters, edge detection operators, ridge filters, and thresholding methods.

92

93

```python { .api }

94

def gaussian(image, sigma=1, **kwargs): ...

95

def sobel(image, mask=None, **kwargs): ...

96

def canny(image, sigma=1, low_threshold=None, **kwargs): ...

97

def threshold_otsu(image, nbins=256): ...

98

def median(image, disk=None, **kwargs): ...

99

def unsharp_mask(image, radius=1.0, amount=1.0, **kwargs): ...

100

```

101

102

[Filtering](./filtering.md)

103

104

### Morphological Operations

105

106

Perform morphological operations including erosion, dilation, opening, closing, and advanced operations with customizable structuring elements.

107

108

```python { .api }

109

def erosion(image, footprint=None, **kwargs): ...

110

def dilation(image, footprint=None, **kwargs): ...

111

def opening(image, footprint=None, **kwargs): ...

112

def closing(image, footprint=None, **kwargs): ...

113

def skeletonize(image, method='lee'): ...

114

def remove_small_objects(ar, min_size=64, **kwargs): ...

115

```

116

117

[Morphology](./morphology.md)

118

119

### Geometric Transformations

120

121

Transform images through rotation, scaling, warping, and coordinate system transformations. Includes support for various transformation models and image pyramids.

122

123

```python { .api }

124

def resize(image, output_shape, **kwargs): ...

125

def rotate(image, angle, **kwargs): ...

126

def rescale(image, scale, **kwargs): ...

127

def warp(image, inverse_map, **kwargs): ...

128

class AffineTransform(matrix=None, **kwargs): ...

129

class ProjectiveTransform(matrix=None, **kwargs): ...

130

```

131

132

[Transformations](./transform.md)

133

134

### Image Segmentation

135

136

Partition images into regions using watershed, region growing, active contours, and superpixel algorithms for object detection and analysis.

137

138

```python { .api }

139

def watershed(image, markers=None, **kwargs): ...

140

def random_walker(data, labels, **kwargs): ...

141

def slic(image, n_segments=100, **kwargs): ...

142

def felzenszwalb(image, scale=1, **kwargs): ...

143

def chan_vese(image, **kwargs): ...

144

def active_contour(image, snake, **kwargs): ...

145

```

146

147

[Segmentation](./segmentation.md)

148

149

### Feature Detection and Description

150

151

Detect and describe image features including corners, edges, blobs, and keypoints. Includes modern feature descriptors like SIFT, ORB, and texture analysis methods.

152

153

```python { .api }

154

def corner_harris(image, method='k', **kwargs): ...

155

def corner_peaks(image, **kwargs): ...

156

def blob_log(image, **kwargs): ...

157

def blob_dog(image, **kwargs): ...

158

class ORB(n_keypoints=500, **kwargs): ...

159

class SIFT(**kwargs): ...

160

```

161

162

[Feature Detection](./features.md)

163

164

### Image Measurement and Analysis

165

166

Measure geometric properties, analyze regions, compute image moments, and extract quantitative information from processed images.

167

168

```python { .api }

169

def label(image, background=None, **kwargs): ...

170

def regionprops(label_image, intensity_image=None, **kwargs): ...

171

def find_contours(image, level=0.5, **kwargs): ...

172

def moments(image, order=3): ...

173

def centroid(image): ...

174

def perimeter(image, neighbourhood=4): ...

175

```

176

177

[Measurement](./measurement.md)

178

179

### Image Input/Output

180

181

Read and write images in various formats with support for image collections, metadata handling, and multi-frame images.

182

183

```python { .api }

184

def imread(fname, **kwargs): ...

185

def imsave(fname, arr, **kwargs): ...

186

class ImageCollection(pattern, **kwargs): ...

187

def imread_collection(pattern, **kwargs): ...

188

```

189

190

[Input/Output](./io.md)

191

192

### Restoration and Denoising

193

194

Restore degraded images through deconvolution, denoising, and inpainting algorithms for image quality improvement.

195

196

```python { .api }

197

def denoise_tv_chambolle(image, weight=0.1, **kwargs): ...

198

def denoise_bilateral(image, **kwargs): ...

199

def denoise_wavelet(image, **kwargs): ...

200

def richardson_lucy(image, psf, num_iter=50, **kwargs): ...

201

def inpaint_biharmonic(image, mask, **kwargs): ...

202

```

203

204

[Restoration](./restoration.md)

205

206

### Intensity and Exposure Adjustment

207

208

Adjust image intensity, perform histogram operations, and enhance image contrast for better visualization and analysis.

209

210

```python { .api }

211

def rescale_intensity(image, in_range='image', out_range='dtype'): ...

212

def equalize_hist(image, nbins=256, mask=None): ...

213

def equalize_adapthist(image, kernel_size=None, **kwargs): ...

214

def adjust_gamma(image, gamma=1, gain=1): ...

215

def histogram(image, nbins=256, source_range='image', normalize=False): ...

216

```

217

218

[Exposure](./exposure.md)

219

220

### Drawing and Visualization

221

222

Create geometric shapes, draw on images, and generate synthetic test patterns for visualization and algorithm testing.

223

224

```python { .api }

225

def line(r0, c0, r1, c1): ...

226

def circle_perimeter(r, c, radius, method='bresenham', shape=None): ...

227

def polygon(r, c, shape=None): ...

228

def disk(center, radius, shape=None): ...

229

def rectangle(start, end=None, extent=None, shape=None): ...

230

def set_color(image, coords, color, alpha=1): ...

231

```

232

233

[Drawing](./drawing.md)

234

235

### Test Data and Examples

236

237

Access example images and synthetic datasets for testing algorithms and learning image processing techniques.

238

239

```python { .api }

240

def camera(): ...

241

def coins(): ...

242

def astronaut(): ...

243

def binary_blobs(length=512, blob_size_fraction=0.1, n_dim=2, **kwargs): ...

244

def checkerboard(): ...

245

```

246

247

[Data](./data.md)

248

249

### Utilities and Data Types

250

251

Convert between data types, generate noise, manipulate arrays, and access utility functions for image processing workflows.

252

253

```python { .api }

254

def img_as_float(image, force_copy=False): ...

255

def img_as_uint(image, force_copy=False): ...

256

def img_as_ubyte(image, force_copy=False): ...

257

def random_noise(image, mode='gaussian', **kwargs): ...

258

def crop(ar, crop_width, **kwargs): ...

259

def montage(arr_in, **kwargs): ...

260

```

261

262

[Utilities](./utilities.md)

263

264

## Types

265

266

```python { .api }

267

from typing import Union, Optional, Tuple, List, Dict, Any

268

from numpy.typing import NDArray

269

import numpy as np

270

271

# Core image type

272

Image = NDArray[np.number]

273

274

# Common parameter types

275

Sigma = Union[float, Tuple[float, ...]]

276

Footprint = Optional[NDArray[np.bool_]]

277

Shape = Tuple[int, ...]

278

ColorTuple = Tuple[float, float, float]

279

```