Class: RedEye

Inherits:
Object
  • Object
show all
Defined in:
ext/redeye/redeye.c

Constant Summary collapse

Region =
structRegion

Instance Method Summary collapse

Constructor Details

#initialize(__v_pixbuf, __v_minX, __v_minY, __v_maxX, __v_maxY) ⇒ Object



540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
# File 'ext/redeye/redeye.c', line 540

static VALUE
RedEye_initialize(VALUE self OPTIONAL_ATTR , VALUE __v_pixbuf OPTIONAL_ATTR, VALUE __v_minX OPTIONAL_ATTR, VALUE __v_minY OPTIONAL_ATTR, VALUE __v_maxX OPTIONAL_ATTR, VALUE __v_maxY OPTIONAL_ATTR)
{
  GdkPixbuf * pixbuf; GdkPixbuf * __orig_pixbuf;
  int minX; int __orig_minX;
  int minY; int __orig_minY;
  int maxX; int __orig_maxX;
  int maxY; int __orig_maxY;
  __orig_pixbuf = pixbuf = GDK_PIXBUF(RVAL2GOBJ(__v_pixbuf));
  __orig_minX = minX = NUM2INT(__v_minX);
  __orig_minY = minY = NUM2INT(__v_minY);
  __orig_maxX = maxX = NUM2INT(__v_maxX);
  __orig_maxY = maxY = NUM2INT(__v_maxY);

#line 540 "/home/geoff/Projects/redeye/ext/redeye/redeye.cr"

  do {
  redeyeop_t * op  ;
 Data_Get_Struct(self, redeyeop_t, op);
  op->pixbuf = pixbuf;
  op->preview = NULL;
  g_object_ref(op->pixbuf);
  op->area.minX = minX;
  op->area.maxX = maxX;
  op->area.minY = minY;
  op->area.maxY = maxY;
  op->area.width = maxX - minX + 1;
  op->area.height = maxY - minY + 1;
  assert(op->pixbuf != NULL);
  assert(op->area.maxX <= gdk_pixbuf_get_width(op->pixbuf));
  assert(op->area.minX >= 0);
  assert(op->area.minX < op->area.maxX);
  assert(op->area.maxY <= gdk_pixbuf_get_height(op->pixbuf));
  assert(op->area.minY >= 0);
  assert(op->area.minY < op->area.maxY);
  op->mask = ALLOC_N(int, op->area.width * op->area.height);
  op->regions.data = ALLOC_N(int, op->area.width * op->area.height);
  op->regions.region = ALLOC_N(region_info, NO_REGIONS_DEFAULT);
  op->regions.len = 0;
  op->regions.size = NO_REGIONS_DEFAULT;
 

  } while(0);

;
  return Qnil;
}

Instance Method Details

#correct_blob(__v_blob_id) ⇒ Object



645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
# File 'ext/redeye/redeye.c', line 645

static VALUE
RedEye_correct_blob(VALUE self OPTIONAL_ATTR , VALUE __v_blob_id OPTIONAL_ATTR)
{
  int blob_id; int __orig_blob_id;
  __orig_blob_id = blob_id = NUM2INT(__v_blob_id);

#line 600 "/home/geoff/Projects/redeye/ext/redeye/redeye.cr"

  do {
  redeyeop_t * op  ;
 Data_Get_Struct(self, redeyeop_t, op);
  if (op->regions.len <= blob_id) rb_raise(rb_eIndexError, "Only %i blobs in region - %i is invalid", op->regions.len, blob_id);
  desaturate_blob(op, blob_id);
 

  } while(0);

  return Qnil;
}

#highlight_blob(*__p_argv, self) ⇒ Object



665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
# File 'ext/redeye/redeye.c', line 665

static VALUE
RedEye_highlight_blob(int __p_argc, VALUE *__p_argv, VALUE self)
{
  VALUE __v_blob_id = Qnil;
  int blob_id; int __orig_blob_id;
  VALUE __v_col = Qnil;
  int col; int __orig_col;

  /* Scan arguments */
  rb_scan_args(__p_argc, __p_argv, "11",&__v_blob_id, &__v_col);

  /* Set defaults */
  __orig_blob_id = blob_id = NUM2INT(__v_blob_id);

  if (__p_argc > 1)
    __orig_col = col = NUM2INT(__v_col);
  else
    col = 0x00ff00;


#line 612 "/home/geoff/Projects/redeye/ext/redeye/redeye.cr"

  do {
  redeyeop_t * op  ;
 Data_Get_Struct(self, redeyeop_t, op);
  if (op->regions.len <= blob_id) rb_raise(rb_eIndexError, "Only %i blobs in region - %i is invalid", op->regions.len, blob_id);
  highlight_blob(op, blob_id, col);
 

  } while(0);

  return Qnil;
}

#identify_blobs(*__p_argv, self) ⇒ Object



588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
# File 'ext/redeye/redeye.c', line 588

static VALUE
RedEye_identify_blobs(int __p_argc, VALUE *__p_argv, VALUE self)
{
  VALUE __p_retval OPTIONAL_ATTR = Qnil;
  VALUE __v_green_sensitivity = Qnil;
  double green_sensitivity; double __orig_green_sensitivity;
  VALUE __v_blue_sensitivity = Qnil;
  double blue_sensitivity; double __orig_blue_sensitivity;
  VALUE __v_min_red_val = Qnil;
  int min_red_val; int __orig_min_red_val;

  /* Scan arguments */
  rb_scan_args(__p_argc, __p_argv, "03",&__v_green_sensitivity, &__v_blue_sensitivity, &__v_min_red_val);

  /* Set defaults */
  if (__p_argc > 0)
    __orig_green_sensitivity = green_sensitivity = NUM2DBL(__v_green_sensitivity);
  else
    green_sensitivity = 2.0;

  if (__p_argc > 1)
    __orig_blue_sensitivity = blue_sensitivity = NUM2DBL(__v_blue_sensitivity);
  else
    blue_sensitivity = 0.0;

  if (__p_argc > 2)
    __orig_min_red_val = min_red_val = NUM2INT(__v_min_red_val);
  else
    min_red_val = MIN_RED_VAL;


#line 575 "/home/geoff/Projects/redeye/ext/redeye/redeye.cr"

  do {
  redeyeop_t * op  ;
 Data_Get_Struct(self, redeyeop_t, op);
  MEMZERO(op->mask, int, op->area.width * op->area.height);
  MEMZERO(op->regions.data, int, op->area.width * op->area.height);
  identify_possible_redeye_pixels(op, green_sensitivity, blue_sensitivity, min_red_val);
  identify_blob_groupings(op);
  volatile VALUE  ary  =
 rb_ary_new2(op->regions.len);
  int  i  ;
 for (i = MIN_ID;
  i < op->regions.len;
  i++) { region_info * r  =
 &op->regions.region[i];
  /* Ignore CCD noise */ if (r->noPixels < 2) continue;
  rb_ary_push(ary, rb_struct_new(structRegion, self, INT2NUM(i), INT2NUM(r->minX), INT2NUM(r->minY), INT2NUM(r->maxX), INT2NUM(r->maxY), INT2NUM(r->width), INT2NUM(r->height), INT2NUM(r->noPixels)));
  } do { __p_retval = ary; goto out; } while(0);

  } while(0);

out:
  return __p_retval;
}

#pixbufObject



760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
# File 'ext/redeye/redeye.c', line 760

static VALUE
RedEye_pixbuf(VALUE self OPTIONAL_ATTR )
{
  VALUE __p_retval OPTIONAL_ATTR = Qnil;

#line 642 "/home/geoff/Projects/redeye/ext/redeye/redeye.cr"

  do {
  redeyeop_t * op  ;
 Data_Get_Struct(self, redeyeop_t, op);
  do { __p_retval = GOBJ2RVAL(GDK_PIXBUF(op->pixbuf)); goto out; } while(0);

  } while(0);

out:
  return __p_retval;
}

#previewObject



742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
# File 'ext/redeye/redeye.c', line 742

static VALUE
RedEye_preview(VALUE self OPTIONAL_ATTR )
{
  VALUE __p_retval OPTIONAL_ATTR = Qnil;

#line 635 "/home/geoff/Projects/redeye/ext/redeye/redeye.cr"

  do {
  redeyeop_t * op  ;
 Data_Get_Struct(self, redeyeop_t, op);
  do { __p_retval = GOBJ2RVAL(GDK_PIXBUF(redeye_preview(op, FALSE))); goto out; } while(0);

  } while(0);

out:
  return __p_retval;
}

#preview_blob(*__p_argv, self) ⇒ Object



699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
# File 'ext/redeye/redeye.c', line 699

static VALUE
RedEye_preview_blob(int __p_argc, VALUE *__p_argv, VALUE self)
{
  VALUE __p_retval OPTIONAL_ATTR = Qnil;
  VALUE __v_blob_id = Qnil;
  int blob_id; int __orig_blob_id;
  VALUE __v_col = Qnil;
  int col; int __orig_col;
  VALUE __v_reset_preview = Qnil;
  gboolean reset_preview; gboolean __orig_reset_preview;

  /* Scan arguments */
  rb_scan_args(__p_argc, __p_argv, "12",&__v_blob_id, &__v_col, &__v_reset_preview);

  /* Set defaults */
  __orig_blob_id = blob_id = NUM2INT(__v_blob_id);

  if (__p_argc > 1)
    __orig_col = col = NUM2INT(__v_col);
  else
    col = 0x00ff00;

  if (__p_argc > 2)
    __orig_reset_preview = reset_preview = RTEST(__v_reset_preview);
  else
    reset_preview = TRUE;


#line 623 "/home/geoff/Projects/redeye/ext/redeye/redeye.cr"

  do {
  redeyeop_t * op  ;
 Data_Get_Struct(self, redeyeop_t, op);
  if (op->regions.len <= blob_id) rb_raise(rb_eIndexError, "Only %i blobs in region - %i is invalid", op->regions.len, blob_id);
  preview_blob(op, blob_id, col, reset_preview);
  do { __p_retval = GOBJ2RVAL(GDK_PIXBUF(op->preview)); goto out; } while(0);

  } while(0);

out:
  return __p_retval;
}