[pktools] 85/375: adapted mrf in Vector2.cc after personal communication with Guy Thoonen
Bas Couwenberg
sebastic at xs4all.nl
Wed Dec 3 21:54:02 UTC 2014
This is an automated email from the git hooks/post-receive script.
sebastic-guest pushed a commit to branch upstream-master
in repository pktools.
commit 2d275ae53e58dc847f3108dced6b270db75779eb
Author: Pieter Kempeneers <kempenep at gmail.com>
Date: Wed Apr 3 14:27:27 2013 +0200
adapted mrf in Vector2.cc after personal communication with Guy Thoonen
---
src/algorithms/Filter2d.cc | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/algorithms/Filter2d.cc b/src/algorithms/Filter2d.cc
index 3ed1033..fd4ceec 100644
--- a/src/algorithms/Filter2d.cc
+++ b/src/algorithms/Filter2d.cc
@@ -789,6 +789,7 @@ void filter2d::Filter2d::mrf(const ImgReaderGdal& input, ImgWriterGdal& output,
}
}
if(!masked){
+ // if(inBuffer[dimY/2][x]//centre pixel
for(int iclass=0;iclass<m_class.size();++iclass){
if(inBuffer[indexJ][indexI]==m_class[iclass])
potential[iclass]+=1;
@@ -796,14 +797,19 @@ void filter2d::Filter2d::mrf(const ImgReaderGdal& input, ImgWriterGdal& output,
}
}
}
+ double norm=0;
for(int iclass1=0;iclass1<m_class.size();++iclass1){
assert(beta[iclass1].size()==m_class.size());
- for(int iclass2=0;iclass2<m_class.size();++iclass2){
- if(eightConnectivity)
- outBuffer[iclass1][x/down]=exp(-beta[iclass1][iclass2]*(dimX*dimY-1-potential[iclass1]))/(exp(-beta[iclass1][iclass2]*(dimX*dimY-1-potential[iclass1]))+exp(-beta[iclass1][iclass2]*(potential[iclass1])));
- else
- outBuffer[iclass1][x/down]=exp(-beta[iclass1][iclass2]*(dimX+dimY-1-potential[iclass1]))/(exp(-beta[iclass1][iclass2]*(dimX+dimY-1-potential[iclass1]))+exp(-beta[iclass1][iclass2]*(potential[iclass1])));
- }
+ double pot=0;
+ for(int iclass2=0;iclass2<m_class.size();++iclass2)
+ pot+=potential[iclass2]*beta[iclass1][iclass2];
+ double prior=exp(-pot);
+ outBuffer[iclass1][x/down]=prior;
+ norm+=prior;
+ }
+ if(norm){
+ for(int iclass1=0;iclass1<m_class.size();++iclass1)
+ outBuffer[iclass1][x/down]/=norm;
}
}
progress=(1.0+y/down)/output.nrOfRow();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pktools.git
More information about the Pkg-grass-devel
mailing list