MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / readPNG

Function readPNG

dependency/densecrf/examples/my_dense_inference.cpp:78–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78unsigned char * readPNG( char * infile, int& W, int&H, LodePNGColorType format)
79{
80 std::vector<unsigned char> image; //the raw pixels
81 unsigned width, height;
82
83 unsigned error = lodepng::decode(image, width, height, infile, format, 8);
84
85 if(error)
86 {
87 std::cout << "load png error " << std::endl;
88 return 0;
89 }
90 W = width;
91 H = height;
92 std::cout<<"png image loaded, size is "<<W<<" "<<H<<" "<<image.size()<<std::endl;
93 std::cout<<"min and max "<<W<<" "<<H<<" "<<image.size()<<std::endl;
94 int imsize;
95 if(format==LCT_GREY){
96 imsize = W*H;
97 }
98 else{
99 imsize = W*H*3;
100 }
101 unsigned char * r = new unsigned char[imsize];
102 memcpy(r, &image[0], sizeof(unsigned char)*imsize);
103 return r;
104}
105
106int main( int argc, char* argv[]){
107 if (argc<5){

Callers 1

mainFunction · 0.85

Calls 2

decodeFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected