dicom boilerplate: [done]

This commit is contained in:
tth 2021-11-27 00:01:37 +01:00
parent 99187104ce
commit 6e896ee463
7 changed files with 100 additions and 10 deletions

View File

@ -4,7 +4,7 @@
* http://la.buvette.org/photos/cumul
*/
#define FIMG_VERSION 161
#define FIMG_VERSION 163
/*
* in memory descriptor
@ -53,6 +53,7 @@ typedef struct {
#define FILE_TYPE_FITS 6
#define FILE_TYPE_BMP 7
#define FILE_TYPE_EXR 8
#define FILE_TYPE_DICOM 9
/* lib/contrast.c */
#define CONTRAST_NONE 0
@ -142,6 +143,9 @@ int fimg_killrgb_v(FloatImg *src, FloatImg *dst, int k);
int fimg_decomp_rgbz_color(FloatImg *psrc, FloatImg *pdst, int k);
int fimg_decomp_rgbz_gray(FloatImg *psrc, FloatImg *pdst, int k);
int fimg_save_plane_as_dicom(FloatImg *src, char *outname,
char plane, int flags);
/* universal exporter XXX */
int fimg_export_picture(FloatImg *pic, char *fname, int flags);
@ -242,6 +246,8 @@ int fimg_multirandom(FloatImg *fimg, long nbpass);
/* file is 'funcs/utils.c' */
void fimg_print_minmax(float minmax[6], char *titre);
float *charplane2int(char plane, FloatImg *img);
int parse_WxH(char *str, int *pw, int *ph);
int parse_double(char *str, double *dptr);
int irand2(int offset, int modulo);

View File

@ -11,6 +11,7 @@ OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
sfx0.o sfx1.o sfx2.o sfx3.o sfx4.o \
geometry.o rotate.o fimg-openexr.o \
equalize.o fimg-fits.o saturation.o histogram.o \
fimg-dicom.o \
hsv.o classif.o contour2x2.o qsortrgb.o exporter.o \
displacement.o dithering.o plasmas.o incrustator.o \
killrgb.o recurse.o pixelize.o decomprgb.o
@ -70,6 +71,9 @@ fimg-tiff.o: fimg-tiff.c $(DEPS)
fimg-openexr.o: fimg-openexr.c $(DEPS)
gcc $(COPT) -c $<
fimg-dicom.o: fimg-dicom.c $(DEPS)
gcc $(COPT) -c $<
fimg-fits.o: fimg-fits.c $(DEPS)
gcc $(COPT) -I/usr/include/cfitsio/ -c $<

View File

@ -0,0 +1,32 @@
/*
Digital Imaging and Communications in Medicine
nouveau Fri 26 Nov 2021 11:12:44 PM CET - allée de Dinan
*/
#include <stdio.h>
#include <stdint.h>
#include "../floatimg.h"
extern int verbosity; /* must be declared around main() */
/* --------------------------------------------------------------------- */
int fimg_save_plane_as_dicom(FloatImg *src, char *outname,
char plane, int flags)
{
int foo;
float *planeptr;
fprintf(stderr, ">>> %s ( %p %s %c %d )\n", __func__, src, outname, plane, flags);
planeptr = charplane2int(plane, src);
if (verbosity) {
fimg_describe(src, outname);
}
return -1;
}
/* --------------------------------------------------------------------- */

View File

@ -25,7 +25,7 @@ enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff,
Displace, ReadPNG, Plasmas, Hilight, OpenEXR,
Geometrie, FileType, Mirror, KillRGB,
Pixelize,SplitLevel, DecompRgbz, DecompRgbg,
Rectangle };
Rectangle, Dicom };
typedef struct {
char *name;
int Cmd;
@ -59,6 +59,7 @@ Command commands[] = {
{ "decomprgbz", DecompRgbz },
{ "decomprgbg", DecompRgbg },
{ "rectangle", Rectangle },
{ "dicom", Dicom },
{ NULL, 0 }
} ;
@ -242,6 +243,9 @@ switch(opt) {
case Rectangle:
essai_rectangle(outfile, 0);
break;
case Dicom:
foo = essai_dicom(filename, outfile, 0);
break;
default:
fprintf(stderr, "'%s' is a bad command\n", command);

View File

@ -17,6 +17,23 @@
extern int verbosity;
/* --------------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
int essai_dicom(char *inf, char *outf, int k)
{
int foo;
FloatImg img;
fprintf(stderr, ">>> %s ( %s %s %d )\n", __func__, inf, outf, k);
foo = fimg_create(&img, 320, 240, FIMG_TYPE_RGB);
fimg_drand48(&img, 1.0);
foo = fimg_save_plane_as_dicom(&img, outf, 'R', 0);
fprintf(stderr, "dicom: save a plane --> %d\n", foo);
return -1;
}
/* --------------------------------------------------------------------- */
int essai_rectangle(char *outf, int k)
{

View File

@ -37,3 +37,5 @@ int essai_openexr(char *inf, char *outf, int flags);
int essai_pixelize(char *infile, char *outfile);
int essai_rectangle(char *outf, int k);
int essai_dicom(char *inf, char *outf, int k);

View File

@ -21,6 +21,30 @@ fprintf(stderr, "green\t\t%10f %10f\n", minmax[2], minmax[3]);
fprintf(stderr, "blue\t\t%10f %10f\n", minmax[4], minmax[5]);
}
/* --------------------------------------------------------------------- */
/* used in fimg-fits & fimg-dicom */
float *charplane2int(char plane, FloatImg *img)
{
float *pplane = NULL;
fprintf(stderr, "get plane for '%c' in %p ", plane, img);
switch (plane) {
case 'r': case 'R':
pplane = img->R; break;
case 'g': case 'G':
pplane = img->G; break;
case 'b': case 'B':
pplane = img->B; break;
default:
pplane = NULL;
}
fprintf(stderr, "give me %p\n", pplane);
return pplane;
}
/* --------------------------------------------------------------------- */
int parse_WxH(char *str, int *pw, int *ph)
{
// char *ptr;
@ -67,14 +91,15 @@ int file_type_from_name(char *name)
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, name);
#endif
if (!strcasecmp(name, "pnm" )) return FILE_TYPE_PNM;
if (!strcasecmp(name, "fimg")) return FILE_TYPE_FIMG;
if (!strcasecmp(name, "tga" )) return FILE_TYPE_TGA;
if (!strcasecmp(name, "png" )) return FILE_TYPE_PNG;
if (!strcasecmp(name, "tiff")) return FILE_TYPE_TIFF;
if (!strcasecmp(name, "tif" )) return FILE_TYPE_TIFF;
if (!strcasecmp(name, "fits")) return FILE_TYPE_FITS;
if (!strcasecmp(name, "exr")) return FILE_TYPE_EXR;
if (!strcasecmp(name, "pnm" )) return FILE_TYPE_PNM;
if (!strcasecmp(name, "fimg")) return FILE_TYPE_FIMG;
if (!strcasecmp(name, "tga" )) return FILE_TYPE_TGA;
if (!strcasecmp(name, "png" )) return FILE_TYPE_PNG;
if (!strcasecmp(name, "tiff")) return FILE_TYPE_TIFF;
if (!strcasecmp(name, "tif" )) return FILE_TYPE_TIFF;
if (!strcasecmp(name, "fits")) return FILE_TYPE_FITS;
if (!strcasecmp(name, "exr")) return FILE_TYPE_EXR;
if (!strcasecmp(name, "dicom")) return FILE_TYPE_EXR;
return -1;
}