Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <stdio.h>
00011 #include <math.h>
00012 #include <vector>
00013 #include <float.h>
00014 using namespace std;
00015
00016 #include <opencv2/opencv.hpp>
00017 #include "slic.h"
00018 using namespace cv;
00019
00020
00021 int main(int argc, char *argv[]) {
00022
00023 Mat image = imread("dog.png", 1);
00024 Mat lab_image;
00025 cvtColor(image, lab_image, COLOR_BGR2Lab);
00026
00027
00028 int w = image.cols, h = image.rows;
00029 int nr_superpixels = 400;
00030 int nc = 40;
00031
00032 double step = sqrt((w * h) / (double) nr_superpixels);
00033
00034
00035 Slic slic;
00036 slic.generate_superpixels(lab_image, int(step), nc);
00037 slic.create_connectivity(lab_image);
00038 slic.display_contours(image, Vec3b(0,0,255));
00039
00040
00041 imshow("result", image);
00042 waitKey(0);
00043 }