I have room size calculated from mathematica. Now i have to classify between walls from the imageenter image description here

My second output should be from the source image, i have to classify similar walls based on thickness and categorize as External wall 1, Interior wall2 along with their lengths. I am new to mathematica and any help will be appreciated

source image: enter image description here

I have achieved the canvas layout based on

rooms = ComponentMeasurements[watershed, "BoundingBox"];

growRect[{{x1_, y1_}, {x2_, y2_}}] := 
 Module[{checkRectEmpty, growSingleDirection, growSingleStep, cx, cy, 
   left, top, right, bottom, sizeEstimate, size},
   {cx, cy} = Round[{x1 + x2, y1 + y2}/2];

   checkRectEmpty[{left_, top_, right_, bottom_}] := 
       m, {cx - left ;; cx + right, cy - top ;; cy + bottom}]] == 0;
   growSingleDirection[size_, grow_] := 
    If[checkRectEmpty[size + grow], size + grow, size];
   growSingleStep[size_] := 
    Fold[growSingleDirection, size, IdentityMatrix[4]];

   sizeEstimate = 
    Abs[Round[{x2 - x1, y2 - y1, x2 - x1, y2 - y1}/2 - 20]];
   {left, top, right, bottom} = 
    FixedPoint[growSingleStep, sizeEstimate, 20];
   Rectangle[{cx - left, cy - top}, {cx + right, cy + bottom}]

Please let me know how can i enhance further to achieve the sizes for walls similar to room sizes

  • $\begingroup$ What were your code attempts so far? How do you calculate room sizes as you reference? These sorts of things, like your code attempts, go a long way towards helping others to help answer your question! Welcome to mma.SE :) $\endgroup$ Commented Feb 4, 2020 at 7:51
  • $\begingroup$ @CATrevillian - I have calculated room sizes based on reference provided in link $\endgroup$
    – Aditya
    Commented Feb 4, 2020 at 9:33
  • $\begingroup$ You should add this referenced link to your question in an edit, and provide the code you used to do what you have done so-far. It would be far better to do this and would improve your chances of having the question looked at for people to answer it. As it stands, I am not sure what or how you have done what you have done, and have no way to answer. Others may vote to close this also if it does not appear you have done something with Mathematica. Links and updates provided in the comments can be easily buried and become non-visible a result. $\endgroup$ Commented Feb 4, 2020 at 13:45
  • 1
    $\begingroup$ I have edited. Thanks $\endgroup$
    – Aditya
    Commented Feb 5, 2020 at 13:23
  • $\begingroup$ Does mathematica support detecting wall sizes? $\endgroup$
    – Aditya
    Commented Feb 7, 2020 at 5:26


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.