<a id="easyobject-object-selection"></a>

# Selecting and Sorting Blobs

During image encoding, any segmented pixels are treated as part of an object. This can lead to detecting tiny objects that are actually clusters of noisy pixels. Filtering or sorting the blobs can help you select only the object of interest.

You can select which blobs to keep using the class [`EObjectSelection`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html).

<a id="easyobject-object-selection-create"></a>

## Create a Selection

To create a selection, you must perform a combination of add and remove operations based on various criteria:

- [`Add`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a322b18dab858ea465d42493e588f6193) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a240aa121496d94fc527af888ee02a040) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#a6ce7ff7fa20fdc8a24af38cd2c7596db) or [`Remove`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#abd895ecb7e582fd126a780cb98ba5c7d) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a0003900e72b40f08285b9676863a0cb8) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#ab7e7eded430e7286ec6ebf7c5ee27526) a single object.
- Add all the objects from all the layers of a coded image with [`AddObjects`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#ae15c3a7923c9fc7d876dc2715e71d34a) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a592cf2873995153541386fd91568b7e0) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#a2a5ee1b5f478b4a48f0e2d9299a3bf0e).
- Add or remove all the objects from a layer of a coded image with [`AddLayer`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a882ecfad44d749f931e0276e14a9fbfb) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#acf35db2310f3ec3f5aa10b809b286fac) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#a6eb642e0982a84cd2a81428d25700c37) and [`RemoveLayer`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#ac51ba90b11d7244e092b07a4a683fcf8) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#af637f39c7207bdaa3ad95a1e26b0c8e3) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#aa2835c1f9f0c2d2756093d38bd60e61c).
- Add or remove a single object based on its position with [`AddObjectUsingPosition`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a6f09b023330dbd9413061b04a4feee1a) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#aebcfb8b6c5bcfc86dd4817d6961a5ae2) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#aec4a7431df27038af161e40482b07f9f) and [`RemoveObjectUsingPosition`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#ac1338a2d9909f27d71e2a23521dfe9cb) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a3079fb4e17c895e40f8b67d20bec2956) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#abcab303f796175fcdf4c4e04d8fd3fa3).
- Add or remove objects or holes whose location fullfil a criterion based on an arbitrary region or a rectangle:
  - For arbitrary region, use [`AddObjectsUsingRegion`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#af5f776a9218e8bd1efe6b17d2dce998f) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a26b3551ee12349c889f8deb3bc2dfd68) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#a717bc4671bf97866833532c6ad88229f) and [`RemoveObjectUsingPosition`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#af1b663ef88f859ad12b623eb01288f8e) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a880f04349cc7f7c37c8682f741bfc431) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#af296750e0fda07df33fd74149a3c3fad).
  - For a rectangle, use [`AddObjectsUsingRectangle`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#ad7806c920bd0306f1e1f5e3c602c7ecc) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#ae8a89534ade9056df86f6c72f051ae57) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#a17ae3a01d2cc47d26e3a57d827c4f71f) and [`RemoveObjectsUsingRectangle`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a1bf001e6728190ac63c1d1fdea4d7409) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#adcd17424802b47672b31b9b8189ca80f) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#ae12f594536cd01eba857f845066775ac).
  - The selection criterion is defined by [`ERectangleMode`](../../../doxygen_cpp/namespaceeVision.html#a75bced2a3ed6c18626fb7be42de993df) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#a05bb77dd07e7c03024597519ea3b2f58) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ERectangleMode.html).

  ![image](assets/images/easyobject/EasyObject_ERectangleMode.svg)
- Add or remove objects or holes that fullfil a condition based on numerical **[features](objects_holes_features.html.md#easyobject-objects-features)**. The method depends on the type of the feature:
  - For floating point features, use [`AddObjectsUsingFloatFeature`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a38114b09c3d4a030147cdbfc4f3baa5d) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a94dadb30ba578cb76caf2edf6784eb7c) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#a32ce630d438fdb5fc8f2fb13fdc64dc1) and [`RemoveUsingFloatFeature`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a02ed7db47af6c90d57fa67249af2545a) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a4576d091571dcffceacb490412642cd7) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#a1433bf98dfa52529924687b5033e6a88).
  - For unsigned integer features, use [`AddObjectsUsingUnsignedIntegerFeature`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a11da884175285b95377242110bb006a6) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#ae120686390002da32a4ace1aa85f2e20) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#a4ddf9b0d7b34361d1c387bd230b6cda7) and [`RemoveUsingUnsignedIntegerFeature`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#aef104613adcfca8efa3ad4ba16003cd9) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a4faf090396b97351b9a932f08e9dade2) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#a2bd164e1a32eec05d1250698e57786fd).
  - For integer features, use [`AddObjectsUsingIntegerFeature`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a2bea2540ba47141f1d26468e5a678996) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a6ce5301e47c67b68eae5871e5cdd14f9) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#afd9488a04d1d924daab05ba1da77a751) and [`RemoveUsingIntegerFeature`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a0367f30fdc064c2d9cae71e653710930) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a40363f878b17b45665b9b8b1ff64a012) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#a1102ee17c52adae558d38cbcebc58811).
- Add or remove a single hole with [`AddHole`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a865af4388fa25f06b030da192e856452) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a5619830dc044e833aac231e062e8874d) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#af10cdc45b3ec0ada5e425a209a5d8d75) and [`RemoveHole`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#ad2d5dc906f83f88fe4c97d547adf7bb3) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a2f3e11b2e0ddf1e2fac235ccb75947de) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#a8d18a52d4319e09cb375b9c74e363a90).
- Add or remove all the holes from an object, layer, or coded image with [`AddHoles`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a55f2e9237cdf39145ce62d557ac8c2b7) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#ac4dae66d3b07ef813cfb121fc15f6785) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#a07d8629e8b357e512995473c4ed976dd) and [`RemoveHoles`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a335dcb518316fa312cb06fcdd562b00c) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a06e228a9d54bb6b272c93ce3f145e295) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#a9f080bf8fb0fb31798dde5ebd69622fe).
- Add all the holes of all the object currently in the selection with [`AddHolesOfSelectedObjects`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a083e0ed9a47e539652b5516c92851c0d) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a04c10072ada31dbdeac214f7226b0a91) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#aa6141dd3e4f859be4a8c8ff4636c4749).
- Remove all the holes that are currently in the selection with [`RemoveSelectedHoles`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a5bff533de101fbf94cd2fcd460068643) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a6202efe6c2db343e2172d1aaca01a245) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#ad1ca2433459ad3e98b660296f1c8947d).

<a id="easyobject-object-selection-clear"></a>

## Clear a Selection

You can clear a previous selection using [`EObjectSelection::Clear`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#a00b668a4f5e1deebd7f056adf732afdb) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a9a647bbaedcf9eb54ddbe5db2d64c7de) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#aaf28776c86f0a56368fb2746f733579b).

<a id="easyobject-object-selection-sort"></a>

## Sort a Selection

You can sort the elements of a selection according to any of their features using [`EObjectSelection::Sort`](../../../doxygen_cpp/classeVision_1_1EObjectSelection.html#ac1b810a7e8833f62e2ae49a2ee9137a1) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EObjectSelection.html#a52eb89349ae149d959591aa6f352fe9e) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EObjectSelection.html#a286e7a0ec3040a189e65c7910473cff1).

#### SEE ALSO
See the [code snippets](../../../resources/code_snippets/matching_and_measurement/easyobject/selectingandsortingblobs.html.md) showing how to select and sort blobs.
