2
$\begingroup$

I have two distance maps that describe distances from blue segment and the red segment. I need to compute a single weight map that describes transition from blue segment to the red segment. The weight map should have values in the 0-1 range where 0 is one segment and 1 is the other one.

There are the distance maps with the respective segments highlighted:

enter image description here enter image description here

Having $d_{1}$ and $d_{2}$ the distances in the first and second image, I tried the following formula for computing the transition weight map:

$$d=\frac{d_{1}-d_{2}+d_{2max}}{d_{1max}+d_{2max}}$$

where $d_{1max}$, $d_{2max}$ are maximum distances found in the first and second image. The numerator have range $<0, d_{1max}+d_{2max}>$ so the result is in $<0,1>$ range. This resulted in the following map:

enter image description here

However, there are sharp transitions between each segment and the map.

I have also tried multiplicative formula:

$$d=\bar{d_{1}}\cdot (1 - \bar{d_{2}})$$

where $\bar{d_{1}}, \bar{d_{2}}$ are distances normalized to $<0,1>$ range. This resulted in little better transition, but still suffers from the same problem:

enter image description here

Do you have any other ideas how to combine the distance maps to obtain transition map?

$\endgroup$
1
$\begingroup$

An obvious choice would be $\frac{d_1}{d_1+d_2+\epsilon }$, where $\epsilon$ is a small value to prevent division by zero.

Using your images, I get:

top = ColorNegate[Binarize[ImageApply[StandardDeviation, 
           Import["http://i.stack.imgur.com/aFNfB.jpg"]]]];
bottom = ColorNegate[Binarize[ImageApply[StandardDeviation, 
           Import["http://i.stack.imgur.com/Kipvo.jpg"]]]];
tDist = ImageData[DistanceTransform[top]];
bDist = ImageData[DistanceTransform[bottom]];

\[Epsilon] = 10^-10;
Image[tDist/(tDist + bDist + \[Epsilon])] // ImageAdjust

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.