Closed pakiessling closed 1 year ago
Ok,
label = cd.data.contours2labels(y["contours"][0].detach().numpy(),size=img.shape[:2])
does the trick
I noticed that
label = cd.data.contours2labels(y["contours"][0].to("cpu").detach().numpy(),size=img.shape[:2])
returns multiple channels.
What excatly does "Channels are used to model overlap" mean?
I saved label = label[:,:,0]
, but it actually looked different (much worse) then the plotted contour.
What is the best way to create a single 1 ... n label image for comparison to ground truth?
Hi, for the contours2labels
function it is important to note that it expects numpy arrays, rather than Tensors, and works on single batch items.
For specifics, you may also refer to the documentation.
By default, the label images come with channels, as contours may assign pixels to multiple objects.
Since such multi-assignments cannot be easily encoded in a channel-free label image, channels are used.
I updated the documentation to make this clearer.
There are many ways to resolve unwanted overlaps, i.e. channels. I just pushed cd.data.resolve_label_channels
, which currently offers the solution used in the CellSeg challenge.
For your case you could do the following:
contours, = cd.asnumpy(y['contours'])
labels = cd.data.contours2labels(contours, img.shape[:2])
labels = cd.data.resolve_label_channels(labels) # remove channels
Note, that you need to install the latest version of celldetection
from git to use resolve_label_channels
.
Thanks for pushing such a quick update!
Hi, I must be overlooking something obvious. How do I save calculated contours as a label image?
Keeping with your Coin example:
Both
label = cd.data.contours2labels(y['contours'],size=img.shape[:2])
andlabel = cd.data.contours2labels(np.array(y['contours']),size=img.shape[:2])
give me error messages.