# Patch Optimization Tutorial

### Data Preparation:

**The Code Path:** LineArtCoherenceTool/StreamlineCorresponding/patchOptimization.py

<div align="left"><img src="https://2623269614-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfkqTPfO1tvFPgDTJLX%2F-MhmSG8PsTEizV60h2pR%2F-MhmUzbbMnctSTRO0k1g%2Fimage.png?alt=media&#x26;token=297e918d-dbb0-4a13-a460-deb983d81594" alt=""></div>

**Argument Needed:**&#x20;

* Image Segment Input

The Input Frame Segment Image.

![Walking\_0000.png](https://2623269614-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfkqTPfO1tvFPgDTJLX%2F-MhmSG8PsTEizV60h2pR%2F-MhmVMZzTmbCIc4Orcf1%2Fwalking_0000.png?alt=media\&token=e471723c-21c7-4abd-8da2-acdec6319bbf)

* PatchInfo.txt

The Patch Information of all the (b,g,r) color.

<div align="left"><img src="https://2623269614-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfkqTPfO1tvFPgDTJLX%2F-MhmSG8PsTEizV60h2pR%2F-MhmVhd4uAaszm5KEOUz%2Fimage.png?alt=media&#x26;token=ceb03d29-36ec-4b30-94d1-b1b67e75770e" alt="Walking_0000_PatchInfo.txt"></div>

### How To Use:

**1.Set-up the input path:**

<div align="left"><img src="https://2623269614-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfkqTPfO1tvFPgDTJLX%2F-MhmSG8PsTEizV60h2pR%2F-MhmW-HNvIY0Qnktyv3w%2Fimage.png?alt=media&#x26;token=a0294b09-3cc2-47a3-ab21-56b91f0b3fff" alt="Main Code of the patchOptimization.py"></div>

**2.Run The Code:**

![Output Result of the Program](https://2623269614-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfkqTPfO1tvFPgDTJLX%2F-MhmSG8PsTEizV60h2pR%2F-MhmWKha1zT2JzhdByU9%2Fimage.png?alt=media\&token=84d222b4-9462-4897-b1cb-7a35e3631786)

### Output Result:

**Output Value Explain:**

* Patch \[BGR Color] = 'Patch Score Value'
* 1st area = pixel count of the patch ; 2nd area = pixel count of the patch /total count of the entire patch
* 1st obstacle = obstacle value of the patch ; 2nd obtacle = obstacle ratio over the entire patch.

**Next Step (manually):**

1. Decide a threshold value manually based on the observation of Patch Score Value. (ex: 0.01)
2. Only render the threshold value that over the decided threshold.
