## Prerequisites

Before starting this lesson, you should be familiar with:

## Learning Objectives

After completing this lesson, learners should be able to:
• Remove objects from a label mask image.

## Motivation

Once objects have been identified in an image as a result of image segmentation, one often filters the objects based on certain measured criteria. For example, very small objects may be noise rather than real objects and could be removed.

## Activities

Show activity for:

## ImageJ GUI

• Open the above mentioned image
• [ Plugins > MorpholibJ > Label Images > Remove Border Labels ] to remove labels at the border
• [ Plugins > MorpholibJ > Analyze > Analyze Regions ] to see area and number of objects
• Using `[X] Pixel Count`. One can uncheck the rest of measurements
• [ Plugins > MorpholibJ > Label Images > Label Size Filtering ] to remove smaller objects
• `Operation "Greater_than"`
• This will keep all objects greater than `Size Limit (pixels)`
• `Size Limit (pixels) 100`

## Exercises

Show exercise/solution for:

## ImageJ GUI

• Open xyz_16bit_labels_nuclei.tif
• See if you have objects touching the borders, if yes, count them manually
• Automatically remove the border objects
• Check how many objects have been removed (Hint: generate measurement tables before and after border removal operation)

## Solution

• Scroll to the last slice of the image and check how many distinct labels you can find there (i.e. count = 13)
• [Plugins › MorphoLibJ › Analyze › Analyze Regions 3D] (Note: [X] Voxel Count)
• [Plugins › MorphoLibJ › Label Images › Remove Border Labels]
• [Plugins › MorphoLibJ › Analyze › Analyze Regions 3D] (Note: [X] Voxel Count)
• Compare the first columns of both the tables and count the entries. In the second table, there should be exactly 13 entries less than total number of entries in first table

## Assessment

### True of false?

1. In bioimage analysis, one should always remove all labels that touch the image boundary.
2. The largest object has the highest label index.
3. If you remove one object, the number of distinct labels decreases by one.

## Solution

1. Very often, but not always. Sometimes it also is an option to normalize downstream measurements by the visible size of objects.
2. No, the label index usually has no meaning.
3. Yes.

1. Is it a good idea to manually remove objects (labels) from an image or should this rather be an automated procedure?
2. What are the pros and cons of removing labels from the image as opposed to keeping all of them and removing the corresponding object measurements later during statistical analysis of the measurement results?

## Solution

1. Automated typically is better as it forces you to define objective and reproducible criteria for which objects to remove.
2. Pro: (i) Reduce computational load for further processing (e.g. morphological filters), (ii) Label mask image is easier to inspect visually (less clutter); Con: (i) You cannot check during analysis how your conclusions would have changed including those objects, (ii) …

## Follow-up material

Recommended follow-up modules: