Commit aa77b6eae6bef882adb0ac9bb2a04c7ffd9382b0

Authored by Arnaud Blanchard
2 parents 799531f3 2d6c2f79

Merge branch 'master' of

# Set the minimum version of cmake required to build this project
cmake_minimum_required(VERSION 2.6)
# Set the name of the project as the directory basename
add_executable(i_d2gaussian i_d2gaussian.cpp)
target_link_libraries(i_d2gaussian ${BL_LIBRARIES})
# Copyright ETIS — ENSEA, Université de Cergy-Pontoise, CNRS (2011 - 2016)
# Author: Arnaud Blanchard (November 2016)
# This software is governed by the CeCILL v2.1 license under French law and abiding by the rules of distribution of free software.
# You can use, modify and/ or redistribute the software under the terms of the CeCILL v2.1 license as circulated by CEA, CNRS and INRIA at the following URL "".
# As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license,
# users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability.
# In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge.
# Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured  and, more generally, to use and operate it in the same conditions as regards security.
# The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms.
cd `dirname $0`
echo "Checking `basename $PWD`"
echo "===================="
echo "No check for now"
// Created by Arnaud Blanchard on 22/12/15.
// Copyright ETIS 2015. All rights reserved.
#include "blc_channel.h"
#include "blc_program.h"
#include <unistd.h>
#include <math.h>
#define DEFAULT_OUTPUT_NAME ":d2gaussian<pid>"
int main(int argc, char **argv){
blc_channel output;
char const *output_name, *size_str, *type_str, *sigma_str, *gain_str;
float sigma, coeff, x, y, gain;
int i, j, id, jd;
uint32_t type;
blc_program_set_description("Create second derivative gaussian");
blc_program_add_option(&gain_str, 'g', "gain", "real", "gain to apply to the filter", "1");
blc_program_add_option(&output_name, 'o', "output", "blc_channel-out", "channel name", DEFAULT_OUTPUT_NAME);
blc_program_add_option(&size_str, 's', "size", "(integer)[x(integer)]", "size of the output 1 or 2D", "3x3");
blc_program_add_option(&type_str, 't', "type", "FL32", "type of values", "FL32");
blc_program_add_option(&sigma_str, 'S', "sigma", "float", "sigma of the initial gaussian", "1");
blc_program_init(&argc, &argv, blc_quit);
if (strcmp(output_name, DEFAULT_OUTPUT_NAME)==0) SYSTEM_ERROR_CHECK(asprintf((char**)&output_name, ":d2gaussian%d", getpid()),-1, NULL);
SSCANF(1, gain_str, "%f", &gain);
SYSTEM_SUCCESS_CHECK(sscanf(sigma_str, "%f", &sigma), 1, "Error parsing '%s'", sigma_str);
output.create_or_open(output_name, BLC_CHANNEL_WRITE, type, 'NDEF', size_str);
// 1/(pi*sigma²)(1-1/2(x²+y²)/sigma²)*exp(-1/2*(x²+y²)/sigma²)
FOR(j, output.dims[1].length){
FOR(i, output.dims[0].length){
coeff=(x*x+y*y)/(float)(2*sigma*sigma); //(x²+y²)/(2*sigma²)
if (output.sem_ack_data) sem_wait(output.sem_ack_data);
if (output.sem_new_data) sem_post(output.sem_new_data);