44 for (
int k = 0; k < channels; k++) {
45 (*image)(
y,
x, k) = (
float)
buffer[
a++] / 255.0f;
59 for (
int k = 0; k < channels; k++) {
67 for (
int y = 0,
a = 0;
y < image.Height();
y++) {
68 for (
int x = 0;
x < image.Width();
x++) {
69 for (
int k = 0; k < image.Depth(); k++) {
78 for (
int y = 0,
a = 0;
y < image.
Height();
y++) {
79 for (
int x = 0;
x < image.
Width();
x++) {
80 for (
int k = 0; k < image.
Depth(); k++) {
92 const char* file_name) {
95 FILE* fp = fopen(file_name,
"wb");
102 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
NULL,
NULL,
NULL);
103 info_ptr = png_create_info_struct(png_ptr);
105 if (setjmp(png_jmpbuf(png_ptr))) {
110 png_init_io(png_ptr, fp);
113 if (setjmp(png_jmpbuf(png_ptr))) {
118 png_set_IHDR(png_ptr,
125 PNG_COMPRESSION_TYPE_BASE,
126 PNG_FILTER_TYPE_BASE);
128 png_write_info(png_ptr, info_ptr);
131 if (setjmp(png_jmpbuf(png_ptr))) {
136 png_write_image(png_ptr, row_pointers);
139 if (setjmp(png_jmpbuf(png_ptr))) {
144 png_write_end(png_ptr,
NULL);
155 png_bytep* row_pointers;
157 assert(image.Depth() == 1);
159 row_pointers =
new png_bytep[image.Height()];
161 for (
y = 0;
y < image.Height();
y++) {
162 row_pointers[
y] =
new png_byte[4 * image.Width()];
164 for (
x = 0;
x < image.Width();
x++) {
165 if (x0 ==
x && image.Height() - y0 - 1 ==
y) {
166 row_pointers[
y][
x * 4 + 0] = 255;
167 row_pointers[
y][
x * 4 + 1] = 0;
168 row_pointers[
y][
x * 4 + 2] = 0;
169 row_pointers[
y][
x * 4 + 3] = 255;
171 float pixel = image(image.Height() -
y - 1,
x, 0);
172 row_pointers[
y][
x * 4 + 0] = pixel * 255;
173 row_pointers[
y][
x * 4 + 1] = pixel * 255;
174 row_pointers[
y][
x * 4 + 2] = pixel * 255;
175 row_pointers[
y][
x * 4 + 3] = 255;
180 static int image_counter = 0;
183 file_name,
sizeof(file_name),
"%s_%02d.png", prefix, ++image_counter);
191 for (
y = 0;
y < image.Height();
y++) {
192 delete[] row_pointers[
y];
194 delete[] row_pointers;
209 double* warped_position_x,
210 double* warped_position_y) {
211 FloatImage libmv_image, libmv_patch, libmv_mask;
218 libmv_mask_for_sample = &libmv_mask;
226 libmv_mask_for_sample,
243 unsigned char* patch,
244 double* warped_position_x,
245 double* warped_position_y) {
253 libmv_mask_for_sample = &libmv_mask;
261 libmv_mask_for_sample,
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
3D array (row, column, channel).
bool libmv_saveImage(const FloatImage &image, const char *prefix, int x0, int y0)
static bool savePNGImage(png_bytep *row_pointers, int width, int height, int depth, int color_type, const char *file_name)
void libmv_floatBufferToFloatImage(const float *buffer, int width, int height, int channels, FloatImage *image)
void libmv_samplePlanarPatchFloat(const float *image, int width, int height, int channels, const double *xs, const double *ys, int num_samples_x, int num_samples_y, const float *mask, float *patch, double *warped_position_x, double *warped_position_y)
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)
void libmv_floatImageToFloatBuffer(const FloatImage &image, float *buffer)
void libmv_floatImageDestroy(libmv_FloatImage *image)
void libmv_floatImageToByteBuffer(const libmv::FloatImage &image, unsigned char *buffer)
void libmv_byteBufferToFloatImage(const unsigned char *buffer, int width, int height, int channels, FloatImage *image)
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
bool SamplePlanarPatch(const FloatImage &image, const double *xs, const double *ys, int num_samples_x, int num_samples_y, FloatImage *mask, FloatImage *patch, double *warped_position_x, double *warped_position_y)
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)