diff options
Diffstat (limited to 'intern/libmv/intern/image.cc')
-rw-r--r-- | intern/libmv/intern/image.cc | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/intern/libmv/intern/image.cc b/intern/libmv/intern/image.cc index a6e09277680..564e4762448 100644 --- a/intern/libmv/intern/image.cc +++ b/intern/libmv/intern/image.cc @@ -21,14 +21,14 @@ #include "intern/utildefines.h" #include "libmv/tracking/track_region.h" -#include <cassert> #include <png.h> +#include <cassert> using libmv::FloatImage; using libmv::SamplePlanarPatch; -void libmv_floatImageDestroy(libmv_FloatImage *image) { - delete [] image->buffer; +void libmv_floatImageDestroy(libmv_FloatImage* image) { + delete[] image->buffer; } /* Image <-> buffers conversion */ @@ -63,8 +63,7 @@ void libmv_floatBufferToFloatImage(const float* buffer, } } -void libmv_floatImageToFloatBuffer(const FloatImage &image, - float* buffer) { +void libmv_floatImageToFloatBuffer(const FloatImage& image, float* buffer) { for (int y = 0, a = 0; y < image.Height(); y++) { for (int x = 0; x < image.Width(); x++) { for (int k = 0; k < image.Depth(); k++) { @@ -74,9 +73,9 @@ void libmv_floatImageToFloatBuffer(const FloatImage &image, } } -void libmv_floatImageToByteBuffer(const libmv::FloatImage &image, +void libmv_floatImageToByteBuffer(const libmv::FloatImage& image, unsigned char* buffer) { - for (int y = 0, a= 0; y < image.Height(); y++) { + for (int y = 0, a = 0; y < image.Height(); y++) { for (int x = 0; x < image.Width(); x++) { for (int k = 0; k < image.Depth(); k++) { buffer[a++] = image(y, x, k) * 255.0f; @@ -93,7 +92,7 @@ static bool savePNGImage(png_bytep* row_pointers, const char* file_name) { png_infop info_ptr; png_structp png_ptr; - FILE *fp = fopen(file_name, "wb"); + FILE* fp = fopen(file_name, "wb"); if (fp == NULL) { return false; @@ -153,7 +152,7 @@ bool libmv_saveImage(const FloatImage& image, int x0, int y0) { int x, y; - png_bytep *row_pointers; + png_bytep* row_pointers; assert(image.Depth() == 1); @@ -180,9 +179,8 @@ bool libmv_saveImage(const FloatImage& image, static int image_counter = 0; char file_name[128]; - snprintf(file_name, sizeof(file_name), - "%s_%02d.png", - prefix, ++image_counter); + snprintf( + file_name, sizeof(file_name), "%s_%02d.png", prefix, ++image_counter); bool result = savePNGImage(row_pointers, image.Width(), image.Height(), @@ -191,9 +189,9 @@ bool libmv_saveImage(const FloatImage& image, file_name); for (y = 0; y < image.Height(); y++) { - delete [] row_pointers[y]; + delete[] row_pointers[y]; } - delete [] row_pointers; + delete[] row_pointers; return result; } @@ -211,7 +209,7 @@ void libmv_samplePlanarPatchFloat(const float* image, double* warped_position_x, double* warped_position_y) { FloatImage libmv_image, libmv_patch, libmv_mask; - FloatImage *libmv_mask_for_sample = NULL; + FloatImage* libmv_mask_for_sample = NULL; libmv_floatBufferToFloatImage(image, width, height, channels, &libmv_image); @@ -221,8 +219,10 @@ void libmv_samplePlanarPatchFloat(const float* image, } SamplePlanarPatch(libmv_image, - xs, ys, - num_samples_x, num_samples_y, + xs, + ys, + num_samples_x, + num_samples_y, libmv_mask_for_sample, &libmv_patch, warped_position_x, @@ -232,19 +232,19 @@ void libmv_samplePlanarPatchFloat(const float* image, } void libmv_samplePlanarPatchByte(const unsigned char* image, - int width, - int height, - int channels, - const double* xs, - const double* ys, - int num_samples_x, - int num_samples_y, - const float* mask, - unsigned char* patch, - double* warped_position_x, - double* warped_position_y) { + int width, + int height, + int channels, + const double* xs, + const double* ys, + int num_samples_x, + int num_samples_y, + const float* mask, + unsigned char* patch, + double* warped_position_x, + double* warped_position_y) { libmv::FloatImage libmv_image, libmv_patch, libmv_mask; - libmv::FloatImage *libmv_mask_for_sample = NULL; + libmv::FloatImage* libmv_mask_for_sample = NULL; libmv_byteBufferToFloatImage(image, width, height, channels, &libmv_image); @@ -254,8 +254,10 @@ void libmv_samplePlanarPatchByte(const unsigned char* image, } libmv::SamplePlanarPatch(libmv_image, - xs, ys, - num_samples_x, num_samples_y, + xs, + ys, + num_samples_x, + num_samples_y, libmv_mask_for_sample, &libmv_patch, warped_position_x, |