preparing DICOM entry

This commit is contained in:
tth 2021-11-26 23:10:29 +01:00
parent be4e6b0dc9
commit 99187104ce
12 changed files with 127 additions and 12 deletions

View File

@ -356,7 +356,7 @@ switch (idFx) {
retval = des_bords_sombres_a(image, 160);
break;
case CR_bsombrb: /* experiment ! */
retval = des_bords_sombres_b(image, 100);
retval = des_bords_sombres_b(image, 120);
break;
case CR_vsglitch:

View File

@ -53,17 +53,29 @@ return -1;
static int pixel_trinitron(FloatImg *pimg, int pos[4], float *fvals)
{
int x, y, pline, off;
int ym;
fimg_clear_rectangle(pimg, pos);
for (y=pos[1]; y<pos[1]+pos[3]; y++) {
ym = pos[1]+pos[3]-1;
#define FDIM 0.60
for (y=pos[1]; y<ym; y++) {
pline = y*pimg->width;
for (x=pos[0]+2; x<(pos[0]+pos[2]-2); x++) {
off = pline + x;
for (x=0; x<5; x++) {
off = pline + (x+pos[0]);
/* wtf i'm doing here ? */
if ( (pos[1]==y) || (ym-1==y) ) {
pimg->R[off] = fvals[0] * FDIM;
pimg->G[off+5] = fvals[1] * FDIM;
pimg->B[off+10] = fvals[2] * FDIM;
}
else {
pimg->R[off] = fvals[0];
pimg->G[off] = fvals[1];
pimg->B[off] = fvals[2];
pimg->G[off+5] = fvals[1];
pimg->B[off+10] = fvals[2];
}
}
}
return 0;

View File

@ -16,3 +16,10 @@ printf("this is the version ZERO !!!\n");
}
/* ------------------------------------------------------------ */
int init_empty_cache(int iw, int ih, int szc, int nbre)
{
return -1;
}
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */

View File

@ -3,3 +3,5 @@
*/
void cachengn_print_version(int k);
int init_empty_cache(int iw, int ih, int szc, int nbre);

View File

@ -6,11 +6,21 @@
#include "cachengn.h"
#define IMGW 320
#define IMGH 240
#define SIZE 20
#define NBRI 1000
/* ------------------------------------------------------------ */
int main(int argc, char *argv[])
{
int foo;
fprintf(stderr, "Test of the cache engin - %s %s\n", __DATE__, __TIME__);
cachengn_print_version(1);
foo = init_empty_cache(IMGW, IMGH, SIZE, NBRI);
fprintf(stderr, "init_empty_cache --> %d\n", foo);
return 0;
}

View File

@ -10,6 +10,34 @@
#include "../floatimg.h"
extern int verbosity;
/* -------------------------------------------------------------------- */
int fimg_show_filter(char *title, FimgFilter3x3 *filtr)
{
float *M; /* alias of filter matrix */
int foo, idx;
float sum, value;
if (title) fprintf(stderr, "--------- %s ---------\n", title);
M = filtr->matrix; /* aliasing here */
fprintf(stderr, "%8.3f %8.3f %8.3f\n", M[0], M[1], M[2]);
fprintf(stderr, "%8.3f %8.3f %8.3f\n", M[3], M[4], M[5]);
fprintf(stderr, "%8.3f %8.3f %8.3f\n", M[6], M[7], M[8]);
sum = 0.0;
for (idx=0; idx<9; idx++) sum += M[idx];
fprintf(stderr, " sum %8.3f\n", sum);
fprintf(stderr, " mult %8.3f\n", filtr->mult);
fprintf(stderr, " offset %8.3f\n", filtr->offset);
value = (sum * filtr->mult) + filtr->offset;
fprintf(stderr, " value %8.3f ???\n", sum);
return 0;
}
/* -------------------------------------------------------------------- */
int fimg_filter_3x3(FloatImg *src, FloatImg *dst, FimgFilter3x3 *filtr)
{
@ -35,6 +63,10 @@ if (fimg_images_not_compatible(src, dst)) {
return -98;
}
if (verbosity) {
fimg_show_filter("essai", filtr);
}
/* aliasing some vars for cleaner code */
pr = src->R; pg = src->G; pb = src->B;
w = src->width; h = src->height;

0
funcs/fimg-dicom.c Normal file
View File

View File

@ -17,6 +17,12 @@
extern int verbosity;
/*
https://baillehachepascal.dev/2021/rgb_hsv.php
*/
/* --------------------------------------------------------------------- */
/* helper functions */
static float maxi3f(float a, float b, float c)
@ -29,7 +35,7 @@ return ((a < b)? (a < c ? a : c) : (b < c ? b : c));
}
static int pseudoeq(float a, float b)
{
return (fabsf(a-b)<0.00000000000001); // UGLY HACK ???
return (fabsf(a-b)<0.00000001); // UGLY HACK ???
}
/* --------------------------------------------------------------------- */
/*

View File

@ -24,7 +24,8 @@ enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff,
Histo, Hsv, Classif, Ctr2x2, Qsortrgb,
Displace, ReadPNG, Plasmas, Hilight, OpenEXR,
Geometrie, FileType, Mirror, KillRGB,
Pixelize,SplitLevel,DecompRgbz, Rectangle };
Pixelize,SplitLevel, DecompRgbz, DecompRgbg,
Rectangle };
typedef struct {
char *name;
int Cmd;
@ -56,6 +57,7 @@ Command commands[] = {
{ "pixelize", Pixelize },
{ "spltlvl", SplitLevel },
{ "decomprgbz", DecompRgbz },
{ "decomprgbg", DecompRgbg },
{ "rectangle", Rectangle },
{ NULL, 0 }
} ;
@ -234,6 +236,9 @@ switch(opt) {
case DecompRgbz:
foo = essai_decomprgb_color(filename, outfile);
break;
case DecompRgbg:
foo = essai_decomprgb_gray(filename, outfile);
break;
case Rectangle:
essai_rectangle(outfile, 0);
break;

View File

@ -74,6 +74,38 @@ if (foo) {
return 0;
}
/* --------------------------------------------------------------------- */
int essai_decomprgb_gray(char *inf, char *outf)
{
int foo;
FloatImg src, dst;
fprintf(stderr, ">>> %s ( %s %s )\n", __func__, inf, outf);
foo = fimg_create_from_dump(inf, &src);
if (0 != foo) {
fprintf(stderr, "%s: err %d loading image '%s'\n", __func__,
foo, inf);
return foo;
}
fimg_clone(&src, &dst, 1);
foo = fimg_decomp_rgbz_gray(&src, &dst, 0);
if (foo) {
fprintf(stderr, "%s:%s(): fail %d line %d\n",
__FILE__, __func__, foo, __LINE__);
return foo;
}
foo = fimg_export_picture(&dst, outf, 0);
if (foo) {
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
return foo;
}
fimg_destroy(&src); fimg_destroy(&dst);
return 0;
}
/* --------------------------------------------------------------------- */
int essai_decomprgb_color(char *inf, char *outf)
{

View File

@ -7,6 +7,7 @@ int essai_plasma(char *infile, char *outfile, int ikoef, float fkoef);
int essai_miroir(char *inf, char *outf, int flags);
int essai_killrgb(char *inf, char *outf);
int essai_decomprgb_color(char *inf, char *outf);
int essai_decomprgb_gray(char *inf, char *outf);
int essai_split_level(char *inf, char *outf, int flags);
int essai_displacement(char *infile, char *outfile);

View File

@ -28,7 +28,7 @@ enum fxid { Fx_cos01=5, Fx_cos010, Fx_pow2, Fx_sqrt, Fx_gray0, Fx_halfsz0,
Fx_rot90, Fx_cmixa, Fx_desat, Fx_ctr2x2, Fx_norm,
Fx_classtrial, Fx_mirror, Fx_shift0, Fx_trimul,
Fx_xper, Fx_binarize, Fx_trinarize, Fx_hilight_R,
Fx_absolute };
Fx_absolute, Fx_clamp };
Fx fx_list[] = {
{ "cos01", Fx_cos01, 0, 1 },
@ -51,6 +51,7 @@ Fx fx_list[] = {
{ "trinarize", Fx_trinarize, 0, 1 },
{ "hilightr", Fx_hilight_R, 0, 1 },
{ "abs", Fx_absolute, 0, 1 },
{ "clamp", Fx_clamp, 0, 1 },
{ NULL, 0, 0, 0 }
};
@ -237,6 +238,13 @@ switch (action) {
fimg_copy_data(&src, &dest);
foo = fimg_absolute(&dest);
break;
case Fx_clamp:
fimg_copy_data(&src, &dest);
foo = fimg_clamp_negativ(&dest);
/* this func return the count of
negative pixels killed */
if (foo > 0) foo = 0;
break;
default:
fprintf(stderr, "%s %s : %d is bad action\n",
__FILE__, __func__, action);
@ -298,7 +306,7 @@ if (action < 0) {
exit(1);
}
if (verbosity) {
if (verbosity > 1) {
fprintf(stderr, " global fvalue %f\n", global_fvalue);
fprintf(stderr, " action %d\n", action);
fprintf(stderr, " verbosity %d\n", verbosity);
@ -310,7 +318,7 @@ if ((nba=fx_list[action].nbarg)) {
srcname = argv[optind+1];
dstname = argv[optind+2];
if (verbosity) fprintf(stderr, "%s ==> %s\n", srcname, dstname);
if (verbosity > 1) fprintf(stderr, "Fx %s ==> %s\n", srcname, dstname);
foo = do_an_effect(srcname, action, dstname);
if (foo) {