~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/tools/imcalc/imc_view.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2 **/
  3 #include <stdio.h>
  4 #include <tina/sys.h>
  5 #include <tina/sysfuncs.h>
  6 #include <tina/math.h>
  7 #include <tina/mathfuncs.h>
  8 #include <tina/vision.h>
  9 #include <tina/visionfuncs.h>
 10 #include <tina/tv.h>
 11 #include <tina/tvfuncs.h>
 12 #include <tina/draw.h>
 13 #include <tina/drawfuncs.h>
 14 
 15 Tv     *tv_create();
 16 Tv     *imcalc_tv_get();
 17 void    imcalc_draw(Tv *tv);
 18 
 19 void   *stack_pop();
 20 void   *stack_inspect();
 21 Bool    stack_check_types();
 22 static Imrect *reg_a=NULL;
 23 static int reg_type = 0;
 24 
 25 void    imcalc_reg_set(Imrect *im, int type)
 26 {
 27      if (im!=NULL)
 28      {
 29         if (reg_a!=NULL) im_free(reg_a);
 30         reg_a = im;
 31         reg_type = type;
 32      }
 33 }
 34 
 35 Imrect *imcalc_reg_get(void)
 36 {
 37     return(reg_a);
 38 }
 39 
 40 int imcalc_reg_type(void)
 41 {
 42     return(reg_type);
 43 }
 44 
 45 static void cmap_set_anaglyph(Tv *tv)
 46 {
 47     extern void tv_screen_cmap_find_and_install ();
 48 
 49     if (tv && tv->tv_screen)
 50       {
 51           Bool (*cmap_create_fn) () = NULL;
 52           extern void tv_cmap_create_fn_set ();
 53 
 54           tv->cmap_create_fn = tv_anag_cmap_create;
 55           tv_screen_cmap_find_and_install (tv, tv->tv_screen);
 56           tv_screen_color_set(tv->tv_screen, tv->cmap_data_visible->std_lut[tv->color]);
 57       }
 58 }
 59 
 60 static void cmap_set_standard(Tv *tv)
 61 {
 62     extern void tv_screen_cmap_find_and_install ();
 63 
 64     if (tv && tv->tv_screen )
 65       {
 66           Bool (*cmap_create_fn) () = NULL;
 67           extern void tv_cmap_create_fn_set ();
 68 
 69           tv->cmap_create_fn = tv_standard_cmap_create;
 70           tv_screen_cmap_find_and_install (tv, tv->tv_screen);
 71           tv_screen_color_set(tv->tv_screen, tv->cmap_data_visible->std_lut[tv->color]);
 72       }
 73 }
 74 
 75 
 76 
 77 static void fulldraw(Tv * tv)
 78 {
 79     int     type;
 80     Imrect *im,*im1,*im2;
 81 
 82     im = (Imrect *) stack_inspect(&type);
 83     switch (type)
 84     {
 85     case IMRECT:
 86         tv_erase(tv);
 87         if (im->vtype!=complex_v)
 88         {
 89            cmap_set_standard(tv);
 90            im1 = imf_scale_nzero(im, 0.0, 255.0);
 91            tv_imrect2(tv, im1);
 92            im_free(im1);
 93         }
 94         else 
 95         {
 96            cmap_set_anaglyph(tv);  
 97            im1 = imf_scale_nzero(im_re(im), 0.0, 255.0); 
 98            im2 = imf_scale_nzero(im_im(im), 0.0, 255.0); 
 99            tv_imrect_anaglyph(tv, im1, im2, 0.0, 255.0);
100            im_free(im1); 
101            im_free(im2); 
102         }
103         break;
104     case EDGERECT:
105         tv_edges_conn(tv, im);
106         tv_strings(tv, im);
107         break;
108     }
109 }
110 
111 void    imcalc_draw(Tv *tv)
112 {
113     if (tv!=NULL)
114     {
115        tv_free_background(tv);
116        tv_repaint(tv);
117     }
118 }
119 
120 static void skeldraw(Tv * tv)
121 {
122     int     type;
123     Imrect *im;
124 
125     im = (Imrect *) stack_inspect(&type);
126     if (type == IMRECT)
127         tv_imrect_skel(tv, im);
128 }
129 
130 static void init(Tv * tv)
131 {
132     Imrect *im;
133     int     type;
134 
135     im = (Imrect *) stack_inspect(&type);
136     if ((type == IMRECT || type == EDGERECT) && im != NULL)
137         tv_camera2_image(tv, im->width, im->height);
138 }
139 
140 static void fulldraw2(Tv * tv)
141 {
142     int     type;
143     int     type2;
144     Imrect *im;
145     Imrect *im2;
146 
147     im = (Imrect *) stack_pop(&type);
148     if (im!=NULL)
149     {
150        im2 = (Imrect *) stack_inspect(&type2);
151        switch (type2)
152        {
153           case IMRECT:
154              tv_erase(tv);
155              im2 = imf_scale_nzero(im2, 0.0, 255.0);
156              tv_imrect2(tv, im2);
157              im_free(im2);
158              break;
159           case EDGERECT:
160              tv_edges_conn(tv, im2);
161              tv_strings(tv, im2);
162              break;
163        }
164        stack_push(im,type,im_free);
165     }
166 }
167 
168 static void skeldraw2(Tv * tv)
169 {
170     int     type;
171     int     type2;
172     Imrect *im;
173     Imrect *im2;
174 
175     im = (Imrect *) stack_pop(&type);
176     if (im!=NULL)
177     {
178        im2 = (Imrect *) stack_inspect(&type2);
179        if (type2 == IMRECT)
180            tv_imrect_skel(tv, im2);
181        stack_push(im,type,im_free);
182     }
183 }
184 
185 static void fulldrawreg(Tv * tv)
186 {
187     int     type;
188     int     type2;
189     Imrect *im;
190     Imrect *im2;
191 
192     if (reg_a!=NULL)
193     {
194        switch (reg_type)
195        {
196           case IMRECT:
197              tv_erase(tv);
198              im2 = imf_scale_nzero(reg_a, 0.0, 255.0);
199              tv_imrect2(tv, im2);
200              im_free(im2);
201              break;
202           case EDGERECT:
203              tv_edges_conn(tv, reg_a);
204              tv_strings(tv, reg_a);
205              break;
206        }
207     }
208 }
209 
210 static void skeldrawreg(Tv * tv)
211 {
212     int     type;
213     int     type2;
214     Imrect *im;
215 
216     if (reg_a!=NULL)
217     {
218        if (reg_type == IMRECT)
219           tv_imrect_skel(tv, reg_a);
220     }
221 }
222 
223 Tv     *imcalc_tv_make(void)
224 {
225     static Tv *tv;
226 
227     tv = tv_create("imcalc");
228     (void) tv_set_backdraw(tv, fulldraw);
229     (void) tv_set_skeldraw(tv, skeldraw);
230     tv_set_init(tv, init);
231     (void) tv_set_zoomlevel(tv, IMZOOM);
232 
233     return (tv);
234 }
235 
236 Tv     *imcal2_tv_make(void)
237 {
238     static Tv *tv;
239 
240     tv = tv_create("imcalc2");
241     (void) tv_set_backdraw(tv, fulldraw2);
242     (void) tv_set_skeldraw(tv, skeldraw2);
243     tv_set_init(tv, init);
244     (void) tv_set_zoomlevel(tv, IMZOOM);
245     return (tv);
246 }
247 
248 Tv     *imcmem_tv_make(void)
249 {
250     static Tv *tv;
251 
252     tv = tv_create("imcalc reg");
253     (void) tv_set_backdraw(tv, fulldrawreg);
254     (void) tv_set_skeldraw(tv, skeldrawreg);
255     tv_set_init(tv, init);
256     (void) tv_set_zoomlevel(tv, IMZOOM);
257     return (tv);
258 }
259 
260 void    imcalc_draw_scale(void)
261 {
262     Imrect *im;
263     int     type;
264 
265     im = (Imrect *) stack_inspect(&type);
266     if (type != IMRECT)
267         return;
268 
269     im = imf_scale(im, 0.0, 255.0);
270     tv_imrect2(imcalc_tv_get(), im);
271     im_free(im);
272 }
273 
274 static void grey_level(Tv * tv, Ipos pos)
275 {
276     Vec2    v = {Vec2_id};
277     Vec2    tv_backproj2();
278     int     x, y;
279     double  val;
280     Imrect *im;
281     int     type;
282 
283     im = (Imrect *) stack_inspect(&type);
284     if (type != IMRECT)
285     {
286         error("grey_level: no image on stack", warning);
287         return;
288     }
289     v = tv_backproj2(tv, pos);
290     x = tina_int(vec2_x(v));
291     y = tina_int(vec2_y(v));
292     val = im_get_pixf(im, y, x);
293 
294     format("pos %10d %10d:     grey level = %3.2f\n", x, y, val);
295 }
296 
297 Tv_mouse imcalc_grey_level_mouse(void)
298 {
299     return (mouse_define(LEFT_DOWN, grey_level, LEFT_NAME, "grey", NULL));
300 }
301 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.