本文整理汇总了C++中image::pointer::getNrOfChannels方法的典型用法代码示例。如果您正苦于以下问题:C++ pointer::getNrOfChannels方法的具体用法?C++ pointer::getNrOfChannels怎么用?C++ pointer::getNrOfChannels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image::pointer
的用法示例。
在下文中一共展示了pointer::getNrOfChannels方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createIGTLImageMessage
static igtl::ImageMessage::Pointer createIGTLImageMessage(Image::pointer image) {
// size parameters
int size[3] = {(int)image->getWidth(), (int)image->getHeight(), (int)image->getDepth()}; // image dimension
float spacing[3] = {image->getSpacing().x(), image->getSpacing().y(), image->getSpacing().z()}; // spacing (mm/pixel)
int svoffset[3] = {0, 0, 0}; // sub-volume offset
int scalarType;
size_t totalSize = image->getWidth()*image->getHeight()*image->getDepth()*image->getNrOfChannels();
switch(image->getDataType()) {
case TYPE_UINT8:
scalarType = igtl::ImageMessage::TYPE_UINT8;
totalSize *= sizeof(unsigned char);
break;
case TYPE_INT8:
scalarType = igtl::ImageMessage::TYPE_INT8;
totalSize *= sizeof(char);
break;
case TYPE_UINT16:
scalarType = igtl::ImageMessage::TYPE_UINT16;
totalSize *= sizeof(unsigned short);
break;
case TYPE_INT16:
scalarType = igtl::ImageMessage::TYPE_INT16;
totalSize *= sizeof(short);
break;
case TYPE_FLOAT:
scalarType = igtl::ImageMessage::TYPE_FLOAT32;
totalSize *= sizeof(float);
break;
}
//------------------------------------------------------------
// Create a new IMAGE type message
igtl::ImageMessage::Pointer imgMsg = igtl::ImageMessage::New();
imgMsg->SetDimensions(size);
imgMsg->SetSpacing(spacing);
imgMsg->SetNumComponents(image->getNrOfChannels());
imgMsg->SetScalarType(scalarType);
imgMsg->SetDeviceName("DummyImage");
imgMsg->SetSubVolume(size, svoffset);
imgMsg->AllocateScalars();
ImageAccess::pointer access = image->getImageAccess(ACCESS_READ);
memcpy(imgMsg->GetScalarPointer(), access->get(), totalSize);
return imgMsg;
}
示例2: recompileOpenCLCode
/*
void NoneLocalMeans::recompileOpenCLCode(Image::pointer input) {
// Check if there is a need to recompile OpenCL code
if (input->getDimensions() == mDimensionCLCodeCompiledFor &&
input->getDataType() == mTypeCLCodeCompiledFor && !recompile)
return;
OpenCLDevice::pointer device = std::dynamic_pointer_cast<OpenCLDevice>(getMainDevice());
recompile = false;
std::string buildOptions = "";
const bool writingTo3DTextures = device->getDevice().getInfo<CL_DEVICE_EXTENSIONS>().find("cl_khr_3d_image_writes") != std::string::npos;
if (!writingTo3DTextures) {
switch (mOutputType) {
case TYPE_FLOAT:
buildOptions += " -DTYPE=float";
break;
case TYPE_INT8:
buildOptions += " -DTYPE=char";
break;
case TYPE_UINT8:
buildOptions += " -DTYPE=uchar";
break;
case TYPE_INT16:
buildOptions += " -DTYPE=short";
break;
case TYPE_UINT16:
buildOptions += " -DTYPE=ushort";
break;
}
}
buildOptions += " -D WINDOW=";
buildOptions += std::to_string((windowSize-1)/2);
buildOptions += " -D GROUP=";
buildOptions += std::to_string((groupSize-1)/2);
std::string filename;
//might have to seperate color vs gray here, for better runtime
if (input->getDimensions() == 2) {
if(k == 0){
filename = "Algorithms/NoneLocalMeans/NoneLocalMeans2Dconstant.cl";
}else if(k == 1){
filename = "Algorithms/NoneLocalMeans/NoneLocalMeans2Dgaussian.cl";
}else{
filename = "Algorithms/NoneLocalMeans/NoneLocalMeans2Dconstant.cl";
}
//filename = "Algorithms/NoneLocalMeans/NoneLocalMeans2DgsPixelWise.cl";
//filename = "Algorithms/NoneLocalMeans/NoneLocalMeans2Dgs.cl";
//filename = "Algorithms/NoneLocalMeans/NoneLocalMeans2Dc.cl";
}
else {
filename = "Algorithms/NoneLocalMeans/NoneLocalMeans3Dgs.cl";
}
int programNr = device->createProgramFromSource(Config::getKernelSourcePath() + filename, buildOptions);
mKernel = cl::Kernel(device->getProgram(programNr), "noneLocalMeans");
mDimensionCLCodeCompiledFor = input->getDimensions();
mTypeCLCodeCompiledFor = input->getDataType();
}*/
void NonLocalMeans::execute() {
std::cout << "EXECUTE" << std::endl;
Image::pointer input = getInputData<Image>(0);
Image::pointer output = getOutputData<Image>(0);
std::cout << "GOT DATA" << std::endl;
// Initialize output image
ExecutionDevice::pointer device = std::dynamic_pointer_cast<OpenCLDevice>(getMainDevice());
if(mOutputTypeSet) {
output->create(input->getSize(), mOutputType, input->getNrOfChannels());
output->setSpacing(input->getSpacing());
} else {
output->createFromImage(input);
}
mOutputType = output->getDataType();
SceneGraph::setParentNode(output, input);
if(device->isHost()) {
switch(input->getDataType()) {
fastSwitchTypeMacro(executeAlgorithmOnHost<FAST_TYPE>(input, output, groupSize, windowSize, denoiseStrength, sigma));
}
} else {
OpenCLDevice::pointer clDevice = std::static_pointer_cast<OpenCLDevice>(device);
recompileOpenCLCode(input);
cl::NDRange globalSize;
OpenCLImageAccess::pointer inputAccess = input->getOpenCLImageAccess(ACCESS_READ, clDevice);
if(input->getDimensions() == 2) {
std::cout << "DOING CL" << std::endl;
OpenCLImageAccess::pointer outputAccess = output->getOpenCLImageAccess(ACCESS_READ_WRITE, clDevice);
mKernel.setArg(2, (denoiseStrength*denoiseStrength));
mKernel.setArg(3, (sigma*sigma));
globalSize = cl::NDRange(input->getWidth(),input->getHeight());
mKernel.setArg(0, *inputAccess->get2DImage());
mKernel.setArg(1, *outputAccess->get2DImage());
clDevice->getCommandQueue().enqueueNDRangeKernel(
mKernel,
cl::NullRange,
globalSize,
cl::NullRange
//.........这里部分代码省略.........