/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
void DistanceTransform( float *source, float* dest, unsigned int length )
{
- int parabolas[length]; // Locations of parabolas in lower envelope
- float edge[length + 1]; // Locations of boundaries between parabolas
+ std::vector<int> parabolas(length); // Locations of parabolas in lower envelope
+ std::vector<float> edge(length + 1); // Locations of boundaries between parabolas
+
int rightmost(0); // Index of rightmost parabola in lower envelope
parabolas[0] = 0;
{
++rightmost;
}
- dest[i] = SQUARE( i - parabolas[rightmost] ) + source[parabolas[rightmost]];
+ dest[i] = SQUARE( static_cast< int >( i ) - parabolas[rightmost] ) + source[parabolas[rightmost]];
}
}
{
for ( int x = 0; x < paddedWidth; ++x)
{
- if( y < (int)fieldBorder || y >= (paddedHeight - (int)fieldBorder) ||
- x < (int)fieldBorder || x >= (paddedWidth - (int)fieldBorder) )
+ if( y < static_cast< int >( fieldBorder ) || y >= ( paddedHeight - static_cast< int >( fieldBorder ) ) ||
+ x < static_cast< int >( fieldBorder ) || x >= ( paddedWidth - static_cast< int >( fieldBorder ) ) )
{
outside[ y * paddedWidth + x ] = MAX_DISTANCE;
inside[ y * paddedWidth + x ] = 0.0f;