本文整理汇总了C++中Image::Depth方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::Depth方法的具体用法?C++ Image::Depth怎么用?C++ Image::Depth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::Depth方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: string
TEST(ReadPng, Png_Monochrome) {
Image<unsigned char> image;
string png_filename = string(THIS_SOURCE_DIR) + "/image_test/two_pixels_monochrome.png";
EXPECT_TRUE(ReadImage(png_filename.c_str(), &image));
EXPECT_EQ(2, image.Width());
EXPECT_EQ(1, image.Height());
EXPECT_EQ(1, image.Depth());
EXPECT_EQ(image(0,0), (unsigned char)255);
EXPECT_EQ(image(0,1), (unsigned char)0);
}
示例2: Apply
void CMeanFilter_GPU::Apply(const Image& input, Image& output)
{
const int radius = CFilterParameterInterpreter<int>::Convert(_parameters->GetParameter("Radius"));
const int width = input.Width();
const int height = input.Height();
const int NbPixel = width * height;
const int depth = input.Depth();
const unsigned char *image_data = input.Data();
unsigned char *output_data = output.Data();
//int *TempPix = new int[ NbPixel * 2 ];
unsigned char *TempMask = new unsigned char[NbPixel];
//memset( TempPix, 0, NbPixel * 2 * sizeof( int ) );
memset(TempMask, 255, NbPixel * sizeof(unsigned char));
auto current_device = OpenCLUtils::Instance()->GetCurrentDevice();
const cl::Context Context = current_device.Context();
cl_int Error;
cl_mem_flags InOutMemFlags = CL_MEM_READ_WRITE;
cl_mem_flags InMemFlags = CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR;
cl_mem_flags OutMemFlags = CL_MEM_WRITE_ONLY;
// If you ever change the local size, don't forget to change the size in the kernel
// Global size must be a multiple of local size
unsigned int GlobalSizeY = height;
unsigned int GlobalSizeX = width;
cl::Buffer ImBuffer(Context, InMemFlags, NbPixel * depth * sizeof(unsigned char), (void*)image_data, &Error);
cl::Buffer MaskBuffer(Context, InMemFlags, NbPixel * sizeof(unsigned char), (void*)TempMask, &Error);
cl::Buffer OutBuffer(Context, OutMemFlags, NbPixel * depth * sizeof(unsigned char), 0, &Error);
cl::CommandQueue Queue = current_device.CommandQueue();
cl::Event Event;
// Horizontal pass
int Index = 0;
m_KernelH.setArg(Index++, ImBuffer);
m_KernelH.setArg(Index++, MaskBuffer);
m_KernelH.setArg(Index++, OutBuffer);
m_KernelH.setArg(Index++, height);
m_KernelH.setArg(Index++, width);
m_KernelH.setArg(Index++, radius);
Queue.enqueueNDRangeKernel(m_KernelH, cl::NullRange, cl::NDRange(GlobalSizeX, GlobalSizeY), cl::NullRange, 0, &Event);
Event.wait();
Queue.enqueueReadBuffer(OutBuffer, true, 0, NbPixel * depth * sizeof(unsigned char), (void*)output_data, 0, &Event);
Event.wait();
Queue.finish();
delete[] TempMask;
}
示例3: assert
//template<typename ImageOut>
static void rgbFloat2rgbInt(
const Image< RGBfColor >& imaIn,
Image< RGBColor > *imaOut,
float factor = 255.f )
{
assert( imaIn.Depth() == 3 );
(*imaOut).resize(imaIn.Width(), imaIn.Height());
// Convert each int RGB to float RGB values
for( int j = 0; j < imaIn.Height(); ++j )
for( int i = 0; i < imaIn.Width(); ++i )
convertFloatToInt( imaIn( j, i ), (*imaOut)( j, i ), factor );
}
示例4: GetTypeRange
double GetTypeRange(const Image& Img)
{
switch (Img.Depth())
{
case 8:
return 0xFF;
case 16:
return 0xFFFF;
case 32:
if (Img.IsFloat())
return 0xFF;
return 0xFFFFFFFF;
default:
assert(false); // Wrong type used
return 1;
}
}
示例5: GetTypeMin
double GetTypeMin(const Image& Img)
{
if (Img.IsUnsigned())
return 0;
if (Img.IsFloat())
return 0;
switch (Img.Depth())
{
case 8:
return -128.;
case 16:
return -32768.;
case 32:
return -2147483648.;
default:
assert(false); // Wrong type used
return 0;
}
}
示例6: build
/*
====================
build
====================
*/
VOID Game::build()
{
GUARD(Game::build);
// build the color texture
Image* image = GNEW(Image);
CHECK(image);
image->Width(256);
image->Height(256);
image->Depth(1);
image->PixelFormat(PF_RGBA);
image->DataType(DT_UNSIGNED_BYTE);
mColorTexPtr = GNEW(Texture);
CHECK(mColorTexPtr);
mColorTexPtr->Load(image);
// build the color rt
mColorRTPtr = GNEW(Target(mColorTexPtr.Ptr()));
CHECK(mColorRTPtr);
// build the primitive
mQuadPtr = GNEW(Primitive);
CHECK(mQuadPtr);
mQuadPtr->SetType(Primitive::PT_TRIANGLES);
// set the wvp
Constant* wvp_constant_ptr = GNEW(Constant);
CHECK(wvp_constant_ptr);
wvp_constant_ptr->SetMatrix(Matrix());
mQuadPtr->SetConstant("gWVP",wvp_constant_ptr);
// set the color texture
Constant* texture_constant_ptr = GNEW(Constant);
CHECK(texture_constant_ptr);
texture_constant_ptr->SetTexture(mColorTexPtr.Ptr());
mQuadPtr->SetConstant("gBaseTex",texture_constant_ptr);
// set the shader
Str shader_key_name = "shader/default.xml";
KeyPtr shader_key_ptr = Key::Find(shader_key_name.c_str());
if(shader_key_ptr == NULL)
{
Shader*shader = GNEW(Shader);
CHECK(shader);
shader->Load(GLoad(shader_key_name.c_str()));
shader_key_ptr = GNEW(Key(shader_key_name.c_str(), shader));
CHECK(shader_key_ptr);
}
mKeys.push_back(shader_key_ptr);
mQuadPtr->SetShader(dynamic_cast<Shader*>(shader_key_ptr->Ptr()),"p0");
// build the vertex buffer
F32 x = 0.0f, y = 0.0f, w = 256, h = 256;
DVT vertexes[] =
{
{x, y, 0, 0, 0},
{x+w, y, 0, 1, 0},
{x+w, y+h, 0, 1, 1},
{x, y+h, 0, 0, 1},
};
VertexBufferPtr vb_ptr = GNEW(VertexBuffer);
CHECK(vb_ptr);
{
GDataPtr vd_ptr = GNEW(GData);
CHECK(vd_ptr);
vd_ptr->Size(3*sizeof(U32) + 3*sizeof(U8) + sizeof(vertexes));
U8*data_ptr = (U8*)vd_ptr->Ptr();
*(U32*)data_ptr = MAKEFOURCC('G','V','B','O');
data_ptr += sizeof(U32);
*(U32*)data_ptr = sizeof(vertexes)/sizeof(DVT);
data_ptr += sizeof(U32);
*(U32*)data_ptr = sizeof(DVT);
data_ptr += sizeof(U32);
*(U8*)data_ptr = 2;
data_ptr += sizeof(U8);
*(U8*)data_ptr = VertexBuffer::VT_3F;
data_ptr += sizeof(U8);
*(U8*)data_ptr = VertexBuffer::VT_2F;
data_ptr += sizeof(U8);
::memcpy(data_ptr, vertexes, sizeof(vertexes));
data_ptr += sizeof(vertexes);
vb_ptr->Load(vd_ptr.Ptr());
}
mQuadPtr->SetVertexBuffer(vb_ptr.Ptr());
// build the index
const U16 indexes[] = { 3, 0, 2, 2, 0, 1 };
IndexBufferPtr ib_ptr = GNEW(IndexBuffer);
CHECK(ib_ptr);
{
GDataPtr id_ptr = GNEW(GData);
CHECK(id_ptr);
id_ptr->Size(3*sizeof(U32) + sizeof(indexes));
U8*data_ptr = (U8*)id_ptr->Ptr();
*(U32*)data_ptr = MAKEFOURCC('G','I','B','O');
//.........这里部分代码省略.........