# Learning to Segment Blob-like Objects by Image-Level Counting
## 1 Introduction  
Image segmentation is a common task in deep learning, but it typically involves time-consuming manual annotation work. Usually, it becomes necessary to outline polygons around each object by hand on a large number of images. This not only creates much work, but it also causes inconsistencies in the annotation characteristics, e.g., in the case of unsharp boundaries between objects and the background. This is especially the case when multiple annotators are involved as interobserver variability and, thus, different annotation characteristics may occur. Even if the annotator remains the same, deviations due to intraobserver variabilities cannot be excluded [1]. Existing solutions for training a segmentation with weak supervision are intended for classifications and not for counting [2] as they not only use the pure number of objects, but also use additional information like key points or density maps [3] (or rely on pre-trained encoders, which have to be available for the domain of application or have to be trained beforehand with strong supervision [4]). A straightforward candidate for a solution is to use class activation mapping (CAM) [5] to obtain segmentations from a counting network. In using a self-developed CAM-based approach, we show that this methodology is unsuitable when applied to real data since it does not allow for the controlling of the extracted segmentation shapes. We introduce a counting head, which we constructed as an extension of a segmentation network to enable the counting of objects. To prevent such problems, we developed a weakly supervised segmentation approach, based on specialized loss functions, which corrects undesired segmentation shapes during the training phase. It requires no input other than the expected number of objects in an image, and it does not rely on pre-trained encoders. This training method allows for an annotator to specify the number of objects in an image instead of having tomark the object regions. In this way, manual effort is reduced significantly, and inconsistencies, which can occur with localized annotation, are prevented. We saw advantages in use cases where a large number of objects with unsharp boundaries are to be segmented. This holds particularly for microscopy techniques like fluorescence microscopy [6], bright-field microscopy [7], and surface plasmon resonance imaging (SPRi) [8]. For our studies, we used the image data from the plasmon-assisted microscopy of nano-objects (PAMONO) sensor [9], an SPRi sensor for the detection of viruses and virus-like particles in a biological sample. Annotating the data recorded by this sensor is a monotonous task as it \"can take up to one week to label a large data set with high virus concentration\" [10], which, thus, makes the obtained annotations person-dependent and potentially inaccurate. We used these data to evaluate our training method from a practical point of view. As a complement to the natural data that were only available in limited numbers, as well as due to the fact that annotations may contain errors and inconsistencies, we also used synthetic data generation for our evaluation. This addition has an advantage in the fact that the images are available in an arbitrary number, the annotations are always consistent, and the number of objects is adjustable. Thus, the evaluation of the synthetic case indicates the achievable results in a controlled environment. In brief, the main contributions of this paper are as follows:  
* The development of a counting head as an extension that enables count training for segmentation networks;
* The introduction of a method to connect counting networks to classification-based CAM analysis without losing the counting information;
* The development of two losses, contrast loss and morphological loss, which enforce the outputs of a segmentation learned by count training to be suitable for subsequent blob detection by penalizing noise and favoring blob-like structures.