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

Comparing CV/CV.xs (file contents):
Revision 1.14 by root, Tue Feb 8 12:51:12 2005 UTC vs.
Revision 1.16 by root, Wed Jul 20 02:26:46 2005 UTC

225 225
226 er += p[0] - (r * 255 + 4) / 7; 226 er += p[0] - (r * 255 + 4) / 7;
227 eg += p[1] - (g * 255 + 4) / 7; 227 eg += p[1] - (g * 255 + 4) / 7;
228 eb += p[2] - (b * 255 + 2) / 3; 228 eb += p[2] - (b * 255 + 2) / 3;
229 229
230 Er[x] = er / 2; er -= er / 2 + RAND % 7 - 3; 230 Er[x] = er / 2; er -= er / 2 + RAND % 5 - 2;
231 Eg[x] = eg / 2; eg -= eg / 2 + RAND % 7 - 3; 231 Eg[x] = eg / 2; eg -= eg / 2 + RAND % 5 - 2;
232 Eb[x] = eb / 2; eb -= eb / 2 + RAND % 7 - 3; 232 Eb[x] = eb / 2; eb -= eb / 2 + RAND % 5 - 2;
233 233
234 *dst++ = r << 5 | g << 2 | b; 234 *dst++ = r << 5 | g << 2 | b;
235 } 235 }
236 } 236 }
237} 237}
251 av = (AV *) SvRV (ar); 251 av = (AV *) SvRV (ar);
252 result = newAV (); 252 result = newAV ();
253 253
254 for (i = 0; i <= av_len (av); ++i) 254 for (i = 0; i <= av_len (av); ++i)
255 { 255 {
256 const int HISTSIZE = 64;
257
256 int bigst, j; 258 int j;
257 SV *sv = *av_fetch (av, i, 1); 259 SV *sv = *av_fetch (av, i, 1);
258 STRLEN len; 260 STRLEN len;
259 char *buf = SvPVbyte (sv, len); 261 char *buf = SvPVbyte (sv, len);
260 262
261 int tmphist[256]; 263 int tmphist[HISTSIZE];
262 char *hist; 264 float *hist;
263 265
264 SV *histsv = newSV (257); 266 SV *histsv = newSV (HISTSIZE * sizeof (float) + 1);
265 SvPOK_on (histsv); 267 SvPOK_on (histsv);
266 SvCUR_set (histsv, 256); 268 SvCUR_set (histsv, HISTSIZE * sizeof (float));
267 hist = SvPVX (histsv); 269 hist = (float *)SvPVX (histsv);
268 270
269 Zero (tmphist, 256, int); 271 Zero (tmphist, sizeof (tmphist), char);
270 272
271 j = len; 273 for (j = len; j--; )
274 {
275 unsigned int idx
276 = ((*buf & 0xc0) >> 2)
277 | ((*buf & 0x18) >> 1)
278 | (*buf & 0x03);
272 279
273 while (len--) 280 ++tmphist[idx];
274 ++tmphist[(unsigned char)*buf++ & 0xda]; 281 ++buf;
282 }
275 283
276 len = j;
277
278 bigst = 1;
279 for (j = 0; j < 256; ++j) 284 for (j = 0; j < HISTSIZE; ++j)
280 if (tmphist[j] > bigst) 285 hist[j] = (float)tmphist[j] / (len + 1e-30);
281 bigst = tmphist[j];
282
283 for (j = 0; j < 256; ++j)
284 hist[j] = tmphist[j] * 255 / (len == 0 ? 1 : len);//bigst;
285 286
286 av_push (result, histsv); 287 av_push (result, histsv);
287 } 288 }
288 289
289 RETVAL = newRV_noinc ((SV *)result); 290 RETVAL = newRV_noinc ((SV *)result);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines