Fawkes API  Fawkes Development Version
color_train_widget.cpp
1 
2 /***************************************************************************
3  * color_train_widget.cpp - Color training widget
4  *
5  * Created: Thu Mar 20 22:19:36 2008
6  * Copyright 2008 Daniel Beck
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #include "color_train_widget.h"
24 #include "colormap_viewer_widget.h"
25 #include <fvutils/color/yuv.h>
26 #include <fvutils/color/zauberstab.h>
27 #include <fvutils/color/colorspaces.h>
28 #include <fvutils/color/conversions.h>
29 #include <fvutils/draw/drawer.h>
30 #include <fvutils/scalers/lossy.h>
31 #include <fvutils/colormap/bayes/bayes_generator.h>
32 #include <fvutils/colormap/yuvcm.h>
33 #include <fvutils/colormap/cmfile.h>
34 
35 #include <fvutils/writers/jpeg.h>
36 
37 #include <fvutils/color/color_object_map.h>
38 
39 #include <core/exceptions/software.h>
40 
41 using namespace firevision;
42 
43 /** @class ColorTrainWidget "color_train_widget.h"
44  * This widget implements the complete color training process.
45  *
46  * @author Daniel Beck
47  */
48 
49 /** Constructor.
50  * @param parent the parent window
51  */
53 {
54  m_generator = 0;
55  m_zauberstab = new Zauberstab();
56  m_cvw = new ColormapViewerWidget();
57 
58  m_src_buffer = 0;
59  m_draw_buffer = 0;
60 
61  m_wnd_parent = parent;
62  m_btn_reset_selection = 0;
63  m_btn_add_to_colormap = 0;
64  m_btn_reset_colormap = 0;
65  m_btn_load_histos = 0;
66  m_btn_save_histos = 0;
67  m_btn_load_colormap = 0;
68  m_btn_save_colormap = 0;
69  m_spbtn_cm_depth = 0;
70  m_spbtn_cm_width = 0;
71  m_spbtn_cm_height = 0;
72  m_img_segmentation = 0;
73  m_scl_threshold = 0;
74  m_scl_min_prob = 0;
75  m_fcd_filechooser = 0;
76 }
77 
78 /** Destructor. */
80 {
81  delete m_cvw;
82  delete m_generator;
83  delete m_zauberstab;
84 }
85 
86 /** Set the current foreground object.
87  * @param fg_object the foreground object
88  */
89 void
91 {
92  m_fg_object = fg_object;
93 }
94 
95 /** Set the buffer containing the image data.
96  * @param yuv422_buffer the YUV422_PLANAR buffer holding the image data
97  * @param img_width the width of the image
98  * @param img_height the height of the image
99  */
100 void
101 ColorTrainWidget::set_src_buffer(unsigned char* yuv422_buffer,
102  unsigned int img_width, unsigned int img_height)
103 {
104  m_img_width = img_width;
105  m_img_height = img_height;
106  m_src_buffer = yuv422_buffer;
107  m_img_cs = YUV422_PLANAR;
108  m_img_size = colorspace_buffer_size( m_img_cs, m_img_width, m_img_height );
109 
110  if (yuv422_buffer)
111  {
112  m_zauberstab->deleteRegion();
113  m_zauberstab->setBuffer(m_src_buffer, m_img_width, m_img_height);
114  m_zauberstab->setThreshold(10);
115  }
116  else
117  {
118  m_img_segmentation->clear();
119  m_img_segmentation->set("gtk-missing-image");
120  }
121 }
122 
123 /** Set the buffer to draw the selection into.
124  * It is assumed that this buffer has the same dimensions as the buffer holding
125  * the soruce image.
126  * @param buffer the draw buffer
127  */
128 void
129 ColorTrainWidget::set_draw_buffer(unsigned char* buffer)
130 {
131  m_draw_buffer = buffer;
132 }
133 
134 /** The user clicked into the image.
135  * @param x the x-coordinate
136  * @param y the y-coordinate
137  * @param button 1 for left click, 3 for right click @see GdkEventButton
138  */
139 void
140 ColorTrainWidget::click(unsigned int x, unsigned int y, unsigned int button)
141 {
142  if (m_src_buffer == 0 || m_draw_buffer == 0)
143  { return; }
144 
145  if ( m_zauberstab->isEmptyRegion() )
146  {
147  if (button == MOUSE_BUTTON_LEFT) //left click
148  {
149  m_zauberstab->findRegion(x, y);
150  }
151  }
152  else
153  {
154  if (button == MOUSE_BUTTON_LEFT) //left click
155  {
156  m_zauberstab->addRegion(x, y);
157  }
158 
159  if (button == MOUSE_BUTTON_RIGHT) //right click
160  {
161  m_zauberstab->deleteRegion(x, y);
162  }
163  }
164 
165  memcpy(m_draw_buffer, m_src_buffer, m_img_size);
166 
167  ZRegion *region = m_zauberstab->getRegion();
168  Drawer *d = new Drawer();
169  d->set_buffer( m_draw_buffer, m_img_width, m_img_height );
170 
171  for (unsigned int s = 0; s < region->slices->size(); s++)
172  {
173  d->draw_rectangle_inverted( region->slices->at(s)->leftX,
174  region->slices->at(s)->y,
175  region->slices->at(s)->rightX - region->slices->at(s)->leftX,
176  1 );
177  }
178 
179  delete d;
180 
181  m_signal_update_image();
182 }
183 
184 /** Reset the selection. */
185 void
187 {
188  if (m_zauberstab)
189  { m_zauberstab->deleteRegion(); }
190 
191  if( m_src_buffer && m_draw_buffer )
192  { memcpy(m_draw_buffer, m_src_buffer, m_img_size); }
193 
194  m_signal_update_image();
195 }
196 
197 /** Set the button to reset the selection.
198  * @param btn the reset selection button
199  */
200 void
202 {
203  m_btn_reset_selection = btn;
204  m_btn_reset_selection->signal_clicked().connect( sigc::mem_fun(*this, &ColorTrainWidget::reset_selection) );
205 }
206 
207 /** Set the button to trigger the generation of the colormap.
208  * @param btn a Button
209  */
210 void
212 {
213  m_btn_add_to_colormap = btn;
214  m_btn_add_to_colormap->signal_clicked().connect( sigc::mem_fun(*this, &ColorTrainWidget::add_to_colormap) );
215 }
216 
217 /** Set the button to reset the colormap.
218  * @param btn a Button
219  */
220 void
222 {
223  m_btn_reset_colormap = btn;
224  m_btn_reset_colormap->signal_clicked().connect( sigc::mem_fun(*this, &ColorTrainWidget::reset_colormap) );
225 }
226 
227 /** Set the buffon to open a dialog to load histograms.
228  * @param btn a Button
229  */
230 void
232 {
233  m_btn_load_histos = btn;
234  m_btn_load_histos->signal_clicked().connect( sigc::mem_fun(*this, &ColorTrainWidget::load_histograms) );
235 }
236 
237 /** Set the buffon to open a dialog to save histograms.
238  * @param btn a Button
239  */
240 void
242 {
243  m_btn_save_histos = btn;
244  m_btn_save_histos->signal_clicked().connect( sigc::mem_fun(*this, &ColorTrainWidget::save_histograms) );
245 }
246 
247 /** Set the buffon to open a dialog to load a colormap.
248  * @param btn a Button
249  */
250 void
252 {
253  m_btn_load_colormap = btn;
254  m_btn_load_colormap->signal_clicked().connect( sigc::mem_fun(*this, &ColorTrainWidget::load_colormap) );
255 }
256 
257 /** Set the buffon to open a dialog to save a colormap.
258  * @param btn a Button
259  */
260 void
262 {
263  m_btn_save_colormap = btn;
264  m_btn_save_colormap->signal_clicked().connect( sigc::mem_fun(*this, &ColorTrainWidget::save_colormap) );
265 }
266 
267 /** Set the image to render the colormap into.
268  * @param img an Image
269  */
270 void
272 {
273  m_cvw->set_colormap_img(img);
274 }
275 
276 /** Set the image to render the segmented image into.
277  * @param img an Image
278  */
279 void
281 {
282  m_img_segmentation = img;
283  m_seg_img_max_width = m_img_segmentation->get_width();
284  m_seg_img_max_height = m_img_segmentation->get_height();
285  m_img_segmentation->signal_size_allocate().connect( sigc::mem_fun( *this, &ColorTrainWidget::resize_seg_image) );
286 }
287 
288 void
289 ColorTrainWidget::resize_seg_image(Gtk::Allocation& allocation)
290 {
291  unsigned int new_width = (unsigned int) allocation.get_width();
292  unsigned int new_height = (unsigned int) allocation.get_height();
293 
294  if (new_width != m_seg_img_max_width || new_height != m_seg_img_max_height)
295  {
296  m_seg_img_max_width = new_width;
297  m_seg_img_max_height = new_height;
298  draw_segmentation_result();
299  }
300 }
301 
302 /** Set the scale to control the selection threshold.
303  * @param scl a Scale
304  */
305 void
307 {
308  m_scl_threshold = scl;
309  m_scl_threshold->signal_change_value().connect( sigc::mem_fun(*this, &ColorTrainWidget::set_threshold) );
310 }
311 
312 /** Set the scale to control the minimum probability.
313  * @param scl a Scale
314  */
315 void
317 {
318  m_scl_min_prob = scl;
319  m_scl_min_prob->signal_change_value().connect( sigc::mem_fun(*this, &ColorTrainWidget::set_min_prob) );
320 }
321 
322 /** Set the filechooser dialog to be used by this widget.
323  * @param dlg a FileChooserDialog
324  */
325 void
326 ColorTrainWidget::set_filechooser_dlg(Gtk::FileChooserDialog* dlg)
327 {
328  m_fcd_filechooser = dlg;
329 }
330 
331 /** Set the widget to choose the layer of the colormap to display.
332  * @param scl a Scale
333  */
334 void
336 {
337  m_cvw->set_layer_selector(scl);
338 }
339 
340 /** Set the widget to adjust the depth of the colormap.
341  * @param depth SpinButton to set the Y-resolution of the color map
342  * @param width SpinButton to set the U-resolution of the color map
343  * @param height SpinButton to set the V-resolution of the color map
344  */
345 void
346 ColorTrainWidget::set_cm_selector(Gtk::SpinButton* depth, Gtk::SpinButton* width, Gtk::SpinButton* height)
347 {
348  m_spbtn_cm_depth = depth;
349  m_spbtn_cm_width = width;
350  m_spbtn_cm_height = height;
351 }
352 
353 /** Access the signal that is emitted whenever a redraw of the image is necessary.
354  * @return reference to a Dispatcher.
355  */
356 Glib::Dispatcher&
358 {
359  return m_signal_update_image;
360 }
361 
362 /** Access the signal that is emitted whenever the colormap has changed.
363  * @return reference to a Dispatcher.
364  */
365 Glib::Dispatcher&
367 {
368  return m_signal_colormap_updated;
369 }
370 
371 /** Open a dialog to load a histogram. */
372 void
374 {
375  if ( !m_fcd_filechooser )
376  { return; }
377 
378  m_fcd_filechooser->set_title("Load histograms");
379  m_fcd_filechooser->set_action(Gtk::FILE_CHOOSER_ACTION_OPEN);
380 
381  m_fcd_filechooser->set_transient_for(*m_wnd_parent);
382 
383  int result = m_fcd_filechooser->run();
384 
385  switch(result)
386  {
387  case (Gtk::RESPONSE_OK):
388  {
389  std::string filename = m_fcd_filechooser->get_filename();
390  if (!m_generator)
391  { m_generator = new BayesColormapGenerator(); }
392  m_generator->load_histograms( filename.c_str() );
393  m_generator->calc();
394  m_signal_colormap_updated();
395 
396  YuvColormap *cur = m_generator->get_current();
397  if (m_spbtn_cm_depth) m_spbtn_cm_depth->set_value(log(cur->depth()) / log(2));
398  if (m_spbtn_cm_width) m_spbtn_cm_width->set_value(log(cur->width()) / log(2));
399  if (m_spbtn_cm_height) m_spbtn_cm_height->set_value(log(cur->height()) / log(2));
400 
401  m_cvw->set_colormap(cur);
402  m_cvw->draw();
403  draw_segmentation_result();
404  break;
405  }
406 
407  case (Gtk::RESPONSE_CANCEL):
408  break;
409 
410  default:
411  break;
412  }
413 
414  m_fcd_filechooser->hide();
415 }
416 
417 /** Open a dialog to save a histogram. */
418 void
420 {
421  if ( !m_fcd_filechooser )
422  { return; }
423 
424  m_fcd_filechooser->set_title("Save histograms");
425  m_fcd_filechooser->set_action(Gtk::FILE_CHOOSER_ACTION_SAVE);
426 
427  m_fcd_filechooser->set_transient_for(*m_wnd_parent);
428 
429  int result = m_fcd_filechooser->run();
430 
431  switch(result)
432  {
433  case (Gtk::RESPONSE_OK):
434  {
435  std::string filename = m_fcd_filechooser->get_filename();
436  m_generator->save_histograms( filename.c_str() );
437  break;
438  }
439 
440  case (Gtk::RESPONSE_CANCEL):
441  break;
442 
443  default:
444  break;
445  }
446 
447  m_fcd_filechooser->hide();
448 }
449 
450 /** Generate a new colormap by adding the current histograms. */
451 void
453 {
454  if ( !m_src_buffer )
455  { return; }
456 
457  unsigned int cm_depth;
458  if (m_spbtn_cm_depth)
459  { cm_depth = (unsigned int) rint( pow(2.0, m_spbtn_cm_depth->get_value()) ); }
460  else
461  { cm_depth = 1; }
462 
463  unsigned int cm_width;
464  if (m_spbtn_cm_width)
465  { cm_width = (unsigned int) rint( pow(2.0, m_spbtn_cm_width->get_value()) ); }
466  else
467  { cm_width = 256; }
468 
469  unsigned int cm_height;
470  if (m_spbtn_cm_height)
471  { cm_height = (unsigned int) rint( pow(2.0, m_spbtn_cm_height->get_value()) ); }
472  else
473  { cm_height = 256; }
474 
475  if ( !m_generator
476  || cm_depth != m_generator->get_current()->depth()
477  || cm_width != m_generator->get_current()->width()
478  || cm_height != m_generator->get_current()->height())
479  {
480  delete m_generator;
481  m_generator = new BayesColormapGenerator(cm_depth, H_UNKNOWN, cm_width, cm_height);
482  m_cvw->set_colormap( m_generator->get_current() );
483  }
484 
485  if (m_fg_object == H_UNKNOWN)
486  {
487  printf("CTW::add_to_colormap(): no fg object set\n");
488  return;
489  }
490 
491  m_generator->set_fg_object(m_fg_object);
492  m_generator->reset_undo();
493  m_generator->set_buffer(m_src_buffer, m_img_width, m_img_height);
494  m_generator->set_selection( m_zauberstab->getSelection() );
495  m_generator->consider();
496  m_generator->calc();
497  m_signal_colormap_updated();
498 
499  // update colormap image
500  m_cvw->draw(-1);
501 
502  // update segmentation image
503  draw_segmentation_result();
504 }
505 
506 /** Reset the colormap. */
507 void
509 {
510  Gtk::MessageDialog dialog(*m_wnd_parent, "Are you sure you want to reset the colormap?",
511  false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_OK_CANCEL);
512 
513  int result = dialog.run();
514 
515  if (result != Gtk::RESPONSE_OK) return;
516 
517  if (m_generator)
518  {
519  m_generator->reset();
520  m_signal_colormap_updated();
521 
522  if (m_cvw)
523  { m_cvw->draw(); }
524 
525  draw_segmentation_result();
526  }
527 }
528 
529 /** Open a dialog to load a colormap. */
530 void
532 {
533  if ( !m_fcd_filechooser )
534  { return; }
535 
536  m_fcd_filechooser->set_title("Load colormap colormap");
537  m_fcd_filechooser->set_action(Gtk::FILE_CHOOSER_ACTION_OPEN);
538 
539  m_fcd_filechooser->set_transient_for(*m_wnd_parent);
540 
541  int result = m_fcd_filechooser->run();
542 
543  switch(result)
544  {
545  case (Gtk::RESPONSE_OK):
546  {
547  delete m_generator;
548 
549  std::string filename = m_fcd_filechooser->get_filename();
550  ColormapFile cmf;
551  cmf.read(filename.c_str());
552  Colormap *tcm = cmf.get_colormap();
553  YuvColormap *tycm = dynamic_cast<YuvColormap *>(tcm);
554  if ( ! tycm ) {
555  delete tcm;
556  throw fawkes::TypeMismatchException("File does not contain a YUV colormap");
557  }
558  unsigned int cm_depth = tcm->depth();
559  unsigned int cm_width = tcm->width();
560  unsigned int cm_height = tcm->height();
561  m_generator = new BayesColormapGenerator(cm_depth, H_UNKNOWN, cm_width, cm_height);
562  YuvColormap *current = m_generator->get_current();
563  *current = *tycm;
564  delete tcm;
565 
566  if (m_spbtn_cm_depth) m_spbtn_cm_depth->set_value(log(cm_depth) / log(2));
567  if (m_spbtn_cm_width) m_spbtn_cm_width->set_value(log(cm_width) / log(2));
568  if (m_spbtn_cm_height) m_spbtn_cm_height->set_value(log(cm_height) / log(2));
569 
570  m_signal_colormap_updated();
571  m_cvw->set_colormap( m_generator->get_current() );
572  m_cvw->draw();
573  draw_segmentation_result();
574  break;
575  }
576 
577  case (Gtk::RESPONSE_CANCEL):
578  break;
579 
580  default:
581  break;
582  }
583 
584  m_fcd_filechooser->hide();
585 }
586 
587 /** Open a dialog to save a colormap. */
588 void
590 {
591  if ( !m_fcd_filechooser )
592  { return; }
593 
594  m_fcd_filechooser->set_title("Save colormap colormap");
595  m_fcd_filechooser->set_action(Gtk::FILE_CHOOSER_ACTION_SAVE);
596 
597  m_fcd_filechooser->set_transient_for(*m_wnd_parent);
598 
599  int result = m_fcd_filechooser->run();
600 
601  switch(result)
602  {
603  case(Gtk::RESPONSE_OK):
604  {
605  std::string filename = m_fcd_filechooser->get_filename();
606  YuvColormap *current = m_generator->get_current();
607  ColormapFile cmf(current->depth(), current->width(), current->height());
608  cmf.add_colormap(current);
609  cmf.write( filename.c_str() );
610  break;
611  }
612 
613  case(Gtk::RESPONSE_CANCEL):
614  break;
615 
616  default:
617  break;
618  }
619 
620  m_fcd_filechooser->hide();
621 }
622 
623 /** Get the current colormap.
624  * @return the current colormap
625  */
626 YuvColormap *
628 {
629  if ( !m_generator )
630  { return 0; }
631 
632  return m_generator->get_current();
633 }
634 
635 bool
636 ColorTrainWidget::set_threshold(Gtk::ScrollType scroll, double value)
637 {
638  unsigned int threshold = (unsigned int) rint(value);
639  m_zauberstab->setThreshold(threshold);
640 
641  return true;
642 }
643 
644 bool
645 ColorTrainWidget::set_min_prob(Gtk::ScrollType scroll, double value)
646 {
647  if ( !m_generator )
648  { return true; }
649 
650  m_generator->set_min_probability(value);
651 
652  return true;
653 }
654 
655 void
656 ColorTrainWidget::reset_gui()
657 {
658  m_scl_min_prob->set_value(0.0);
659 }
660 
661 /** Render the result of segmenting the image in the source buffer considering the current
662  * colormap into the specified Image.
663  */
664 void
666 {
667  if ( !m_src_buffer || !m_img_segmentation || !m_generator)
668  { return; }
669 
670  unsigned char* seg_buffer = (unsigned char*) malloc(m_img_size);
671  bzero(seg_buffer, m_img_size);
672 
673  Drawer d;
674  d.set_buffer(seg_buffer, m_img_width, m_img_height);
675 
676  YuvColormap* cm = m_generator->get_current();
677 
678  for (unsigned int w = 0; w < m_img_width; ++w)
679  {
680  for (unsigned int h = 0; h < m_img_height; ++h)
681  {
682  unsigned int y = YUV422_PLANAR_Y_AT(m_src_buffer, m_img_width, w, h);
683  unsigned int u = YUV422_PLANAR_U_AT(m_src_buffer, m_img_width, m_img_height, w, h);
684  unsigned int v = YUV422_PLANAR_V_AT(m_src_buffer, m_img_width, m_img_height, w, h);
685 
687  d.color_point(w, h);
688  }
689  }
690 
691  LossyScaler scaler;
692  scaler.set_original_buffer(seg_buffer);
693  scaler.set_original_dimensions(m_img_width, m_img_height);
694  scaler.set_scaled_dimensions(m_seg_img_max_width, m_seg_img_max_height);
695  unsigned int width = scaler.needed_scaled_width();
696  unsigned int height = scaler.needed_scaled_height();
697 
698  unsigned char* scaled_buffer = (unsigned char*) malloc( colorspace_buffer_size( m_img_cs,
699  width,
700  height ) );
701  scaler.set_scaled_buffer(scaled_buffer);
702  scaler.scale();
703 
704  unsigned char* rgb_buffer = (unsigned char*) malloc( colorspace_buffer_size( RGB,
705  width,
706  height ) );
707  convert(m_img_cs, RGB, scaled_buffer, rgb_buffer, width, height);
708 
709  Glib::RefPtr<Gdk::Pixbuf> image = Gdk::Pixbuf::create_from_data( rgb_buffer,
710  Gdk::COLORSPACE_RGB,
711  false,
712  8,
713  width,
714  height,
715  3 * width,
716  Gdk::Pixbuf::SlotDestroyData(&free_rgb_buffer));
717 
718  m_img_segmentation->set(image);
719 
720  free(scaled_buffer);
721  free(seg_buffer);
722 }
723 
724 /** Callback to free the rgb buffer
725  * @param rgb_buffer pointer to the buffer
726  */
727 void ColorTrainWidget::free_rgb_buffer(const guint8* rgb_buffer)
728 {
729  free(const_cast<guint8 *>(rgb_buffer));
730 }
virtual unsigned int needed_scaled_height()
Minimum needed height of scaled image depending on factor and original image height.
Definition: lossy.cpp:140
void set_load_histos_btn(Gtk::Button *btn)
Set the buffon to open a dialog to load histograms.
virtual ~ColorTrainWidget()
Destructor.
void add_colormap(Colormap *colormap)
Add colormap.
Definition: cmfile.cpp:98
virtual void set_scaled_buffer(unsigned char *buffer)
Set scaled image buffer.
Definition: lossy.cpp:126
Glib::Dispatcher & update_image()
Access the signal that is emitted whenever a redraw of the image is necessary.
virtual void set_original_buffer(unsigned char *buffer)
Set original image buffer.
Definition: lossy.cpp:119
void set_load_colormap_btn(Gtk::Button *btn)
Set the buffon to open a dialog to load a colormap.
void set_min_prob_scl(Gtk::Scale *scl)
Set the scale to control the minimum probability.
void set_reset_selection_btn(Gtk::Button *btn)
Set the button to reset the selection.
void load_colormap()
Open a dialog to load a colormap.
virtual unsigned int width() const
Get width of colormap.
Definition: yuvcm.cpp:322
virtual unsigned int depth() const =0
Get depth of colormap.
ColorTrainWidget(Gtk::Window *parent)
Constructor.
void save_histograms()
Open a dialog to save a histogram.
Draw to an image.
Definition: drawer.h:34
Colormap interface.
Definition: colormap.h:38
virtual unsigned int height() const =0
Get height of colormap.
void set_add_to_colormap_btn(Gtk::Button *btn)
Set the button to trigger the generation of the colormap.
Colormap * get_colormap()
Get a freshly generated colormap based on current file content.
Definition: cmfile.cpp:169
YUV Colormap.
Definition: yuvcm.h:39
void draw_rectangle_inverted(unsigned int x, unsigned int y, unsigned int w, unsigned int h)
Draw inverted rectangle.
Definition: drawer.cpp:268
virtual void read(const char *file_name)
Read file.
Definition: fvfile.cpp:308
Colormap file.
Definition: cmfile.h:55
Lossy image scaler.
Definition: lossy.h:35
void click(unsigned int x, unsigned int y, unsigned int button=MOUSE_BUTTON_LEFT)
The user clicked into the image.
std::vector< ZSlice * > * slices
slices
Definition: zauberstab.h:60
void set_buffer(unsigned char *buffer, unsigned int width, unsigned int height)
Set the buffer to draw to.
Definition: drawer.cpp:62
void reset_colormap()
Reset the colormap.
Glib::Dispatcher & colormap_updated()
Access the signal that is emitted whenever the colormap has changed.
firevision::YuvColormap * get_colormap() const
Get the current colormap.
void set_save_histos_btn(Gtk::Button *btn)
Set the buffon to open a dialog to save histograms.
void set_fg_object(firevision::hint_t fg_object)
Set the current foreground object.
void load_histograms()
Open a dialog to load a histogram.
virtual void set_original_dimensions(unsigned int width, unsigned int height)
Set original image dimensions.
Definition: lossy.cpp:83
void set_save_colormap_btn(Gtk::Button *btn)
Set the buffon to open a dialog to save a colormap.
a region is a stack of slices, together with the y-position of the slice at the top ...
Definition: zauberstab.h:58
void reset_selection()
Reset the selection.
Zaubertab selection utility.
Definition: zauberstab.h:68
virtual void set_scaled_dimensions(unsigned int width, unsigned int height)
Set dimenins of scaled image buffer.
Definition: lossy.cpp:92
void set_reset_colormap_btn(Gtk::Button *btn)
Set the button to reset the colormap.
void set_draw_buffer(unsigned char *buffer)
Set the buffer to draw the selection into.
virtual unsigned int width() const =0
Get width of colormap.
virtual unsigned int depth() const
Get depth of colormap.
Definition: yuvcm.cpp:336
Colormap Generator using Bayes method.
virtual color_t determine(unsigned int y, unsigned int u, unsigned int v) const
Determine color class for given YUV value.
Definition: yuvcm.h:94
void set_colormap_img(Gtk::Image *img)
Set the image to render the colormap into.
void set_filechooser_dlg(Gtk::FileChooserDialog *dlg)
Set the filechooser dialog to be used by this widget.
void set_src_buffer(unsigned char *buffer, unsigned int img_width, unsigned int img_height)
Set the buffer containing the image data.
void set_cm_layer_selector(Gtk::Scale *scl)
Set the widget to choose the layer of the colormap to display.
virtual unsigned int needed_scaled_width()
Minimum needed width of scaled image depending on factor and original image width.
Definition: lossy.cpp:133
void color_point(unsigned int x, unsigned int y)
Color the given point.
Definition: drawer.cpp:336
virtual void scale()
Scale image.
Definition: lossy.cpp:153
static YUV_t get_color(color_t color)
YUV_t getter.
void save_colormap()
Open a dialog to save a colormap.
virtual unsigned int height() const
Get height of colormap.
Definition: yuvcm.cpp:329
Select a layer from a colormap and render it to a Gtk::Image.
void set_cm_selector(Gtk::SpinButton *depth, Gtk::SpinButton *width=0, Gtk::SpinButton *height=0)
Set the widget to adjust the depth of the colormap.
void set_segmentation_img(Gtk::Image *img)
Set the image to render the segmented image into.
void draw_segmentation_result()
Render the result of segmenting the image in the source buffer considering the current colormap into ...
void add_to_colormap()
Generate a new colormap by adding the current histograms.
void set_color(unsigned char y, unsigned char u, unsigned char v)
Set drawing color.
Definition: drawer.cpp:77
void set_threshold_scl(Gtk::Scale *scl)
Set the scale to control the selection threshold.