2022-06-26 20:06:35 +11:00
|
|
|
/*
|
|
|
|
television.c
|
|
|
|
------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2022-06-27 09:48:18 +11:00
|
|
|
#include "../tthimage.h"
|
2022-06-26 20:06:35 +11:00
|
|
|
|
|
|
|
/*::------------------------------------------------------------------::*/
|
2022-09-21 09:06:11 +11:00
|
|
|
int Image_TV_grink(Image_Desc *src, Image_Desc *dst, int yo)
|
2022-06-26 20:06:35 +11:00
|
|
|
{
|
|
|
|
int foo;
|
|
|
|
int x, y, r, g, b;
|
|
|
|
int resteY;
|
|
|
|
|
|
|
|
if ( (foo=Image_compare_desc(src, dst)) )
|
|
|
|
{
|
|
|
|
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
resteY = src->height % 3;
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, "Image TV grink: height %d reste Y %d\n", src->height, resteY);
|
|
|
|
#endif
|
|
|
|
resteY /= 2; /* half for the top, half for the bottom */
|
|
|
|
|
2022-09-21 09:06:11 +11:00
|
|
|
for (y=resteY; y<src->height-resteY-1; y+=3) {
|
|
|
|
for (x=0; x<src->width; x++) {
|
2022-06-26 20:06:35 +11:00
|
|
|
r = ( Image_R_pixel(src, x, y) +
|
|
|
|
Image_R_pixel(src, x, y+1) +
|
|
|
|
Image_R_pixel(src, x, y+2) ) / 3;
|
|
|
|
g = ( Image_G_pixel(src, x, y) +
|
|
|
|
Image_G_pixel(src, x, y+1) +
|
|
|
|
Image_G_pixel(src, x, y+2) ) / 3;
|
|
|
|
b = ( Image_B_pixel(src, x, y) +
|
|
|
|
Image_B_pixel(src, x, y+1) +
|
|
|
|
Image_B_pixel(src, x, y+2) ) / 3;
|
|
|
|
Image_plotRGB(dst, x, y, r, g, b);
|
2022-09-21 09:06:11 +11:00
|
|
|
if (yo) {
|
2022-06-26 20:06:35 +11:00
|
|
|
Image_plotRGB(dst, x, y+1, r, b, g);
|
|
|
|
Image_plotRGB(dst, x, y+2, r, g, b);
|
|
|
|
}
|
2022-09-21 09:06:11 +11:00
|
|
|
else {
|
2022-06-26 20:06:35 +11:00
|
|
|
Image_plotRGB(dst, x, y+2, r, b, g);
|
|
|
|
Image_plotRGB(dst, x, y+1, r, g, b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return OLL_KORRECT;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
2022-09-21 09:06:11 +11:00
|
|
|
int Image_TV_grok(Image_Desc *src, Image_Desc *dst, int yo)
|
2022-06-26 20:06:35 +11:00
|
|
|
{
|
|
|
|
int foo, x, y;
|
|
|
|
int r, g, b;
|
|
|
|
|
2022-09-21 09:06:11 +11:00
|
|
|
if ( (foo=Image_compare_desc(src, dst)) ) {
|
2022-06-26 20:06:35 +11:00
|
|
|
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
2022-09-21 09:06:11 +11:00
|
|
|
for (y=0; y<src->height; y++) {
|
|
|
|
for (x=0; x<src->width; x++) {
|
2022-06-26 20:06:35 +11:00
|
|
|
Image_getRGB(src, x, y, &r, &g, &b);
|
|
|
|
if (yo)
|
|
|
|
Image_plotRGB(dst, x, y, r&0xa0, g&0xa0, b&0xa0);
|
|
|
|
else
|
|
|
|
Image_plotRGB(dst, x, y, r&0xf0, g&0xf0, b&0xf0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FUNC_IS_BETA;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
/* new 8 jan 2002
|
2022-10-28 14:07:32 +11:00
|
|
|
* le parametre 'yo' ne sert a rien et doit etre mis a 0
|
2022-06-26 20:06:35 +11:00
|
|
|
*/
|
2022-09-21 09:06:11 +11:00
|
|
|
int Image_TV_gruud(Image_Desc *src, Image_Desc *dst, int yo)
|
2022-06-26 20:06:35 +11:00
|
|
|
{
|
|
|
|
int x, y, i, j;
|
|
|
|
int r, g, b, rc, gc, bc;
|
|
|
|
int foo;
|
|
|
|
|
|
|
|
if (yo != 0) {
|
|
|
|
fprintf(stderr, "%s: yo (%d) _must_ be 0\n", __func__, yo);
|
|
|
|
return INVALID_PARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (foo=Image_compare_desc(src, dst)) ) {
|
|
|
|
fprintf(stderr, "%s: images are differents %d\n",__func__, foo);
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
2022-09-21 09:06:11 +11:00
|
|
|
for (y=0; y<src->height-2; y+=3) {
|
|
|
|
for (x=0; x<src->width-2; x+=3) {
|
2022-06-26 20:06:35 +11:00
|
|
|
rc = gc = bc = 0;
|
2022-09-21 09:06:11 +11:00
|
|
|
for (i=0; i<3; i++) {
|
|
|
|
for (j=0; j<3; j++) {
|
2022-06-26 20:06:35 +11:00
|
|
|
Image_getRGB(src, x+i, y+j, &r, &g, &b);
|
|
|
|
rc += r;
|
|
|
|
gc += g;
|
|
|
|
bc += b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rc /= 9; gc /= 9; bc /= 9;
|
2022-09-21 09:06:11 +11:00
|
|
|
for (i=0; i<3; i++) {
|
2022-06-26 20:06:35 +11:00
|
|
|
Image_plotRGB(dst, x, y+i, rc, 0, 0);
|
|
|
|
Image_plotRGB(dst, x+1, y+i, 0, gc, 0);
|
|
|
|
Image_plotRGB(dst, x+2, y+i, 0, 0, bc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FUNC_IS_BETA;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
|
|
|
|
#define GRIIIZ_SIZE 20
|
|
|
|
|
|
|
|
/*
|
2022-10-28 14:07:32 +11:00
|
|
|
* le parametre 'yo' ne sert e rien et doit etre mis a 0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 0, 0, 0, 0, 0, 0, 0 },
|
|
|
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0 },
|
|
|
|
{ 0, 0, 0, 0, 0, 0, 0, 2, 4, 5, 7, 4, 2, 2, 0, 0, 0, 0, 0, 0 },
|
|
|
|
{ 0, 0, 0, 0, 0, 0, 2, 4, 7, 9, 9, 4, 4, 2, 2, 0, 0, 0, 0, 0 },
|
|
|
|
{ 0, 0, 0, 0, 0, 2, 4, 0, 9, 9, 9, 9, 4, 4, 2, 2, 0, 0, 0, 0 },
|
|
|
|
{ 0, 0, 0, 0, 2, 5, 7, 8, 9, 9, 9, 9, 9, 7, 5, 2, 1, 0, 0, 0 },
|
|
|
|
{ 0, 0, 0, 2, 4, 6, 6, 6, 7, 7, 7, 7, 7, 6, 5, 4, 2, 1, 0, 0 },
|
|
|
|
{ 0, 0, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 3, 2, 1, 0 },
|
|
|
|
{ 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0 },
|
|
|
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
int kr, kg, kb;
|
|
|
|
|
2022-09-21 09:06:11 +11:00
|
|
|
if (yo != 0) {
|
|
|
|
fprintf(stderr, "%s: yo (%d) _must_ be 0\n", __func__, yo);
|
2022-06-26 20:06:35 +11:00
|
|
|
return INVALID_PARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (foo=Image_compare_desc(src, dst)) )
|
|
|
|
{
|
|
|
|
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
ox = (src->width % GRIIIZ_SIZE) / 2;
|
|
|
|
oy = (src->height % GRIIIZ_SIZE) / 2;
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, "%s : X %d-%d Y %d-%d\n", __func__,
|
|
|
|
src->width, ox, src->height, oy);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
kr = kg = kb = 0;
|
2022-09-21 09:06:11 +11:00
|
|
|
for (i=0; i<GRIIIZ_SIZE; i++) {
|
|
|
|
for (j=0; j<GRIIIZ_SIZE; j++) {
|
2022-06-26 20:06:35 +11:00
|
|
|
kr += mr[i][j];
|
|
|
|
kg += mg[i][j];
|
|
|
|
kb += mb[i][j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if DEBUG_LEVEL
|
2022-09-21 09:06:11 +11:00
|
|
|
fprintf(stderr, "%s: kr %d kg %d kb %d\n", __func__, kr, kg, kb);
|
2022-06-26 20:06:35 +11:00
|
|
|
#endif
|
|
|
|
|
2022-09-21 09:06:11 +11:00
|
|
|
for (x=ox; x<src->width-(ox+1); x+=GRIIIZ_SIZE) {
|
|
|
|
for (y=oy; y<src->height-(oy+1); y+=GRIIIZ_SIZE) {
|
2022-06-26 20:06:35 +11:00
|
|
|
cr = cb = cg = 0;
|
2022-09-21 09:06:11 +11:00
|
|
|
for (i=0; i<GRIIIZ_SIZE; i++) {
|
|
|
|
for (j=0; j<GRIIIZ_SIZE; j++) {
|
2022-06-26 20:06:35 +11:00
|
|
|
Image_getRGB(src, x+i, y+j, &r, &g, &b);
|
|
|
|
cr += r;
|
|
|
|
cg += g;
|
|
|
|
cb += b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-21 09:06:11 +11:00
|
|
|
for (i=0; i<GRIIIZ_SIZE; i++) {
|
|
|
|
for (j=0; j<GRIIIZ_SIZE; j++) {
|
2022-06-26 20:06:35 +11:00
|
|
|
r = (cr*mr[j][i] / kr) ;
|
|
|
|
g = (cg*mg[j][i] / kg) ;
|
|
|
|
b = (cb*mb[j][i] / kb) ; /* XXX / (GRIIIZ_SIZE*GRIIIZ_SIZE); */
|
|
|
|
Image_plotRGB(dst, x+i, y+j, r, g, b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FUNC_IS_BETA;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
/*::------------------------------------------------------------------::*/
|