为什么python调用stardist识别细胞的结果这么差,imagej里的识别结果就是正常的,参数什么的也都调的一样的
import numpy as np
import matplotlib.pyplot as plt
from stardist.models import StarDist2D
from stardist import random_label_cmap
from skimage import io
from skimage.color import gray2rgb
import cv2
lbl_cmap = random_label_cmap()
model = StarDist2D.from_pretrained('2D_versatile_fluo')
image = io.imread('MAX_Image-37.png')
re,th1=cv2.threshold(image ,127,255,cv2.THRESH_BINARY)
kernel = np.ones((5, 5), np.uint8)
kernel = np.ones((3,3),np.uint8)
erosion = cv2.erode(th1,None,iterations = 1)
labels, details = model.predict_instances(
erosion,
prob_thresh=0.3,
nms_thresh=0.5
)
plt.figure(figsize=(10, 10))
plt.subplot(1, 2, 1)
plt.imshow(image, cmap='gray')
plt.title('Original Image')
plt.subplot(1, 2, 2)
plt.imshow(gray2rgb(image), cmap='gray')
plt.imshow(labels, cmap=lbl_cmap, alpha=0.5)
plt.title('Segmented Cells')
plt.show()