Identification of rooms in a floorplan

조회 수: 3 (최근 30일)
CHINTALA NIRMAL SRINIVAS
CHINTALA NIRMAL SRINIVAS 2020년 5월 17일
댓글: darova 2020년 5월 21일
I have a floorplan image with only walls. I want to identify the room coordinates of the floorplan.
This code actually closes the doors and identifies the rooms in the floorplan. This works well when shape of the rooms is rectangles. But It does not work well when the shape is either trapezium or L shape. Can somebody help me please?
Also it is not closing all the doors properly.
load('Walls')
e=ones(1,105);
A=imclose(imclose(~Image,e),e.');
B=imfill(A,'holes')&~A;
imshow(B)
  댓글 수: 4
Matt J
Matt J 2020년 5월 19일
And what about the doorways?
CHINTALA NIRMAL SRINIVAS
CHINTALA NIRMAL SRINIVAS 2020년 5월 20일
Not all the doors are closed but if I increase the number in ones() then they are being closed

댓글을 달려면 로그인하십시오.

채택된 답변

darova
darova 2020년 5월 19일
I skeletonized the image and found endpoints with bwmorph. Found shortest distances and connected points
I0 = imread('image.jpeg');
I1 = im2bw(I0); % binarize image
I2 = bwmorph(~I1,'skel',inf); % make thin lines
I3 = bwmorph(I2,'spur',10); % remove spurs
B = bwmorph(I3,'endpoints'); % find free ends (endpoints)
[ii,jj] = find(B); % find rows and columns of endpoints
D = pdist2([ii(:) jj(:)],[ii(:) jj(:)]); % find distances
D(D<1e-3) = nan; % remove zeros
[~,ix] = min(D); % find shortest distances
for i = 1:length(ix)
i1 = ii(i):ii(ix(i));
j1 = jj(i):jj(ix(i));
I3(i1,j1) = 1; % connect door ends
end
I4 = imdilate(I3,ones(15)); % make lines thicker
imshowpair(I0,I4) % display original and modificated images
Result
  댓글 수: 5
CHINTALA NIRMAL SRINIVAS
CHINTALA NIRMAL SRINIVAS 2020년 5월 21일
Yes they always have white backgrounds. How can I get the coordinates of each room if the bounding box is only rectangular in shape. I mean how can I get the coordinates of those rooms which are not in rectangular shape
darova
darova 2020년 5월 21일
You can label image with bwlabel and select each region separately
[L,n] = bwlabel(I);
for i = 1:n
I = L == i;
imshow(I)
pause(0.5)
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by