JWS C Library
C language utility library
surface.h
Go to the documentation of this file.
00001 /*
00002  * This work is licensed under a Creative Commons 
00003  * Attribution-Noncommercial-Share Alike 3.0 United States License.
00004  * 
00005  *    http://creativecommons.org/licenses/by-nc-sa/3.0/us/
00006  * 
00007  * You are free:
00008  * 
00009  *    to Share - to copy, distribute, display, and perform the work
00010  *    to Remix - to make derivative works
00011  * 
00012  * Under the following conditions:
00013  * 
00014  *    Attribution. You must attribute the work in the manner specified by the
00015  *    author or licensor (but not in any way that suggests that they endorse you
00016  *    or your use of the work).
00017  * 
00018  *    Noncommercial. You may not use this work for commercial purposes.
00019  * 
00020  *    Share Alike. If you alter, transform, or build upon this work, you may
00021  *    distribute the resulting work only under the same or similar license to
00022  *    this one.
00023  * 
00024  * For any reuse or distribution, you must make clear to others the license
00025  * terms of this work. The best way to do this is by including this header.
00026  * 
00027  * Any of the above conditions can be waived if you get permission from the
00028  * copyright holder.
00029  * 
00030  * Apart from the remix rights granted under this license, nothing in this
00031  * license impairs or restricts the author's moral rights.
00032  */
00033 
00034 
00051 #ifndef SURFACE_H 
00052 #define SURFACE_H 
00053 
00054 
00055 #include <jwsc/config.h>
00056 
00057 #include <stdlib.h>
00058 #include <inttypes.h>
00059 
00060 #include "jwsc/base/error.h"
00061 #include "jwsc/vector/vector.h"
00062 #include "jwsc/imgblock/imgblock.h"
00063 #include "jwsc/matblock/matblock.h"
00064 
00065 
00066 #ifdef __cplusplus
00067 namespace jwsc {
00068 extern "C" {
00069 #endif
00070 
00071 
00081 typedef struct
00082 {
00084     uint32_t col;
00085 
00087     uint32_t row;
00088 
00090     uint32_t mat;
00091 
00093     float dcol;
00094 
00096     float drow;
00097 
00099     float dmat;
00100 
00102     float intensity;
00103 }
00104 Surface_point_f;
00105 
00106 
00107 
00108 
00115 typedef struct
00116 {
00120     Vector_f* pts[4];
00121 
00127     Vector_f* normal;
00128 
00134     Vector_f* center;
00135 
00137     float albedo;
00138 }
00139 Surface_patch_f;
00140 
00141 
00153 Error* detect_imgblock_surface_points_f
00154 (
00155     Surface_point_f** r_pts_out,
00156     uint32_t*         num_r_pts_out,
00157     Surface_point_f** g_pts_out,
00158     uint32_t*         num_g_pts_out,
00159     Surface_point_f** b_pts_out,
00160     uint32_t*         num_b_pts_out,
00161     const Imgblock_f* img,
00162     float             sigma, 
00163     float             grad_img_weight,
00164     float             grad_row_weight,
00165     float             grad_col_weight,
00166     float             begin_thresh, 
00167     float             end_thresh
00168 );
00169 
00186 Error* detect_matblock_surface_points_f
00187 (
00188     Surface_point_f** pts_out,
00189     uint32_t*         num_pts_out,
00190     const Matblock_f* m,
00191     float             sigma, 
00192     float             grad_mat_weight,
00193     float             grad_row_weight,
00194     float             grad_col_weight,
00195     float             begin_thresh, 
00196     float             end_thresh
00197 );
00198 
00215 void sample_surface_points_f
00216 (
00217     Surface_point_f**      pts_out, 
00218     uint32_t*              num_pts_out,
00219     const Surface_point_f* pts_in, 
00220     uint32_t               num_pts_in,
00221     float                  p
00222 );
00223 
00237 void color_surface_points_f
00238 (
00239     Imgblock_f**           img_out,
00240     const Imgblock_f*      img_in,
00241     const Surface_point_f* pts, 
00242     uint32_t               num_pts,
00243     const Pixel_f*         pxl
00244 );
00245 
00262 Error* read_surface_points_f
00263 (
00264     Surface_point_f** pts_out,
00265     uint32_t*         num_pts_out,
00266     const char*       fname
00267 );
00268 
00285 Error* write_surface_points_f
00286 (
00287     const Surface_point_f* pts,
00288     uint32_t               num_pts,
00289     const char*            fname
00290 );
00291 
00305 void create_surface_patch_f
00306 (
00307     Surface_patch_f**      patch_out,
00308     const Surface_point_f* point,
00309     float                  size,
00310     float                  x_scale,
00311     float                  y_scale,
00312     float                  z_scale
00313 );
00314 
00328 void free_surface_patch_f(Surface_patch_f* patch);
00329 
00333 #ifdef __cplusplus
00334 }
00335 }
00336 #endif
00337 
00338 
00339 #endif