首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NPP BoxFilters与二进制数据

NPP BoxFilters与二进制数据
EN

Stack Overflow用户
提问于 2013-08-14 13:48:15
回答 1查看 701关注 0票数 0

我试图为BoxFiltering创建NPP示例,但是在8位灰度图像中,我有RGBA二进制数据。我的代码看起来是:

代码语言:javascript
复制
#include "./common/ImagesCPU.h"
#include "./common/ImagesNPP.h"
#include "./common/ImageIO.h"
#include "./common/Exceptions.h"

#include <npp.h>

void boxfilter_transform( Npp8u *oHostSrc, int width, int height ){
    size_t size = width * height * 4;

    // declare a device image and copy construct from the host image,
    // i.e. upload host to device
    npp::ImageNPP_8u_C4 oDeviceSrc(oHostSrc);

    // create struct with box-filter mask size
    NppiSize oMaskSize = {5, 5};
    // create struct with ROI size given the current mask
    NppiSize oSizeROI = {oDeviceSrc.width() - oMaskSize.width + 1, oDeviceSrc.height() - oMaskSize.height + 1};
    // allocate device image of appropriatedly reduced size
    npp::ImageNPP_8u_C4 oDeviceDst(oSizeROI.width, oSizeROI.height);
    // set anchor point inside the mask to (0, 0)
    NppiPoint oAnchor = {0, 0};
    // run box filter
    NppStatus eStatusNPP;
    eStatusNPP = nppiFilterBox_8u_C4R(oDeviceSrc.data(), oDeviceSrc.pitch(),
                                      oDeviceDst.data(), oDeviceDst.pitch(),
                                      oSizeROI, oMaskSize, oAnchor);
    NPP_ASSERT(NPP_NO_ERROR == eStatusNPP);
    // declare a host image for the result
    npp::ImageCPU_8u_C4 oHostDst(oDeviceDst.size());
    // and copy the device result data into it
    oDeviceDst.copyTo(oHostDst.data(), oHostDst.pitch());

    return 0;
}

我试着编译它并得到:

代码语言:javascript
复制
npp_filters.cpp: In function ‘void boxfilter_transform(Npp8u*, int, int)’:
npp_filters.cpp:18:44: error: no matching function for call to ‘npp::ImageNPP<unsigned char, 4u>::ImageNPP(Npp8u*&)’
npp_filters.cpp:18:44: note: candidates are:
./common/ImagesNPP.h:52:13: note: template<class X> npp::ImageNPP::ImageNPP(const npp::ImageCPU<D, N, X>&, bool)
./common/ImagesNPP.h:45:13: note: npp::ImageNPP<D, N>::ImageNPP(const npp::ImageNPP<D, N>&) [with D = unsigned char, unsigned int N = 4u]
./common/ImagesNPP.h:45:13: note:   no known conversion for argument 1 from ‘Npp8u* {aka unsigned char*}’ to ‘const npp::ImageNPP<unsigned char, 4u>&’
./common/ImagesNPP.h:40:13: note: npp::ImageNPP<D, N>::ImageNPP(const npp::Image::Size&) [with D = unsigned char, unsigned int N = 4u]
./common/ImagesNPP.h:40:13: note:   no known conversion for argument 1 from ‘Npp8u* {aka unsigned char*}’ to ‘const npp::Image::Size&’
./common/ImagesNPP.h:35:13: note: npp::ImageNPP<D, N>::ImageNPP(unsigned int, unsigned int, bool) [with D = unsigned char, unsigned int N = 4u]
./common/ImagesNPP.h:35:13: note:   candidate expects 3 arguments, 1 provided
./common/ImagesNPP.h:30:13: note: npp::ImageNPP<D, N>::ImageNPP() [with D = unsigned char, unsigned int N = 4u]
./common/ImagesNPP.h:30:13: note:   candidate expects 0 arguments, 1 provided
npp_filters.cpp:39:12: error: return-statement with a value, in function returning 'void' [-fpermissive]

怎么啦?你能告诉我正确的路吗?

现在,我的代码如下:

代码语言:javascript
复制
// declare a host image object for an 8-bit RGBA image
npp::ImageCPU_8u_C4 oHostSrc(width, height);

// copy data to oHostSrc.data()
Npp8u *nDstData = oHostSrc.data();
memcpy(nDstData, data, size * sizeof(Npp8u));

// declare a device image and copy construct from the host image,
// i.e. upload host to device
npp::ImageNPP_8u_C4 oDeviceSrc(oHostSrc);

但是现在我不能声明一个设备映像并复制(最后一行),得到这样的错误:未定义符号: nppiMalloc_8u_C4。它能是什么?

EN

回答 1

Stack Overflow用户

发布于 2013-08-14 14:48:30

npp::ImageNPP_8u_C4中没有针对单个主机指针的构造函数,您需要首先在npp::ImageCPU_8u_C4中包装主机数组,就像在您所包含的ImageIO.h中所做的那样。关键是,您的NPP映像需要获取一些维度信息,这些信息是oDeviceSrc当前缺少的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18233569

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档