Changes

Jump to: navigation, search

BarraCUDA Boiz

8,001 bytes added, 00:37, 6 February 2017
Assignment 1
0.23 105.08 0.24 frame_dummy
0.04 105.12 0.04 1000 0.04 0.04 std::vector<int, std::allocator<int> >::resize(unsigned long, int)
 
 
 
====KmeansPlusPlus====
Kmeansplusplus is a clustering method that determins which in this case takes an image and splits it into k number of clusters. For an image it selects k number of pixels and uses those pixels as a reference point to compare all the other pixels to change their colors based on which reference pixel they are closest to.
The first integer is k (the number of reference points), the second integer is the number of times to iterate through the image.
 
Original source code:
https://github.com/tatsy/ImageProcessing/tree/master/KmeansPlusPlus
 
Opencv setup instructions (linux):
Required opencv, cmake, g++, make, gprof
 
1) sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
2) downoad opencv version 2.4.13 and extract it
http://opencv.org/downloads.html
3) cd opencv-2.4.13
4) mkdir build
5) cd build
6) cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
7) make -j7
8) sudo make install
 
(At this point we recomend you test to see if opencv is working correctly by following:
http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html)
 
Build KmeansPlusPlus :
 
1) create "CMakeLists.txt"
 
cmake_minimum_required(VERSION 2.8)
project( Kmeans++ )
find_package( OpenCV REQUIRED )
add_executable( Kmeans++ main.cpp mt19937ar.c )
target_link_libraries( Kmeans++ ${OpenCV_LIBS} )
 
2) cmake -DCMAKE_CXX_FLAGS=-pg -DCMAKE_EXE_LINKER_FLAGS=-pg -DCMAKE_SHARED_LINKER_FLAGS=-pg .
3) make
Note possible errors (if compiling from original source):
1) Error : "opencv2\opencv.hpp: No such file or directory #include <opencv2\opencv.hpp>"
Solution : Change '<opencv2\opencv.hpp>' to '<opencv2/opencv.hpp>'
2) Error : " 'printf' was not declared in this scope"
Solution : add "#include <stdio.h>"
4) ./Kmeans++ <source_img> <output_img> <#clusters> <#iterations>
5) gprof -p -b ./Kmeans++ > Kmeans++.flt
 
 
Test Cases:
 
Command line:
./Kmeans++ baboon.jpg baboon_out_5x100.jpg 5 100
Flat profile:
 
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
50.51 1.60 1.60 951584265 0.00 0.00 float& cv::Mat::at<float>(int, int)
42.62 2.95 1.35 1 1.35 3.15 kmeanspp(cv::Mat&, cv::Mat&, cv::Mat&, cv::Mat&, int, int)
4.26 3.09 0.14 78906844 0.00 0.00 int& cv::Mat::at<int>(int, int)
1.89 3.15 0.06 1 0.06 0.06 std::vector<double, std::allocator<double> >::~vector()
0.32 3.16 0.01 1572864 0.00 0.00 unsigned char& cv::Mat::at<unsigned char>(int, int)
0.32 3.17 0.01 main
0.16 3.17 0.01 3053814 0.00 0.00 std::vector<double, std::allocator<double> >::operator[](unsigned long)
 
 
 
Command line:
./Kmeans++ baboon.jpg baboon_out_5x500.jpg 5 500
Flat profile:
 
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
45.62 7.34 7.34 1 7.34 16.11 kmeanspp(cv::Mat&, cv::Mat&, cv::Mat&, cv::Mat&, int, int)
43.88 14.41 7.06 4726463865 0.00 0.00 float& cv::Mat::at<float>(int, int)
6.90 15.52 1.11 393485644 0.00 0.00 int& cv::Mat::at<int>(int, int)
3.17 16.03 0.51 1 0.51 0.51 std::vector<double, std::allocator<double> >::~vector()
0.44 16.10 0.07 3273980 0.00 0.00 std::vector<double, std::allocator<double> >::operator[](unsigned long)
0.06 16.11 0.01 1 0.01 0.01 std::vector<double, std::allocator<double> >::vector(unsigned long, double const&, std::allocator<double> const&)
 
 
 
Command line:
./Kmeans++ baboon.jpg baboon_out_100x5.jpg 100 5
Flat profile:
 
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
46.29 1.30 1.30 1 1.30 2.79 kmeanspp(cv::Mat&, cv::Mat&, cv::Mat&, cv::Mat&, int, int)
45.94 2.59 1.29 951585120 0.00 0.00 float& cv::Mat::at<float>(int, int)
4.27 2.71 0.12 66348332 0.00 0.00 std::vector<double, std::allocator<double> >::operator[](unsigned long)
2.49 2.78 0.07 1 0.07 0.07 std::vector<double, std::allocator<double> >::~vector()
0.71 2.80 0.02 main
0.36 2.81 0.01 1 0.01 0.01 std::vector<double, std::allocator<double> >::vector(unsigned long, double const&, std::allocator<double> const&)
 
 
 
Command line:
./Kmeans++ baboon.jpg baboon_out_500x5.jpg 500 5
Flat profile:
 
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
49.65 7.07 7.07 4726468320 0.00 0.00 float& cv::Mat::at<float>(int, int)
44.97 13.47 6.40 1 6.40 14.22 kmeanspp(cv::Mat&, cv::Mat&, cv::Mat&, cv::Mat&, int, int)
2.53 13.83 0.36 327813766 0.00 0.00 std::vector<double, std::allocator<double> >::operator[](unsigned long)
2.28 14.16 0.33 1 0.33 0.33 std::vector<double, std::allocator<double> >::~vector()
0.42 14.22 0.06 1 0.06 0.06 std::vector<double, std::allocator<double> >::vector(unsigned long, double const&, std::allocator<double> const&)
0.14 14.24 0.02 main
0.07 14.25 0.01 1572864 0.00 0.00 unsigned char& cv::Mat::at<unsigned char>(int, int)
 
 
 
Command line:
./Kmeans++ baboon.jpg baboon_out_100x100.jpg 100 100
Flat profile:
 
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
69.03 60.68 60.68 1 60.68 87.95 kmeanspp(cv::Mat&, cv::Mat&, cv::Mat&, cv::Mat&, int, int)
28.80 86.00 25.32 7453309108 0.00 0.00 float& cv::Mat::at<float>(int, int)
1.95 87.71 1.71 1 1.71 1.71 std::vector<double, std::allocator<double> >::~vector()
0.15 87.84 0.14 78935344 0.00 0.00 int& cv::Mat::at<int>(int, int)
0.11 87.94 0.10 66396782 0.00 0.00 std::vector<double, std::allocator<double> >::operator[](unsigned long)
0.02 87.96 0.02 1 0.02 0.02 std::vector<double, std::allocator<double> >::vector(unsigned long, double const&, std::allocator<double> const&)
 
 
 
Command line:
./Kmeans++ baboon.jpg baboon_out_500x500.jpg 500 500
Flat profile:
 
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls Ks/call Ks/call name
54.00 919.48 919.48 1 0.92 1.70 kmeanspp(cv::Mat&, cv::Mat&, cv::Mat&, cv::Mat&, int, int)
44.16 1671.44 751.95 8242561860 0.00 0.00 float& cv::Mat::at<float>(int, int)
1.82 1702.36 30.93 1 0.03 0.03 std::vector<double, std::allocator<double> >::~vector()
0.06 1703.31 0.95 394228144 0.00 0.00 int& cv::Mat::at<int>(int, int)
0.03 1703.75 0.44 329563076 0.00 0.00 std::vector<double, std::allocator<double> >::operator[](unsigned long)
0.00 1703.78 0.03 1 0.00 0.00 std::vector<double, std::allocator<double> >::vector(unsigned long, double const&, std::allocator<double> const&)
0.00 1703.79 0.01 1572864 0.00 0.00 unsigned char& cv::Mat::at<unsigned char>(int, int)
0.00 1703.80 0.01 1 0.00 0.00 __gnu_cxx::__enable_if<std::__is_scalar<double>::__value, double*>::__type std::__fill_n_a<double*, unsigned long, double>(double*, unsigned long, double const&)
36
edits

Navigation menu