float Evaluate(const VoxImage<VoxelT> &buffer, int index) { const Vector<VoxelT> &vbuf = buffer.ConstData(); const Vector<VoxelT> &vker = this->m_KernelData.ConstData(); int img_size = vbuf.size(); int ker_size = vker.size(); int pos; Vector<FPair> mfh(ker_size); for (int i = 0; i < ker_size; ++i) mfh[i].first = vker[i].Value; // kernel value in first for (int ik = 0; ik < ker_size; ik++) { pos = index + vker[ik].Count - vker[this->m_KernelData.GetCenterData()].Count; pos = (pos + img_size) % img_size; mfh[ik].second = vbuf[pos].Value; // image value in second } std::sort(mfh.begin(), mfh.end(), KernelSortAscending()); float conv = 0, ksum = 0; float gamma_smooth; // for (int ik = 0; ik < mAtrim; ik++) // ksum += mfh[ik].first; for (int ik = mAtrim; ik < ker_size - mBtrim; ik++) { gamma_smooth = compute_gauss( fabs(vbuf[index].Value - mfh[ik].second) * 1.E6 ); conv += mfh[ik].first * mfh[ik].second * gamma_smooth; ksum += mfh[ik].first * gamma_smooth; } // for (int ik = ker_size - mBtrim; ik < ker_size; ik++) // ksum += mfh[ik].first; return conv / ksum; }
float Evaluate(const VoxImage<VoxelT> &buffer, int index) { const Vector<VoxelT> &vbuf = buffer.ConstData(); const Vector<VoxelT> &vker = this->m_KernelData.ConstData(); int vox_size = vbuf.size(); int ker_size = vker.size(); int pos; float conv = 0, ksum = 0; for (int ik = 0; ik < ker_size; ++ik) { pos = index + vker[ik].Count - vker[this->m_KernelData.GetCenterData()].Count; pos = (pos + vox_size) % vox_size; conv += vbuf[pos].Value * vker[ik].Value; ksum += vker[ik].Value; } return conv / ksum; }
float Evaluate(const VoxImage<VoxelT> &buffer, int index) { const Vector<VoxelT> &vbuf = buffer.ConstData(); const Vector<VoxelT> &vker = this->m_KernelData.ConstData(); int vox_size = vbuf.size(); int ker_size = vker.size(); int pos; float conv = 0, ksum = 0; float gamma_smooth; for (int ik = 0; ik < ker_size; ++ik) { // if (ik==this->m_KernelData.GetCenterData()) continue; pos = index + vker[ik].Count - vker[this->m_KernelData.GetCenterData()].Count; pos = (pos + vox_size) % vox_size; gamma_smooth = compute_gauss( fabs(vbuf[index].Value - vbuf[pos].Value) * 1.E6 ); conv += vbuf[pos].Value * vker[ik].Value * gamma_smooth; ksum += vker[ik].Value * gamma_smooth; } return conv / ksum; }
int main() { BEGIN_TESTING(VoxImageFilters); VoxImage<TestVoxel> image(Vector3i(20,30,40)); image[Vector3i(10,10,10)].Value = 1; //image[Vector3i(10,10,8)].Value = 1; image.ExportToVtk("test_filter_original.vtk",0); //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// // RPS // { VoxFilterAlgorithmSPR<TestVoxel> filter(Vector3i(2,3,4)); VoxImage<TestVoxel> filtered = image; Vector<float> values; for(int i=0; i < filter.GetKernelData().GetDims().prod(); ++i) { values.push_back(1.); std::cout << values[i] << " "; } std::cout << "\n"; filter.SetImage(&filtered); filter.SetKernelNumericXZY(values); filter.SetABTrim(0,2); filter.GetKernelData().PrintSelf(std::cout); filter.Run(); filtered.ExportToVtk("filter_RPS_out.vtk",0); } { VoxImage<TestVoxel> image(Vector3i(20,30,40)); image[Vector3i(10,10,10)].Value = 1; image[Vector3i(9,10,8)].Value = 2; image.ExportToVtk("test_filter_max_original.vtk",0); VoxFilterAlgorithmCustom<TestVoxel> filter(Vector3i(3,3,4)); Vector<float> values; for(int i=0; i < filter.GetKernelData().GetDims().prod(); ++i) { values.push_back(static_cast<float>(1)); } filter.SetImage(&image); filter.SetKernelNumericXZY(values); filter.SetCustomEvaluate(MaxInVector); filter.Run(); image.ExportToVtk("test_filter_max.vtk",0); } END_TESTING; }