~ubuntu-branches/ubuntu/maverick/digikam/maverick

« back to all changes in this revision

Viewing changes to libs/dimg/filters/dimgimagefilters.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Luka Renko
  • Date: 2009-03-17 23:07:56 UTC
  • mfrom: (1.2.20 upstream) (3.1.4 experimental)
  • Revision ID: james.westby@ubuntu.com-20090317230756-db5b8rqjwb2j35e5
Tags: 2:0.10.0-1ubuntu1
* Remaining changes to Debian (committed to Debian SVN):
  - Depends: kde-icons-oxygen dropped (included through kdelibs)
  - Recommends: kipi-plugins added (provides major functionality)
  - debian/digikamthemedesigner.manpage: add missing manpage
* Remaning change to Debian:
  - Section: devel for -dbg package (no debug in Jaunty)

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
    histogram->calculate();
80
80
 
81
81
    // Memory allocation.
82
 
    map          = new double_packet[histogram->getHistogramSegment()];
83
 
    equalize_map = new int_packet[histogram->getHistogramSegment()];
 
82
    map          = new double_packet[histogram->getHistogramSegments()];
 
83
    equalize_map = new int_packet[histogram->getHistogramSegments()];
84
84
 
85
85
    if( !histogram || !map || !equalize_map )
86
86
    {
103
103
    memset(&high,      0, sizeof(struct double_packet));
104
104
    memset(&low,       0, sizeof(struct double_packet));
105
105
 
106
 
    for(i = 0 ; i < histogram->getHistogramSegment() ; i++)
 
106
    for(i = 0 ; i < histogram->getHistogramSegments() ; i++)
107
107
    {
108
108
       intensity.red   += histogram->getValue(ImageHistogram::RedChannel, i);
109
109
       intensity.green += histogram->getValue(ImageHistogram::GreenChannel, i);
115
115
    // Stretch the histogram.
116
116
 
117
117
    low  = map[0];
118
 
    high = map[histogram->getHistogramSegment()-1];
119
 
    memset(equalize_map, 0, histogram->getHistogramSegment()*sizeof(int_packet));
 
118
    high = map[histogram->getHistogramSegments()-1];
 
119
    memset(equalize_map, 0, histogram->getHistogramSegments()*sizeof(int_packet));
120
120
 
121
 
    for(i = 0 ; i < histogram->getHistogramSegment() ; i++)
 
121
    for(i = 0 ; i < histogram->getHistogramSegments() ; i++)
122
122
    {
123
123
       if(high.red != low.red)
124
 
          equalize_map[i].red = (uint)(((256*histogram->getHistogramSegment() -1) *
 
124
          equalize_map[i].red = (uint)(((256*histogram->getHistogramSegments() -1) *
125
125
                                (map[i].red-low.red))/(high.red-low.red));
126
126
 
127
127
       if(high.green != low.green)
128
 
          equalize_map[i].green = (uint)(((256*histogram->getHistogramSegment() -1) *
 
128
          equalize_map[i].green = (uint)(((256*histogram->getHistogramSegments() -1) *
129
129
                                  (map[i].green-low.green))/(high.green-low.green));
130
130
 
131
131
       if(high.blue != low.blue)
132
 
          equalize_map[i].blue = (uint)(((256*histogram->getHistogramSegment() -1) *
 
132
          equalize_map[i].blue = (uint)(((256*histogram->getHistogramSegments() -1) *
133
133
                                 (map[i].blue-low.blue))/(high.blue-low.blue));
134
134
 
135
135
       if(high.alpha != low.alpha)
136
 
          equalize_map[i].alpha = (uint)(((256*histogram->getHistogramSegment() -1) *
 
136
          equalize_map[i].alpha = (uint)(((256*histogram->getHistogramSegments() -1) *
137
137
                                  (map[i].alpha-low.alpha))/(high.alpha-low.alpha));
138
138
    }
139
139
 
230
230
    histogram->calculate();
231
231
 
232
232
    // Memory allocation.
233
 
    normalize_map = new int_packet[histogram->getHistogramSegment()];
 
233
    normalize_map = new int_packet[histogram->getHistogramSegments()];
234
234
 
235
235
    if( !histogram || !normalize_map )
236
236
    {
256
256
 
257
257
    memset(&intensity, 0, sizeof(struct double_packet));
258
258
 
259
 
    for(high.red = histogram->getHistogramSegment()-1 ; high.red != 0 ; high.red--)
 
259
    for(high.red = histogram->getHistogramSegments()-1 ; high.red != 0 ; high.red--)
260
260
    {
261
261
       intensity.red += histogram->getValue(ImageHistogram::RedChannel, (int)high.red);
262
262
 
269
269
       threshold_intensity = 0;
270
270
       memset(&intensity, 0, sizeof(struct double_packet));
271
271
 
272
 
       for(low.red = 0 ; low.red < histogram->getHistogramSegment()-1 ; low.red++)
 
272
       for(low.red = 0 ; low.red < histogram->getHistogramSegments()-1 ; low.red++)
273
273
       {
274
274
          intensity.red += histogram->getValue(ImageHistogram::RedChannel, (int)low.red);
275
275
 
279
279
 
280
280
       memset(&intensity, 0, sizeof(struct double_packet));
281
281
 
282
 
       for(high.red = histogram->getHistogramSegment()-1 ; high.red != 0 ; high.red--)
 
282
       for(high.red = histogram->getHistogramSegments()-1 ; high.red != 0 ; high.red--)
283
283
       {
284
284
          intensity.red += histogram->getValue(ImageHistogram::RedChannel, (int)high.red);
285
285
 
292
292
 
293
293
    memset(&intensity, 0, sizeof(struct double_packet));
294
294
 
295
 
    for(high.green = histogram->getHistogramSegment()-1 ; high.green != 0 ; high.green--)
 
295
    for(high.green = histogram->getHistogramSegments()-1 ; high.green != 0 ; high.green--)
296
296
    {
297
297
       intensity.green += histogram->getValue(ImageHistogram::GreenChannel, (int)high.green);
298
298
 
305
305
       threshold_intensity = 0;
306
306
       memset(&intensity, 0, sizeof(struct double_packet));
307
307
 
308
 
       for(low.green = 0 ; low.green < histogram->getHistogramSegment()-1 ; low.green++)
 
308
       for(low.green = 0 ; low.green < histogram->getHistogramSegments()-1 ; low.green++)
309
309
       {
310
310
          intensity.green += histogram->getValue(ImageHistogram::GreenChannel, (int)low.green);
311
311
 
315
315
 
316
316
       memset(&intensity, 0, sizeof(struct double_packet));
317
317
 
318
 
       for(high.green = histogram->getHistogramSegment()-1 ; high.green != 0 ; high.green--)
 
318
       for(high.green = histogram->getHistogramSegments()-1 ; high.green != 0 ; high.green--)
319
319
       {
320
320
          intensity.green += histogram->getValue(ImageHistogram::GreenChannel, (int)high.green);
321
321
 
328
328
 
329
329
    memset(&intensity, 0, sizeof(struct double_packet));
330
330
 
331
 
    for(high.blue = histogram->getHistogramSegment()-1 ; high.blue != 0 ; high.blue--)
 
331
    for(high.blue = histogram->getHistogramSegments()-1 ; high.blue != 0 ; high.blue--)
332
332
    {
333
333
       intensity.blue += histogram->getValue(ImageHistogram::BlueChannel, (int)high.blue);
334
334
 
341
341
       threshold_intensity = 0;
342
342
       memset(&intensity, 0, sizeof(struct double_packet));
343
343
 
344
 
       for(low.blue = 0 ; low.blue < histogram->getHistogramSegment()-1 ; low.blue++)
 
344
       for(low.blue = 0 ; low.blue < histogram->getHistogramSegments()-1 ; low.blue++)
345
345
       {
346
346
          intensity.blue += histogram->getValue(ImageHistogram::BlueChannel, (int)low.blue);
347
347
 
351
351
 
352
352
       memset(&intensity, 0, sizeof(struct double_packet));
353
353
 
354
 
       for(high.blue = histogram->getHistogramSegment()-1 ; high.blue != 0 ; high.blue--)
 
354
       for(high.blue = histogram->getHistogramSegments()-1 ; high.blue != 0 ; high.blue--)
355
355
       {
356
356
          intensity.blue += histogram->getValue(ImageHistogram::BlueChannel, (int)high.blue);
357
357
 
364
364
 
365
365
    memset(&intensity, 0, sizeof(struct double_packet));
366
366
 
367
 
    for(high.alpha = histogram->getHistogramSegment()-1 ; high.alpha != 0 ; high.alpha--)
 
367
    for(high.alpha = histogram->getHistogramSegments()-1 ; high.alpha != 0 ; high.alpha--)
368
368
    {
369
369
       intensity.alpha += histogram->getValue(ImageHistogram::AlphaChannel, (int)high.alpha);
370
370
 
377
377
       threshold_intensity = 0;
378
378
       memset(&intensity, 0, sizeof(struct double_packet));
379
379
 
380
 
       for(low.alpha = 0 ; low.alpha < histogram->getHistogramSegment()-1 ; low.alpha++)
 
380
       for(low.alpha = 0 ; low.alpha < histogram->getHistogramSegments()-1 ; low.alpha++)
381
381
       {
382
382
          intensity.alpha += histogram->getValue(ImageHistogram::AlphaChannel, (int)low.alpha);
383
383
 
387
387
 
388
388
       memset(&intensity, 0, sizeof(struct double_packet));
389
389
 
390
 
       for(high.alpha = histogram->getHistogramSegment()-1 ; high.alpha != 0 ; high.alpha--)
 
390
       for(high.alpha = histogram->getHistogramSegments()-1 ; high.alpha != 0 ; high.alpha--)
391
391
       {
392
392
          intensity.alpha += histogram->getValue(ImageHistogram::AlphaChannel, (int)high.alpha);
393
393
 
400
400
 
401
401
    // Stretch the histogram to create the normalized image mapping.
402
402
 
403
 
    memset(normalize_map, 0, histogram->getHistogramSegment()*sizeof(struct int_packet));
 
403
    memset(normalize_map, 0, histogram->getHistogramSegments()*sizeof(struct int_packet));
404
404
 
405
 
    for(i = 0 ; i <= (long)histogram->getHistogramSegment()-1 ; i++)
 
405
    for(i = 0 ; i <= (long)histogram->getHistogramSegments()-1 ; i++)
406
406
    {
407
407
       if(i < (long) low.red)
408
408
          normalize_map[i].red = 0;
409
409
       else if (i > (long) high.red)
410
 
          normalize_map[i].red = (256*histogram->getHistogramSegment() -1);
 
410
          normalize_map[i].red = (256*histogram->getHistogramSegments() -1);
411
411
       else if (low.red != high.red)
412
 
          normalize_map[i].red = (int)(((256*histogram->getHistogramSegment() -1)*(i-low.red))/(high.red-low.red));
 
412
          normalize_map[i].red = (int)(((256*histogram->getHistogramSegments() -1)*(i-low.red))/(high.red-low.red));
413
413
 
414
414
       if(i < (long) low.green)
415
415
          normalize_map[i].green = 0;
416
416
       else if (i > (long) high.green)
417
 
          normalize_map[i].green = (256*histogram->getHistogramSegment() -1);
 
417
          normalize_map[i].green = (256*histogram->getHistogramSegments() -1);
418
418
       else if (low.green != high.green)
419
 
          normalize_map[i].green = (int)(((256*histogram->getHistogramSegment() -1)*(i-low.green))/(high.green-low.green));
 
419
          normalize_map[i].green = (int)(((256*histogram->getHistogramSegments() -1)*(i-low.green))/(high.green-low.green));
420
420
 
421
421
       if(i < (long) low.blue)
422
422
          normalize_map[i].blue = 0;
423
423
       else if (i > (long) high.blue)
424
 
          normalize_map[i].blue = (256*histogram->getHistogramSegment() -1);
 
424
          normalize_map[i].blue = (256*histogram->getHistogramSegments() -1);
425
425
       else if (low.blue != high.blue)
426
 
          normalize_map[i].blue = (int)(((256*histogram->getHistogramSegment() -1)*(i-low.blue))/(high.blue-low.blue));
 
426
          normalize_map[i].blue = (int)(((256*histogram->getHistogramSegments() -1)*(i-low.blue))/(high.blue-low.blue));
427
427
 
428
428
       if(i < (long) low.alpha)
429
429
          normalize_map[i].alpha = 0;
430
430
       else if (i > (long) high.alpha)
431
 
          normalize_map[i].alpha = (256*histogram->getHistogramSegment() -1);
 
431
          normalize_map[i].alpha = (256*histogram->getHistogramSegments() -1);
432
432
       else if (low.alpha != high.alpha)
433
 
          normalize_map[i].alpha = (int)(((256*histogram->getHistogramSegment() -1)*(i-low.alpha))/(high.alpha-low.alpha));
 
433
          normalize_map[i].alpha = (int)(((256*histogram->getHistogramSegments() -1)*(i-low.alpha))/(high.alpha-low.alpha));
434
434
    }
435
435
 
436
436
    // Apply result to image.