CamH
CamH

Reputation: 25

How to Divide Relative Distance into Three Equidistant Regions in MATLAB?

I have two distance maps. One refers to the distance from one point to the outside (starting at 0, ending at a high number reflecting distance from one point). The other is basically equal and opposite (starts at a high number, ends at 0, reflecting distance from the opposite point). There is a point between the two where they are equidistant.

I want to split a central region based on relative distance between these two maps. This is relatively easy if one was only to base this division on the point where the two maps are equidistant, because if the difference between distance map 1 and distance map 2 > 0, then this would qualify as one zone. If the difference between distance map 1 and distance map 2 equal to or < 0, then this would qualify as the other zone. This is displayed in image 3 (Taken from A PDE Approach for Thickness, Correspondence, and Gridding of Annular Tissues, by Yezzi & Prince, 2002).

However, I am trying to do this for three equidistant zones. I am wondering if there is any way this could be achieved using MATLAB code. I am unfortunately not mathematically inclined... however there is this paper [ https://link-springer-com/chapter/10.1007/3-540-47979-1_39 ] that explains how this could be done on a more mathematical & theoretical level.

The rationale for this is because I can create equidistant regions between two points for all participants, instead of employing a fixed unilateral distance that is susceptible to brain changes.

I have so far tried this code:

function Out = test_wmhs_BD(Mask_WMH,Mask_WM,Dmap_Vent,Dmap_Cort)

if ~isequal(size(Mask_WMH),size(Mask_WM),size(Dmap_Vent),size(Dmap_Cort))
    disp('Dimension of inputs must match.');
    Out=[];
    
else
    bd=Dmap_Cort-Dmap_Vent;
    bdThird = bd/3;
    Out((bd < bdThird) && Mask_WMH==1) = 1;
    Out((bdThird <= bd) <= bd-bdThird && Mask_WMH==1) = 2;
    Out((bd > bd-bdThird) && Mask_WMH==1) = 3;
       
end

Where Dmap_Vent refers to one distance map, and Dmap_Cort refers to the other distance map.

I basically tried to split the bilateral distance into thirds, and use conditions to say if the bilateral distance was less than a third, then classify the output as 1, if the bilateral distance was greater than one third but less than two thirds, then classify the output as 2, and if the bilateral distance was greater than two thirds, classify the output as 3.

I was expecting this to work... however I then realised that because the bilateral distance includes a zero crossing point, any division would fail because it isn't mathematically correct! (The function failed).

Edit to include pictures, all of which are screenshots from a paper: "A PDE Approach for Thickness, Correspondence, and Gridding of Annular Tissues", by Yezzi & Prince, 2002.

Image 1: Imagine the greyscale of this distance map represents distance from the central point, with the black border representing 0 distance, and increasing distance with increasing signal intensity:

Image 1: Imagine the greyscale of this distance map represents distance from the central point, with the black border representing 0 distance, and increasing distance with increasing signal intensity

Image 2: Likewise, imagine that the black border around this distance map represents 0 distance, and the distance increases the further from the outer border you go:

Image 2: Likewise, imagine that the black border around this distance map represents 0 distance, and the distance increases the further from the outer border you go

Image 3: The ideal output would be analogous to this image, except instead of two equally-sized "zones" (zone referring to equal spaced regions on either side of the drawn line), there would be three equally sized "zones", separated by two lines:

Image 3: The ideal output would be analogous to this image, except instead of two equally-sized "zones" (zone referring to equal spaced regions on either side of the drawn line), there would be three equally sized "zones", separated by two lines

These maps would be in 3D

Upvotes: 2

Views: 66

Answers (1)

Cris Luengo
Cris Luengo

Reputation: 60444

Let's say your two distance maps are called A and B.

A > B splits the area into two regions, one where you are closer to the first edge, one where you are closer to the other. The two regions should have the same width.

To split into three regions instead, you can scale the distances appropriately. 3*A > 2*B and 2*A > 3*B would split the area at 1/3 and 2/3 of the distance, leading to three equally wide regions.

Upvotes: 1

Related Questions