ImageProcessing 1.0.0

Edit this page

How to code

In this tutorial, we will look at how to work with the ImageProcessing library using code rather than console commands.

Installing ImageProcessing

> dotnet add package LeonidLodygin.ImageProcessing --version 1.0.0

Load your image using the loadAsImage function from the MyImage module.

let image = loadAsImage "path to the image"

For CPU and GPU the list of transforms is identical, decide what you want to process your image on and select the appropriate function to process from the CpuProcessing module or the GpuProcessing module respectively.

In the case of CPU processing:

Apply the fisheye filter to the uploaded image.

let newImage = fishEye image

Don't forget to save the processed image using the saveImage function from the MyImage module!

let newImage = saveImage "path"

In the case of GPU processing:

In the case of GPU processing, you have to go through a few extra steps to achieve your goal:

Prepare OpenCl context and queue(from Brahma.FSharp module):

let clContext = ClContext(ClDevice.GetFirstAppropriateDevice(device))
let queue = clContext.QueueProvider.CreateQueue()

Compile the kernel to apply the filter using the fishEyeKernel function from the GpuKernels module:

let fishKernel = fishEyeKernel clContext

Process the image using the fishEye function from the GpuProcessing module:

let newImage = fishEye fishKernel clContext 64 queue image

Don't forget to save the new image:

let newImage = saveImage "path"