root/trunk/lib/cc3-ilp/cc3_histogram.c

Revision 449, 1.5 kB (checked in by goodea, 2 years ago)

exec

Line 
1 /*
2  * Copyright 2006  Anthony Rowe and Adam Goode
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18
19 #include "cc3.h"
20 #include "cc3_ilp.h"
21 #include "cc3_histogram.h"
22 #include <stdbool.h>
23 #include <stdio.h>
24
25
26
27 uint8_t cc3_histogram_scanline_start(cc3_histogram_pkt_t *pkt)
28 {
29 uint8_t i;
30
31 if(pkt->hist==NULL ) return 0;
32 if(cc3_g_pixbuf_frame.coi!=CC3_CHANNEL_ALL)
33         pkt->channel=0; //cc3_g_pixbuf_frame.coi;
34 for(i=0; i<pkt->bins; i++ )
35 {
36  pkt->hist[i]=0;
37 }
38 pkt->scratch_y=0;
39 pkt->bin_div=(MAX_PIXEL_VALUE/pkt->bins);
40 return 1;
41 }
42
43 uint8_t cc3_histogram_scanline(cc3_image_t *img, cc3_histogram_pkt_t *pkt)
44 {
45 uint32_t x,y;
46 cc3_pixel_t cp;
47
48
49 for(y=pkt->scratch_y; y<(pkt->scratch_y+img->height); y++ )
50 for(x=0; x<img->width; x++ )
51 {
52         uint8_t i;
53         cc3_get_pixel( img, x, y-pkt->scratch_y, &cp );
54         i=cp.channel[pkt->channel]/pkt->bin_div;
55         if(i>0) i--;
56         if(i>=pkt->bins) i=pkt->bins-1;
57         pkt->hist[i]++;
58 }
59 pkt->scratch_y=y;
60
61 return 1;
62 }
63
64
65
66 uint8_t cc3_histogram_scanline_finish(cc3_histogram_pkt_t *pkt)
67 {
68 // We don't need to do anything...
69 return 1;
70 }
71
72
73
Note: See TracBrowser for help on using the browser.