-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathMaincpp.cpp
More file actions
42 lines (34 loc) · 1.12 KB
/
Copy pathMaincpp.cpp
File metadata and controls
42 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//--------------------------------------------------------------------
// Bingyang Liu 2015/07/14
// Meanshift Algorithm
// OpenCV 3.0.0
//--------------------------------------------------------------------
//---------------- Head File ---------------------------------------
#include <iostream>
#include "MeanShift.h"
int main(){
// Load image
Mat Img = imread("mandril_color.tif");
resize(Img, Img, Size(256, 256), 0, 0, 1);
// Show that image
namedWindow("The Original Picture");
imshow("The Original Picture", Img);
// Convert color from RGB to Lab
cvtColor(Img, Img, CV_RGB2Lab);
// Initilize Mean Shift with spatial bandwith and color bandwith
MeanShift MSProc(8, 16);
// Filtering Process
MSProc.MSFiltering(Img);
// Segmentation Process include Filtering Process (Region Growing)
// MSProc.MSSegmentation(Img);
// Print the bandwith
cout<<"the Spatial Bandwith is "<<MSProc.hs<<endl;
cout<<"the Color Bandwith is "<<MSProc.hr<<endl;
// Convert color from Lab to RGB
cvtColor(Img, Img, CV_Lab2RGB);
// Show the result image
namedWindow("MS Picture");
imshow("MS Picture", Img);
waitKey();
return 1;
}