- // Very slow, I know ... but image should be very small
- input->TransformIndexToPhysicalPoint(siter.GetIndex(), C);
- double s = (B[0] - A[0]) * (C[1] - A[1]) - (B[1] - A[1]) * (C[0] - A[0]);
- if (s == 0) {
- if (!keepIfEqual) siter.Set(BG); // on the line, we decide to remove
- }
- if (isPositive) {
- if (s > 0) siter.Set(BG);
- }
- else {
- if (s < 0) siter.Set(BG);
+ if (siter.Get() != BG) { // do only if not BG
+ // Very slow, I know ... but image should be very small
+ input->TransformIndexToPhysicalPoint(siter.GetIndex(), C);
+ double s = (B[0] - A[0]) * (C[1] - A[1]) - (B[1] - A[1]) * (C[0] - A[0]);
+ if (s == 0) {
+ if (!keepIfEqual) siter.Set(BG); // on the line, we decide to remove
+ }
+ if (isPositive) {
+ if (s > 0) siter.Set(BG);
+ }
+ else {
+ if (s < 0) siter.Set(BG);
+ }