mirror of
https://github.com/eddyem/improclib.git
synced 2026-03-20 08:40:57 +03:00
add Bresenham algorythms
This commit is contained in:
@@ -5,15 +5,22 @@ Examples
|
||||
Open given image file as 1-channel uint8_t, equalize histogram, plot two crosses (red at 30,30 and green at 150,50) ans save as output.jpg
|
||||
|
||||
## generate
|
||||
Generate pseudo-star images with given Moffat parameters at given coordinates xi,yi (with amplitude ampi, ampi < 256)
|
||||
Usage: %s [args] x1,y1[,amp1] x2,y2[,amp2] ... xn,yn[,amp3]
|
||||
args:
|
||||
Generate pseudo-star images with given Moffat parameters at given coordinates xi,yi (with amplitude ampi, ampi < 256).
|
||||
Also draw different primitives and text.
|
||||
|
||||
Usage: genu16 [args] x1,y1[,w1] x2,y2[,w2] ... xn,yn[,w3] - draw 'stars' at coords xi,yi with weight wi (default: 1.)
|
||||
|
||||
Where args are:
|
||||
|
||||
-?, --help show this help
|
||||
-b, --beta=arg beta Moffat parameter of 'star' images (default: 1)
|
||||
-h, --height=arg resulting image height (default: 1024)
|
||||
-i, --input=arg input file with coordinates and amplitudes (comma separated)
|
||||
-o, --output=arg output file name (default: output.png)
|
||||
-s, --halfwidth=arg FWHM of 'star' images (default: 3.5)
|
||||
-w, --width=arg resulting image width (default: 1024)
|
||||
|
||||
- w - resulting image width (default: 1024)
|
||||
- h - resulting image height (default: 1024)
|
||||
- o - output file name (default: output.jpg)
|
||||
- s - FWHM of 'star' images (default: 3.5)
|
||||
- b - beta Moffat parameter of 'star' images (default: 1)
|
||||
|
||||
## genu16
|
||||
The same as 'generate', but works with 16-bit image and save it as 1-channel png (`ampi` now is weight).
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ int main(int argc, char **argv){
|
||||
I3->height = h;
|
||||
I3->width = w;
|
||||
ilPattern *cross = ilPattern_xcross(25, 25);
|
||||
ilPattern_draw3(I3, cross, 30, 30, ilColor_red);
|
||||
ilPattern_draw3(I3, cross, 150, 50, ilColor_green);
|
||||
ilImg3_drawpattern(I3, cross, 30, 30, ilColor_red);
|
||||
ilImg3_drawpattern(I3, cross, 150, 50, ilColor_green);
|
||||
ilPattern_free(&cross);
|
||||
int ret = ilImg3_jpg("output.jpg", I3, 95);
|
||||
ilImg3_free(&I3);
|
||||
|
||||
@@ -62,8 +62,8 @@ static void addstar(ilImg3 *I, const char *str){
|
||||
if(!getpars(str, &x, &y, &a)) return;
|
||||
printf("Add 'star' at %d,%d (ampl=%d)\n", x,y,a);
|
||||
uint8_t c[3] = {a,a,a};
|
||||
ilPattern_draw3(I, star, x, y, c);
|
||||
ilPattern_draw3(I, cross, x, y, ilColor_red);
|
||||
ilImg3_drawpattern(I, star, x, y, c);
|
||||
ilImg3_drawpattern(I, cross, x, y, ilColor_red);
|
||||
}
|
||||
|
||||
static void addfromfile(ilImg3 *I){
|
||||
@@ -94,6 +94,10 @@ int main(int argc, char **argv){
|
||||
for(int i = 0; i < argc; ++i) addstar(I, argv[i]);
|
||||
if(inp) addfromfile(I);
|
||||
ilPattern_free(&star);
|
||||
uint8_t color[] = {255, 0, 100};
|
||||
//uint8_t color[] = {0, 0, 0};
|
||||
ilImg3_putstring(I, "Test string", 450, 520, color);
|
||||
ilImg3_drawline(I, -10,900, 1600,1050, color);
|
||||
int ret = ilImg3_jpg(outp, I, 95);
|
||||
//int ret = ilImg3_png(outp, I);
|
||||
ilImg3_free(&I);
|
||||
|
||||
@@ -62,7 +62,7 @@ static void addstar(ilImage *I, const char *str){
|
||||
double w;
|
||||
if(!getpars(str, &x, &y, &w)) return;
|
||||
printf("Add 'star' at %d,%d (weight=%g)\n", x,y,w);
|
||||
iladd_subimage(I, star, x, y, w);
|
||||
ilImage_addsub(I, star, x, y, w);
|
||||
}
|
||||
|
||||
static void addfromfile(ilImage *I){
|
||||
@@ -97,6 +97,10 @@ int main(int argc, char **argv){
|
||||
ilImage_putstring(I, "0", 0, 1016);
|
||||
ilImage_putstring(I, "Hello, world.!?\"'\nMore again", 50, 500);
|
||||
ilImage_putstring(I, "Hello, world!", 950, 1018);
|
||||
uint16_t v = 50000;
|
||||
ilImage_drawline(I, -100,-1000, 1000, 1200, &v);
|
||||
ilImage_drawcircle(I, 1000,1000, 1000, &v);
|
||||
ilImage_drawcircle(I, 512,512, 512, &v);
|
||||
for(int _ = 0; _ < 1024; _ += 50){
|
||||
char s[6];
|
||||
snprintf(s, 6, "%d", _);
|
||||
|
||||
Reference in New Issue
Block a user