Main Page
Classes
Files
File List
File Members
src
perception
road
road_recognition
src
watershedSegmentation.h
Go to the documentation of this file.
1
/*------------------------------------------------------------------------------------------*\
2
This file contains material supporting chapter 5 of the cookbook:
3
Computer Vision Programming using the OpenCV Library.
4
by Robert Laganiere, Packt Publishing, 2011.
5
6
This program is free software; permission is hereby granted to use, copy, modify,
7
and distribute this source code, or portions thereof, for any purpose, without fee,
8
subject to the restriction that the copyright notice may not be removed
9
or altered from any source or altered source distribution.
10
The software is released on an as-is basis and without any warranties of any kind.
11
In particular, the software is not guaranteed to be fault-tolerant or free from failure.
12
The author disclaims all warranties with regard to this software, any use,
13
and any consequent failure, is purely the responsibility of the user.
14
15
Copyright (C) 2010-2011 Robert Laganiere, www.laganiere.name
16
\*------------------------------------------------------------------------------------------*/
17
18
#if !defined WATERSHS
19
#define WATERSHS
20
21
#include <opencv2/core/core.hpp>
22
#include <opencv2/imgproc/imgproc.hpp>
23
24
class
WatershedSegmenter
{
25
26
private
:
27
28
cv::Mat
markers
;
29
30
public
:
31
32
void
setMarkers
(
const
cv::Mat& markerImage) {
33
34
// Convert to image of ints
35
markerImage.convertTo(
markers
,CV_32S);
36
}
37
38
cv::Mat
process
(
const
cv::Mat &image) {
39
40
// Apply watershed
41
cv::watershed(image,
markers
);
42
43
return
markers
;
44
}
45
46
// Return result in the form of an image
47
cv::Mat
getSegmentation
() {
48
49
cv::Mat tmp;
50
// all segment with label higher than 255
51
// will be assigned value 255
52
markers
.convertTo(tmp,CV_8U);
53
54
return
tmp;
55
}
56
57
// Return watershed in the form of an image
58
cv::Mat
getWatersheds
() {
59
60
cv::Mat tmp;
61
markers
.convertTo(tmp,CV_8U,255,255);
62
63
return
tmp;
64
}
65
};
66
67
68
#endif
WatershedSegmenter::markers
cv::Mat markers
Definition:
watershedSegmentation.h:28
WatershedSegmenter::setMarkers
void setMarkers(const cv::Mat &markerImage)
Definition:
watershedSegmentation.h:32
WatershedSegmenter::getWatersheds
cv::Mat getWatersheds()
Definition:
watershedSegmentation.h:58
WatershedSegmenter
Definition:
watershedSegmentation.h:24
WatershedSegmenter::getSegmentation
cv::Mat getSegmentation()
Definition:
watershedSegmentation.h:47
WatershedSegmenter::process
cv::Mat process(const cv::Mat &image)
Definition:
watershedSegmentation.h:38
road_recognition
Author(s): Ricardo Morais
autogenerated on Mon Mar 2 2015 01:32:51