1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
/*
* metapixel.h
*
* metapixel
*
* Copyright (C) 1997-2004 Mark Probst
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __METAPIXEL_H__
#define __METAPIXEL_H__
#include "readimage.h"
#define DEFAULT_WIDTH 64
#define DEFAULT_HEIGHT 64
#define DEFAULT_PREPARE_WIDTH 128
#define DEFAULT_PREPARE_HEIGHT 128
#define DEFAULT_CLASSIC_MIN_DISTANCE 5
#define DEFAULT_COLLAGE_MIN_DISTANCE 256
#define NUM_CHANNELS 3
#define IMAGE_SIZE 64
#define ROW_LENGTH (IMAGE_SIZE * NUM_CHANNELS)
#define SIGNIFICANT_COEFFS 40
#define NUM_COEFFS (NUM_CHANNELS * SIGNIFICANT_COEFFS)
#define NUM_INDEXES (IMAGE_SIZE * IMAGE_SIZE * NUM_CHANNELS * 2)
#define NUM_SUBPIXEL_ROWS_COLS 5
#define NUM_SUBPIXELS (NUM_SUBPIXEL_ROWS_COLS * NUM_SUBPIXEL_ROWS_COLS)
#define METRIC_WAVELET 1
#define METRIC_SUBPIXEL 2
#define SEARCH_LOCAL 1
#define SEARCH_GLOBAL 2
#define TABLES_FILENAME "tables.mxt"
typedef struct
{
int index;
float coeff;
} coefficient_with_index_t;
typedef unsigned short index_t;
typedef struct
{
index_t coeffs[NUM_COEFFS];
} search_coefficients_t;
typedef struct _position_t
{
int x, y;
struct _position_t *next;
} position_t;
typedef struct _metapixel_t
{
char *filename;
search_coefficients_t coeffs;
float means[NUM_CHANNELS];
unsigned char subpixels[NUM_SUBPIXELS * NUM_CHANNELS];
int flag;
unsigned char *data; /* only used if from an antimosaic or if benchmarking rendering */
int width, height; /* only valid if data != 0 */
int anti_x, anti_y; /* only used if from an antimosaic */
position_t *collage_positions; /* only used in collages */
struct _metapixel_t *next;
} metapixel_t;
typedef struct
{
metapixel_t *pixel;
float score;
} match_t;
typedef struct
{
int metawidth;
int metaheight;
match_t *matches;
} mosaic_t;
typedef struct
{
image_reader_t *image_reader;
int in_image_width;
int in_image_height;
int out_image_width;
int out_image_height;
int metawidth;
int metaheight;
int y;
int num_lines;
unsigned char *in_image_data;
} classic_reader_t;
typedef union
{
struct
{
search_coefficients_t coeffs;
float means[NUM_CHANNELS];
float sums[NUM_COEFFS];
} wavelet;
struct
{
unsigned char subpixels[NUM_SUBPIXELS * NUM_CHANNELS];
} subpixel;
} coeffs_t;
typedef struct
{
metapixel_t *pixel;
float score;
int x;
int y;
} global_match_t;
typedef struct _string_list_t
{
char *str;
struct _string_list_t *next;
} string_list_t;
typedef float(*compare_func_t)(coeffs_t*, metapixel_t*, float);
#endif
|