Skip to content

Commit

Permalink
Colored output
Browse files Browse the repository at this point in the history
  • Loading branch information
hgaiser committed May 7, 2014
1 parent 1f8be66 commit 5714708
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_store
build
Binary file removed graph/output.jpg
Binary file not shown.
12 changes: 8 additions & 4 deletions graph/src/segment-image.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <map>

#define square(x) ((x)*(x))
#define COLORED_OUTPUT

// random color
cv::Vec3b random_rgb(){
Expand Down Expand Up @@ -92,9 +93,10 @@ cv::Mat segment_image(cv::Mat image, float sigma, float c, int min_size) {
}
}

cv::Mat output(image.size(), CV_16UC1);
#ifdef COLORED_OUTPUT
cv::Mat output(image.size(), CV_8UC3);

/*// pick random colors for each component
// pick random colors for each component
std::vector<cv::Vec3b> colors;
colors.resize(image.total());
for (int i = 0; i < image.total(); i++)
Expand All @@ -105,8 +107,9 @@ cv::Mat segment_image(cv::Mat image, float sigma, float c, int min_size) {
int comp = find(clusters, y * image.cols + x);
output.at<cv::Vec3b>(y, x) = colors[comp];
}
}*/

}
#else
cv::Mat output(image.size(), CV_16UC1);
std::map<int, uint16_t> cluster_ids;
uint16_t max_id = 1;

Expand All @@ -118,6 +121,7 @@ cv::Mat segment_image(cv::Mat image, float sigma, float c, int min_size) {
output.at<uint16_t>(y, x) = cluster_ids[comp];
}
}
#endif

return output;
}
Expand Down

0 comments on commit 5714708

Please sign in to comment.