imagej / imagej-tensorflow

ImageJ/TensorFlow integration library
https://imagej.net/libs/tensorflow
Other
25 stars 13 forks source link

Feature Request: Object Detection or Instance Segmentation #17

Closed MisterVladimir closed 5 years ago

MisterVladimir commented 5 years ago

In my past life as a cell biologist, I used Imagej/FIJI to manually label regions of interest (ROI) in microscope images. After loading them in the RoiManager, ROI would be processed/analyzed with ImageJ/FIJI's various other tools. Here's an example image -- not mine -- in which someone might want to identify the oval-shaped cell nuclei psuedocolored in blue.
DAPI blue nuclei cells
In this particular image, it might be possible to use traditional signal intensity thresholding + watershed methods, but most images, including possibly the above, have enough edge cases such that traditional approaches don't work.

I guess what I'm trying to say is, manual segmentation fairly labor-intensive and I would have welcomed a plugin for reliably predicting ROI. Would anyone be interested in writing an object detection plugin? I don't think this should be too difficult to implement; much of the code can be copied directly from Tensorflow's Object Detection Java API.

That said, object detection though may not be ideal for microscope images because biological objects are often not regularly shaped. For example, a biologist might be interested in outlining the solid-green individual cells in the above image. If it's not too difficult, we might instead look to implement object instance segmentation instead, e.g. with Mask RCNN, again with the Object Detection API.

I can start working on this myself, but because I have zero experience in Java, the going might be slow. I could learn, but if anyone else is interested in helping out, I'd more than welcome the support.

ctrueden commented 5 years ago

In this particular image, it might be possible to use traditional signal intensity thresholding + watershed methods, but most images, including possibly the above, have enough edge cases such that traditional approaches don't work.

I would not give up so easily. That image and similar ones could probably be segmented using a traditional segmentation approach in a reasonable amount of time by someone with enough experience creating such workflows.

I would have welcomed a plugin for reliably predicting ROI. Would anyone be interested in writing an object detection plugin?

Fiji has a lot of options already, including both "traditional" algorithms as well as [pixel-based classification via ML](). See Category:Segmentation for the list of plugins. There is also a guide on how to automate segmentation. And there is also CellProfiler, whose primary purpose in life is to automate object detection and measurements on that sort of data.

That's not to say that a plugin built on top of that particular pretrained TensorFlow model wouldn't be a good addition to Fiji! As a starting point, I'd encourage you to model your plugin after the MicroscopeImageFocusQualityClassifier. Reuse the same code to download and cache your particular pretrained model on demand. Strip out the logic and parameters you don't need. Tweak the calls to the actual TensorFlow API to build/invoke the graph the way it needs to be done for your model. Happy to help overcome obstacles; just post questions on the Image.sc Forum.