|
Revision 449, 1.5 kB
(checked in by goodea, 2 years ago)
|
exec
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 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; |
|---|
| 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 |
|
|---|
| 69 |
return 1; |
|---|
| 70 |
} |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|