#4683 clang-format on all files in ApplicationCode

This commit is contained in:
Magne Sjaastad
2019-09-06 10:40:57 +02:00
parent 3a317504bb
commit fe9e567825
2092 changed files with 117952 additions and 111846 deletions

View File

@@ -14,13 +14,13 @@
/// http://fab.cba.mit.edu/classes/S62.12/docs/Meijster_distance.pdf
/// Currently Euclidean only, but can be easily extended by replacing the lambda functions.
//--------------------------------------------------------------------------------------------------
void RiaImageTools::distanceTransform2d(std::vector<std::vector<unsigned int>>& image)
void RiaImageTools::distanceTransform2d( std::vector<std::vector<unsigned int>>& image )
{
if (image.empty())
if ( image.empty() )
{
return;
}
if (image.front().empty())
if ( image.front().empty() )
{
return;
}
@@ -28,22 +28,22 @@ void RiaImageTools::distanceTransform2d(std::vector<std::vector<unsigned int>>&
const int64_t N = (int64_t)image.front().size();
int64_t infVal = M + N;
CVF_ASSERT(infVal <= std::numeric_limits<unsigned int>::max());
CVF_ASSERT( infVal <= std::numeric_limits<unsigned int>::max() );
// First phase
std::vector<std::vector<int64_t>> g(M);
std::vector<std::vector<int64_t>> g( M );
#pragma omp parallel for
for (int64_t x = 0; x < M; ++x)
for ( int64_t x = 0; x < M; ++x )
{
g[x].resize(N, infVal);
if (image[x][0])
g[x].resize( N, infVal );
if ( image[x][0] )
{
g[x][0] = 0;
}
for (int64_t y = 1; y < N - 1; ++y)
for ( int64_t y = 1; y < N - 1; ++y )
{
if (image[x][y])
if ( image[x][y] )
{
g[x][y] = 0;
}
@@ -52,50 +52,50 @@ void RiaImageTools::distanceTransform2d(std::vector<std::vector<unsigned int>>&
g[x][y] = 1 + g[x][y - 1];
}
}
for (int64_t y = N - 2; y >= 0; --y)
for ( int64_t y = N - 2; y >= 0; --y )
{
if (g[x][y + 1] < g[x][y])
if ( g[x][y + 1] < g[x][y] )
{
g[x][y] = 1 + g[x][y + 1];
}
}
}
auto f = [](int64_t x, int64_t i, const std::vector<std::vector<int64_t>>& g, int64_t y) {
return (x - i) * (x - i) + g[i][y] * g[i][y];
auto f = []( int64_t x, int64_t i, const std::vector<std::vector<int64_t>>& g, int64_t y ) {
return ( x - i ) * ( x - i ) + g[i][y] * g[i][y];
};
auto sep = [](int64_t i, int64_t u, const std::vector<std::vector<int64_t>>& g, int64_t y) {
if (i == u) return (int64_t)0;
auto sep = []( int64_t i, int64_t u, const std::vector<std::vector<int64_t>>& g, int64_t y ) {
if ( i == u ) return (int64_t)0;
int64_t numerator = u * u - i * i + g[u][y] * g[u][y] - g[i][y] * g[i][y];
int64_t divisor = 2 * (u - i);
int64_t divisor = 2 * ( u - i );
return numerator / divisor;
};
// Second phase
#pragma omp parallel for
for (int64_t y = 0; y < N; ++y)
for ( int64_t y = 0; y < N; ++y )
{
int64_t q = 0;
std::vector<int64_t> s(std::max(N, M), (int64_t) 0);
std::vector<int64_t> t(std::max(N, M), (int64_t) 0);
int64_t q = 0;
std::vector<int64_t> s( std::max( N, M ), (int64_t)0 );
std::vector<int64_t> t( std::max( N, M ), (int64_t)0 );
for (int64_t u = 1; u < M - 1; ++u)
for ( int64_t u = 1; u < M - 1; ++u )
{
while (q >= 0 && f(t[q], s[q], g, y) > f(t[q], u, g, y))
while ( q >= 0 && f( t[q], s[q], g, y ) > f( t[q], u, g, y ) )
{
q--;
}
if (q < 0)
if ( q < 0 )
{
q = 0;
s[0] = u;
}
else
{
int64_t w = 1 + sep((int64_t)s[q], u, g, y);
if (w < M)
int64_t w = 1 + sep( (int64_t)s[q], u, g, y );
if ( w < M )
{
q++;
s[q] = u;
@@ -103,12 +103,12 @@ void RiaImageTools::distanceTransform2d(std::vector<std::vector<unsigned int>>&
}
}
}
for (int64_t u = M - 1; u >= 0; --u)
for ( int64_t u = M - 1; u >= 0; --u )
{
int64_t fVal = f(u, s[q], g, y);
CVF_ASSERT(fVal <= std::numeric_limits<double>::max());
image[u][y] = static_cast<unsigned int>(fVal);
if (u == t[q])
int64_t fVal = f( u, s[q], g, y );
CVF_ASSERT( fVal <= std::numeric_limits<double>::max() );
image[u][y] = static_cast<unsigned int>( fVal );
if ( u == t[q] )
{
q = q - 1;
}
@@ -119,18 +119,17 @@ void RiaImageTools::distanceTransform2d(std::vector<std::vector<unsigned int>>&
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaImageTools::makeGrayScale(QImage& image)
void RiaImageTools::makeGrayScale( QImage& image )
{
for (int i = 0; i < image.height(); i++)
for ( int i = 0; i < image.height(); i++ )
{
uchar* scanLine = image.scanLine(i);
for (int j = 0; j < image.width(); j++)
uchar* scanLine = image.scanLine( i );
for ( int j = 0; j < image.width(); j++ )
{
QRgb* pixel = reinterpret_cast<QRgb*>(scanLine + j * 4);
int gray = qGray(*pixel);
int alpha = qAlpha(*pixel);
*pixel = QColor(gray, gray, gray, alpha).rgba();
QRgb* pixel = reinterpret_cast<QRgb*>( scanLine + j * 4 );
int gray = qGray( *pixel );
int alpha = qAlpha( *pixel );
*pixel = QColor( gray, gray, gray, alpha ).rgba();
}
}
}