Compare commits

..

No commits in common. "3849485c02751647faeff5695b8c4df6055c2388" and "7eee0bd4d9290583ed71773c320907d139d85680" have entirely different histories.

8 changed files with 17 additions and 119 deletions

1
.gitignore vendored
View File

@ -28,7 +28,6 @@ funcs/t
funcs/*.o
funcs/*.png
funcs/*.gif
funcs/*.fits
scripts/*.fimg
scripts/*.pnm

View File

@ -3,7 +3,7 @@
* ugly code from tTh
*/
#define FIMG_VERSION 103
#define FIMG_VERSION 102
/*
* in memory descriptor
@ -39,7 +39,6 @@ typedef struct {
#define FILE_TYPE_PNG 3
#define FILE_TYPE_TGA 4
#define FILE_TYPE_TIFF 5
#define FILE_TYPE_FITS 6
/* lib/contrast.c */
#define CONTRAST_NONE 0
@ -122,6 +121,7 @@ int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval);
/* module funcs/geometry.c */
int fimg_equalize_compute(FloatImg *src, void *vptr);
int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k);
int fimg_desaturate(FloatImg *src, FloatImg *dst, int k);
@ -138,9 +138,6 @@ int fimg_dump_to_file(FloatImg *head, char *fname, int notused);
int fimg_load_from_dump(char *fname, FloatImg *where);
int fimg_create_from_dump(char *fname, FloatImg *head);
int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags);
/* mathematics operations */
float fimg_get_maxvalue(FloatImg *head);
int fimg_get_minmax_rgb(FloatImg *head, float mmvals[6]);

View File

@ -4,13 +4,12 @@ COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0
DEPS = ../floatimg.h Makefile
OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
fimg-libpnm.o rampes.o sfx0.o geometry.o rotate.o \
equalize.o fimg-fits.o
equalize.o
#---------------------------------------------------------------
t: t.c $(DEPS) ../libfloatimg.a
gcc $(COPT) $< ../libfloatimg.a -lnetpbm -lpnglite -lcfitsio \
-lz -lm -o $@
gcc $(COPT) $< ../libfloatimg.a -lnetpbm -lpnglite -lz -lm -o $@
#---------------------------------------------------------------
@ -23,9 +22,6 @@ fimg-png.o: fimg-png.c $(DEPS)
fimg-tiff.o: fimg-tiff.c $(DEPS)
gcc $(COPT) -c $<
fimg-fits.o: fimg-fits.c $(DEPS)
gcc $(COPT) -c $<
fimg-libpnm.o: fimg-libpnm.c $(DEPS)
gcc $(COPT) -c $<

View File

@ -17,7 +17,7 @@ float *M; /* alias of filter matrix */
double dval;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %p)\n", __func__, src, dst, filtr);
fprintf(stderr, ">>> %s ( %p %p %p)\n", __func__, s, d, filtr);
#endif
/* aliasing some vars for cleaner code */

View File

@ -1,69 +0,0 @@
/*
* FLOATIMG
* import/export to/from FITS files
*/
#include <stdio.h>
#include <stdlib.h>
#include <fitsio.h>
#include "../floatimg.h"
extern int verbosity;
/* --------------------------------------------------------------------- */
int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags)
{
fitsfile *fptr; /* pointer to the FITS file */
int status, idx, sz;
int bitpix = FLOAT_IMG;
long naxis = 2;
long naxes[2];
float **array;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p '%s' %d )\n", __func__, src, outname, flags);
#endif
status = 0;
remove(outname); /* Delete old file if it already exists */
if (fits_create_file(&fptr, outname, &status)) {
fits_report_error(stderr, status);
return -9;
}
naxes[0] = src->width; naxes[1] = src->height;
array = calloc(src->height, sizeof(float *));
if (verbosity) fimg_describe(src, "to be saved as fits");
/* initialize pointers to the start of each row of the image */
for( idx=0; idx<naxes[1]; idx++ ) {
/**** MAGIC CODE MUST COME HERE ****/
array[idx] = src->R + (idx*naxes[0]);
// fprintf(stderr, " %6d %p\n", idx, array[idx]);
}
if ( fits_create_img(fptr, bitpix, naxis, naxes, &status) ) {
fits_report_error(stderr, status);
return -10;
}
sz = naxes[0]*naxes[1];
if ( fits_write_img(fptr, TFLOAT, 1, sz, array[0], &status) ) {
fits_report_error(stderr, status);
return -10;
}
if ( fits_close_file(fptr, &status) ) {
fits_report_error(stderr, status);
return -9;
}
return 0;
}
/* --------------------------------------------------------------------- */

View File

@ -46,7 +46,7 @@ for (x=0; x<fimg->width; x++) {
fimg_plot_rgb(fimg, x, y, fr, fg, fb);
}
k = fimg->height / 4;
k = fimg->height/4;
for (x=0; x<fimg->width; x++) {
val = ((double)x / (double)fimg->width) * dval;
for (y=0; y<20; y++) {

View File

@ -6,32 +6,12 @@
#include <string.h>
#include <pam.h>
#include "../floatimg.h"
int verbosity;
float global_fvalue;
/* --------------------------------------------------------------------- */
/* essai de fichiers FITS (astronomie) */
int essai_ecriture_fits(char *outname)
{
FloatImg src;
int foo;
fprintf(stderr, "%s is creating the picz\n", __func__);
fimg_create(&src, 512, 512, FIMG_TYPE_RGB);
fimg_test_pattern(&src, 0, 255.0);
foo = fimg_save_as_pnm(&src, "foo.pnm", 0);
foo = fimg_save_R_as_fits(&src, outname, 0);
fprintf(stderr, "saving '%s' to fits --> %d\n", outname, foo);
return -1;
}
/* --------------------------------------------------------------------- */
/*
* egalisation dynamique approximative
@ -58,6 +38,7 @@ else {
foo = fimg_equalize_compute(&src, NULL);
fprintf(stderr, "equalize compute --> %d\n", foo);
fimg_destroy(&src);
return -1;
@ -334,9 +315,7 @@ int re;
fimg_create(&fimg, 1280, 960, FIMG_TYPE_RGB);
re = fimg_test_pattern(&fimg, 9, 1.0);
if (re) {
fprintf(stderr, "fimg_test_pattern -> %d\n", re);
}
fimg_save_as_pnm(&fimg, "mire.pnm", 0);
return -1;
@ -367,10 +346,15 @@ int essai_ecrire_png(char *fname)
FloatImg fimg;
int foo;
fimg_create(&fimg, 800, 600, FIMG_TYPE_RGB);
fimg_create(&fimg, 512, 512, FIMG_TYPE_RGB);
fimg_draw_something(&fimg);
/* XXX
for (foo=0; foo<512; foo++) {
fimg_plot_rgb(&fimg, foo, foo, 17000.0, 8000.0, 11111.1);
}
*/
foo = fimg_save_as_pnm(&fimg, "quux.pnm", 0);
fprintf(stderr, "save as pnm -> %d\n", foo);
@ -381,7 +365,7 @@ fprintf(stderr, "save as png -> %d\n", foo);
return 0;
}
/* --------------------------------------------------------------------- */
enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng };
enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE };
typedef struct {
char *name;
int Cmd;
@ -393,8 +377,6 @@ Command commands[] = {
{ "sfx0", Sfx0 },
{ "f3x3", F3x3 },
{ "mire", MIRE },
{ "wfits", Wfits },
{ "wpng", Wpng },
{ NULL, 0 }
} ;
@ -462,7 +444,7 @@ if (verbosity) {
}
opt = lookup_cmd(command);
// fprintf(stderr, "lookup '%s' --> %d\n", command, opt);
fprintf(stderr, "lookup '%s' --> %d\n", command, opt);
switch(opt) {
case Equalize:
@ -476,12 +458,7 @@ switch(opt) {
case MIRE:
foo = essai_mire(filename, 0);
break;
case Wfits:
foo = essai_ecriture_fits(filename);
break;
case Wpng:
foo = essai_ecrire_png(filename);
break;
default:
fprintf(stderr, "%s : bad command\n", command);
exit(1);

View File

@ -58,10 +58,8 @@ fprintf(stderr, "[%s] --> [%s]\n", fname, cptr);
if (!strcasecmp(cptr, ".pnm")) return FILE_TYPE_PNM;
if (!strcasecmp(cptr, ".fimg")) return FILE_TYPE_FIMG;
if (!strcasecmp(cptr, ".tga")) return FILE_TYPE_TGA;
if (!strcasecmp(cptr, ".png")) return FILE_TYPE_PNG;
if (!strcasecmp(cptr, ".tiff")) return FILE_TYPE_TIFF;
if (!strcasecmp(cptr, ".fits")) return FILE_TYPE_FITS;
return -1;
}