Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include "vmal_convert_vtol.h"
00007 #include <vtol/vtol_vertex_2d.h>
00008 #include <vtol/vtol_edge_2d.h>
00009 #include <vil1/vil1_memory_image_of.h>
00010 #include <vil1/vil1_image_as.h>
00011
00012 void convert_lines_double_3(vcl_vector<vtol_edge_2d_sptr> in,
00013 vnl_double_3 * &outp,
00014 vnl_double_3 * &outq)
00015 {
00016 int numlines=in.size();
00017 outp=new vnl_double_3[numlines];
00018 outq=new vnl_double_3[numlines];
00019
00020 for (int i=0;i<numlines;i++)
00021 {
00022 outp[i][0]=in[i]->v1()->cast_to_vertex_2d()->x();
00023 outp[i][1]=in[i]->v1()->cast_to_vertex_2d()->y();
00024 outp[i][2]=1;
00025
00026 outq[i][0]=in[i]->v2()->cast_to_vertex_2d()->x();
00027 outq[i][1]=in[i]->v2()->cast_to_vertex_2d()->y();
00028 outq[i][2]=1;
00029 }
00030 }
00031
00032 void convert_points_double_3(vcl_vector<vtol_vertex_2d_sptr> in,
00033 vnl_double_3 * &out)
00034 {
00035 int numpoints=in.size();
00036 out=new vnl_double_3[numpoints];
00037
00038 for (int i=0;i<numpoints;i++)
00039 {
00040 out[i][0]=in[i]->x();
00041 out[i][1]=in[i]->y();
00042 out[i][2]=1;
00043 }
00044 }
00045
00046 void convert_points_vect_double_3(vcl_vector<vtol_vertex_2d_sptr> & in,
00047 vcl_vector<vnl_double_3> & out)
00048 {
00049 int numpoints=in.size();
00050 for (int i=0;i<numpoints;i++)
00051 {
00052 vnl_double_3 pt;
00053 pt[0]=in[i]->x();
00054 pt[1]=in[i]->y();
00055 pt[2]=1;
00056 out.push_back(pt);
00057 }
00058 }
00059
00060 void convert_line_double_3(vtol_edge_2d_sptr in,
00061 vnl_double_3 &outp,
00062 vnl_double_3 &outq)
00063 {
00064 outp[0]=in->v1()->cast_to_vertex_2d()->x();
00065 outp[1]=in->v1()->cast_to_vertex_2d()->y();
00066 outp[2]=1;
00067
00068 outq[0]=in->v2()->cast_to_vertex_2d()->x();
00069 outq[1]=in->v2()->cast_to_vertex_2d()->y();
00070 outq[2]=1;
00071 }
00072
00073 void convert_line_double_2(vtol_edge_2d_sptr in,
00074 vnl_double_2 &outp,
00075 vnl_double_2 &outq)
00076 {
00077 outp[0]=in->v1()->cast_to_vertex_2d()->x();
00078 outp[1]=in->v1()->cast_to_vertex_2d()->y();
00079
00080 outq[0]=in->v2()->cast_to_vertex_2d()->x();
00081 outq[1]=in->v2()->cast_to_vertex_2d()->y();
00082 }
00083
00084 void convert_point_double_3(vtol_vertex_2d_sptr in,
00085 vnl_double_3 &out)
00086 {
00087 out[0]=in->x();
00088 out[1]=in->y();
00089 out[2]=1;
00090 }
00091
00092 void convert_grey_memory_image(const vil1_image & image,
00093 vil1_memory_image_of<vxl_byte> &ima_mono)
00094 {
00095 int w=image.width();
00096 int h=image.height();
00097
00098 ima_mono.resize(w,h);
00099
00100 vil1_image_as_byte(image).get_section(ima_mono.get_buffer(), 0, 0, w, h);
00101 }