# DeblurModes

Parameter `DeblurModes` defines the mode and priority for deblurring.

## JSON Structure

**Location in template:**
```
BarcodeReaderTaskSettingOptions[i]
    ├── SectionArray[j]
    │   └── StageArray[k] (Stage object)
    │       └── DeblurModes
```

**Parent object:** [DecodeBarcodesStage](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-reader-task-settings/stage-decode-barcodes.md) object

**Example:**

```json
{
    "DeblurModes": [
        {
            "Mode": "DM_BASED_ON_LOC_BIN"
        },
        {
            "Mode": "DM_THRESHOLD_BINARIZATION" 
        }
    ]
}
```

> [!NOTE]
> - This snippet shows only the `DeblurModes` parameter.
> - To use it, embed this parameter within a Stage object at the `SST_DECODE_BARCODES` stage.
> - For the complete JSON structure, see:
>   - [Full JSON Structure](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/index.md#full-json-structure)
>   - [Minimal Valid JSON](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/index.md#minimal-valid-json-example)

## Parameter Details

Parameter `DeblurModes` consists of a group of deblur mode objects. Each deblur mode object includes a candidate mode and a series of auxiliary mode arguments.

### Mode Arguments

The mode arguments of the deblur mode object are shown as follows:

<table style = "text-align:left">
    <thead>
        <tr>
            <th nowrap="nowrap">Mode Argument Name</th>
            <th nowrap="nowrap">Mode Argument Summary</th>
        </tr>
    </thead>
    <tr>
        <td rowspan = "3" style="vertical-align:text-top">Mode<br>(Required)</td>
        <td><b>Description</b><br>Specifies a deblur mode.
        </td>
    </tr>
    <tr>
        <td><b>Type</b><br><i>String</i>
        </td>
    </tr>
    <tr>
        <td><b>Candidate Mode List</b>
            <br>DM_DIRECT_BINARIZATION
            <br>DM_THRESHOLD_BINARIZATION
            <br>DM_GRAY_EQUALIZATION
            <br>DM_SMOOTHING
            <br>DM_MORPHING
            <br>DM_DEEP_ANALYSIS
            <br>DM_SHARPENING
            <br>DM_BASED_ON_LOC_BIN
            <br>DM_SHARPENING_SMOOTHING
            <br>DM_NEURAL_NETWORK
            <br>DM_SKIP
        </td>
    </tr>
    <tr>
        <td rowspan = "6" style="vertical-align:text-top">DeblurModelNameArray<br>(Optional)</td>
        <td><b>Description</b><br>Sets the Convolutional Neural Networks (CNN) model files used for barcode decoding. It references the names of <a href="/capture-vision/docs/core/parameters/reference/capture-vision-model/index.html" target="_blank">CaptureVisionModel</a> objects.
        </td>
    </tr>
    <tr>
        <td><b>Type</b><br><i>String Array</i>
        </td>
    </tr>
    <tr>
        <td><b>Range</b><br>Each element is the name of a `CaptureVisionModel` object.
        </td>
    </tr>
    <tr>
        <td><b>Default Value</b><br>null
        </td>
    </tr>
    <tr>
        <td><b>Valid For</b><br>DM_NEURAL_NETWORK.
        </td>
    </tr>
    <tr>
        <td><b>Remarks</b><br>Deprecated in version 11.2.1000 and will be removed in future versions. Please use `ModelNameArray` instead.<br>
        </td>
    </tr>
    <tr>
        <td rowspan = "6" style="vertical-align:text-top" id="modelnamearray">ModelNameArray<br>(Optional)</td>
        <td><b>Description</b><br>Sets the Convolutional Neural Networks (CNN) model files used for barcode decoding. It references the names of <a href="/capture-vision/docs/core/parameters/reference/capture-vision-model/index.html" target="_blank">CaptureVisionModel</a> objects.
        </td>
    </tr>
    <tr>
        <td><b>Type</b><br><i>String Array</i>
        </td>
    </tr>
    <tr>
        <td><b>Range</b><br>Each element is the name of a `CaptureVisionModel` object.<br>Candidate values: "OneDDeblur", "EAN13Decoder", "Code128Decoder", "Code39ITFDecoder", "DataMatrixQRCodeDeblur", "PDF417Deblur".<br>"OneDDeblur": for OneD barcodes.<br>"EAN13Decoder": for EAN13 barcodes.<br>"Code128Decoder": for Code128 barcodes.<br>"Code39ITFDecoder": for Code39 and ITF barcodes. Introduced in version 11.4.1000.<br>"DataMatrixQRCodeDeblur": for DataMatrix and QRCode barcodes. Introduced in version 11.4.1000.<br>"PDF417Deblur": for PDF417 barcodes. Introduced in version 11.4.1000.
        </td>
    </tr>
    <tr>
        <td><b>Default Value</b><br>null
        </td>
    </tr>
    <tr>
        <td><b>Valid For</b><br>DM_NEURAL_NETWORK.
        </td>
    </tr>
    <tr>
        <td><b>Remarks</b><br>Introduced in version 11.2.1000.<br>When set to null in version 11.2.1000, "OneDDeblur", "EAN13Decoder", "Code128Decoder" models will be used by default.<br>When set to null in version 11.4.1000, "OneDDeblur", "EAN13Decoder", "Code128Decoder", "Code39ITFDecoder", "DataMatrixQRCodeDeblur", "PDF417Deblur" models will be used by default.
        </td>
    </tr>
    <tr>
        <td rowspan = "5" style="vertical-align:text-top">Level<br>(Optional)</td>
        <td><b>Description</b><br>Sets the effort level used for deblurring, a larger value may improve the Read Rate but slowdown the Speed.
        </td>
    </tr>
    <tr>
        <td><b>Type</b><br><i>int</i>
        </td>
    </tr>
    <tr>
        <td><b>Range</b><br>[1, 9]
        </td>
    </tr>
    <tr>
        <td><b>Default Value</b><br>4
        </td>
    </tr>
    <tr>
        <td><b>Valid For</b><br>DM_NEURAL_NETWORK.
        </td>
    </tr>
    <tr>
        <td rowspan = "6" style="vertical-align:text-top">Methods<br>(Optional)</td>
        <td><b>Description</b><br>Sets the methods used for deep analysis.
        </td>
    </tr>
    <tr>
        <td><b>Type</b><br><i>String Array</i>
        </td>
    </tr>
    <tr>
        <td><b>Range</b><br>Each element is a deep analysis method.<br>OneDGeneral: for OneD barcodes.<br>TwoDGeneral: for 2D barcodes.<br>EAN13Enhanced: for EAN13 barcodes.
        </td>
    </tr>
    <tr>
        <td><b>Default Value</b><br>null
        </td>
    </tr>
    <tr>
        <td><b>Valid For</b><br>DM_DEEP_ANALYSIS.
        </td>
    </tr>
    <tr>
        <td><b>Remarks</b><br>Introduced in version 11.2.1000.<br>
        </td>
    </tr>
</table>

### Default Setting

By default, deblur modes are not configured and set to null.

```json
{
    "DeblurModes": null
}
```

**Remarks:**

When `DeblurModes` is null, the actual deblur modes used depend on the barcode format:

- **For PDF417 format:**  
  [DM_BASED_ON_LOC_BIN, DM_THRESHOLD_BINARIZATION, DM_DIRECT_BINARIZATION, DM_SMOOTHING, DM_GRAY_EQUALIZATION, DM_MORPHING, DM_DEEP_ANALYSIS]

- **For OneD formats:**  
  [DM_BASED_ON_LOC_BIN, DM_THRESHOLD_BINARIZATION, DM_DIRECT_BINARIZATION, **DM_NEURAL_NETWORK (with EAN13Decoder, Code128Decoder and Code39ITFDecoder)**, DM_DEEP_ANALYSIS, DM_SMOOTHING, DM_GRAY_EQUALIZATION, DM_MORPHING]

- **For other formats**

  [DM_BASED_ON_LOC_BIN,DM_THRESHOLD_BINARIZATION,DM_DIRECT_BINARIZATION,DM_DEEP_ANALYSIS,DM_SMOOTHING,DM_GRAY_EQUALIZATION,DM_MORPHING]

## Candidate Mode Introductions

### DM_DIRECT_BINARIZATION

Performs deblur process using the binarization algorithm. This mode has the following arguments for further customizing.

### DM_THRESHOLD_BINARIZATION

Performs deblur process using the threshold binarization algorithm.

When processing OneD barcodes, you can add two `DM_THRESHOLD_BINARIZATION` to your DeblurModes settings. If you do, the second round `DM_THRESHOLD_BINARIZATION` will detect and fill in the blurry area with predicted barcode modules. The second round `DM_THRESHOLD_BINARIZATION` can sharpenly improve the read-rate of blurry OneD barcodes but sacrifice the accuracy.

This mode has the following arguments for further customizing.

### DM_GRAY_EQUALIZATION

Performs deblur process using the gray equalization algorithm. This mode has the following arguments for further customizing.

### DM_SMOOTHING

Performs deblur process using the smoothing algorithm. This mode has the following arguments for further customizing.

### DM_MORPHING

Performs deblur process using the morphing algorithm. This mode has the following arguments for further customizing.

### DM_DEEP_ANALYSIS

Performs deblur process using the deep analysis algorithm. This mode has the following arguments for further customizing.

**Available Mode Arguments:**

- Methods

### DM_SHARPENING

Performs deblur process using the sharpening algorithm. This mode has the following arguments for further customizing.

### DM_BASED_ON_LOC_BIN

Performs deblur process based on the binary image from the localization process. This mode has the following arguments for further customizing.

### DM_SHARPENING_SMOOTHING

Performs deblur process using the sharpening and smoothing algorithm. This mode has the following arguments for further customizing.

### DM_NEURAL_NETWORK

Performs deblur process by utilizing a neural network model.

**Available Mode Arguments:**

- ModelNameArray
- Level
