# EasySegmentUnsupervisedInference

| Support            | ![](assets/images/sample_programs/applies_to/cpp.svg) ![](assets/images/sample_programs/applies_to/cs.svg) ![](assets/images/sample_programs/applies_to/qt.svg) ![](assets/images/sample_programs/applies_to/python.svg)   |
|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Required licenses  | **EasySegment**                                                                                                                                                                                                            |
| Recommended images | In the Deep Learning Additional Resources, the images from the folder `EasySegment Unsupervised/Fabric/Images`                                                                                                             |
| Location           | `Deep Learning Inspection/EasySegmentUnsupervisedInference` and `Console samples/Deep Learning Inspection` *with Python*                                                                                                   |

## Purpose

This sample program demonstrates how to:

- Perform an inference with **EasySegment Unsupervised**.
- Display the results.

![](assets/images/sample_programs/deep_learning_easysegmentunsupervisedinference.webp)

## Code highlights

In the Deep Learning Additional Resources, use the tool `EasySegment Unsupervised/Fabric/Tool 1/Fabric.edltool`.

1. Apply the tool on an image.
   ```c++
   EUnsupervisedSegmenterResult m_Result = m_Segmenter.Apply(m_Img);
   ```
2. Draw the image.
   ```c++
   if (!pDoc->m_Img.IsVoid())
   {
     pDoc->m_Img.Draw(drawAdapter, 2.f, 2.f, -20, -20);
   }
   ```
3. Draw the segmentation map.
   ```c++
   pDoc->m_Result.Draw(drawAdapter);
   ```
4. Check whether the image is defective and construct a label for this image.
   ```c++
   std::wstring label;

   if (pDoc->m_Result.IsDefective())
   {
     label = L"Not ";
   }

   label += ToUnicode(pDoc->m_Segmenter.GetGoodLabel().c_str());
   ```
