35 #include <opencv2/opencv.hpp> 54 int region_width,
double ratio,
int iterations,
int threshold,
55 int color_space, cv::Mat &labels)
57 unsigned char* R =
new unsigned char[image.rows*image.cols];
58 unsigned char* G =
new unsigned char[image.rows*image.cols];
59 unsigned char* B =
new unsigned char[image.rows*image.cols];
61 for (
int i = 0; i < image.rows; i++) {
62 for (
int j = 0; j < image.cols; j++) {
63 R[i*image.cols + j] = image.at<cv::Vec3b>(i, j)[2];
64 G[i*image.cols + j] = image.at<cv::Vec3b>(i, j)[1];
65 B[i*image.cols + j] = image.at<cv::Vec3b>(i, j)[0];
69 unsigned short* labeling =
new unsigned short[image.rows*image.cols];
70 for (
int i = 0; i < image.rows*image.cols; i++) {
74 LSC(R, G, B, image.rows, image.cols, region_height, region_width, ratio,
75 iterations, threshold, color_space, labeling);
77 labels.create(image.rows, image.cols, CV_32SC1);
78 for (
int i = 0; i < image.rows; i++) {
79 for (
int j = 0; j < image.cols; j++) {
80 labels.at<
int>(i, j) = labeling[i*image.cols + j];
static void computeSuperpixels(const cv::Mat &image, int region_height, int region_width, double ratio, int iterations, int threshold, int color_space, cv::Mat &labels)
Compute superpixels using LSC.
Definition: lsc_opencv.h:53
Wrapper for running LSC on OpenCV images.
Definition: lsc_opencv.h:41