Git Product home page Git Product logo

findrectanglesinbinary2dmatrix's Introduction

FindRectanglesInBinary2DMatrix

a C++ program to find all rectangles containing binary sub-matrices with all 0s and return their areas, heights and widths. This C++ program uses Largest Rectangular Area In Histogram Algorithm and it is inspired from a python-3 version written by tommy carstensen ( https://stackoverflow.com/a/30418912).
The program print row, column indices of four corners points of each rectangle with all 0s detected in a sub-matrix. The 0s belonging to theses rectangles are shown in red color. .
The First detected rectangle with id=0 is the largest one.

To compile the program, only to do is to open new Linux terminal and put the following command:
g++ -O2 FindRectanglesInBinary2DMatrix.cc -o FindRectanglesInBinary2DMatrix

To run the program, you should type:
./FindRectanglesInBinary2DMatrix 2dbinarymatrix_file.txt numberOfColumns

Here a demonstrative example, the file 2dbinary_matrix.txt contains the following matrix:

1 0 0 0 0 0 1
0 0 0 0 0 0 1
1 1 0 0 0 0 1
0 1 1 1 0 0 0
0 1 1 1 0 0 0
1 1 1 0 0 1 1
1 1 1 0 0 1 1
0 0 1 1 1 1 1

As we can see the number of columns is 7 whereas the number of rows is 8.

./FindRectanglesInBinary2DMatrix 2dbinary_matrix.txt 7

Afte execution, the output of the program will be as follows:

findrectanglesinbinary2dmatrix's People

Contributors

el-bakkali-jaafar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.