Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
c9e3e220
Commit
c9e3e220
authored
Jan 19, 2016
by
Maximilien Cuony
Committed by
Maximilien Cuony
Jan 20, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implementation of SelectiveSearchSegmentation
parent
ef4dd5e5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
190 additions
and
9 deletions
+190
-9
README.md
modules/ximgproc/README.md
+1
-0
ximgproc.bib
modules/ximgproc/doc/ximgproc.bib
+12
-0
segmentation.hpp
modules/ximgproc/include/opencv2/ximgproc/segmentation.hpp
+0
-0
graphsegmentation_demo.cpp
modules/ximgproc/samples/graphsegmentation_demo.cpp
+12
-9
selectivesearchsegmentation_demo.cpp
...les/ximgproc/samples/selectivesearchsegmentation_demo.cpp
+115
-0
graphsegmentation.cpp
modules/ximgproc/src/graphsegmentation.cpp
+50
-0
selectivesearchsegmentation.cpp
modules/ximgproc/src/selectivesearchsegmentation.cpp
+0
-0
No files found.
modules/ximgproc/README.md
View file @
c9e3e220
...
...
@@ -8,3 +8,4 @@ Extended Image Processing
5.
Joint Bilateral Filter
6.
Superpixels
7.
Graph segmentation
8.
Selective search from segmentation
modules/ximgproc/doc/ximgproc.bib
View file @
c9e3e220
...
...
@@ -67,6 +67,18 @@
publisher={Springer}
}
@article{uijlings2013selective,
title={Selective search for object recognition},
author={Uijlings, Jasper RR and van de Sande, Koen EA and Gevers, Theo and Smeulders, Arnold WM},
journal={International journal of computer vision},
volume={104},
number={2},
pages={154--171},
year={2013},
publisher={Springer}
}
@article{Min2014,
title={Fast global image smoothing based on weighted least squares},
author={Min, Dongbo and Choi, Sunghwan and Lu, Jiangbo and Ham, Bumsub and Sohn, Kwanghoon and Do, Minh N},
...
...
modules/ximgproc/include/opencv2/ximgproc/segmentation.hpp
View file @
c9e3e220
This diff is collapsed.
Click to expand it.
modules/ximgproc/samples/
cpp/
graphsegmentation_demo.cpp
→
modules/ximgproc/samples/graphsegmentation_demo.cpp
View file @
c9e3e220
...
...
@@ -32,13 +32,16 @@ the use of this software, even if advised of the possibility of such damage.
#include "opencv2/ximgproc/segmentation.hpp"
#include "opencv2/highgui.hpp"
#include
<opencv2/core/utility.hpp>
#include
<opencv2/opencv.hpp>
#include
"opencv2/core.hpp"
#include
"opencv2/imgproc.hpp"
#include <iostream>
using
namespace
cv
;
using
namespace
cv
::
ximgproc
::
segmentation
;
Scalar
hsv_to_rgb
(
Scalar
);
Scalar
color_mapping
(
int
);
static
void
help
()
{
std
::
cout
<<
std
::
endl
<<
"A program demonstrating the use and capabilities of a particular graph based image"
<<
std
::
endl
<<
...
...
@@ -55,9 +58,9 @@ Scalar hsv_to_rgb(Scalar c) {
float
*
p
=
in
.
ptr
<
float
>
(
0
);
p
[
0
]
=
c
[
0
]
*
360
;
p
[
1
]
=
c
[
1
];
p
[
2
]
=
c
[
2
];
p
[
0
]
=
(
float
)
c
[
0
]
*
360.0
f
;
p
[
1
]
=
(
float
)
c
[
1
];
p
[
2
]
=
(
float
)
c
[
2
];
cvtColor
(
in
,
out
,
COLOR_HSV2RGB
);
...
...
@@ -97,7 +100,7 @@ int main(int argc, char** argv) {
gs
->
setSigma
(
atof
(
argv
[
3
]));
if
(
argc
>
4
)
gs
->
setK
(
atoi
(
argv
[
4
]));
gs
->
setK
(
(
float
)
atoi
(
argv
[
4
]));
if
(
argc
>
5
)
gs
->
setMinSize
(
atoi
(
argv
[
5
]));
...
...
@@ -137,9 +140,9 @@ int main(int argc, char** argv) {
for
(
int
j
=
0
;
j
<
output
.
cols
;
j
++
)
{
Scalar
color
=
color_mapping
(
p
[
j
]);
p2
[
j
*
3
]
=
color
[
0
];
p2
[
j
*
3
+
1
]
=
color
[
1
];
p2
[
j
*
3
+
2
]
=
color
[
2
];
p2
[
j
*
3
]
=
(
uchar
)
color
[
0
];
p2
[
j
*
3
+
1
]
=
(
uchar
)
color
[
1
];
p2
[
j
*
3
+
2
]
=
(
uchar
)
color
[
2
];
}
}
...
...
modules/ximgproc/samples/selectivesearchsegmentation_demo.cpp
0 → 100644
View file @
c9e3e220
/*
By downloading, copying, installing or using the software you agree to this
license. If you do not agree to this license, do not download, install,
copy or use the software.
License Agreement
For Open Source Computer Vision Library
(3-clause BSD License)
Copyright (C) 2013, OpenCV Foundation, all rights reserved.
Third party copyrights are property of their respective owners.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the names of the copyright holders nor the names of the contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
This software is provided by the copyright holders and contributors "as is" and
any express or implied warranties, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose are
disclaimed. In no event shall copyright holders or contributors be liable for
any direct, indirect, incidental, special, exemplary, or consequential damages
(including, but not limited to, procurement of substitute goods or services;
loss of use, data, or profits; or business interruption) however caused
and on any theory of liability, whether in contract, strict liability,
or tort (including negligence or otherwise) arising in any way out of
the use of this software, even if advised of the possibility of such damage.
*/
#include "opencv2/ximgproc/segmentation.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
#include <ctime>
using
namespace
cv
;
using
namespace
cv
::
ximgproc
::
segmentation
;
static
void
help
()
{
std
::
cout
<<
std
::
endl
<<
"A program demonstrating the use and capabilities of a particular image segmentation algorithm described"
<<
std
::
endl
<<
" in Jasper R. R. Uijlings, Koen E. A. van de Sande, Theo Gevers, Arnold W. M. Smeulders: "
<<
std
::
endl
<<
"
\"
Selective Search for Object Recognition
\"
"
<<
std
::
endl
<<
"International Journal of Computer Vision, Volume 104 (2), page 154-171, 2013"
<<
std
::
endl
<<
std
::
endl
<<
"Usage:"
<<
std
::
endl
<<
"./selectivesearchsegmentation_demo input_image (single|fast|quality)"
<<
std
::
endl
<<
"Use a to display less rects, d to display more rects, q to quit"
<<
std
::
endl
;
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
<
3
)
{
help
();
return
-
1
;
}
setUseOptimized
(
true
);
setNumThreads
(
8
);
std
::
srand
((
int
)
std
::
time
(
0
));
Mat
img
=
imread
(
argv
[
1
]);
Ptr
<
SelectiveSearchSegmentation
>
gs
=
createSelectiveSearchSegmentation
();
gs
->
setBaseImage
(
img
);
if
(
argv
[
2
][
0
]
==
's'
)
{
gs
->
switchToSingleStrategy
();
}
else
if
(
argv
[
2
][
0
]
==
'f'
)
{
gs
->
switchToSelectiveSearchFast
();
}
else
if
(
argv
[
2
][
0
]
==
'q'
)
{
gs
->
switchToSelectiveSearchQuality
();
}
else
{
help
();
return
-
2
;
}
std
::
vector
<
Rect
>
rects
;
gs
->
process
(
rects
);
int
nb_rects
=
10
;
char
c
=
(
char
)
waitKey
();
while
(
c
!=
'q'
)
{
Mat
wimg
=
img
.
clone
();
int
i
=
0
;
for
(
std
::
vector
<
Rect
>::
iterator
it
=
rects
.
begin
();
it
!=
rects
.
end
();
++
it
)
{
if
(
i
++
<
nb_rects
)
{
rectangle
(
wimg
,
*
it
,
Scalar
(
0
,
0
,
255
));
}
}
imshow
(
"Output"
,
wimg
);
c
=
(
char
)
waitKey
();
if
(
c
==
'd'
)
{
nb_rects
+=
10
;
}
if
(
c
==
'a'
&&
nb_rects
>
10
)
{
nb_rects
-=
10
;
}
}
return
0
;
}
modules/ximgproc/src/graphsegmentation.cpp
View file @
c9e3e220
...
...
@@ -47,6 +47,56 @@ namespace cv {
namespace
ximgproc
{
namespace
segmentation
{
// Helpers
// Represent an edge between two pixels
class
Edge
{
public
:
int
from
;
int
to
;
float
weight
;
bool
operator
<
(
const
Edge
&
e
)
const
{
return
weight
<
e
.
weight
;
}
};
// A point in the sets of points
class
PointSetElement
{
public
:
int
p
;
int
size
;
PointSetElement
()
{
}
PointSetElement
(
int
p_
)
{
p
=
p_
;
size
=
1
;
}
};
// An object to manage set of points, who can be fusionned
class
PointSet
{
public
:
PointSet
(
int
nb_elements_
);
~
PointSet
();
int
nb_elements
;
// Return the main point of the point's set
int
getBasePoint
(
int
p
);
// Join two sets of points, based on their main point
void
joinPoints
(
int
p_a
,
int
p_b
);
// Return the set size of a set (based on the main point)
int
size
(
unsigned
int
p
)
{
return
mapping
[
p
].
size
;
}
private
:
PointSetElement
*
mapping
;
};
class
GraphSegmentationImpl
:
public
GraphSegmentation
{
public
:
GraphSegmentationImpl
()
{
...
...
modules/ximgproc/src/selectivesearchsegmentation.cpp
0 → 100644
View file @
c9e3e220
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment