12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #include <segmentation/RSMarkovCluster.h>
- #include <core/basics/Config.h>
- #include <core/image/DeprecatedConverter.h>
- #include <iostream>
- #include <iomanip>
- #include <deque>
- #include <stdlib.h>
- #include <time.h>
- using namespace OBJREC;
- using namespace NICE;
- using namespace std;
- int main ( int argc, char** argv ) {
- if ( argc < 3 ) return -1;
- Config* conf = new Config ( argv[1] );
- RSMarkovCluster clusterAlg ( conf );
- ColorImage cimg ( argv[2] );
- ColorImage segImage ( cimg.width(), cimg.height() );
- //clusterAlg.findAttractorsOfGraph();
- Matrix clusterMatrix ( cimg.height(), cimg.width(), 0 );
- int count = clusterAlg.segRegions ( cimg, clusterMatrix );
- printf ( "%d Regionen gefunden\n", count );
- if ( count != 0 )
- {
- /* initialize random seed: */
- srand ( time ( NULL ) );
- VVector colors;
- colors.resize ( ( cimg.height() *cimg.width() ) );
- for ( uint i = 0;i < ( cimg.height() *cimg.width() );i++ )
- {
- Vector colors_i ( 3 );
- for ( uint c = 0;c < 3;c++ ) colors_i[c] = ( rand() % 255 + 1 );
- colors[i] = colors_i;
- }
- for ( uint y = 0;y < cimg.height();y++ )
- {
- for ( uint x = 0;x < cimg.width();x++ )
- {
- int indexP = clusterMatrix ( y, x );
- //int R=round((double(clusterMatrix(y,x)))/255.0);//rand() % 255 + 1;
- //int G=R;//rand() % 255 + 1;
- //int B=G;//rand() % 255 + 1;
- segImage.setPixel ( x, y, 0, colors[indexP][0] );
- segImage.setPixel ( x, y, 1, colors[indexP][1] );
- segImage.setPixel ( x, y, 2, colors[indexP][2] );
- }
- }
- showImage ( segImage );
- }
- delete conf;
- return 0;
- }
|