码迷,mamicode.com
首页 > 其他好文 > 详细

顶帽变化(转载)

时间:2014-12-24 11:28:03      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

  顶帽变化代码(VC实现)

1
void CISLSView::OnTopHatA() 2 { 3 //顶帽变换 4 //李立宗 lilizong@gmail.com 5 //2012-8-23 6 CImage topHatImage; 7 OnOpeningGray(); 8 int maxY = myImage1.GetHeight(); 9 int maxX=myImage1.GetWidth(); 10 byte* pRealData1; 11 byte* pRealData2; 12 pRealData1=(byte*)myImage1.GetBits(); 13 pRealData2=(byte*)myImage2.GetBits(); 14 int pit1=myImage1.GetPitch(); 15 int pit2=myImage2.GetPitch(); 16 int bitCount1=myImage1.GetBPP()/8; 17 int bitCount2=myImage2.GetBPP()/8; 18 int tempMyImage1,tempMyImage2,temp; 19 for (int y=0; y<maxY; y++) { 20 for (int x=0; x<maxX; x++) { 21 tempMyImage1=*(pRealData1+pit1*(y)+(x)*bitCount1); 22 tempMyImage2=*(pRealData2+pit2*(y)+(x)*bitCount2); 23 temp=tempMyImage1-tempMyImage2; 24 *(pRealData2+pit2*(y)+(x)*bitCount2)=temp; 25 *(pRealData2+pit2*(y)+(x)*bitCount2+1)=temp; 26 *(pRealData2+pit2*(y)+(x)*bitCount2+2)=temp; 27 28 } 29 } 30 Invalidate(); 31 } 32 33 34 void CISLSView::OnTopHatB() 35 { 36 //顶帽变换 37 //李立宗 lilizong@gmail.com 38 //2012-8-23 39 CImage topHatImage; 40 OnOpeningGray(); 41 int maxY = myImage1.GetHeight(); 42 int maxX=myImage1.GetWidth(); 43 byte* pRealData1; 44 byte* pRealData2; 45 pRealData1=(byte*)myImage1.GetBits(); 46 pRealData2=(byte*)myImage2.GetBits(); 47 int pit1=myImage1.GetPitch(); 48 int pit2=myImage2.GetPitch(); 49 int bitCount1=myImage1.GetBPP()/8; 50 int bitCount2=myImage2.GetBPP()/8; 51 int tempMyImage1,tempMyImage2,temp; 52 for (int y=0; y<maxY; y++) { 53 for (int x=0; x<maxX; x++) { 54 tempMyImage1=*(pRealData1+pit1*(y)+(x)*bitCount1); 55 tempMyImage2=*(pRealData2+pit2*(y)+(x)*bitCount2); 56 temp=tempMyImage1-tempMyImage2; 57 temp=abs(temp); 58 *(pRealData2+pit2*(y)+(x)*bitCount2)=temp; 59 *(pRealData2+pit2*(y)+(x)*bitCount2+1)=temp; 60 *(pRealData2+pit2*(y)+(x)*bitCount2+2)=temp; 61 62 } 63 } 64 Invalidate(); 65 } 66 67 68 void CISLSView::OnTopHatC() 69 { 70 //顶帽变换 71 //李立宗 lilizong@gmail.com 72 //2012-8-23 73 CImage topHatImage; 74 OnClosingGray(); 75 int maxY = myImage1.GetHeight(); 76 int maxX=myImage1.GetWidth(); 77 byte* pRealData1; 78 byte* pRealData2; 79 pRealData1=(byte*)myImage1.GetBits(); 80 pRealData2=(byte*)myImage2.GetBits(); 81 int pit1=myImage1.GetPitch(); 82 int pit2=myImage2.GetPitch(); 83 int bitCount1=myImage1.GetBPP()/8; 84 int bitCount2=myImage2.GetBPP()/8; 85 int tempMyImage1,tempMyImage2,temp; 86 for (int y=0; y<maxY; y++) { 87 for (int x=0; x<maxX; x++) { 88 tempMyImage1=*(pRealData1+pit1*(y)+(x)*bitCount1); 89 tempMyImage2=*(pRealData2+pit2*(y)+(x)*bitCount2); 90 temp=tempMyImage1-tempMyImage2; 91 *(pRealData2+pit2*(y)+(x)*bitCount2)=temp; 92 *(pRealData2+pit2*(y)+(x)*bitCount2+1)=temp; 93 *(pRealData2+pit2*(y)+(x)*bitCount2+2)=temp; 94 95 } 96 } 97 Invalidate(); 98 } 99 100 101 void CISLSView::OnTopHatD() 102 { 103 //顶帽变换 104 //李立宗 lilizong@gmail.com 105 //2012-8-23 106 CImage topHatImage; 107 OnClosingGray(); 108 int maxY = myImage1.GetHeight(); 109 int maxX=myImage1.GetWidth(); 110 byte* pRealData1; 111 byte* pRealData2; 112 pRealData1=(byte*)myImage1.GetBits(); 113 pRealData2=(byte*)myImage2.GetBits(); 114 int pit1=myImage1.GetPitch(); 115 int pit2=myImage2.GetPitch(); 116 int bitCount1=myImage1.GetBPP()/8; 117 int bitCount2=myImage2.GetBPP()/8; 118 int tempMyImage1,tempMyImage2,temp; 119 for (int y=0; y<maxY; y++) { 120 for (int x=0; x<maxX; x++) { 121 tempMyImage1=*(pRealData1+pit1*(y)+(x)*bitCount1); 122 tempMyImage2=*(pRealData2+pit2*(y)+(x)*bitCount2); 123 temp=tempMyImage1-tempMyImage2; 124 temp=abs(temp); 125 *(pRealData2+pit2*(y)+(x)*bitCount2)=temp; 126 *(pRealData2+pit2*(y)+(x)*bitCount2+1)=temp; 127 *(pRealData2+pit2*(y)+(x)*bitCount2+2)=temp; 128 129 } 130 } 131 Invalidate(); 132 }


 

顶帽变化(转载)

标签:

原文地址:http://www.cnblogs.com/yunzhongniao19915/p/4181758.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!