Programa para el testeo de las funciones.Para compilar o código example_funcarraylabeling.cpp:
g++ -static -o example_funcarraylabeling example_funcarraylabeling.cpp -lpdsramm -lpdsspmm
Para executar o programa:
./example_funcarraylabeling
Retornando por consola:
Elapsed time: 17.6 ms
Elapsed time: 3.656 ms
Perimeter[0]: 41.8995 Area[0]: 53 Gamma[0]: 1.62355
Perimeter[1]: 76.1421 Area[1]: 110 Gamma[1]: 2.04797
Perimeter[2]: 217.054 Area[2]: 2666 Gamma[2]: 1.18586
Perimeter[3]: 279.765 Area[3]: 5521 Gamma[3]: 1.06213
Perimeter[4]: nan Area[4]: 10260 Gamma[4]: nan
Perimeter[5]: 258.024 Area[5]: 4333 Gamma[5]: 1.10576
Perimeter[6]: 170.569 Area[6]: 1188 Gamma[6]: 1.396
Perimeter[7]: 279.765 Area[7]: 5521 Gamma[7]: 1.06213
Perimeter[8]: nan Area[8]: 10415 Gamma[8]: nan
Perimeter[9]: 125.941 Area[9]: 451 Gamma[9]: 1.67292
Perimeter[10]: 276.451 Area[10]: 5411 Gamma[10]: 1.06017
Perimeter[11]: 219.054 Area[11]: 2745 Gamma[11]: 1.17944
Perimeter[12]: 43.8995 Area[12]: 57 Gamma[12]: 1.64028
Este es la imagen de la matriz A.
Esta es la imagen con los ID de los grupos de A.
Código example_funcarraylabeling.cpp:
#include <Pds/Ra>
#include <Pds/Sp>
int main(void)
{
Pds::Ra::Randomize();
unsigned int L=512;
Pds::Array<unsigned char> A(L,L);
Pds::Matrix(A).Scale(0,255).ExportBmpFile(Pds::Colormap::Gray,"A-binary-circle.bmp");
Pds::Array<unsigned int> ID;
Pds::Ra::Tic();
Pds::Ra::Toc();
Pds::Matrix(ID).Scale(0,255).ExportBmpFile(Pds::Colormap::Steps,"A-id-circle.bmp");
std::vector<std::vector<Pds::Position>> Data;
Pds::Ra::Tic();
Pds::Ra::Toc();
for(unsigned int i=0;i<Data.size();i++)
{
unsigned int Area=Data[i].size();
std::cout<<"Perimeter["<<i<<"]:\t"<<Per<<"\t";
std::cout<<" Area["<<i<<"]:\t"<<Area<<"\t";
std::cout<<" Gamma["<<i<<"]:\t"<<(Per/2.0)/sqrt(Area*Pds::Ra::Pi)<<"\n";
}
return 0;
}
bool LoadDataCircles(Pds::Array< unsigned char > &BW, unsigned int L=4, double Offset=1)
Generando datos de grupos de 1s formando circulos.
double PerimeterOfConvexGroup(const std::vector< Pds::Position > &Group)
Calcula el perimetro de un grupo si este es convexo. EL perimetro es calculado usando un criterio de ...
std::vector< std::vector< Pds::Position > > VectorGroupFromIdMap(const Pds::Array< unsigned int > &ID_MAP)
Retorna todos los grupos de posiciones (std::vector<Pds::Position>) agrupados en un vector (std:vecto...
Pds::Array< unsigned int > IdMapUsingCC4(const Pds::Array< unsigned char > &BW)
Connected-component labeling para 4 conectividad.