ds_laplace.c

来自「微软的基于HMM的人脸识别原代码, 非常经典的说」· C语言 代码 · 共 56 行

C
56
字号
char wname[] = "Processed frame";
char barname1[] = "Red";
char barname2[] = "Green";
char barname3[] = "Blue";
int slider_pos[3] = {16, 16, 16};
IPLIMAGE im = 0;
IPLIMAGE temp = 0, temp16 = 0;

void threshold(IPLIMAGE in, IPLIMAGE out, int* thresh)
{
    IplROI roi = {0, 0, 0, 0, 0};
    int i;
    
    roi.width = in->width;
    roi.height = in->height;
    in->roi = &roi;
    out->roi = &roi;
    
    if(!temp)
        temp = cvCreateImage(cvSize(in->width, in->height), IPL_DEPTH_8U, 1);
    if(!temp16)
        temp16 = cvCreateImage(cvSize(in->width, in->height), IPL_DEPTH_16S, 1);
    temp->origin = in->origin;
    temp16->origin = in->origin;
   
    for(i = 0; i < 3; i++)
    {
        roi.coi = i + 1;
        iplThreshold(in, out, (char)(thresh[i]*8));
        iplCopy(in, temp);
        cvLaplace(temp, temp16, 5);
        iplConvert(temp16, temp);
        iplCopy(temp, out);
    }
    
    in->roi = 0;
    out->roi = 0;
}

void process(IPLIMAGE image)
{
    if(!im)
        im = iplCloneImage(image);
    else
        iplCopy(image, im);
        
    
    threshold(im, im, slider_pos);
    show_iplimage(wname, im);
}

named_window(wname, 0);
create_trackbar(barname1, wname, &slider_pos[0], 31, 0);
create_trackbar(barname2, wname, &slider_pos[1], 31, 0);
create_trackbar(barname3, wname, &slider_pos[2], 31, 0);
play_ds(process);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?