Figure 1: Image distorted by half-shades of wires connected
to the pin diode in the centre
Using a pin diode as the beam stop results in peculiar image distortions as is shown in Fig. 1. There are two very thin fibres running in horizontal direction which carry the pin diode. The corresponding distortion can be tolerated. But the two electrical wires connected to the diode curl through the image and cause a considerable distortion. What can we do?
We know that the SOBEL operator, applied to the image, will enhance all the gradients. Using the function sf_maskwire we obtain a fair mask of the gradients in img.
WAVE> smo=img
WAVE> smo.map = MEDIAN( img.map, 10)
WAVE> m = sf_maskwire(img,20,smo)
The first two lines generate a pattern smo, in which the edges have been smoothed. This pattern will internally be used to subtract the alpine landscape underlying the fence, which is generated by the SOBEL operator. "20" is the cut-off level: Where the fence is higher than 20 above the flattened landscape, there is a severe distortion.
WAVE> m = sf_life( m )
WAVE> sf_closing, m
The fence has been very thin. sf_life generates "black points, where there are already many black points". This is like widening the line of the fence by brushing across with a wide brush. sf_closing is the morphological closing operator, which will remove remaining small islands and such clear the mask. The function unwire performs all the steps in one and returns with the mask m:
WAVE> m = unwire( img )
Figure 2: The gradient mask, generated by unwire.pro
The resulting mask is shown in Fig. 2. Now we can remove the distorted areas simply by multiplying the original image by the mask.
WAVE> img2 = img
WAVE> img2.map = img.map * m.map
Figure 3: The pattern after masking the regions with steep
gradients