1 //============================================================================ 2 // Copyright (c) Kitware, Inc. 3 // All rights reserved. 4 // See LICENSE.txt for details. 5 // 6 // This software is distributed WITHOUT ANY WARRANTY; without even 7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 8 // PURPOSE. See the above copyright notice for more information. 9 //============================================================================ 10 11 #ifndef vtk_m_filter_ImageMedian_h 12 #define vtk_m_filter_ImageMedian_h 13 14 #include <vtkm/filter/FilterField.h> 15 16 /// \brief Median algorithm for general image blur 17 /// 18 /// The ImageMedian filter finds the median value for each pixel in an image. 19 /// Currently the algorithm has the following restrictions. 20 /// - Only supports a neighborhood of 5x5x1 or 3x3x1 21 /// 22 /// This means that volumes are basically treated as an image stack 23 /// along the z axis 24 /// 25 /// Default output field name is 'median' 26 namespace vtkm 27 { 28 namespace filter 29 { 30 class ImageMedian : public vtkm::filter::FilterField<ImageMedian> 31 { 32 int Neighborhood = 1; 33 34 public: 35 using SupportedTypes = vtkm::TypeListScalarAll; 36 ImageMedian()37 VTKM_CONT ImageMedian() { this->SetOutputFieldName("median"); } 38 Perform3x3()39 VTKM_CONT void Perform3x3() { this->Neighborhood = 1; }; Perform5x5()40 VTKM_CONT void Perform5x5() { this->Neighborhood = 2; }; 41 42 43 template <typename T, typename StorageType, typename DerivedPolicy> 44 VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input, 45 const vtkm::cont::ArrayHandle<T, StorageType>& field, 46 const vtkm::filter::FieldMetadata& fieldMetadata, 47 const vtkm::filter::PolicyBase<DerivedPolicy>&); 48 }; 49 } 50 } // namespace vtkm::filter 51 52 #include <vtkm/filter/ImageMedian.hxx> 53 54 #endif //vtk_m_filter_ImageMedian_h 55