2013-10-29 29 views
1

我想申請「std過濾器」與一個固定的補丁大小的單通道圖像。
這就是我想要out[i,j]等於img[i,j]附近的像素值的標準差。滑動窗口std過濾器爲一個通道圖像

對於那些你們誰熟悉MATLAB,我正在尋找的

>> out = nlfilter(img, [P P], @std); 

相當於有沒有辦法做到這一點使用ippi的功能呢?

我碰到了ippiMean_StdDev,但它似乎適用於單個窗口,而不是滑動窗口(返回標量值而不是數組)。
我也看到ippiRectStdDev,但手冊聲明此功能是爲整體圖像 - 我不明白這是如何適用於我的情況。

有沒有人有一個工作的例子或更詳細的手冊呢?

回答

1

最後我想通了。

  1. 輸入圖像必須是UINT8格式
  2. 需要分配2個緩衝器(32位浮點和64位浮在我的情況)
  3. 尺寸數組:
    輸入大小H X W
    濾波器尺寸,P x P
    結果大小H-P+1 x W-P+1
    intermidate buffers(32f and 64f)sizes H+1 X W+1(注意加上一個積分圖像邊界!)

    // first, compute integral and sqIntegral image 
    IppiSize sz; sz.width = W; sz.height = H; 
    ippiSqrIntegral_8u32f64f_C1R(uint8ImgPtr, W*sizeof(unsigned char), 
        d32ImgPtr, (W+1)*sizeof(float), 
        d64ImgPtr, (W+1)*sizeof(double), 
        sz, 0, 0); 
    // using the integral images compute the std filter result 
    IppiRect rect = { 0, 0, P, P }; 
    IppiSize dsz; dsz.width = W-P+1; dsz.height = H-P+1; 
    ippiRectStdDev_32f_C1R(d32ImgPtr, (W+1)*sizeof(float), 
        d64ImgPtr, (W+1)*sizeof(double), 
        dstPtr, (W-P+1)*sizeof(float), dsz, rect);