------------------------------------------------------------------------------ This method performs one pass of the diffusion filter. The inData and outData are assumed to have data type double, and have the same extent.
| 158 | // The inData and outData are assumed to have data type double, |
| 159 | // and have the same extent. |
| 160 | void vtkImageAnisotropicDiffusion2D::Iterate( |
| 161 | vtkImageData* inData, vtkImageData* outData, double ar0, double ar1, int* coreExtent, int count) |
| 162 | { |
| 163 | int idx0, idx1, idx2; |
| 164 | vtkIdType inInc0, inInc1, inInc2; |
| 165 | vtkIdType outInc0, outInc1, outInc2; |
| 166 | int inMin0, inMax0, inMin1, inMax1, inMin2, inMax2; |
| 167 | int min0, max0, min1, max1, min2, max2; |
| 168 | double *inPtr0, *inPtr1, *inPtr2; |
| 169 | double *outPtr0, *outPtr1, *outPtr2; |
| 170 | double th0, th1, th01; |
| 171 | double df0, df1, df01; |
| 172 | double temp, sum; |
| 173 | int idxC, maxC; |
| 174 | |
| 175 | maxC = inData->GetNumberOfScalarComponents(); |
| 176 | inData->GetExtent(inMin0, inMax0, inMin1, inMax1, inMin2, inMax2); |
| 177 | inData->GetIncrements(inInc0, inInc1, inInc2); |
| 178 | outData->GetIncrements(outInc0, outInc1, outInc2); |
| 179 | |
| 180 | // Avoid warnings. |
| 181 | th0 = th1 = th01 = df0 = df1 = df01 = 0.0; |
| 182 | |
| 183 | // Compute direction specific diffusion thresholds and factors. |
| 184 | sum = 0.0; |
| 185 | if (this->Edges) |
| 186 | { |
| 187 | th0 = ar0 * this->DiffusionThreshold; |
| 188 | df0 = 1.0 / ar0; |
| 189 | th1 = ar1 * this->DiffusionThreshold; |
| 190 | df1 = 1.0 / ar1; |
| 191 | // two edges per direction. |
| 192 | sum += 2.0 * (df0 + df1); |
| 193 | } |
| 194 | if (this->Corners) |
| 195 | { |
| 196 | temp = sqrt(ar0 * ar0 + ar1 * ar1); |
| 197 | th01 = temp * this->DiffusionThreshold; |
| 198 | df01 = 1 / temp; |
| 199 | // four corners per plane |
| 200 | sum += 4 * (df01); |
| 201 | } |
| 202 | |
| 203 | if (sum > 0.0) |
| 204 | { |
| 205 | temp = this->DiffusionFactor / sum; |
| 206 | df0 *= temp; |
| 207 | df1 *= temp; |
| 208 | df01 *= temp; |
| 209 | } |
| 210 | else |
| 211 | { |
| 212 | vtkWarningMacro(<< "Iterate: NO NEIGHBORS"); |
| 213 | return; |
| 214 | } |
| 215 | |
| 216 | // Compute the shrinking extent to loop over. |
| 217 | min0 = coreExtent[0] - count; |
no test coverage detected