Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Commit

Permalink
Fix code in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
PolinaSavelyeva committed Sep 15, 2023
1 parent 3e5a21f commit 1278cee
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 49 deletions.
24 changes: 12 additions & 12 deletions docs/How_Tos/Making_A_Code.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ <h3><a name="Multi-threaded-processing-on-CPU" class="anchor" href="#Multi-threa
</ul>
<h3><a name="Simple-CPU-Example" class="anchor" href="#Simple-CPU-Example">Simple CPU Example</a></h3>
<p>Open library and load image to process:</p>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">ImageProcessing</span><span class="pn">.</span><span class="id">MyImage</span>
<span class="k">open</span> <span class="id">ImageProcessing</span><span class="pn">.</span><span class="id">CPU</span>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">MyImage</span>
<span class="k">open</span> <span class="id">CPU</span>

<span class="k">let</span> <span onmouseout="hideTip(event, 'fs1', 1)" onmouseover="showTip(event, 'fs1', 1)" class="id">myImage</span> <span class="o">=</span> <span class="id">load</span> <span class="pn">(</span><span class="s">&quot;Full/Path/To/Images/Folder/image_name.jpg&quot;</span><span class="pn">)</span>
</code></pre>
Expand All @@ -227,8 +227,8 @@ <h3><a name="Simple-CPU-Example" class="anchor" href="#Simple-CPU-Example">Simpl
<span class="id">save</span> <span onmouseout="hideTip(event, 'fs7', 10)" onmouseover="showTip(event, 'fs7', 10)" class="id">rotatedImage</span> <span onmouseout="hideTip(event, 'fs4', 11)" onmouseover="showTip(event, 'fs4', 11)" class="id">pathToSave</span>
</code></pre>
<p>The result:</p>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">ImageProcessing</span><span class="pn">.</span><span class="id">MyImage</span>
<span class="k">open</span> <span class="id">ImageProcessing</span><span class="pn">.</span><span class="id">CPU</span>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">MyImage</span>
<span class="k">open</span> <span class="id">CPU</span>

<span class="k">let</span> <span onmouseout="hideTip(event, 'fs1', 12)" onmouseover="showTip(event, 'fs1', 12)" class="id">myImage</span> <span class="o">=</span> <span class="id">load</span> <span class="pn">(</span><span class="s">&quot;Full/Path/To/Images/Folder/image_name.jpg&quot;</span><span class="pn">)</span>

Expand Down Expand Up @@ -276,8 +276,8 @@ <h3><a name="Multi-threaded-processing-on-GPU" class="anchor" href="#Multi-threa
</ul>
<h3><a name="Simple-GPU-Example" class="anchor" href="#Simple-GPU-Example">Simple GPU Example</a></h3>
<p>Open library and load image to process:</p>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">ImageProcessing</span><span class="pn">.</span><span class="id">MyImage</span>
<span class="k">open</span> <span class="id">ImageProcessing</span><span class="pn">.</span><span class="id">GPU</span>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">MyImage</span>
<span class="k">open</span> <span class="id">GPU</span>

<span class="k">let</span> <span onmouseout="hideTip(event, 'fs1', 27)" onmouseover="showTip(event, 'fs1', 27)" class="id">myImage</span> <span class="o">=</span> <span class="id">load</span> <span class="pn">(</span><span class="s">&quot;Full/Path/To/Images/Folder/image_name.jpg&quot;</span><span class="pn">)</span>
</code></pre>
Expand All @@ -300,8 +300,8 @@ <h3><a name="Simple-GPU-Example" class="anchor" href="#Simple-GPU-Example">Simpl
<span class="id">save</span> <span onmouseout="hideTip(event, 'fs7', 45)" onmouseover="showTip(event, 'fs7', 45)" class="id">rotatedImage</span> <span onmouseout="hideTip(event, 'fs4', 46)" onmouseover="showTip(event, 'fs4', 46)" class="id">pathToSave</span>
</code></pre>
<p>The result:</p>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">ImageProcessing</span><span class="pn">.</span><span class="id">MyImage</span>
<span class="k">open</span> <span class="id">ImageProcessing</span><span class="pn">.</span><span class="id">GPU</span>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">MyImage</span>
<span class="k">open</span> <span class="id">GPU</span>

<span class="k">let</span> <span onmouseout="hideTip(event, 'fs1', 47)" onmouseover="showTip(event, 'fs1', 47)" class="id">myImage</span> <span class="o">=</span> <span class="id">load</span> <span class="pn">(</span><span class="s">&quot;Full/Path/To/Images/Folder/image_name.jpg&quot;</span><span class="pn">)</span>

Expand Down Expand Up @@ -335,8 +335,8 @@ <h3><a name="Process-parameters" class="anchor" href="#Process-parameters">Proce
<p>And define a list of <a href="https://polinasavelyeva.github.io/ImageProcessing/reference/imageprocessing-process-transformations.html">transformations</a> to apply to the image, and specify the <a href="https://polinasavelyeva.github.io/ImageProcessing/reference/imageprocessing-process-processingunits.html">processing unit</a> (CPU or GPU) for the operation.</p>
<h3><a name="Simple-Directory-Processing-Example" class="anchor" href="#Simple-Directory-Processing-Example">Simple Directory Processing Example</a></h3>
<p>Open library and define directories:</p>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">ImageProcessing</span><span class="pn">.</span><span class="id">Process</span>
<span class="k">open</span> <span class="id">ImageProcessing</span><span class="pn">.</span><span class="id">AgentSupport</span>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">Process</span>
<span class="k">open</span> <span class="id">AgentSupport</span>

<span class="k">let</span> <span onmouseout="hideTip(event, 'fs14', 71)" onmouseover="showTip(event, 'fs14', 71)" class="id">inputDirectory</span> <span class="o">=</span> <span class="s">&quot;Full/Path/To/Input/Images/Folder/&quot;</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs15', 72)" onmouseover="showTip(event, 'fs15', 72)" class="id">outputDirectory</span> <span class="o">=</span> <span class="s">&quot;Full/Path/To/Output/Images/Folder/&quot;</span>
Expand All @@ -349,8 +349,8 @@ <h3><a name="Simple-Directory-Processing-Example" class="anchor" href="#Simple-D
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs18', 75)" onmouseover="showTip(event, 'fs18', 75)" class="id">agentsSupport</span> <span class="o">=</span> <span class="id">AgentSupport</span><span class="pn">.</span><span class="id">Full</span>
</code></pre>
<p>The result:</p>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">ImageProcessing</span><span class="pn">.</span><span class="id">Process</span>
<span class="k">open</span> <span class="id">ImageProcessing</span><span class="pn">.</span><span class="id">AgentSupport</span>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">Process</span>
<span class="k">open</span> <span class="id">AgentSupport</span>

<span class="k">let</span> <span onmouseout="hideTip(event, 'fs14', 76)" onmouseover="showTip(event, 'fs14', 76)" class="id">inputDirectory</span> <span class="o">=</span> <span class="s">&quot;Full/Path/To/Input/Images/Folder/&quot;</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs15', 77)" onmouseover="showTip(event, 'fs15', 77)" class="id">outputDirectory</span> <span class="o">=</span> <span class="s">&quot;Full/Path/To/Output/Images/Folder/&quot;</span>
Expand Down
28 changes: 16 additions & 12 deletions docs/Tutorials/Getting_Started.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,16 @@ <h3><a name="Using-CLI" class="anchor" href="#Using-CLI">Using CLI</a></h3>
<p>You can find more details about CLI processing <a href="https://polinasavelyeva.github.io/ImageProcessing/How_Tos/Using_A_CLI.html">here</a>.</p>
<h3><a name="Using-Your-Own-Code" class="anchor" href="#Using-Your-Own-Code">Using Your Own Code</a></h3>
<p>Open library and load image to process:</p>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">ImageProcessing</span>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">MyImage</span>
<span class="k">open</span> <span class="id">CPU</span>
<span class="k">open</span> <span class="id">GPU</span>

<span class="k">let</span> <span class="id">myImage</span> <span class="o">=</span> <span class="id">MyImage</span><span class="pn">.</span><span class="id">load</span> <span class="pn">(</span><span class="s">&quot;Full/Path/To/Images/Folder/image_name.jpg&quot;</span><span class="pn">)</span>
<span class="k">let</span> <span class="id">myImage</span> <span class="o">=</span> <span class="id">load</span> <span class="pn">(</span><span class="s">&quot;Full/Path/To/Images/Folder/image_name.jpg&quot;</span><span class="pn">)</span>
</code></pre>
<p>Create new function which sequentially applies blur filter and clockwise rotation to images and saves it on CPU:</p>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">let</span> <span class="id">applyCustomFilterOnCPU</span> <span class="pn">(</span><span class="id">image</span><span class="pn">:</span> <span class="id">MyImage</span><span class="pn">)</span> <span class="pn">(</span><span class="id">pathToSave</span> <span class="pn">:</span> <span onmouseout="hideTip(event, 'fs1', 1)" onmouseover="showTip(event, 'fs1', 1)" class="id">string</span><span class="pn">)</span> <span class="o">=</span>
<span class="k">let</span> <span class="id">blurredImage</span> <span class="o">=</span> <span class="id">image</span> <span class="o">|&gt;</span> <span class="id">CPU</span><span class="pn">.</span><span class="id">applyFilter</span> <span class="id">gaussianBlurKernel</span>
<span class="k">let</span> <span class="id">rotatedImage</span> <span class="o">=</span> <span class="id">blurredImage</span> <span class="o">|&gt;</span> <span class="id">CPU</span><span class="pn">.</span><span class="id">rotate</span> <span class="k">true</span>
<span class="k">let</span> <span class="id">blurredImage</span> <span class="o">=</span> <span class="id">image</span> <span class="o">|&gt;</span> <span class="id">applyFilter</span> <span class="id">gaussianBlurKernel</span>
<span class="k">let</span> <span class="id">rotatedImage</span> <span class="o">=</span> <span class="id">blurredImage</span> <span class="o">|&gt;</span> <span class="id">rotate</span> <span class="k">true</span>

<span class="id">MyImage</span><span class="pn">.</span><span class="id">save</span> <span class="id">rotatedImage</span> <span class="id">pathToSave</span>
</code></pre>
Expand All @@ -235,8 +237,8 @@ <h3><a name="Using-Your-Own-Code" class="anchor" href="#Using-Your-Own-Code">Usi
<span class="k">let</span> <span class="id">clContext</span> <span class="o">=</span> <span class="id">Brahma</span><span class="pn">.</span><span class="id">FSharp</span><span class="pn">.</span><span class="id">ClContext</span><span class="pn">(</span><span class="id">device</span><span class="pn">)</span>
</code></pre>
<p>Next, define new values for filter and rotation functions. This action is necessary because of compiling <a href="https://polinasavelyeva.github.io/ImageProcessing/How_Tos/Making_A_Code.html#GPU-processing-kernels">kernel function</a> once:</p>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">let</span> <span class="id">applyFilterGPU</span> <span class="o">=</span> <span class="id">GPU</span><span class="pn">.</span><span class="id">applyFilter</span> <span class="id">clContext</span> <span class="n">64</span>
<span class="k">let</span> <span class="id">rotateGPU</span> <span class="o">=</span> <span class="id">GPU</span><span class="pn">.</span><span class="id">rotate</span> <span class="id">clContext</span> <span class="n">64</span>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">let</span> <span class="id">applyFilterGPU</span> <span class="o">=</span> <span class="id">applyFilter</span> <span class="id">clContext</span> <span class="n">64</span>
<span class="k">let</span> <span class="id">rotateGPU</span> <span class="o">=</span> <span class="id">rotate</span> <span class="id">clContext</span> <span class="n">64</span>
</code></pre>
<p>And the final function:</p>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">let</span> <span class="id">applyCustomFilterOnGPU</span> <span class="pn">(</span><span class="id">image</span><span class="pn">:</span> <span class="id">MyImage</span><span class="pn">)</span> <span class="pn">(</span><span class="id">pathToSave</span> <span class="pn">:</span> <span onmouseout="hideTip(event, 'fs1', 2)" onmouseover="showTip(event, 'fs1', 2)" class="id">string</span><span class="pn">)</span> <span class="o">=</span>
Expand All @@ -246,21 +248,23 @@ <h3><a name="Using-Your-Own-Code" class="anchor" href="#Using-Your-Own-Code">Usi
<span class="id">MyImage</span><span class="pn">.</span><span class="id">save</span> <span class="id">rotatedImage</span> <span class="id">pathToSave</span>
</code></pre>
<p>The result:</p>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">ImageProcessing</span>
<pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="id">MyImage</span>
<span class="k">open</span> <span class="id">CPU</span>
<span class="k">open</span> <span class="id">GPU</span>

<span class="k">let</span> <span class="id">myImage</span> <span class="o">=</span> <span class="id">MyImage</span><span class="pn">.</span><span class="id">load</span> <span class="pn">(</span><span class="s">&quot;Full/Path/To/Images/Folder/image_name.jpg&quot;</span><span class="pn">)</span>
<span class="k">let</span> <span class="id">myImage</span> <span class="o">=</span> <span class="id">load</span> <span class="pn">(</span><span class="s">&quot;Full/Path/To/Images/Folder/image_name.jpg&quot;</span><span class="pn">)</span>

<span class="k">let</span> <span class="id">applyCustomFilterOnCPU</span> <span class="pn">(</span><span class="id">image</span><span class="pn">:</span> <span class="id">MyImage</span><span class="pn">)</span> <span class="pn">(</span><span class="id">pathToSave</span> <span class="pn">:</span> <span onmouseout="hideTip(event, 'fs1', 3)" onmouseover="showTip(event, 'fs1', 3)" class="id">string</span><span class="pn">)</span> <span class="o">=</span>
<span class="k">let</span> <span class="id">blurredImage</span> <span class="o">=</span> <span class="id">image</span> <span class="o">|&gt;</span> <span class="id">CPU</span><span class="pn">.</span><span class="id">applyFilter</span> <span class="id">gaussianBlurKernel</span>
<span class="k">let</span> <span class="id">rotatedImage</span> <span class="o">=</span> <span class="id">blurredImage</span> <span class="o">|&gt;</span> <span class="id">CPU</span><span class="pn">.</span><span class="id">rotate</span> <span class="k">true</span>
<span class="k">let</span> <span class="id">blurredImage</span> <span class="o">=</span> <span class="id">image</span> <span class="o">|&gt;</span> <span class="id">applyFilter</span> <span class="id">gaussianBlurKernel</span>
<span class="k">let</span> <span class="id">rotatedImage</span> <span class="o">=</span> <span class="id">blurredImage</span> <span class="o">|&gt;</span> <span class="id">rotate</span> <span class="k">true</span>

<span class="id">MyImage</span><span class="pn">.</span><span class="id">save</span> <span class="id">rotatedImage</span> <span class="id">pathToSave</span>

<span class="k">let</span> <span class="id">device</span> <span class="o">=</span> <span class="id">Brahma</span><span class="pn">.</span><span class="id">FSharp</span><span class="pn">.</span><span class="id">ClDevice</span><span class="pn">.</span><span class="id">GetFirstAppropriateDevice</span><span class="pn">(</span><span class="pn">)</span>
<span class="k">let</span> <span class="id">clContext</span> <span class="o">=</span> <span class="id">Brahma</span><span class="pn">.</span><span class="id">FSharp</span><span class="pn">.</span><span class="id">ClContext</span><span class="pn">(</span><span class="id">device</span><span class="pn">)</span>

<span class="k">let</span> <span class="id">applyFilterGPU</span> <span class="o">=</span> <span class="id">GPU</span><span class="pn">.</span><span class="id">applyFilter</span> <span class="id">clContext</span> <span class="n">64</span>
<span class="k">let</span> <span class="id">rotateGPU</span> <span class="o">=</span> <span class="id">GPU</span><span class="pn">.</span><span class="id">rotate</span> <span class="id">clContext</span> <span class="n">64</span>
<span class="k">let</span> <span class="id">applyFilterGPU</span> <span class="o">=</span> <span class="id">applyFilter</span> <span class="id">clContext</span> <span class="n">64</span>
<span class="k">let</span> <span class="id">rotateGPU</span> <span class="o">=</span> <span class="id">rotate</span> <span class="id">clContext</span> <span class="n">64</span>

<span class="k">let</span> <span class="id">applyCustomFilterOnGPU</span> <span class="pn">(</span><span class="id">image</span><span class="pn">:</span> <span class="id">MyImage</span><span class="pn">)</span> <span class="pn">(</span><span class="id">pathToSave</span> <span class="pn">:</span> <span onmouseout="hideTip(event, 'fs1', 4)" onmouseover="showTip(event, 'fs1', 4)" class="id">string</span><span class="pn">)</span> <span class="o">=</span>
<span class="k">let</span> <span class="id">blurredImage</span> <span class="o">=</span> <span class="id">image</span> <span class="o">|&gt;</span> <span class="id">applyFilterGPU</span> <span class="id">gaussianBlurKernel</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions docsSrc/How_Tos/Making_A_Code.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ Four of them are implemented:
Open library and load image to process:

```fsharp
open ImageProcessing.MyImage
open ImageProcessing.CPU
open MyImage
open CPU
let myImage = load ("Full/Path/To/Images/Folder/image_name.jpg")
```
Expand All @@ -97,8 +97,8 @@ let applyCustomFilterOnCPU (image: MyImage) (pathToSave : string) =
The result:

```fsharp
open ImageProcessing.MyImage
open ImageProcessing.CPU
open MyImage
open CPU
let myImage = load ("Full/Path/To/Images/Folder/image_name.jpg")
Expand Down Expand Up @@ -157,8 +157,8 @@ Four of them are implemented:
Open library and load image to process:

```fsharp
open ImageProcessing.MyImage
open ImageProcessing.GPU
open MyImage
open GPU
let myImage = load ("Full/Path/To/Images/Folder/image_name.jpg")
```
Expand Down Expand Up @@ -194,8 +194,8 @@ let applyCustomFilterOnGPU (image: MyImage) (pathToSave : string) =
The result:

```fsharp
open ImageProcessing.MyImage
open ImageProcessing.GPU
open MyImage
open GPU
let myImage = load ("Full/Path/To/Images/Folder/image_name.jpg")
Expand Down Expand Up @@ -237,8 +237,8 @@ And define a list of [transformations](https://polinasavelyeva.github.io/ImagePr
Open library and define directories:

```fsharp
open ImageProcessing.Process
open ImageProcessing.AgentSupport
open Process
open AgentSupport
let inputDirectory = "Full/Path/To/Input/Images/Folder/"
let outputDirectory = "Full/Path/To/Output/Images/Folder/"
Expand All @@ -260,8 +260,8 @@ let agentsSupport = AgentSupport.Full
The result:

```fsharp
open ImageProcessing.Process
open ImageProcessing.AgentSupport
open Process
open AgentSupport
let inputDirectory = "Full/Path/To/Input/Images/Folder/"
let outputDirectory = "Full/Path/To/Output/Images/Folder/"
Expand Down
Loading

0 comments on commit 1278cee

Please sign in to comment.