ROPO
Loading...
Searching...
No Matches
fmi_image.h
1
24#ifndef __FMI_IMAGE__
25#define __FMI_IMAGE__
26#define FMI_IMAGE_VER "fmi_image \t v2.2\t Jul 2002 (c) Markus.Peura@fmi.fi"
27
28#include <stdio.h>
29#include "rave_types.h"
30/*
31 typedef Coord short int;
32 typedef Byte unsigned char;
33*/
34
35/*
36enum fmi_image_format {
37 PBM_ASC=1,
38 PGM_ASC=2,
39 PPM_ASC=3,
40 PBM_RAW=4,
41 PGM_RAW=5,
42 PPM_RAW=6};
43*/
44
45typedef enum {
46 UNDEFINED=0,
47 PBM_ASC=1,
48 PGM_ASC=2,
49 PPM_ASC=3,
50 PBM_RAW=4,
51 PGM_RAW=5,
52 PPM_RAW=6
53} FmiImageFormat;
54
55typedef enum {
56 NULL_IMAGE,
57 TRUE_IMAGE,
58 LINK_IMAGE
59} FmiImageType;
60
61extern char FmiImageFormatExtension[7][4];
62/*char FmiImageFormatExtension[][]; */
63
64typedef enum {
65 ZERO,
66 MAX,
67 MIRROR,
68 BORDER,
69 WRAP,
70 TILE
71} CoordOverflowHandler;
72
73/*typedef signed char Dbz; */
74typedef unsigned char Byte;
75typedef int Celsius;
76
77#define HISTOGRAM_SIZE (256+15)
78/*typedef unsigned long Histogram[HISTOGRAM_SIZE]; */
79typedef signed long Histogram[HISTOGRAM_SIZE]; /* signed is needed for AREA */
80/* this list contains special entries which are not very useful */
81/* in standard histogram usage */
82
83enum histogram_special_data {
84 HIST_SIZE = 256,
85 HIST_SUM,
86 HIST_MIN,
87 HIST_AREA,
88 HIST_MAX,
89 HIST_PERIMx3,
90 HIST_SUM_I,
91 HIST_SUM_J,
92 HIST_SUM_II,
93 HIST_SUM_JJ,
94 HIST_SUM_IJ,
95 HIST_MIN_I,
96 HIST_MIN_J,
97 HIST_MAX_I,
98 HIST_MAX_J
99};
100/* lis�� my�s dump_stats:iin */
101
102/*
103#define HIST_SIZE 256
104#define HIST_SUM 257
105#define HIST_MIN 258
106#define HIST_AREA 259
107#define HIST_MAX 260
108#define HIST_PERIMx2 261
109#define HIST_SUM_I 262
110#define HIST_SUM_J 263
111#define HIST_SUM_II 264
112#define HIST_SUM_JJ 265
113#define HIST_SUM_IJ 266
114#define HIST_MIN_I 267
115#define HIST_MIN_J 268
116#define HIST_MAX_I 269
117#define HIST_MAX_J 270
118*/
119
120
121typedef unsigned char ColorMap[][4];
122typedef unsigned char ColorMap256[256][3];
123
124#define MAX_COMMENT_LENGTH 1024
125
126extern int FMI_IMAGE_COMMENT;
127
128struct fmi_image {
129
130 /*
131 width = bins
132 height = rays
133 */
134 int width,height,channels;
135 /* int *channel_mapping; */
136 int area,volume;
137 int max_value;
138
139 int sweep_count;
140 int *heights;
141
142 float bin_depth;
143 float elevation_angle;
144
145 /* depth ? */
146 /* unsigned char **array;*/
147 Byte *array;
148
149 RaveDataType original_type;
150 double original_nodata;
151 double original_undetect;
152 double original_gain;
153 double original_offset;
154 double *original;
156 CoordOverflowHandler coord_overflow_handler_x, coord_overflow_handler_y;
157 /* unsigned char *stream;*/
158 char comment_string[MAX_COMMENT_LENGTH];
159 FmiImageFormat format;
160 FmiImageType type;
161};
162
163typedef struct fmi_image FmiImage;
164
166int legal_coords(FmiImage *img,int x,int y);
167
168/* BASIC OPERATIONS OFR SETTING AND RESETTING IMAGES */
169/*int set(FmiImage *img,int width,int height,int channels);*/
170FmiImage *new_image(int sweep_count); /* Allocator */
171void init_new_image(FmiImage* img);
172int initialize_image(FmiImage *img); /* constructor */
173
174void reset_image(FmiImage *img);
175
176/* virtual images */
177int link_image_segment(FmiImage *reference_img,int channel_start,int channel_count,FmiImage *linked_img);
178void link_image_channel(FmiImage *source,int channel,FmiImage *linked);
179
180void release_image(FmiImage *img); /* destructor */
181
182void split_to_link_array(FmiImage *source,int segments,FmiImage *target);
183void split_to_channels(FmiImage *source,int channels);
184
185int check_image_properties(FmiImage *sample,FmiImage *target);
186/*
187 int split_to_channels(FmiImage *img,int channels);
188 int restore_to_single_channel(FmiImage *img);
189 int reclaim_channels(FmiImage *source,int channels);
190 int channels_to_link_array(FmiImage *source,FmiImage *target);
191*/
192
193void concatenate_images_vert(FmiImage *source,int count,FmiImage *target);
194/*int convert_to_linkarray(FmiImage *source,FmiImage *target); */
195
196int copy_image_properties(FmiImage *sample,FmiImage *target);
197int check_image_integrity(FmiImage *sample,FmiImage *target);
198int canonize_image(FmiImage *sample,FmiImage *target);
199
200
201Byte get_pixel(FmiImage *img,int x,int y,int channel);
202double get_pixel_orig(FmiImage *img,int x,int y,int channel);
203
204/*#define get_pixel(img,x,y,channel) get(img,x,y,channel) */
205
206Byte get_pixel_direct(FmiImage *img,int i);
207
208void put_pixel(FmiImage *img,int x,int y,int channel,Byte c);
209void put_pixel_orig(FmiImage *img,int x,int y,int channel, double c);
210/*#define put_pixel(img,x,y,channel,c) put(img,x,y,channel,c) */
211void put_pixel_direct(FmiImage *img,int address,Byte c);
212void put_pixel_direct_inc(FmiImage *img,int address);
213
214void put_pixel_min(FmiImage *img,int x,int y,int channel,Byte c);
215void put_pixel_max(FmiImage *img,int x,int y,int channel,Byte c);
216void put_pixel_or(FmiImage *img,int x,int y,int channel,Byte c);
217void put_pixel_and(FmiImage *img,int x,int y,int channel,Byte c);
218
219void fill_image(FmiImage *img,Byte c);
220void fill_image_orig(FmiImage *img,double c);
221void image_fill_random(FmiImage *img,Byte mean,Byte amplitude);
222void invert_image(FmiImage *img);
223void translate_intensity(FmiImage *img,Byte from,Byte to);
224void limit_image_intensities(FmiImage *img,Byte min,Byte max);
225
226void add_image(FmiImage *source,FmiImage *source2,FmiImage *target);
227void average_images(FmiImage *source,FmiImage *source2,FmiImage *target);
228void subtract_image(FmiImage *source,FmiImage *source2,FmiImage *target);
229void subtract_image128(FmiImage *source,FmiImage *source2,FmiImage *target);
230void multiply_image255(FmiImage *source,FmiImage *source2,FmiImage *target);
231void multiply_image255_flex(FmiImage *source,FmiImage *source2,FmiImage *target);
232void multiply_image255_sigmoid(FmiImage *source,FmiImage *source2,FmiImage *target);
233void max_image(FmiImage *source,FmiImage *source2,FmiImage *target);
234void min_image(FmiImage *source,FmiImage *source2,FmiImage *target);
235
236/* intensity mappings */
237void multiply_image_scalar255(FmiImage *img,int coeff);
238void semisigmoid_image(FmiImage *source,int half_width); /* scale */
239void semisigmoid_image_inv(FmiImage *source,int half_width); /* scale */
240void sigmoid_image(FmiImage *source,int threshold,int slope); /* soft threshold */
241void gaussian_image(FmiImage *source,int mean,int half_width);/* soft threshold */
242
243void copy_image(FmiImage *source,FmiImage *target);
244void insert(FmiImage *source,FmiImage *target,int i0,int j0);
245void compose2x2(FmiImage *source_ul,FmiImage *source_ur,FmiImage *source_ll,FmiImage *source_lr,FmiImage *target);
246void compose3x2(FmiImage *source_ul,FmiImage *source_um,FmiImage *source_ur,FmiImage *source_ll,FmiImage *source_lm,FmiImage *source_lr,FmiImage *target);
247
248int legal_coord(FmiImage *img,int x,int y);
249
250/* INPUT/OUTPUT */
251/* int write(FmiImage *img,char *filename,int fmi_image_format);*/
252void write_image(char *filename,FmiImage *img,FmiImageFormat format);
253void read_image(char *filename,FmiImage *img);
254void image_info(FmiImage *img);
255
256void read_pnm_image(FILE *fp,FmiImage *img,FmiImageFormat format);
257void write_pnm_image(FILE *fp,FmiImage *img,FmiImageFormat format);
258
259
260/* BASIC TRANSFORMS (further tricks in other *.c files) */
261void extract_channel(FmiImage *source,int channel,FmiImage *target);
262void write_channel(FmiImage *source,int channel,FmiImage *target);
263
264/* TRANSFORMS */
265/* intensity */
266void expand_channel_to_rgb(FmiImage *source,int channel,FmiImage *target);
267void map_channel_to_colors(FmiImage *source,int channel,FmiImage *target,int map_size,ColorMap map);
268void map_channel_to_256_colors(FmiImage *source,int channel,FmiImage *target,ColorMap256 map);
269void map_256_colors_to_gray(FmiImage *source,FmiImage *target,ColorMap256 map);
270void read_colormap256(char *filename,ColorMap256 map);
271/* int to_rgb(FmiImage *source,FmiImage *target); */
272
273
275void to_cart(FmiImage *source,FmiImage *target,Byte outside_fill);
276
277
278
279/* filters */
280/* typedef struct {int width;int height;int *array;} Mask; */
281/*
282 typedef struct {int width;int height;char *name;} Mask;
283 Mask mask_speck1;
284 typedef struct {int width;int height;int array[3][3];} Mask;
285 char *stri;
286*/
287
288void calc_histogram(FmiImage *source,Histogram hist);
289void clear_histogram(Histogram hist);
290void write_histogram(char *filename,Histogram hist);
291void dump_histogram(Histogram hist);
292/*initialize_vert_stripe */
293int initialize_vert_stripe(FmiImage *img,int height);
294
295
296#endif
double * original
Definition fmi_image.h:154