evawilson asked . 2020-05-27

How to get the coordinates of each room in a floor plan image through object identification method?

I have a floor plan image which contains objects and walls. I removed all the objects in it so it now contains only walls. Now I want to get the coordinates of each room.
I am new to this platform. Can somebody please help me how to get the coordinates of each room? Or Can I get the end points of each line segment?
This is the code.
 
function [bbox_loc,sign_objects,index1,st,furniture]=classify_objects_test1(I1)
%  clear all;
%  clc;
%  close all;
I_initial=imread("C:\\Users\\User\\Desktop\\tkinter_codes\\floorplans\\ROBIN\\Dataset_3roomsmall\\Cat1_1.jpg");

%I_initial = imread('room_4.png');
I=I_initial;
imshow(I);
SE = strel('square',10);
I = imdilate(I,SE);
SE = strel('square',10);
I = imerode(I,SE);
wall_image=I;

wall = I;
I=I_initial;
wall=im2bw(wall);
imshow(wall);

I=im2bw(I);
I=imcomplement(I);
wall = imcomplement(wall);
I=I-wall;
% imshow(I);
I=imcomplement(I);
SE = strel('square',1);
IM2 = imdilate(I,SE);

IM2 = I;
IM2 = imerode(IM2,SE);

imwrite(IM2,'fl_0sym.tif');


se1=strel('square',8);
intm1=imerode(IM2,se1);
se2=strel('square',4);
intm2=imdilate(intm1,se2);
intm3=imdilate(intm2,se2);
imwrite(intm3,'fl_0sym1.tif');
I = imread('fl_0sym1.tif');
I = imcomplement(I);

J = imfill(I);
J = ~J;

imwrite(J,'blb_0_1.jpg');


figure=I_initial;
[m,n] = size(figure);
figure1 = figure(:,:,[1 1 1]);
figure = im2bw(figure);
[m,n] = size(figure);
image = imread('blb_0_1.jpg');
BW = im2bw(image);
BW = imresize(BW,[m,n]);
BW = ~BW;


%for 4,1,9,8
 SE = strel('square',10);
 BW = imdilate(BW,SE);

%% figure;imshow(BW);
st = regionprops(BW,'BoundingBox');
 shape.Inserter = vision.ShapeInserter('LineWidth',4,'BorderColor','Custom','CustomBorderColor',uint8([255 0 0]));
 
str_ele=strel('disk',1,0);
 for k = 1:length(st)
%  k=1;       
%         for k = 1:1
thisBB = st(k).BoundingBox;
%figure1 = step(shape.Inserter,figure1,bbox_loc{k});
thisBBarea=thisBB(3)*thisBB(4);
if thisBB(3)>20 &&  thisBB(4)>20 
rectangle = int32([thisBB(1),thisBB(2),thisBB(3),thisBB(4)]);


end
 if(thisBBarea >870)
bbox_loc{k}=rectangle;
 
 crop_I_new=imcrop(figure1,rectangle);
 crop_I_new_gray=rgb2gray(crop_I_new);
 crop_I=im2bw(crop_I_new_gray,0.7);
%   figure;imshow(crop_I);
signature{k}=signature_find(crop_I);
if isempty(signature{k})
   
    signature{k}=[99999,99999,99999];
end
    
  figure1 = step(shape.Inserter,figure1,bbox_loc{k});
 end
end     
signature=signature(~cellfun('isempty',signature)); 

save('signature.mat','signature');
signature=load('signature.mat');
sign_objects=load('sign_object2');
for i=1:length(signature.signature)
    for j=1:length(sign_objects.sign_object2)

diff{i,j}=abs(signature.signature{1,i}-sign_objects.sign_object2{j,1}.count);

    
    end
       

end
for(i=1:size(diff,1))
    for(j=1:size(diff,2))
        if(sign_objects.sign_object2{j,1}.count(3)>1000)
            temp1(i,j)=diff{i,j}(1)+diff{i,j}(2);
        else
            temp1(i,j)=diff{i,j}(1)+diff{i,j}(2)+diff{i,j}(3);
        end
    end
end
for(i=1:size(temp1,1))
[temp1_min(i),index1(i)]=min(temp1(i,:));  
disp(sign_objects.sign_object2{index1(i),2});
  furniture{i,1}=sign_objects.sign_object2{index1(i),2}
  figure;imshow(figure1);
bbox_loc=bbox_loc(~cellfun('isempty',bbox_loc)); 
end

for k = 1:length(bbox_loc)
     H= text( double(bbox_loc{k}(1)),double(bbox_loc{k}(2)),sign_objects.sign_object2{index1(k),2});
           set(gcf,'DefaultTextColor','blue')
end
% for i=1:size(diff,1)
%      for j=1:size(diff,2)
% 
%         temp1(i,j)=(diff{i,j}(1));
%         temp2(i,j)=(diff{i,j}(2));
%         temp3(i,j)=(diff{i,j}(3));
% 
% 
%      end
%   [temp1_min(i),index1(i)]=min(temp1(i,:));  
%   disp(sign_objects.sign_object1{index1(i),2});
%   furniture{i,1}=sign_objects.sign_object1{index1(i),2}
% end
I am attaching a zip file which contains files which will be used by this code while running.
This is the floorplan image with objects.
 

This is the image with only walls.

deep learning , matlab

Expert Answer

Prashant Kumar answered . 2024-11-23 14:50:14

One approach is to close all of the doors morphologically:

 

load('Walls')

e=ones(1,105);

A=imclose(imclose(~Image,e),e.');
B=imfill(A,'holes')&~A;

imshow(B)

Now, you can simply use regionprops to get all of the pixel coordinates in each room,

>> Rooms=regionprops(B,'PixelList')

Rooms = 

  3×1 struct array with fields:

    PixelList


Not satisfied with the answer ?? ASK NOW

Frequently Asked Questions

MATLAB offers tools for real-time AI applications, including Simulink for modeling and simulation. It can be used for developing algorithms and control systems for autonomous vehicles, robots, and other real-time AI systems.

MATLAB Online™ provides access to MATLAB® from your web browser. With MATLAB Online, your files are stored on MATLAB Drive™ and are available wherever you go. MATLAB Drive Connector synchronizes your files between your computers and MATLAB Online, providing offline access and eliminating the need to manually upload or download files. You can also run your files from the convenience of your smartphone or tablet by connecting to MathWorks® Cloud through the MATLAB Mobile™ app.

Yes, MATLAB provides tools and frameworks for deep learning, including the Deep Learning Toolbox. You can use MATLAB for tasks like building and training neural networks, image classification, and natural language processing.

MATLAB and Python are both popular choices for AI development. MATLAB is known for its ease of use in mathematical computations and its extensive toolbox for AI and machine learning. Python, on the other hand, has a vast ecosystem of libraries like TensorFlow and PyTorch. The choice depends on your preferences and project requirements.

You can find support, discussion forums, and a community of MATLAB users on the MATLAB website, Matlansolutions forums, and other AI-related online communities. Remember that MATLAB's capabilities in AI and machine learning continue to evolve, so staying updated with the latest features and resources is essential for effective AI development using MATLAB.

Without any hesitation the answer to this question is NO. The service we offer is 100% legal, legitimate and won't make you a cheater. Read and discover exactly what an essay writing service is and how when used correctly, is a valuable teaching aid and no more akin to cheating than a tutor's 'model essay' or the many published essay guides available from your local book shop. You should use the work as a reference and should not hand over the exact copy of it.

Matlabsolutions.com provides guaranteed satisfaction with a commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been empanelled after extensive research and quality check.

Matlabsolutions.com provides undivided attention to each Matlab assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work done at the best price in industry.