new kluge : extracteur
This commit is contained in:
parent
6dc9aab6ba
commit
2e2448b9c9
1
.gitignore
vendored
1
.gitignore
vendored
@ -79,6 +79,7 @@ Fonderie/crapdef.h
|
||||
Fonderie/crapstr.h
|
||||
|
||||
experiment/assemblage
|
||||
experiment/extracteur
|
||||
experiment/*.fimg
|
||||
experiment/*.pnm
|
||||
experiment/*.o
|
||||
|
@ -6,7 +6,7 @@ COPT = -Wall -fpic -g -DDEBUG_LEVEL=1 -lm
|
||||
DEPS = ../floatimg.h ../libfloatimg.a Makefile
|
||||
LIBS = -ltiff -lpnglite -lcfitsio
|
||||
|
||||
all: assemblage
|
||||
all: assemblage extracteur
|
||||
|
||||
incrustator.o: incrustator.c incrustator.h Makefile
|
||||
gcc -c $(COPT) $<
|
||||
@ -14,3 +14,5 @@ incrustator.o: incrustator.c incrustator.h Makefile
|
||||
assemblage: assemblage.c Makefile incrustator.o
|
||||
gcc $(COPT) $< incrustator.o ../libfloatimg.a $(LIBS) -o $@
|
||||
|
||||
extracteur: extracteur.c Makefile
|
||||
gcc $(COPT) $< ../libfloatimg.a $(LIBS) -o $@
|
||||
|
@ -1,3 +1,6 @@
|
||||
# EXPÉRIMENTATION ÀLC
|
||||
|
||||
# ASSEMBLAGE
|
||||
## ASSEMBLAGE
|
||||
|
||||
## EXTRACTEUR
|
||||
|
||||
|
104
experiment/extracteur.c
Normal file
104
experiment/extracteur.c
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* another ugly experiment
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
#include "incrustator.h"
|
||||
|
||||
int verbosity;
|
||||
|
||||
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
||||
typedef struct {
|
||||
int w, h;
|
||||
int x, y;
|
||||
int flags;
|
||||
} Rectangle;
|
||||
|
||||
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
||||
int print_rectangle(Rectangle *rect)
|
||||
{
|
||||
|
||||
printf("rect @ %p : %dx%d at %d,%d\n", rect, rect->w, rect->h,
|
||||
rect->x, rect->y);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
||||
int essai_extraction(FloatImg *in, FloatImg *out, Rectangle *rect)
|
||||
{
|
||||
int foo;
|
||||
int xs, ys, xd, yd;
|
||||
int count;
|
||||
float rgb[3];
|
||||
|
||||
fimg_describe(in, "source");
|
||||
fimg_describe(out, "destination");
|
||||
print_rectangle(rect);
|
||||
|
||||
count = 0;
|
||||
for (yd=0; yd<rect->h; yd++) {
|
||||
ys = yd + rect->y;
|
||||
if ((ys<0) || (ys>=in->height)) continue;
|
||||
for (xd=0; xd<rect->w; xd++) {
|
||||
|
||||
xs = xd + rect->x;
|
||||
fimg_get_rgb(in, xs, ys, rgb);
|
||||
fimg_put_rgb(out, xd, yd, rgb);
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s: %d pix moved\n", __func__, count);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo;
|
||||
FloatImg src, dst;
|
||||
Rectangle zone;
|
||||
char *infile = "foo.fimg";
|
||||
char *outfile = "out.fimg";
|
||||
|
||||
verbosity = 1;
|
||||
|
||||
if (3 != argc) {
|
||||
fprintf(stderr, "usage\n\t %s infile.fimg outfile.???\n",
|
||||
argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fimg_print_version(1);
|
||||
|
||||
infile = argv[1]; outfile = argv[2];
|
||||
|
||||
foo = fimg_create_from_dump(infile, &src);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: err %d loading image '%s'\n", __func__,
|
||||
foo, infile);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
zone.w = src.width / 2; zone.h = src.height / 2;
|
||||
zone.x = src.width / 4 ; zone.y = src.height / 4;
|
||||
|
||||
foo = fimg_create(&dst, zone.w, zone.h, FIMG_TYPE_RGB);
|
||||
|
||||
foo = essai_extraction(&src, &dst, &zone);
|
||||
if (foo) {
|
||||
fprintf(stderr, "EXTRACTOR EPIC FAIL %d\n", foo);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
foo = fimg_export_picture(&dst, outfile, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
@ -3,9 +3,9 @@
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
unsigned long magic;
|
||||
int w, h;
|
||||
int x, y;
|
||||
unsigned long magic;
|
||||
} FimgArea51;
|
||||
|
||||
int incrustator_0(FloatImg *psrc, FloatImg *pdst,
|
||||
|
Loading…
Reference in New Issue
Block a user