16 delete[] image->buffer;
26 image->
Resize(height, width, channels);
27 for (
int y = 0, a = 0; y < height; y++) {
28 for (
int x = 0; x < width; x++) {
30 (*image)(
y,
x, k) = (
float)buffer[a++] / 255.0f;
41 image->Resize(height, width, channels);
42 for (
int y = 0, a = 0; y < height; y++) {
43 for (
int x = 0; x < width; x++) {
45 (*image)(
y,
x, k) = buffer[a++];
52 for (
int y = 0, a = 0; y < image.Height(); y++) {
53 for (
int x = 0; x < image.Width(); x++) {
54 for (
int k = 0; k < image.Depth(); k++) {
55 buffer[a++] =
image(y, x, k);
62 unsigned char* buffer) {
63 for (
int y = 0, a = 0; y < image.Height(); y++) {
64 for (
int x = 0; x < image.Width(); x++) {
65 for (
int k = 0; k < image.Depth(); k++) {
66 buffer[a++] =
image(y, x, k) * 255.0f;
77 const char* file_name) {
80 FILE* fp = fopen(file_name,
"wb");
87 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
NULL,
NULL,
NULL);
88 info_ptr = png_create_info_struct(png_ptr);
90 if (setjmp(png_jmpbuf(png_ptr))) {
95 png_init_io(png_ptr, fp);
98 if (setjmp(png_jmpbuf(png_ptr))) {
103 png_set_IHDR(png_ptr,
110 PNG_COMPRESSION_TYPE_BASE,
111 PNG_FILTER_TYPE_BASE);
113 png_write_info(png_ptr, info_ptr);
116 if (setjmp(png_jmpbuf(png_ptr))) {
121 png_write_image(png_ptr, row_pointers);
124 if (setjmp(png_jmpbuf(png_ptr))) {
129 png_write_end(png_ptr,
NULL);
140 png_bytep* row_pointers;
142 assert(image.Depth() == 1);
144 row_pointers =
new png_bytep[image.Height()];
146 for (y = 0; y < image.Height(); y++) {
147 row_pointers[
y] =
new png_byte[4 * image.Width()];
149 for (x = 0; x < image.Width(); x++) {
150 if (x0 == x && image.Height() - y0 - 1 == y) {
151 row_pointers[
y][x * 4 + 0] = 255;
152 row_pointers[
y][x * 4 + 1] = 0;
153 row_pointers[
y][x * 4 + 2] = 0;
154 row_pointers[
y][x * 4 + 3] = 255;
156 float pixel =
image(image.Height() - y - 1, x, 0);
157 row_pointers[
y][x * 4 + 0] = pixel * 255;
158 row_pointers[
y][x * 4 + 1] = pixel * 255;
159 row_pointers[
y][x * 4 + 2] = pixel * 255;
160 row_pointers[
y][x * 4 + 3] = 255;
165 static int image_counter = 0;
168 file_name,
sizeof(file_name),
"%s_%02d.png", prefix, ++image_counter);
176 for (y = 0; y < image.Height(); y++) {
177 delete[] row_pointers[
y];
179 delete[] row_pointers;
194 double* warped_position_x,
195 double* warped_position_y) {
196 FloatImage libmv_image, libmv_patch, libmv_mask;
197 FloatImage* libmv_mask_for_sample =
NULL;
203 libmv_mask_for_sample = &libmv_mask;
206 SamplePlanarPatch(libmv_image,
211 libmv_mask_for_sample,
228 unsigned char* patch,
229 double* warped_position_x,
230 double* warped_position_y) {
238 libmv_mask_for_sample = &libmv_mask;
246 libmv_mask_for_sample,
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
3D array (row, column, channel).
void Resize(int height, int width, int depth=1)
input_tx image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "preview_img") .compute_source("compositor_compute_preview.glsl") .do_static_compilation(true)
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)
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)