Skip to content
Snippets Groups Projects
Commit 02c41437 authored by thib's avatar thib
Browse files

quad

parent 561ee902
Branches
No related tags found
No related merge requests found
*.o
*.x
pgm/*
\ No newline at end of file
cc=gcc
CFLAGS=-Wextra -Wall -g -fsanitize=address -fsanitize=leak
LFLAGS=-fsanitize=address -fsanitize=leak -lm
main: main.x
./main.x
main.x: quadTree.o main.o PGM.o matrix.o
$(cc) -o $@ $^ $(CFLAGS) $(LFLAGS)
quadTree.o: quadTree.c quadTree.h PGM.h matrix.h
$(CC) -c $<
clean:
rm -f *.o *.x
rebuild: clean main
#include "PGM.h"
// #include "gfx.h"
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// typedef struct _pgm {
// int max;
// matrix pixels;
// } pgm;
pgm_error pmg_read_from_file(pgm *p, char *filename) {
if (NULL == filename || NULL == p) {
return failure;
}
FILE *f = fopen(filename, "r");
if (f == NULL) {
printf("error with file");
return failure;
}
int row;
int col;
int max;
char p5[80];
fscanf(f, "%s %d %d %d", p5, &row, &col, &max);
// printf("%s %d %d %d\n", p5, row, col, max);
matrix_alloc(&(p->pixels), row, col);
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
uint8_t tmp;
fread(&tmp, sizeof(uint8_t), 1, f);
p->pixels.data[i][j] = (int)tmp;
}
}
fclose(f);
p->max = max;
return success;
}
pgm_error pmg_write_to_file(pgm *p, char *filename) {
if (NULL == filename || NULL == p) {
return failure;
}
char folder[80]="pgm/";
strcat(folder, filename);
FILE *f = fopen(folder, "w");
if (f == NULL) {
printf("error with file");
return failure;
}
fprintf(f, "%s\n%d %d\n%d\n", "P5", p->pixels.m, p->pixels.n, p->max);
for (int i = 0; i < p->pixels.m; i++) {
for (int j = 0; j < p->pixels.n; j++) {
fwrite(&(p->pixels.data[i][j]), sizeof(uint8_t), 1, f);
}
}
fclose(f);
return success;
}
pgm_error pmg_negative(pgm *neg, const pgm *const orig) {
if (NULL == orig || NULL == neg) {
return failure;
}
matrix_alloc(&(neg->pixels), orig->pixels.m, orig->pixels.n);
neg->max = orig->max;
for (int i = 0; i < orig->pixels.m; i++) { // ligne
for (int j = 0; j < orig->pixels.n; j++) { // col
neg->pixels.data[i][j] = orig->max - orig->pixels.data[i][j];
}
}
return success;
}
pgm_error pmg_symmetry_hori(pgm *sym, const pgm *const orig) {
if (NULL == orig || NULL == sym) {
return failure;
}
matrix_alloc(&(sym->pixels), orig->pixels.m, orig->pixels.n);
sym->max = orig->max;
for (int i = 0; i < orig->pixels.m; i++) { // ligne
for (int j = 0; j < orig->pixels.n; j++) { // col
sym->pixels.data[i][j] = orig->pixels.data[i][orig->pixels.n - 1 - j];
}
}
return success;
}
pgm_error pmg_symmetry_vert(pgm *sym, const pgm *const orig) {
if (NULL == orig || NULL == sym) {
return failure;
}
matrix_alloc(&(sym->pixels), orig->pixels.m, orig->pixels.n);
sym->max = orig->max;
for (int i = 0; i < orig->pixels.m; i++) { // ligne
for (int j = 0; j < orig->pixels.n; j++) { // col
sym->pixels.data[i][j] = orig->pixels.data[orig->pixels.m - 1 - i][j];
}
}
return success;
}
pgm_error pmg_symmetry_cent(pgm *sym, const pgm *const orig) {
if (NULL == orig || NULL == sym) {
return failure;
}
matrix_alloc(&(sym->pixels), orig->pixels.m, orig->pixels.n);
sym->max = orig->max;
for (int i = 0; i < orig->pixels.m; i++) { // ligne
for (int j = 0; j < orig->pixels.n; j++) { // col
sym->pixels.data[i][j] =
orig->pixels.data[orig->pixels.m - 1 - i][orig->pixels.n - 1 - j];
}
}
return success;
}
pgm_error pmg_photomaton(pgm *photomaton, const pgm *const orig) {
if (NULL == orig || NULL == photomaton) {
return failure;
}
matrix_alloc(&(photomaton->pixels), orig->pixels.m, orig->pixels.n);
photomaton->max = orig->max;
int y;
int x;
for (int i = 0; i < orig->pixels.m; i++) { // ligne
for (int j = 0; j < orig->pixels.n; j++) { // col
y = i / 2;
if (i % 2 != 0) {
y += orig->pixels.m / 2;
}
x = j / 2;
if (j % 2 != 0) {
x += orig->pixels.n / 2;
}
photomaton->pixels.data[y][x] = orig->pixels.data[i][j];
}
}
return success;
}
// alternative
// int x=0;
// int y=0;
// for (int i = 0; i < orig->pixels.m; i+=2) { // ligne
// for (int j = 0; j < orig->pixels.n; j+=2) { // col
// photomaton->pixels.data[y][x] = orig->pixels.data[i][j];
// photomaton->pixels.data[y +(orig->pixels.n/2)][x] = orig->pixels.data[i
// + 1][j]; photomaton->pixels.data[y][x +(orig->pixels.m/2)] =
// orig->pixels.data[i][j + 1]; photomaton->pixels.data[y
// +(orig->pixels.n/2)][x +(orig->pixels.m/2)] = orig->pixels.data[i +
// 1][j+ 1];
// x++;
// }
// y++;
// }
// printf("[%d,%d]=[%d,%d]\n", y, x, i, j);
//
pgm_error pmg_crop(pgm *crop, const pgm *const orig, int x0, int x1, int y0,
int y1) {
if (ok !=
matrix_extract_submatrix(&crop->pixels, orig->pixels, y0, y1, x0, x1)) {
return failure;
}
crop->max = orig->max;
return success;
}
int get_divider(const matrix *const mat) {
int divider = 0;
for (int y = 0; y < mat->m; y++) {
for (int x = 0; x < mat->n; x++) {
divider += mat->data[y][x];
}
}
if (divider < 1) {
divider = 1;
}
return divider;
}
pgm_error pmg_conv(pgm *conv, const pgm *const orig, const matrix *const kernel) {
if (NULL == orig || NULL == conv || NULL == kernel) {
return failure;
}
matrix_alloc(&(conv->pixels), orig->pixels.m, orig->pixels.n);
conv->max = orig->max;
int divider = get_divider(kernel);
for (int i = 0; i < orig->pixels.m; i++) {
for (int j = 0; j < orig->pixels.n; j++) {
double pixel = 0.0;
for (int y = 0; y < kernel->m; y++) {
for (int x = 0; x < kernel->n; x++) {
int yi = i - kernel->m / 2 + y;
int xj = j - kernel->n / 2 + x;
//if pixel is inside matrix
if (xj >= 0 && yi >= 0 && xj < orig->pixels.m && yi < orig->pixels.n) {
pixel += orig->pixels.data[yi][xj] * kernel->data[y][x];
}
}
}
pixel /= divider;
//check pixel's val ->
if (pixel < 0) {
pixel = 0;
} else if (pixel > conv->max) {
pixel = conv->max;
}
//set pixel
conv->pixels.data[i][j] = (int)pixel;
}
}
return success;
}
// pgm_error pgm_display(pgm p) {
// struct gfx_context_t *context =
// gfx_create("SDL Display", p.pixels.m, p.pixels.n);
// if (!context) {
// fprintf(stderr, "Graphics initialization failed!\n");
// return EXIT_FAILURE;
// }
// while (gfx_keypressed() != SDLK_ESCAPE) {
// gfx_clear(context, COLOR_BLACK);
// for (int y = 0; y < p.pixels.m; y++) { // ligne
// for (int x = 0; x < p.pixels.n; x++) { // col
// uint val = p.pixels.data[y][x];
// uint color = MAKE_COLOR(val, val, val);
// gfx_putpixel(context, x, y, color);
// }
// }
// gfx_present(context);
// }
// gfx_destroy(context);
// return success;
// }
#ifndef _PGM_H_
#define _PGM_H_
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "matrix.h"
typedef enum _pgm_error {
success, failure
} pgm_error;
typedef struct _pgm {
int max;
matrix pixels;
} pgm;
pgm_error pmg_read_from_file(pgm *p, char *filename);
pgm_error pmg_write_to_file(pgm *p, char *filename);
pgm_error pmg_negative(pgm *neg, const pgm *const orig);
pgm_error pmg_symmetry_hori(pgm *sym, const pgm *const orig);
pgm_error pmg_symmetry_vert(pgm *sym, const pgm *const orig);
pgm_error pmg_symmetry_cent(pgm *sym, const pgm *const orig);
pgm_error pmg_photomaton(pgm *photomaton, const pgm *const orig);
pgm_error pmg_crop(pgm *crop, const pgm *const orig, int x0, int x1, int y0, int y1);
pgm_error pmg_conv(pgm *conv, const pgm *const orig, const matrix *const kernel);
pgm_error pgm_display(pgm p);
#endif
File added
// /// @file gfx.c
// /// @author Florent Gluck
// /// @date November 6, 2016
// /// Helper routines to render pixels in fullscreen graphic mode.
// /// Uses the SDL2 library.
// #include "gfx.h"
// /// Create a fullscreen graphic window.
// /// @param title Title of the window.
// /// @param width Width of the window in pixels.
// /// @param height Height of the window in pixels.
// /// @return a pointer to the graphic context or NULL if it failed.
// struct gfx_context_t* gfx_create(char *title, uint width, uint height) {
// if (SDL_Init(SDL_INIT_VIDEO) != 0) goto error;
// SDL_Window *window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED,
// SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_RESIZABLE);
// SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, 0);
// SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888,
// SDL_TEXTUREACCESS_STREAMING, width, height);
// uint32_t *pixels = malloc(width*height*sizeof(uint32_t));
// struct gfx_context_t *ctxt = malloc(sizeof(struct gfx_context_t));
// if (!window || !renderer || !texture || !pixels || !ctxt) goto error;
// ctxt->renderer = renderer;
// ctxt->texture = texture;
// ctxt->window = window;
// ctxt->width = width;
// ctxt->height = height;
// ctxt->pixels = pixels;
// SDL_ShowCursor(SDL_DISABLE);
// gfx_clear(ctxt, COLOR_BLACK);
// return ctxt;
// error:
// return NULL;
// }
// /// Draw a pixel in the specified graphic context.
// /// @param ctxt Graphic context where the pixel is to be drawn.
// /// @param x X coordinate of the pixel.
// /// @param y Y coordinate of the pixel.
// /// @param color Color of the pixel.
// void gfx_putpixel(struct gfx_context_t *ctxt, int x, int y, uint32_t color) {
// if (x < ctxt->width && y < ctxt->height)
// ctxt->pixels[ctxt->width*y+x] = color;
// }
// /// Clear the specified graphic context.
// /// @param ctxt Graphic context to clear.
// /// @param color Color to use.
// void gfx_clear(struct gfx_context_t *ctxt, uint32_t color) {
// int n = ctxt->width*ctxt->height;
// while (n)
// ctxt->pixels[--n] = color;
// }
// /// Display the graphic context.
// /// @param ctxt Graphic context to clear.
// void gfx_present(struct gfx_context_t *ctxt) {
// SDL_UpdateTexture(ctxt->texture, NULL, ctxt->pixels, ctxt->width*sizeof(uint32_t));
// SDL_RenderCopy(ctxt->renderer, ctxt->texture, NULL, NULL);
// SDL_RenderPresent(ctxt->renderer);
// }
// /// Destroy a graphic window.
// /// @param ctxt Graphic context of the window to close.
// void gfx_destroy(struct gfx_context_t *ctxt) {
// SDL_ShowCursor(SDL_ENABLE);
// SDL_DestroyTexture(ctxt->texture);
// SDL_DestroyRenderer(ctxt->renderer);
// SDL_DestroyWindow(ctxt->window);
// free(ctxt->pixels);
// ctxt->texture = NULL;
// ctxt->renderer = NULL;
// ctxt->window = NULL;
// ctxt->pixels = NULL;
// SDL_Quit();
// free(ctxt);
// }
// /// If a key was pressed, returns its key code (non blocking call).
// /// List of key codes: https://wiki.libsdl.org/SDL_Keycode
// /// @return the key that was pressed or 0 if none was pressed.
// SDL_Keycode gfx_keypressed() {
// SDL_Event event;
// if (SDL_PollEvent(&event)) {
// if (event.type == SDL_KEYDOWN)
// return event.key.keysym.sym;
// }
// return 0;
// }
// #ifndef _GFX_H_
// #define _GFX_H_
// #include <stdint.h>
// #include <stdbool.h>
// #include <SDL2/SDL.h>
// #define MAKE_COLOR(r,g,b) ((uint32_t)b|((uint32_t)g<<8)|((uint32_t)r<<16))
// #define COLOR_GET_B(color) (color & 0xff)
// #define COLOR_GET_G(color) ((color >> 8) & 0xff)
// #define COLOR_GET_R(color) ((color >> 16) & 0xff)
// #define COLOR_BLACK 0x00000000
// #define COLOR_RED 0x00FF0000
// #define COLOR_GREEN 0x0000FF00
// #define COLOR_BLUE 0x000000FF
// #define COLOR_WHITE 0x00FFFFFF
// #define COLOR_YELLOW 0x00FFFF00
// typedef unsigned int uint;
// typedef unsigned long ulong;
// typedef unsigned char uchar;
// struct gfx_context_t {
// SDL_Window *window;
// SDL_Renderer *renderer;
// SDL_Texture *texture;
// uint32_t *pixels;
// int width;
// int height;
// };
// extern void gfx_putpixel(struct gfx_context_t *ctxt, int x, int y, uint32_t color);
// extern void gfx_clear(struct gfx_context_t *ctxt, uint32_t color);
// extern struct gfx_context_t* gfx_create(char *text, uint width, uint height);
// extern void gfx_destroy(struct gfx_context_t *ctxt);
// extern void gfx_present(struct gfx_context_t *ctxt);
// extern SDL_Keycode gfx_keypressed();
// #endif
#include "PGM.h"
#include "quadTree.h"
int main() {
pgm p;
pmg_read_from_file(&p, "chien-pasteque.pgm");
create_tree(3);
matrix_destroy(&p.pixels);
}
\ No newline at end of file
Source diff could not be displayed: it is too large. Options to address this: view the blob.
#include "matrix.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
// typedef struct _matrix {
// int m, n;
// int **data;
// } matrix;
// m nb ligne n nb col
error_code matrix_alloc(matrix *mat, int m, int n) {
if (m < 0 || n < 0) {
return out_of_bounds;
}
mat->data = malloc(m * sizeof(int *));
if(mat->data == NULL){
return memory_error;
}
for (int i = 0; i < m; i++) {
mat->data[i] = malloc(n * sizeof(int));
if(mat->data[i] == NULL){
return memory_error;
}
}
mat->n = n;
mat->m = m;
return ok;
}
error_code matrix_init(matrix *mat, int m, int n, int val) {
if (m < 1 || n < 1) {
return out_of_bounds;
}
matrix_alloc(mat, m, n);
for (int i = 0; i < m; i++) { // ligne
for (int j = 0; j < n; j++) { // col
mat->data[i][j] = val;
}
}
return ok;
}
error_code matrix_init_from_array(matrix *mat, int m, int n, int data[]) {
if (m < 1 || n < 1) {
return out_of_bounds;
}
mat->data = malloc(m * sizeof(int *));
for (int i = 0; i < m; i++) {
mat->data[i] = malloc(n * sizeof(int));
}
int k = 0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
mat->data[i][j] = data[k++];
}
}
mat->n = n;
mat->m = m;
return ok;
}
error_code matrix_destroy(matrix *mat) {
if(mat==NULL){
printf("pas init");
return uninitialized;
}
for (int i = 0; i < mat->m; i++) {
free(mat->data[i]);
}
free(mat->data);
mat->n = -1;
mat->m = -1;
return ok;
}
error_code matrix_clone(matrix *cloned, const matrix mat) {
matrix_alloc(cloned, mat.m, mat.n);
for (int i = 0; i < cloned->m; i++) { // ligne
for (int j = 0; j < cloned->n; j++) { // col
cloned->data[i][j] = mat.data[i][j];
}
}
return ok;
}
error_code matrix_transpose(matrix *transposed, const matrix mat) {
matrix_alloc(transposed, mat.n, mat.m);
for (int i = 0; i < transposed->m; i++) { // ligne
for (int j = 0; j < transposed->n; j++) { // col
transposed->data[i][j] = mat.data[j][i];
}
}
return ok;
}
error_code matrix_print(const matrix mat) {
for (int i = 0; i < mat.m; i++) {
for (int j = 0; j < mat.n; j++) {
printf("%d ", mat.data[i][j]);
}
printf("\n");
}
printf("\n");
return ok;
}
error_code matrix_extract_submatrix(matrix *sub, const matrix mat, int m0,int m1, int n0, int n1) {
int mDiff=m1 - m0;
int nDiff=n1-n0;
if (mDiff < 0 || nDiff < 0) {
return out_of_bounds;
printf("out of bound");
}
sub->m=mDiff;
sub->n=nDiff;
matrix_alloc(sub, mDiff, nDiff);
for (int i = 0; i < mDiff; i++) { // ligne
for (int j = 0; j < nDiff; j++) { // col
sub->data[i][j] = mat.data[m1-sub->m+i][n1-sub->n+j];
}
}
return ok;
}
bool matrix_is_equal(matrix mat1, matrix mat2) {
if (mat1.m != mat2.m || mat1.n != mat2.n) {
return false;
}
for (int i = 0; i < mat1.m; i++) { // ligne
for (int j = 0; j < mat1.n; j++) { // col
if (mat1.data[i][j] != mat2.data[i][j])
return false;
}
}
return true;
}
error_code matrix_get(int *elem, const matrix mat, int ix, int iy) {
if (mat.m < ix || mat.n < iy) {
return out_of_bounds;
}
*elem = mat.data[ix][iy];
return ok;
}
error_code matrix_set(const matrix mat, int ix, int iy, int elem) {
if (mat.m < ix || mat.n < iy) {
return out_of_bounds;
}
mat.data[ix][iy] = elem;
return ok;
}
void mult2(int *elem){
*elem*=2;
}
void multX(int *elem,int x){
*elem*=x;
}
error_code matrix_map_ip2(matrix mat,int x, void (*foo)(int *,int)) {
for (int i = 0; i < mat.m; i++) { // ligne
for (int j = 0; j < mat.n; j++) { // col
foo(&mat.data[i][j],x);
}
}
return ok;
}
error_code matrix_map_ip(matrix mat, void (*foo)(int *)) {
for (int i = 0; i < mat.m; i++) { // ligne
for (int j = 0; j < mat.n; j++) { // col
foo(&mat.data[i][j]);
}
}
return ok;
}
error_code matrix_map(matrix *mapped, const matrix mat, void (*foo)(int *)) {
matrix_clone(mapped, mat);
for (int i = 0; i < mat.m; i++) { // ligne
for (int j = 0; j < mat.n; j++) { // col
foo(&mapped->data[i][j]);
}
}
return ok;
}
\ No newline at end of file
#ifndef _MATRIX_H_
#define _MATRIX_H_
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
typedef enum _error_code {
ok,
out_of_bounds,
memory_error,
uninitialized,
} error_code;
typedef struct _matrix {
int m, n; //m ligne n col
int **data;
} matrix;
error_code matrix_alloc(matrix *mat, int m, int n);
error_code matrix_init(matrix *mat, int m, int n, int val);
error_code matrix_destroy(matrix *mat);
error_code matrix_init_from_array(matrix *mat, int m, int n, int data[]);
error_code matrix_clone(matrix *cloned, const matrix mat);
error_code matrix_transpose(matrix *transposed, const matrix mat);
error_code matrix_print(const matrix mat);
error_code matrix_extract_submatrix(matrix *sub, const matrix mat, int m0, int m1, int n0, int n1);
bool matrix_is_equal(matrix mat1, matrix mat2);
error_code matrix_get(int *elem, const matrix mat, int ix, int iy);
error_code matrix_set(matrix mat, int ix, int iy, int elem);
void mult2(int *elem);
void multX(int *elem,int x);
error_code matrix_map_ip(matrix mat, void (*foo)(int *));
error_code matrix_map_ip2(matrix mat,int x, void (*foo)(int *,int));
error_code matrix_map(matrix *mapped, const matrix mat, void (*foo)(int *));
#endif
#include "quadTree.h"
#include <math.h>
#include <stdlib.h>
// typedef struct _node
// {
// double ave; // moyenne des valeurs des enfants
// double ave_sq; // moyenne des carrés des valeurs des enfants
// struct _node *child[CHILDREN];
// } node;
bool leaf(node *nd) { return NULL == nd->child[0]; }
node *create_node() {
node *nd = malloc(sizeof(node));
for (int i = 0; i < CHILDREN; i++) {
nd->child[i] = calloc(1, sizeof(node));
}
nd->ave = 0;
nd->ave_sq = 0;
return nd;
}
node *create_tree(int depth) {
node *a = create_node();
if (depth > 0) {
for (int i = 0; i < CHILDREN; i++) {
a->child[i] = create_node();
a->child[i] = create_tree(depth - 1);
}
}
return a;
}
void destroy_tree(node *tree) {
if (!leaf(tree)) {
for (int i = 0; i < CHILDREN; i++) {
destroy_tree(tree->child[i]);
free(tree);
}
}
}
void swap(node *a, node *b) {
node tmp = *a;
*a = *b;
*b = tmp;
}
void symetry(node *arbre, int bit) {
if (!leaf(arbre)) {
for (int i = 0; i < CHILDREN; i++) {
if (i < (i ^ bit)) {
swap(arbre->child[i], arbre->child[i ^ bit]);
}
}
for (int i = 0; i < CHILDREN; i++) {
symetry(arbre->child[i], bit);
}
}
}
node *position(int li, int col, node *a, int d) {
node *crt = a;
// à compléter: tant qu’on n’est pas sur une feuille, déplacer
// <crt> sur un enfant selon valeur du d­ième bit de <li> et <col>
return crt;
}
void matrix2tree(matrix *mat, node *arbre) {
int d = depth(arbre) - 1;
for (int m = 0; m < mat->m; m++) {
for (int n = 0; n < mat->n; n++) {
node *crt = position(m, n, arbre, d);
crt->ave = mat->data[m][n];
crt->ave_sq = (crt->ave) * (crt->ave);
}
}
}
int maxf(int a, int b) {
if (a > b) {
b = a;
}
return b;
}
int depth(node *nd) {
int p[CHILDREN];
memset(p, 0, CHILDREN * sizeof(int));
if (leaf(nd)) {
return 0;
} else {
for (int i = 0; i < CHILDREN; i++) {
p[i] = 1 + depth(nd->child[i]);
}
int m = -1;
for (int i = 0; i < CHILDREN; i++) {
m = maxf(m, p[i]);
}
return m;
}
}
#ifndef _QUADTREE_H_
#define _QUADTREE_H_
#include <stdio.h>
#include <stdbool.h>
#include <malloc.h>
#include "matrix.h"
#include <string.h>
#define CHILDREN 4
typedef struct _node
{
double ave; // moyenne des valeurs des enfants
double ave_sq; // moyenne des carrés des valeurs des enfants
struct _node *child[CHILDREN];
} node;
// typedef node* arbre;
// retourne un pointeur sur un arbre complet de profondeur <depth>
node *create_tree(int depth);
void destroy_tree(node* tree);
// retourne la profondeur d'un arbre <nd>
int depth(node *nd);
// retourne un pointeur sur une feuille d'un arbre <a> de profondeur
// <d> qui correspond à une position <li>,<co> dans une image 2d2
node *position(int li, int co, node *a, int d);
// transfère les données d'une image <mat> dans un arbre <arbre>
void matrix2tree(matrix *mat, node *arbre);
// transfère les données d'un arbre <arbre> dans une image <mat>
void tree2matrix(node *arbre, matrix *mat);
// permet d'obtenir une symétrie horizontale ou verticale en
// permutant les pointeurs <child[i]> et <child[i^bit]>
void symetry(node *arbre, int bit);
// stocke dans chaque noeud de <arbre>, la somme et celle des carrés
// des feuilles du sous­arbre correspondant
void average(node *arbre);
// récursivement on descend à l'avant­dernier niveau de l'arbre
// et on supprime les enfants en remontant si l’écart­type
// est inférieur à <seuil>
void compress(node *arbre, double seuil);
bool leaf(node *nd);
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment