-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmf.cpp
More file actions
42 lines (36 loc) · 1.01 KB
/
mf.cpp
File metadata and controls
42 lines (36 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* @file mf.cpp
* fast median filter wrapper based on OpenCV
*
* @blackball
*/
#include "mf.h"
#include "ctmf.h"
#include <cv.h>
#include <highgui.h>
#include <assert.h>
#define _CHKFMT(src, dst) \
( \
src->width == dst->width && \
src->height == dst->height && \
src->depth == dst->depth && \
src->nChannels == dst->nChannels \
)
/**
* src and dst should be "char" format
* dst was allocated outside, and src must
* be the same size with dst.
*/
void mf(IplImage *src, IplImage *dst, int radius)
{
assert(src && dst && radius > 0 && _CHKFMT(src, dst));
ctmf((unsigned char*)(src->imageData),
(unsigned char*)(dst->imageData),
src->width, src->height,
src->widthStep, dst->widthStep,
radius, /* radius of kernel, 2 * radius + 1 */
src->nChannels,
256 * 1024 /* L2 cache size is a proper option */
);
}
#undef _CHKFMT