Last active
July 24, 2023 03:45
-
-
Save symisc/36f10aa215a98bdb5d4dabc4fb94dbdd to your computer and use it in GitHub Desktop.
Apply Gaussian Blur Filter to a given RGB image using the SOD Embedded Computer Vision Library - https://sod.pixlab.io
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Programming introduction with the SOD Embedded Image Processing API. | |
* Copyright (C) PixLab | Symisc Systems, https://sod.pixlab.io | |
*/ | |
/* | |
* Compile this file together with the SOD embedded source code to generate | |
* the executable. For example: | |
* | |
* gcc sod.c gaussian_blur_image.c -lm -Ofast -march=native -Wall -std=c99 -o sod_img_proc | |
* | |
* Under Microsoft Visual Studio (>= 2015), just drop `sod.c` and its accompanying | |
* header files on your source tree and you're done. If you have any trouble | |
* integrating SOD in your project, please submit a support request at: | |
* https://sod.pixlab.io/support.html | |
*/ | |
/* | |
* This simple program is a quick introduction on how to embed and start | |
* experimenting with SOD without having to do a lot of tedious | |
* reading and configuration. | |
* | |
* Make sure you have the latest release of SOD from: | |
* https://pixlab.io/downloads | |
* The SOD Embedded C/C++ documentation is available at: | |
* https://sod.pixlab.io/api.html | |
*/ | |
#include <stdio.h> | |
#include "sod.h" | |
/* | |
* Apply Gaussian Blur Filter to a given RGB/BGR image | |
*/ | |
int main(int argc, char *argv[]) | |
{ | |
/* Input image (pass a path or use the test image shipped with the samples ZIP archive) */ | |
const char *zInput = argc > 1 ? argv[1] : "./flower.jpg"; | |
/* Processed output image path */ | |
const char *zOut = argc > 2 ? argv[2] : "./out_blur.png"; | |
/* Load the input image in the RGB colorspace */ | |
sod_img imgIn = sod_img_load_from_file(zInput, SOD_IMG_COLOR); | |
if (imgIn.data == 0) { | |
/* Invalid path, unsupported format, memory failure, etc. */ | |
puts("Cannot load input image..exiting"); | |
return 0; | |
} | |
/* Apply Gaussian Blur on the loaded RGB image. */ | |
sod_img imgOut = sod_gaussian_blur_image(imgIn, 5, 1.94); | |
/* Finally save our blurred image to the specified path */ | |
sod_img_save_as_png(imgOut, zOut); | |
/* Cleanup */ | |
sod_free_image(imgIn); | |
sod_free_image(imgOut); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment