I am looking to measure the minimum and maximum diameter of multiple particles (groups) in a TIFF image.
This is my current code:
from PIL import Image
import numpy as np
from skimage import measure
import os
import pandas as pd
import warnings; warnings.filterwarnings(action='once')
dirname1 = path
final1 = []
for fname in os.listdir(dirname1):
im = Image.open(os.path.join(dirname1, fname))
imarray = np.array(im)
final1.append(imarray)
final1 = np.asarray(final1)
groups, group_count = measure.label(final1 == 0, return_num = True, connectivity = 2)
print('Groups: \n', groups)
print(f'Number of particles: {group_count}')
df1 = (pd.DataFrame(dict(zip(['Particle #', 'Size [pixel #]'],
np.unique(groups, return_counts=True))))
.loc[lambda d: d['Particle #'].ne(0)]
)
df1.index -= 1
props = measure.regionprops_table(groups, properties = ['label', 'equivalent_diameter'])
df1_new = pd.DataFrame(props)
My TIFF image looks like this: Image example (I normally work with multiple TIFF images)
In my code, I have used skimage to calculate the equivalent diameter. However, I need the min/max Feret diameter in the df1 DataFrame as well.
Thank you.