Go to the documentation of this file.00001 #include <ros/ros.h>
00002 #include <cpl_superpixels/segment/segment.h>
00003 #include <opencv2/highgui/highgui.hpp>
00004 #include <string>
00005
00006 #include <cpl_superpixels/segment/segment-image.h>
00007 #include <cpl_superpixels/segment/image.h>
00008 #include <cpl_superpixels/segment/converter.h>
00009
00010 namespace cpl_superpixels
00011 {
00012
00013 cv::Mat getSuperpixelImage(cv::Mat input_img, int& num_ccs, cv::Mat& disp_img,
00014 double sigma, double k, int min_size)
00015 {
00016 IplImage ipl_img = input_img;
00017
00018 image<rgb>* im = IPLtoFELZS(&ipl_img);
00019 image<rgb> *disp_im = segment_image(im, sigma, k, min_size, &num_ccs);
00020 delete im;
00021
00022 IplImage* disp_ipl;
00023 IplImage* idx_ipl;
00024 disp_ipl = FELZStoIPL(disp_im);
00025 idx_ipl = FELZSIDXtoIPL(disp_im);
00026 delete disp_im;
00027 cv::Mat tmp_img(disp_ipl);
00028 tmp_img.copyTo(disp_img);
00029 cvReleaseImage(&disp_ipl);
00030 cv::Mat tmp_img2(idx_ipl);
00031 cv::Mat idx_img(tmp_img2.size(), tmp_img2.type());
00032 tmp_img2.copyTo(idx_img);
00033 cvReleaseImage(&idx_ipl);
00034 return idx_img;
00035 }
00036
00037 cv::Mat getSuperpixelImage(cv::Mat color_img, cv::Mat depth_img, int& num_ccs,
00038 cv::Mat& disp_img, double sigma, double k,
00039 int min_size,
00040 double wr, double wg, double wb, double wd)
00041 {
00042 IplImage color_ipl_img = color_img;
00043
00044 image<rgb>* color_im = IPLtoFELZS(&color_ipl_img);
00045 image<float>* depth_im = DEPTHtoFELZS(depth_img);
00046 cv::Mat depth_revert;
00047 image<rgb> *disp_im = segment_image(color_im, depth_im, sigma, k, min_size,
00048 &num_ccs, wr, wg, wb, wd);
00049 delete color_im;
00050 delete depth_im;
00051
00052 IplImage* disp_ipl;
00053 IplImage* idx_ipl;
00054 cv::Mat idx_img;
00055 disp_ipl = FELZStoIPL(disp_im);
00056 idx_img = FELZSIDXtoMAT(disp_im);
00057 delete disp_im;
00058 cv::Mat tmp_img(disp_ipl);
00059 tmp_img.copyTo(disp_img);
00060 cvReleaseImage(&disp_ipl);
00061 return idx_img;
00062 }
00063
00064 };