Image skills for python

Read tiff files

skimage

import skimage.io as skio
imstack1 = skio.imread("FILENAME.TIF", plugin="tifffile")

Gaussian Smoothing

scipy

from scipy.ndimage import gaussian_filter
import matplotlib.pyplot as plt
import numpy as np

a = np.arange(50, step=2).reshape((5,5))
b = gaussian_filter(a, sigma=3)

fig, axs = plt.subplots(1,2)
axs[0].imshow(a)
axs[1].imshow(b)

plt.show()

Gaussian Smoothing

Gaussian example from scipy
© scipy

Turn image to DataFrame

Grey image

import pandas as pd
import numpy as np

# create a 2D image array
image_array = np.array([[10, 20, 30], [40, 50, 60], [70, 80, 90]])
# convert to pandas dataframe
df = pd.DataFrame(image_array)
# print dataframe
print(df)
Author

Karobben

Posted on

2023-03-07

Updated on

2023-06-06

Licensed under

Comments