Surface from level curves of fuzzy levels in MATLAB

I want to get an n * m matrix with an approximate "height" at each discrete point. The entrance is an image (see the link below) of the contours from the map, each contour line represents an increase or decrease in height by 5 m.

My thoughts:

  • I imported the image as a logical png into a matrix with a name A, which means that each contour line in the matrix is ​​a connected strip of '1, and everything else is 0.
  • My initial thought was to just start in the upper left corner of the matrix, set the height to zero, declare a new matrix height and start by calculating height(:,1)by adding 5 meters each time we meet '1' in the matrix A. Knowing the entire first column, I now start for each row on the left and add 5 m each time we meet "1".
  • I quickly realized that this would not work, because the algorithm cannot figure out if it needs to add or subtract height, i.e. if we run uphill or downhill.
  • If I could somehow approximate the gradient from the intensity of the contour lines, which would be good, although it would always be possible for the climb to be downhill and vice versa, but then I could manually decide what applies to these two cases.

Photo: /img/36affb8eafbaa5ace4861757277795ad.jpg

+4
1

%% Read and binarize the image
I=imread('https://i.stack.imgur.com/pRkiY.jpg'); 
I=rgb2gray(I);
I=I>graythresh(I)*255;

%% Get skeleton, i.e. the lines!
sk=bwmorph(~I,'skel',Inf);

%% lines are too thin, dilate them
dilated=~imdilate(sk, strel('disk', 2, 4));

%% label the image!
test=bwlabel(dilated,8);

imshow(test,[]); colormap(plasma); % use colormap parula if you prefer.

enter image description here

: +1 ( -1) ( , )

: . , . , griddata, , .


: , , !

+2

Source: https://habr.com/ru/post/1688860/


All Articles