c++ - In opecv, how to implement get_gradientXY of CImg -


i working on implementing function of cimg, get_gradientxy, using interface of opencv. , found cvsobel in opencv may have same effect of get_gradientxy, after experimenting on sample graph, output graph totally different. stuck this.

here testing code:

imgcv.load("1.jpg"); imgcimg.load("1.jpg");  iplimage* psrcimage = imgcv.getopencvimpptr();//get pointer of src graph iplimage* grad_x = cvcreateimage(cvgetsize(psrcimage), psrcimage->depth, 3); iplimage* grad_y = cvcreateimage(cvgetsize(psrcimage), psrcimage->depth, 3); cvsobel(psrcimage,grad_x,1,0,3); cvsobel(psrcimage,grad_y,0,1,3);  std::string filename1 = "gradcvx.jpg"; std::string filename2 = "gradcvy.jpg"; cvsaveimage(filename1.data(), grad_x); cvsaveimage(filename2.data(), grad_y); //*****   cimg_library::cimglist<unsigned char> gradimages =  imgcimg.getcimg().get_gradientxy(2);  gradimages[0].save("gradcimgx.jpg"); gradimages[1].save("gradcimgy.jpg"); 

and gradcvx.jpg totally different gradcimgx.jpg. wondering why. thank you.

you can try implement sobel filter using cvfilter2d function , if correct, , experiment kernel.

here usage example: http://feelmare.blogspot.ru/2013/01/cvfilter2d-example-source-code-various.html

you can create 2 test images, 1 horizontal lines other vertical, apply filter , @ pixel values. correct values can compute hand. verify if correct in each case.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -