📄 vid_prefilt_sfcn_wrapper.c
字号:
/*
*
* --- THIS FILE GENERATED BY S-FUNCTION BUILDER: 2.0 ---
*
* This file is a wrapper S-function produced by the S-Function
* Builder which only recognizes certain fields. Changes made
* outside these fields will be lost the next time the block is
* used to load, edit, and resave this file. This file will be overwritten
* by the S-function Builder block. If you want to edit this file by hand,
* you must change it only in the area defined as:
*
* %%%-SFUNWIZ_wrapper_XXXXX_Changes_BEGIN
* Your Changes go here
* %%%-SFUNWIZ_wrapper_XXXXXX_Changes_END
*
* For better compatibility with the Real-Time Workshop, the
* "wrapper" S-function technique is used. This is discussed
* in the Real-Time Workshop User's Manual in the Chapter titled,
* "Wrapper S-functions".
*
* Created: Fri Mar 14 14:40:08 2003
*/
/*
* Include Files
*
*/
#include "tmwtypes.h"
/* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */
#include <math.h>
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
#define u_width 120
#define y_width 160
/*
* Create external references here.
*
*/
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
/* extern double func(double a); */
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
/*
* Output functions
*
*/
void vid_prefilt_sfcn_Outputs_wrapper(const uint8_T *I,
real32_T *bx,
real32_T *by,
real32_T *b,
const real_T *dirp, const int_T p_width0)
{
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
/* 2-D pre-filtering for Prewitt edge detection algorithm
* - Input is a uint8 grayscale image, 120x160.
* - Creates three single-precision outputs, bx, bx, and b,
* each of size 120x160.
*
* Numerically equivalent M-code:
* op = [-1 -1 -1; 0 0 0; 1 1 1]; % filter kernel
* bx = filter2(op', I); % I is input image
* by = filter2(op, I);
* b = bx.*bx + by.*by;
*
* Code splits these computations into row/filtering operations,
* merging row-code from bx/by into one loop and col-code into a
* second loop. Also, no multiplies used in bx, by computations.
*
* Dir: 1=both, 2=vert_only, 3=horiz_only
*/
const int_T M = 120; /* rows */
const int_T N = 160; /* cols */
const int_T kx = (int_T)(dirp[0] != 3);
const int_T ky = (int_T)(dirp[0] != 2);
int_T c;
for(c=0; c<N; c++) {
float back2 = 0.0f;
float back1 = (float)(I[c*M]);
int_T r;
for(r=1; r<M; r++) {
float this = (float)(I[r+c*M]);
bx[r-1+c*M] = this + back1 + back2;
by[r-1+c*M] = this - back2;
back2 = back1;
back1 = this;
}
bx[r+c*M] = back1 + back2;
by[r+c*M] = -back2;
}
for(c=0; c<N-2; c++) {
int_T r;
for(r=0; r<M; r++) {
bx[r+c*M] = bx[r+(c+2)*M] - bx[r+c*M];
by[r+c*M] = by[r+c*M] + by[r+(c+1)*M] + by[r+(c+2)*M];
}
}
for (c=0; c<M*N; c++) {
b[c] = 0.0f;
if (kx) b[c] += bx[c]*bx[c];
if (ky) b[c] += by[c]*by[c];
}
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}
/*
* Updates function
*
*/
void vid_prefilt_sfcn_Update_wrapper(const uint8_T *I,
const real32_T *bx,
const real32_T *by,
const real32_T *b,
const real_T *dirp, const int_T p_width0)
{
/* %%%-SFUNWIZ_wrapper_Update_Changes_BEGIN --- EDIT HERE TO _END */
/*
* Code example
* xD[0] = u0[0];
*/
/* %%%-SFUNWIZ_wrapper_Update_Changes_END --- EDIT HERE TO _BEGIN */
}
/*
* Derivatives function
*
*/
void vid_prefilt_sfcn_Derivatives_wrapper(const uint8_T *I,
const real32_T *bx,
const real32_T *by,
const real32_T *b,
real_T *dx,
const real_T *dirp, const int_T p_width0)
{
/* %%%-SFUNWIZ_wrapper_Derivatives_Changes_BEGIN --- EDIT HERE TO _END */
/*
* Code example
* dx[0] = xC[0];
*/
/* %%%-SFUNWIZ_wrapper_Derivatives_Changes_END --- EDIT HERE TO _BEGIN */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -