1. Products
  2.   Image
  3.   Python
  4.   Sikit Image
 
  

Open Source Python API for Images

Scientific Image Analysis, Filtering and Restoration of images via Python API.

Sikit-Image is an open source Python API for image processing. The API provides a wide range of image processing routines in Python. Using the API, you can extract data from specific, scientific, and general purpose images, use NumPy operations for image manipulation, generate structuring elements, block views on images, manipulate exposure and color channels, manage edges and lines and perform geometrical transformations.

Furthermore, the API allows filtering and restoration of images. You can remove small-scale objects in greyscale images, use mean filters, usharp masking, and more. Not only this, the API allows much more features to manipulate images.

Previous Next

Getting Started with Sikit-Image

The recommended way to install Sikit-Image is via Pip. Please use the following command to install Sikit-Image.

Install Sikit-Image via Pip

pip install scikit-image

Manipulate Exposure & Color Channels via Python

Sikit-Image API allows manipulating color & exposure of images programmatically.You can convert and RGB Image to a greyscale image or HSV image. You can work on histogram matching, Immunohistochemical staining colors separation, tinting gray-scale images, histogram Equalization, gamma and log contrast adjustment, filtering regional maxima, and adapting gray-scale filters to RGB images

Geometrical Transformations Using Free Python API

Sikit-Image API allows manipulating color & exposure of images programmatically. You can convert an RGB Image to a greyscale image or HSV image. You can work on histogram matching, Immunohistochemical staining colors separation, tinting gray-scale images, histogram Equalization, gamma and log contrast adjustment, filtering regional maxima, and adapting gray-scale filters to RGB images

Perform Geometrical Transformations via Python

# First we create a transformation using explicit parameters:

tform = transform.SimilarityTransform(scale=1, rotation=math.pi/2,
                                      translation=(0, 1))
print(tform.params)

# Alternatively you can define a transformation by the transformation matrix itself:

matrix = tform.params.copy()
matrix[1, 2] = 2
tform2 = transform.SimilarityTransform(matrix)

# apply forward & inverse coordinate transformations b/t the source & destination coordinate systems:

coord = [1, 0]
print(tform2(coord))
print(tform2.inverse(tform(coord)))

# Geometric transformations  to warp images:

text = data.text()
tform = transform.SimilarityTransform(scale=1, rotation=math.pi/4,
                                      translation=(text.shape[0]/2, -100))

rotated = transform.warp(text, tform)
back_rotated = transform.warp(rotated, tform.inverse)

fig, ax = plt.subplots(nrows=3)

ax[0].imshow(text, cmap=plt.cm.gray)
ax[1].imshow(rotated, cmap=plt.cm.gray)
ax[2].imshow(back_rotated, cmap=plt.cm.gray)

for a in ax:
    a.axis('off')

plt.tight_layout()

Image Filtering & Restoration via Python

Scikit-Image library allows developers to filter and restore images programmatically. You can remove small objects from greyscale images with a top hat filter, use windows functions with images, use mean filters, use unsharp masking, use image deconvolution, and more.

Perform Image Filtering via Python

# Let us load an image available through scikit-image’s data registry.

image = data.astronaut()
image = color.rgb2gray(image)

# Let us blur this image with a series of uniform filters of increasing size.

blurred_images = [ndi.uniform_filter(image, size=k) for k in range(2, 32, 2)]
img_stack = np.stack(blurred_images)

fig = px.imshow(
    img_stack,
    animation_frame=0,
    binary_string=True,
    labels={'animation_frame': 'blur strength ~'}
)
plotly.io.show(fig)

# Plot blur metric

B = pd.DataFrame(
    data=np.zeros((len(blurred_images), 3)),
    columns=['h_size = 3', 'h_size = 11', 'h_size = 30']
)
for ind, im in enumerate(blurred_images):
    B.loc[ind, 'h_size = 3'] = measure.blur_effect(im, h_size=3)
    B.loc[ind, 'h_size = 11'] = measure.blur_effect(im, h_size=11)
    B.loc[ind, 'h_size = 30'] = measure.blur_effect(im, h_size=30)

B.plot().set(xlabel='blur strength (half the size of uniform filter)',
             ylabel='blur metric');

plt.show()

 English