PasseHautv8

1  /***********************************************************************************  
2      ImAnalyse : software in image processing and image analysis 
3     
4      Copyright (C) 27 avril 2008  <Vincent MORARD> 
5    Version: 2.0 
6      Contact: vincent<POINT>morard<AROBAS>cpe<POINT>fr 
7    Website: http://pistol.petesampras.free.fr 
8   
9      This program is free software: you can redistribute it and/or modify 
10      it under the terms of the GNU General Public License as published by 
11      the Free Software Foundation, either version 3 of the License, or 
12      (at your option) any later version. 
13   
14      This program is distributed in the hope that it will be useful, 
15      but WITHOUT ANY WARRANTY; without even the implied warranty of 
16      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
17      GNU General Public License for more details. 
18   
19      You should have received a copy of the GNU General Public License 
20      along with this program.  If not, see <http://www.gnu.org/licenses/ 
21  **********************************************************************************/ 
22  #include "../CImage.h" 
23   
24   
25   
26  bool CImage::PasseHautv8(int Type,CImage *ImgDest) 
27  { 
28    if(hBmp==0){ 
29      MessageBox(NULL,"Passe Haut v8 : L'image source est vide", 
30            NULL,MB_OK|MB_ICONWARNING); 
31      return 0; 
32    } 
33   
34    if(ImgDest!=0 && ImgDest!=this) 
35      ImgDest->Copy(this); 
36    if(ImgDest==0) 
37      ImgDest=this; 
38   
39    int i,j; 
40    double *PHAUT=new double[Width*Height]; 
41   
42   
43    double *PHAUT_Red,*PHAUT_Green; 
44    if(Type==RGBi) 
45    { 
46      PHAUT_Red=new double[Width*Height]; 
47      PHAUT_Green=new double[Width*Height]; 
48    } 
49   
50    //recupération des pixels 
51    GetBitmapBits(hBmp,Width*Height*4,ucBits); 
52   
53    for(i=1;i<Width-1;i++) 
54      for(j=1;j<Height-1;j++) 
55      { 
56        switch(Type) 
57        { 
58        case RGBi: 
59          PHAUT_Red[(i+j*Width)]=-GetPixel(i-1,j-1,RED) -GetPixel(i,j-1,RED) -GetPixel(i+1,j-1,RED) 
60                      -GetPixel(i-1,j,RED)  +9*GetPixel(i,j,RED)  -GetPixel(i+1,j,RED) 
61                      -GetPixel(i-1,j+1,RED)-GetPixel(i,j+1,RED)  -GetPixel(i+1,j+1,RED); 
62   
63   
64          PHAUT_Green[(i+j*Width)]=-GetPixel(i-1,j-1,GREEN) -GetPixel(i,j-1,GREEN) -GetPixel(i+1,j-1,GREEN) 
65                        -GetPixel(i-1,j,GREEN)  +9*GetPixel(i,j,GREEN)  -GetPixel(i+1,j,GREEN) 
66                        -GetPixel(i-1,j+1,GREEN)-GetPixel(i,j+1,GREEN)  -GetPixel(i+1,j+1,GREEN); 
67   
68          PHAUT[(i+j*Width)]=-GetPixel(i-1,j-1,BLUE) -GetPixel(i,j-1,BLUE) -GetPixel(i+1,j-1,BLUE) 
69                  -GetPixel(i-1,j,BLUE)  +9*GetPixel(i,j,BLUE)  -GetPixel(i+1,j,BLUE) 
70                  -GetPixel(i-1,j+1,BLUE)-GetPixel(i,j+1,BLUE)  -GetPixel(i+1,j+1,BLUE); 
71   
72        break; 
73        default: 
74          PHAUT[(i+j*Width)]=-GetPixel(i-1,j-1,Type) -GetPixel(i,j-1,Type) -GetPixel(i+1,j-1,Type) 
75                  -GetPixel(i-1,j,Type)  +9*GetPixel(i,j,Type)  -GetPixel(i+1,j,Type) 
76                    -GetPixel(i-1,j+1,Type)-GetPixel(i,j+1,Type)  -GetPixel(i+1,j+1,Type); 
77          break; 
78        } 
79      } 
80   
81    switch(Type) 
82    { 
83    case RGBi: 
84      ImgDest->ImgType=RGBi; 
85      for(i=0,j=0;i<Width*Height*4;i+=4,j++) 
86      { 
87        ImgDest->ucBits[i]=Limit((int)PHAUT[j]); 
88        ImgDest->ucBits[i+1]=Limit((int)PHAUT_Green[j]); 
89        ImgDest->ucBits[i+2]=Limit((int)PHAUT_Red[j]); 
90      } 
91      delete []PHAUT_Red; 
92      delete []PHAUT_Green; 
93   
94      break; 
95   
96    default: 
97      ImgDest->ImgType=GRAY; 
98      for(i=0,j=0;i<Width*Height*4;i+=4,j++) 
99      { 
100        ImgDest->ucBits[i]=Limit((int)PHAUT[j]); 
101        ImgDest->ucBits[i+1]=Limit((int)PHAUT[j]); 
102        ImgDest->ucBits[i+2]=Limit((int)PHAUT[j]); 
103   
104      } 
105      break; 
106   
107   
108    } 
109   
110    delete []PHAUT; 
111   
112    SetBitmapBits (ImgDest->hBmp,(Width*Height)*4,ImgDest->ucBits); 
113   
114    return 1; 
115  } 

lien1 lien2 lien3