| @@ 31-55 (lines=25) @@ | ||
| 28 | import numpy as np |
|
| 29 | from larix.methods.misc import MEDIAN_FILT |
|
| 30 | ||
| 31 | @register_plugin |
|
| 32 | class MedianFilter(BaseMedianFilter, CpuPlugin): |
|
| 33 | ||
| 34 | def __init__(self): |
|
| 35 | super(MedianFilter, self).__init__("MedianFilter") |
|
| 36 | ||
| 37 | def process_frames(self, data): |
|
| 38 | input_temp = data[0] |
|
| 39 | indices = np.where(np.isnan(input_temp)) |
|
| 40 | input_temp[indices] = 0.0 |
|
| 41 | if (self.parameters['dimension'] == '3D'): |
|
| 42 | if (self.parameters['pattern'] == 'VOLUME_XY'): |
|
| 43 | input_temp =np.swapaxes(input_temp,0,2) |
|
| 44 | if ((self.parameters['pattern'] == 'VOLUME_XZ') or (self.parameters['pattern'] == 'SINOGRAM')): |
|
| 45 | input_temp =np.swapaxes(input_temp,0,1) |
|
| 46 | result = MEDIAN_FILT(input_temp.copy(order='C'), self.parameters['kernel_size']) |
|
| 47 | if (self.parameters['dimension'] == '3D'): |
|
| 48 | if (self.parameters['pattern'] == 'VOLUME_XY'): |
|
| 49 | result =np.swapaxes(result,0,2) |
|
| 50 | if ((self.parameters['pattern'] == 'VOLUME_XZ') or (self.parameters['pattern'] == 'SINOGRAM')): |
|
| 51 | result =np.swapaxes(result,0,1) |
|
| 52 | return result |
|
| 53 | ||
| 54 | def set_options(self, cfg): |
|
| 55 | return cfg |
|
| 56 | ||
| @@ 28-49 (lines=22) @@ | ||
| 25 | import numpy as np |
|
| 26 | from larix.methods.misc import MEDIAN_DEZING |
|
| 27 | ||
| 28 | @register_plugin |
|
| 29 | class Dezinger(BaseMedianFilter, CpuPlugin): |
|
| 30 | ||
| 31 | def __init__(self): |
|
| 32 | super(Dezinger, self).__init__("Dezinger") |
|
| 33 | ||
| 34 | def process_frames(self, data): |
|
| 35 | input_temp = data[0] |
|
| 36 | indices = np.where(np.isnan(input_temp)) |
|
| 37 | input_temp[indices] = 0.0 |
|
| 38 | if (self.parameters['dimension'] == '3D'): |
|
| 39 | if (self.parameters['pattern'] == 'VOLUME_XY'): |
|
| 40 | input_temp =np.swapaxes(input_temp,0,2) |
|
| 41 | if ((self.parameters['pattern'] == 'VOLUME_XZ') or (self.parameters['pattern'] == 'SINOGRAM')): |
|
| 42 | input_temp =np.swapaxes(input_temp,0,1) |
|
| 43 | result = MEDIAN_DEZING(input_temp.copy(order='C'), self.parameters['kernel_size'], self.parameters['outlier_mu']) |
|
| 44 | if (self.parameters['dimension'] == '3D'): |
|
| 45 | if (self.parameters['pattern'] == 'VOLUME_XY'): |
|
| 46 | result =np.swapaxes(result,0,2) |
|
| 47 | if ((self.parameters['pattern'] == 'VOLUME_XZ') or (self.parameters['pattern'] == 'SINOGRAM')): |
|
| 48 | result =np.swapaxes(result,0,1) |
|
| 49 | return result |
|
| 50 | ||