100 if((colors &
HEADER) != 0)
115 if((colors &
BLUE) != 0)
117 printf(
"Blue Pixel\n");
118 for(i=img->
he-1;i>=0;i--)
120 for(j=0;j<img->
wi;j++)
122 printf(
"%2x",img->
Blue[i][j]);
130 if((colors &
GREEN) != 0)
132 printf(
"Green Pixel\n");
133 for(i=img->
he-1;i>=0;i--)
135 for(j=0;j<img->
wi;j++)
137 printf(
"%2x",img->
Green[i][j]);
144 if((colors &
RED) != 0)
146 printf(
"Red Pixel\n");
147 for(i=img->
he-1;i>=0;i--)
149 for(j=0;j<img->
wi;j++)
151 printf(
"%2x",img->
Red[i][j]);
176 move.
x = pix2.
x - pix1.
x ;
177 move.
y = pix2.
y - pix1.
y ;
196 move.
x = pix2.
x - pix1.
x ;
197 move.
y = pix2.
y - pix1.
y ;
282 for(i=0;i< img->
he ;i++)
284 for(j=0 ; j< img->
wi ;j++)
311 printf(
"\n%d,%d\t- \t-\t-\t - %d,%d\n| \t- \t-\t-\t - |\n| \t- \t-\t-\t - |\n%d,%d\t- \t-\t-\t - %d,%d\n\n",
345 img_out->
wi = img_in->
wi;
346 img_out->
he = img_in->
he;
350 for(i=0;i< (img_in->
he ) ;i++)
352 for(j=0 ; (j< img_in->
wi );j++)
354 if ((color &
RED)!=0)
356 img_out->
Red[i][j] = img_in->
Red[i][j];
359 img_out->
Red[i][j] = 0;
361 if ((color &
GREEN)!=0)
366 img_out->
Green[i][j] = 0;
368 if ((color &
BLUE)!=0)
370 img_out->
Blue[i][j] = img_in->
Blue[i][j];
373 img_out->
Blue[i][j] = 0;
400 CPU_INT32U histo_y_red = 1,histo_y_green,histo_y_blue,histo_y_lum ;
408 CPU_INT32U index,histomaxred=0,histomaxgreen=0,histomaxblue=0,histomaxlum =0;
411 histowidth = (img_in->
wi)/4.5;
417 histoheigh = histowidth / 2 ;
419 histo_y_green = histo_y_red + histowidth + 2;
420 histo_y_blue = histo_y_green + histowidth + 2;
421 histo_y_lum = histo_y_blue + histowidth + 2;
430 img_out->
wi = img_in->
wi;
431 img_out->
he = img_in->
he;
435 for(i=0;i< (img_in->
he ) ;i++)
437 for(j=0 ; (j< img_in->
wi );j++)
442 histomaxred =
maxi(histomaxred,redpixel[index]);
447 histomaxgreen =
maxi(histomaxgreen,greenpixel[index]);
451 histomaxblue =
maxi(histomaxblue,bluepixel[index]);
460 luminancepixel[index]++;
461 histomaxlum =
maxi(histomaxlum,luminancepixel[index]);
467 for(i=0;i<histowidth;i++)
469 redpixel[i] = redpixel[i] * histoheigh / histomaxred ;
470 greenpixel[i] = greenpixel[i] * histoheigh / histomaxgreen ;
471 bluepixel[i] = bluepixel[i] * histoheigh / histomaxblue ;
473 luminancepixel[i] = luminancepixel[i] * histoheigh / histomaxblue ;
478 for(i=0;i< (img_in->
he ) ;i++)
480 for(j=0 ; (j< img_in->
wi );j++)
483 if( ((j>=histo_y_red) && (j<=(histo_y_red+histowidth)))
484 && ((i>=histo_x) && (i<(histo_x+histoheigh)))
487 if(redpixel[j-histo_y_red] >= (i-histo_x))
489 img_out->
Red[i][j] = 255;
490 img_out->
Green[i][j] = 0;
491 img_out->
Blue[i][j] = 0;
494 img_out->
Red[i][j] = (img_in->
Red[i][j])/2;
495 img_out->
Green[i][j] = (img_in->
Green[i][j])/2;
496 img_out->
Blue[i][j] = (img_in->
Blue[i][j])/2;
499 else if( ((j>=histo_y_green) && (j<=(histo_y_green+histowidth)))
500 && ((i>=histo_x) && (i<(histo_x+histoheigh)))
503 if(greenpixel[j-histo_y_green] >= (i-histo_x))
505 img_out->
Red[i][j] = 0;
506 img_out->
Green[i][j] = 255;
507 img_out->
Blue[i][j] = 0;
510 img_out->
Red[i][j] = (img_in->
Red[i][j])/2;
511 img_out->
Green[i][j] = (img_in->
Green[i][j])/2;
512 img_out->
Blue[i][j] = (img_in->
Blue[i][j])/2;
515 else if( ((j>=histo_y_blue) && (j<=(histo_y_blue+histowidth)))
516 && ((i>=histo_x) && (i<(histo_x+histoheigh)))
519 if(bluepixel[j-histo_y_blue] >= (i-histo_x))
521 img_out->
Red[i][j] = 0;
522 img_out->
Green[i][j] = 0;
523 img_out->
Blue[i][j] = 255;
526 img_out->
Red[i][j] = (img_in->
Red[i][j])/2;
527 img_out->
Green[i][j] = (img_in->
Green[i][j])/2;
528 img_out->
Blue[i][j] = (img_in->
Blue[i][j])/2;
531 else if( ((j>=histo_y_lum) && (j<=(histo_y_lum+histowidth)))
532 && ((i>=histo_x) && (i<(histo_x+histoheigh)))
535 if(luminancepixel[j-histo_y_lum] >= (i-histo_x))
537 img_out->
Red[i][j] = 180;
538 img_out->
Green[i][j] = 180;
539 img_out->
Blue[i][j] = 180;
542 img_out->
Red[i][j] = (img_in->
Red[i][j])/2;
543 img_out->
Green[i][j] = (img_in->
Green[i][j])/2;
544 img_out->
Blue[i][j] = (img_in->
Blue[i][j])/2;
549 img_out->
Red[i][j] = img_in->
Red[i][j];
551 img_out->
Blue[i][j] = img_in->
Blue[i][j];
585 img_out->
wi = img_in->
wi;
586 img_out->
he = img_in->
he;
589 for(i=0;i< (img_in->
he ) ;i++)
591 for(j=0 ; (j< img_in->
wi );j++)
598 img_out->
Red[i][j] = Luminance;
599 img_out->
Green[i][j] = Luminance;
600 img_out->
Blue[i][j] = Luminance;
634 img_out->
wi = img_in->
wi;
635 img_out->
he = img_in->
he;
639 for(i_img=0;i_img< (img_in->
he ) ;i_img++)
642 for(j_img=0 ; (j_img< img_in->
wi );j_img++)
645 one_pixel[
c_Red] = 0;
648 for (i=0;i<filtersize;i++)
650 for (j=0;j<filtersize;j++)
652 if( ((i_img-filter_range+i )>=0)
653 && ((j_img-filter_range+j )>=0)
654 && ((i_img-filter_range+i )<img_in->
he)
655 && ((j_img-filter_range+j )<img_in->
wi )
658 if ((color &
BLUE)!=0)
661 + (
CPU_FP64)(img_in->
Blue[i_img-filter_range+i][j_img-filter_range+j]) * tab_filtre[i][j] ;
666 if ((color &
RED)!=0)
669 + (
CPU_FP64)(img_in->
Red[i_img-filter_range+i][j_img-filter_range+j]) * tab_filtre[i][j] ;
672 one_pixel[
c_Red] = 0;
674 if ((color &
GREEN)!=0)
677 + (
CPU_FP64)(img_in->
Green[i_img-filter_range+i][j_img-filter_range+j]) * tab_filtre[i][j] ;
685 img_out->
Red[i_img][j_img] = one_pixel[
c_Red] ;
687 img_out->
Blue[i_img][j_img] = one_pixel[
c_Blue] ;
707 CPU_FP64 value = 0,value1 = 0,value2 = 0;
709 value1 = 1.0/(2.0*
PI*sig*sig);
710 value2 = (0.0 -(x*x+y*y))/(2*sig*sig);
712 value = value1 * exp(value2);
733 for (i=0;i<filtersize;i++)
735 for (j=0;j<filtersize;j++)
737 value =
conv_gauss(i-filter_range,j-filter_range,sigma);
739 tab_filtre[i][j] = value;
743 for (i=0;i<filtersize;i++)
745 for (j=0;j<filtersize;j++)
747 tab_filtre[i][j] = tab_filtre[i][j] / sum;
748 sum2 = sum2 + tab_filtre[i][j];
765 for (i=0;i<filtersize;i++)
767 for (j=0;j<filtersize;j++)
769 tab_filtre[i][j] = 1.0/filtersize;
805 for(i=0;i<filtersize;i++)
807 for(j=0;j<filtersize;j++)
817 for(i=0;i<filtersize;i++)
819 for(j=0;j<filtersize;j++)
829 for(i=0;i<filtersize;i++)
831 for(j=0;j<filtersize;j++)
841 for(i=0;i<filtersize;i++)
843 for(j=0;j<filtersize;j++)
853 for(i=0;i<filtersize;i++)
855 for(j=0;j<filtersize;j++)
889 if(filtersize%2 != 1)
893 filter_range = (filtersize -1)/2;
902 img_out->
wi = img_in->
wi;
903 img_out->
he = img_in->
he;
907 for(i_img=0;i_img< (img_in->
he ) ;i_img++)
910 for(j_img=0 ; (j_img< img_in->
wi );j_img++)
912 if( ((i_img-filter_range )>=0)
913 && ((j_img-filter_range )>=0)
914 && ((i_img-filter_range )<img_in->
he)
915 && ((j_img-filter_range )<img_in->
wi )
919 img_out->
Red[i_img][j_img] =
get_median(img_in->
Red,filter_range,i_img,j_img);
944 for(ii =(0 - filter_range);ii<= filter_range;ii++)
946 for(jj =(0 - filter_range);jj<= filter_range;jj++)
948 table[ii+jj] = table2D[i+ii][j+jj];
951 qsort (table, (filter_range*2+1)*(filter_range*2+1),
sizeof(
CPU_INT08U), (
int (*)(
const void*,
const void*))
compare);
952 median = table[(filter_range*2+1)];
970 for(i=0;i<filtersize;i++)
972 for(j=0;j<filtersize;j++)
974 printf(
"%.2f ",tab_filtre[i][j]);
CPU_VOID init_area(t_area *area, CPU_INT16U maxwidth, CPU_INT16U maxheight)
Initialize an area from 0,0 to given values.
const CPU_FP64 lapl_filter_4[3][3]
CPU_CHAR apply_linfilter(t_img *img_in, CPU_FP64 **tab_filtre, CPU_INT16S filtersize, CPU_INT32U color, t_img *img_out)
Apply a predefined filter on the image.
const CPU_FP64 lapl_filter_2[3][3]
CPU_INT08U FileHeader_size
CPU_INT32U maxi(CPU_INT32U a, CPU_INT32U b)
compare two CPU_INT32U to find the biggest
const CPU_FP64 lapl_filter_1[3][3]
CPU_INT16U vectormodule(t_vect vect)
Give module of a vector, in "pixel".
t_vect highlight_line(t_img *img, t_pixel pix1, t_pixel pix2, CPU_INT32U RGB)
Draw a line on image in a given color.
t_vect pixels_to_vector(t_pixel pix1, t_pixel pix2)
Convert two pixel into a vector.
CPU_INT32S compare(const CPU_VOID *a, const CPU_VOID *b)
Compare function for qsort function.
CPU_VOID display_img_value(t_img *img, CPU_INT16S colors)
Display each color of image in ascii.
t_area pixel_to_area(t_pixel pix)
Convert a pixel into a area of 1 x 1.
Global include file for LLIPS.
CPU_VOID display_filter_value(CPU_FP64 **tab_filtre, CPU_INT08U filtersize)
Display values contained in a square filter.
CPU_VOID highlight_area(t_img *img, t_area *area, CPU_INT32U RGB)
Draw a rectangular area on image in a given color.
CPU_CHAR apply_median_filter(t_img *img_in, CPU_INT16S filtersize, t_img *img_out)
Apply a median filter on an image.
CPU_VOID create_gauss_filter(CPU_FP64 **tab_filtre, CPU_INT16S filtersize, CPU_FP64 sigma)
Create a Gaussian filter used to smooth and image.
CPU_FP64 conv_gauss(CPU_INT16S x, CPU_INT16S y, CPU_FP64 sig)
Gaussian convolution, used to create gaussian filter.
CPU_INT08U FileHeader[MAX_HEADER_size]
CPU_VOID printf_area(t_area *area)
Display area corner coordonate in a console.
const CPU_FP64 lapl_filter_5[5][5]
CPU_VOID create_average_filter(CPU_FP64 **tab_filtre, CPU_INT16S filtersize)
Create an average filter for smoothing.
CPU_CHAR histogram(t_img *img_in, t_img *img_out)
Create an image with a view of histogram (RGBY).
CPU_INT08U get_median(CPU_INT08U **table2D, CPU_INT16S filter_range, CPU_INT16S i, CPU_INT16S j)
Calcultate the median value of an area surrounding a pixel.
const CPU_FP64 lapl_filter_3[3][3]
unsigned short CPU_INT16U
CPU_CHAR luminance(t_img *img_in, t_img *img_out)
Create an image only luminance data (desaturated image)
CPU_INT16S create_laplacian_filter(CPU_FP64 **tab_filtre, CPU_INT08U filtertype)
Create a laplacian filter for edge detection (return matrix must have a size of 3 or 5) ...
CPU_CHAR color_filter(t_img *img_in, t_img *img_out, CPU_INT32U color)
Create an image with only the color provided.