ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CV/CV.xs
(Generate patch)

Comparing CV/CV.xs (file contents):
Revision 1.36 by root, Thu Jun 22 20:50:05 2006 UTC vs.
Revision 1.39 by root, Fri Jun 23 09:09:14 2006 UTC

118 return; 118 return;
119 119
120 f->v2 /= f->n; 120 f->v2 /= f->n;
121 f->v3 /= f->n; 121 f->v3 /= f->n;
122 122
123 // this is a peculiar weightung, but it works fine
124 f->v1 /= 255.; 123 f->v1 /= 255.;
125 f->v2 /= 128. * 128.; 124 f->v2 /= 255. * 255.; f->v2 = sqrtf (f->v2);
126 f->v3 /= 128. * 128. * 64.; 125 f->v3 /= 255. * 255. * 255.; f->v3 = powf (fabsf (f->v3), 1./3.);
127} 126}
128 127
129static guint32 a85_val; 128static guint32 a85_val;
130static guint a85_cnt; 129static guint a85_cnt;
131static guchar a85_buf[LINELENGTH], *a85_ptr; 130static guchar a85_buf[LINELENGTH], *a85_ptr;
649{ 648{
650 int i; 649 int i;
651 AV *av, *result; 650 AV *av, *result;
652 651
653 if (!SvROK (ar) || SvTYPE (SvRV (ar)) != SVt_PVAV) 652 if (!SvROK (ar) || SvTYPE (SvRV (ar)) != SVt_PVAV)
654 croak ("Not an array ref as first argument to make_histogram"); 653 croak ("Not an array ref as first argument to extract_features");
655 654
656 av = (AV *) SvRV (ar); 655 av = (AV *) SvRV (ar);
657 result = newAV (); 656 result = newAV ();
658 657
659 for (i = 0; i <= av_len (av); ++i) 658 for (i = 0; i <= av_len (av); ++i)
712 feature_finish_pass_2 (&f_v); 711 feature_finish_pass_2 (&f_v);
713 } 712 }
714 713
715 hist [0] = f_h.v1 * 2.; hist [1] = f_h.v2 * 2.; hist [2] = f_h.v3 * 2.; 714 hist [0] = f_h.v1 * 2.; hist [1] = f_h.v2 * 2.; hist [2] = f_h.v3 * 2.;
716 hist [3] = f_s.v1 ; hist [4] = f_s.v2 ; hist [5] = f_s.v3 ; 715 hist [3] = f_s.v1 ; hist [4] = f_s.v2 ; hist [5] = f_s.v3 ;
717 hist [6] = f_v.v1 ; hist [7] = f_v.v2 ; hist [8] = f_v.v3 ; 716 hist [6] = f_v.v1 * .5; hist [7] = f_v.v2 * .5; hist [8] = f_v.v3 * .5;
718 717
719 av_push (result, histsv); 718 av_push (result, histsv);
720 } 719 }
721 720
722 RETVAL = newRV_noinc ((SV *)result); 721 RETVAL = newRV_noinc ((SV *)result);
723} 722}
724 OUTPUT: 723 OUTPUT:
725 RETVAL 724 RETVAL
726 725
727SV *
728make_histograms (SV *ar)
729 CODE:
730{
731 int i;
732 AV *av, *result;
733
734 if (!SvROK (ar) || SvTYPE (SvRV (ar)) != SVt_PVAV)
735 croak ("Not an array ref as first argument to make_histogram");
736
737 av = (AV *) SvRV (ar);
738 result = newAV ();
739
740 for (i = 0; i <= av_len (av); ++i)
741 {
742 const int HISTSIZE = 64;
743
744 int j;
745 SV *sv = *av_fetch (av, i, 1);
746 STRLEN len;
747 char *buf = SvPVbyte (sv, len);
748
749 int tmphist[HISTSIZE];
750 float *hist;
751
752 SV *histsv = newSV (HISTSIZE * sizeof (float) + 1);
753 SvPOK_on (histsv);
754 SvCUR_set (histsv, HISTSIZE * sizeof (float));
755 hist = (float *)SvPVX (histsv);
756
757 Zero (tmphist, sizeof (tmphist), char);
758
759 for (j = len; j--; )
760 {
761 unsigned int idx
762 = ((*buf & 0xc0) >> 2)
763 | ((*buf & 0x18) >> 1)
764 | (*buf & 0x03);
765
766 ++tmphist[idx];
767 ++buf;
768 }
769
770 for (j = 0; j < HISTSIZE; ++j)
771 hist[j] = (float)tmphist[j] / (len + 1e-30);
772
773 av_push (result, histsv);
774 }
775
776 RETVAL = newRV_noinc ((SV *)result);
777}
778 OUTPUT:
779 RETVAL
780
781

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines