Extract coordinates of nuclei in image
hossam-zaki opened this issue · comments
Hello!
Hope all is well. I have two images. One with the H+E staining, and another one, which is the exact same, but is colored by cell label. I'm wondering if it is possible to extract the coordinates of each nuclei in the input image? I would like to go from the nuclei in one picture to its label in the other using the coordinates. Is this possible?
See the two images below (this is from an open source dataset):
Hi,
I guess you can try something like that:
from histocartography.preprocessing import NucleiExtractor
from PIL import Image
import numpy as np
# 1. load image
image = np.array(Image.open(image.png)) # or whatever your image name is
# 2. extract nuclei as an instance map & centroids (coords)
extractor = NucleiExtractor(pretrained_data='monusac') # you can try another checkpoint with 'pannuke'
instance_map, instance_centroids = extractor.process(image) # instance_centroids is what you look for
Keeping in mind that Monusac and PanNuke datasets include mostly high magnification images. Your image seems to be at low magnification, so maybe try to run the algo with a better resolution, if possible.
Can you print the image size?
Numpy and image-based packages use different indexing conventions, (row,col) for numpy and (x,y) for PIL, cv2 etc.