Divide image into rectangles information in PythonCalling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?How to get the current time in PythonLazy load of images in ListViewDoes Python have a string 'contains' substring method?Image Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition

How to report a triplet of septets in NMR tabulation?

What are these boxed doors outside store fronts in New York?

Is it possible to make sharp wind that can cut stuff from afar?

How long does it take to type this?

Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)

How can bays and straits be determined in a procedurally generated map?

"You are your self first supporter", a more proper way to say it

I see my dog run

A Journey Through Space and Time

What typically incentivizes a professor to change jobs to a lower ranking university?

Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)

Prevent a directory in /tmp from being deleted

Infinite past with a beginning?

"which" command doesn't work / path of Safari?

declaring a variable twice in IIFE

What would the Romans have called "sorcery"?

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?

Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?

Simulate Bitwise Cyclic Tag

How old can references or sources in a thesis be?

Download, install and reboot computer at night if needed

How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?

Why Is Death Allowed In the Matrix?



Divide image into rectangles information in Python


Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?How to get the current time in PythonLazy load of images in ListViewDoes Python have a string 'contains' substring method?Image Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I have a series of images that are nothing more than a series of colored rectangles in a black background
Example:enter image description here. How could I (using PIL in Python 3.7) make a program that would identify these rectangles (xy position, color and size)? Efficiency is not really important, so nested fors are acceptable. Every algorithm I've been able to come up with until now have a lot of flaws and can go wrong in many different ways, or are just WAY too complex and not at all worth it










share|improve this question






























    1















    I have a series of images that are nothing more than a series of colored rectangles in a black background
    Example:enter image description here. How could I (using PIL in Python 3.7) make a program that would identify these rectangles (xy position, color and size)? Efficiency is not really important, so nested fors are acceptable. Every algorithm I've been able to come up with until now have a lot of flaws and can go wrong in many different ways, or are just WAY too complex and not at all worth it










    share|improve this question


























      1












      1








      1








      I have a series of images that are nothing more than a series of colored rectangles in a black background
      Example:enter image description here. How could I (using PIL in Python 3.7) make a program that would identify these rectangles (xy position, color and size)? Efficiency is not really important, so nested fors are acceptable. Every algorithm I've been able to come up with until now have a lot of flaws and can go wrong in many different ways, or are just WAY too complex and not at all worth it










      share|improve this question
















      I have a series of images that are nothing more than a series of colored rectangles in a black background
      Example:enter image description here. How could I (using PIL in Python 3.7) make a program that would identify these rectangles (xy position, color and size)? Efficiency is not really important, so nested fors are acceptable. Every algorithm I've been able to come up with until now have a lot of flaws and can go wrong in many different ways, or are just WAY too complex and not at all worth it







      python image algorithm image-processing python-imaging-library






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 22 at 2:09







      Locked

















      asked Mar 22 at 0:56









      LockedLocked

      316




      316






















          2 Answers
          2






          active

          oldest

          votes


















          1














          You don't need to write any code at all, you can do that with ImageMagick which is installed on most Linux distros and is available for macOS and Windows.



          Just in the Terminal (Command Prompt on Windows), you can run:



          magick convert image.png 
          -define connected-components:verbose=true
          -define connected-components:area-threshold=100
          -connected-components 4 -auto-level output.png


          Sample Output



          Objects (id: bounding-box centroid area mean-color):
          0: 1200x714+0+0 651.2,369.3 703177 srgb(0,0,0)
          164: 1200x86+0+714 599.5,756.5 103200 srgb(255,21,0)
          2: 363x155+80+60 261.0,137.0 56265 srgb(255,255,255)
          26: 127x323+60+302 122.6,463.2 39668 srgb(255,255,255)
          54: 308x109+352+373 505.5,427.0 33572 srgb(255,255,255)
          1: 102x159+641+47 691.5,126.0 16218 srgb(255,255,255)
          53: 79x100+977+371 1016.0,420.5 7900 srgb(0,17,255)


          So, looking at the line starting 0: there is a rectangle measuring 1200x714 starting at 0,0 (top-left corner) with colour black, i.e. srgb(0,0,0).



          Looking at the next line, there is a rectangle measuring 1200x86 starting 714 pixels down from the top-left corner with colour red, i.e. srgb(255,21,0).



          And so on.



          The last line is a rectangle 79x100 positioned at [977,31] with colour blue, i.e. srgb(0,17,255).






          share|improve this answer























          • Well, I would rather have the code print out the UI line directly (something like "button = Button(340, 100, 20, 30, 'Ex. case')"), but thinking about it, since I can (and know how to) run os commands on python, get and parse the output, this is really helpful. Thanks.

            – Locked
            Mar 22 at 23:15



















          1














          I Don't know how far you are OK with OpenCV .



          If your ready to use openCV , you can use the findContours to get the desired things .



          Below is the code:



           import cv2
          readImage= cv2.imread(r"<ImagePath>oKvDi.png")
          img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

          #Code to Find edges of Square using Canny edge detection method and finding Contours and drawing in Back Line

          edges = cv2.Canny(img_gray, 0, 100)
          contours, hierarchy = cv2.findContours(edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

          #Just for your reference to show all rectangles are found
          cv2.drawContours(readImage, contours, -1, (0, 0, 0), 5)
          cv2.imwrite(r"<ImageSavePath>/a.png",readImage)


          Hope this solves your problem






          share|improve this answer























          • Thanks, I have no problem with using OpenCV, just said PIL in the question because I have a better idea of what I'm doing, so how can I get the data about the rectangles? again, I'm pretty much of a newbie in OpenCV. If I got it right contours are the key, but I have little to no idea what do do from here

            – Locked
            Mar 22 at 3:10












          • As you have only rectangles in image , you just print contours to know the co-ordinates

            – ashtav
            Mar 22 at 3:44











          • Well, after using print(contours) in another image with just 1 rectangle, I have this: prntscr.com/n1g2md , and there is the problem, I have no idea how to process all this data. It seems to be split in groups of 7, which is really confusing me

            – Locked
            Mar 22 at 12:51











          • @Locked What actually your are trying to do with that co-ordinate?

            – ashtav
            Mar 22 at 12:53











          • Just to have the top-left co-ordinates and size of the rectangles on the image, and print them, for a UI i'm making, and I don't want to have to re-check every time I change an element's position or size, so I'd just make the UI in a image-editing software, put it into this program, and it would output all I need to know to get the UI the way I want it

            – Locked
            Mar 22 at 13:11












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291381%2fdivide-image-into-rectangles-information-in-python%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You don't need to write any code at all, you can do that with ImageMagick which is installed on most Linux distros and is available for macOS and Windows.



          Just in the Terminal (Command Prompt on Windows), you can run:



          magick convert image.png 
          -define connected-components:verbose=true
          -define connected-components:area-threshold=100
          -connected-components 4 -auto-level output.png


          Sample Output



          Objects (id: bounding-box centroid area mean-color):
          0: 1200x714+0+0 651.2,369.3 703177 srgb(0,0,0)
          164: 1200x86+0+714 599.5,756.5 103200 srgb(255,21,0)
          2: 363x155+80+60 261.0,137.0 56265 srgb(255,255,255)
          26: 127x323+60+302 122.6,463.2 39668 srgb(255,255,255)
          54: 308x109+352+373 505.5,427.0 33572 srgb(255,255,255)
          1: 102x159+641+47 691.5,126.0 16218 srgb(255,255,255)
          53: 79x100+977+371 1016.0,420.5 7900 srgb(0,17,255)


          So, looking at the line starting 0: there is a rectangle measuring 1200x714 starting at 0,0 (top-left corner) with colour black, i.e. srgb(0,0,0).



          Looking at the next line, there is a rectangle measuring 1200x86 starting 714 pixels down from the top-left corner with colour red, i.e. srgb(255,21,0).



          And so on.



          The last line is a rectangle 79x100 positioned at [977,31] with colour blue, i.e. srgb(0,17,255).






          share|improve this answer























          • Well, I would rather have the code print out the UI line directly (something like "button = Button(340, 100, 20, 30, 'Ex. case')"), but thinking about it, since I can (and know how to) run os commands on python, get and parse the output, this is really helpful. Thanks.

            – Locked
            Mar 22 at 23:15
















          1














          You don't need to write any code at all, you can do that with ImageMagick which is installed on most Linux distros and is available for macOS and Windows.



          Just in the Terminal (Command Prompt on Windows), you can run:



          magick convert image.png 
          -define connected-components:verbose=true
          -define connected-components:area-threshold=100
          -connected-components 4 -auto-level output.png


          Sample Output



          Objects (id: bounding-box centroid area mean-color):
          0: 1200x714+0+0 651.2,369.3 703177 srgb(0,0,0)
          164: 1200x86+0+714 599.5,756.5 103200 srgb(255,21,0)
          2: 363x155+80+60 261.0,137.0 56265 srgb(255,255,255)
          26: 127x323+60+302 122.6,463.2 39668 srgb(255,255,255)
          54: 308x109+352+373 505.5,427.0 33572 srgb(255,255,255)
          1: 102x159+641+47 691.5,126.0 16218 srgb(255,255,255)
          53: 79x100+977+371 1016.0,420.5 7900 srgb(0,17,255)


          So, looking at the line starting 0: there is a rectangle measuring 1200x714 starting at 0,0 (top-left corner) with colour black, i.e. srgb(0,0,0).



          Looking at the next line, there is a rectangle measuring 1200x86 starting 714 pixels down from the top-left corner with colour red, i.e. srgb(255,21,0).



          And so on.



          The last line is a rectangle 79x100 positioned at [977,31] with colour blue, i.e. srgb(0,17,255).






          share|improve this answer























          • Well, I would rather have the code print out the UI line directly (something like "button = Button(340, 100, 20, 30, 'Ex. case')"), but thinking about it, since I can (and know how to) run os commands on python, get and parse the output, this is really helpful. Thanks.

            – Locked
            Mar 22 at 23:15














          1












          1








          1







          You don't need to write any code at all, you can do that with ImageMagick which is installed on most Linux distros and is available for macOS and Windows.



          Just in the Terminal (Command Prompt on Windows), you can run:



          magick convert image.png 
          -define connected-components:verbose=true
          -define connected-components:area-threshold=100
          -connected-components 4 -auto-level output.png


          Sample Output



          Objects (id: bounding-box centroid area mean-color):
          0: 1200x714+0+0 651.2,369.3 703177 srgb(0,0,0)
          164: 1200x86+0+714 599.5,756.5 103200 srgb(255,21,0)
          2: 363x155+80+60 261.0,137.0 56265 srgb(255,255,255)
          26: 127x323+60+302 122.6,463.2 39668 srgb(255,255,255)
          54: 308x109+352+373 505.5,427.0 33572 srgb(255,255,255)
          1: 102x159+641+47 691.5,126.0 16218 srgb(255,255,255)
          53: 79x100+977+371 1016.0,420.5 7900 srgb(0,17,255)


          So, looking at the line starting 0: there is a rectangle measuring 1200x714 starting at 0,0 (top-left corner) with colour black, i.e. srgb(0,0,0).



          Looking at the next line, there is a rectangle measuring 1200x86 starting 714 pixels down from the top-left corner with colour red, i.e. srgb(255,21,0).



          And so on.



          The last line is a rectangle 79x100 positioned at [977,31] with colour blue, i.e. srgb(0,17,255).






          share|improve this answer













          You don't need to write any code at all, you can do that with ImageMagick which is installed on most Linux distros and is available for macOS and Windows.



          Just in the Terminal (Command Prompt on Windows), you can run:



          magick convert image.png 
          -define connected-components:verbose=true
          -define connected-components:area-threshold=100
          -connected-components 4 -auto-level output.png


          Sample Output



          Objects (id: bounding-box centroid area mean-color):
          0: 1200x714+0+0 651.2,369.3 703177 srgb(0,0,0)
          164: 1200x86+0+714 599.5,756.5 103200 srgb(255,21,0)
          2: 363x155+80+60 261.0,137.0 56265 srgb(255,255,255)
          26: 127x323+60+302 122.6,463.2 39668 srgb(255,255,255)
          54: 308x109+352+373 505.5,427.0 33572 srgb(255,255,255)
          1: 102x159+641+47 691.5,126.0 16218 srgb(255,255,255)
          53: 79x100+977+371 1016.0,420.5 7900 srgb(0,17,255)


          So, looking at the line starting 0: there is a rectangle measuring 1200x714 starting at 0,0 (top-left corner) with colour black, i.e. srgb(0,0,0).



          Looking at the next line, there is a rectangle measuring 1200x86 starting 714 pixels down from the top-left corner with colour red, i.e. srgb(255,21,0).



          And so on.



          The last line is a rectangle 79x100 positioned at [977,31] with colour blue, i.e. srgb(0,17,255).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 22 at 20:50









          Mark SetchellMark Setchell

          93k784188




          93k784188












          • Well, I would rather have the code print out the UI line directly (something like "button = Button(340, 100, 20, 30, 'Ex. case')"), but thinking about it, since I can (and know how to) run os commands on python, get and parse the output, this is really helpful. Thanks.

            – Locked
            Mar 22 at 23:15


















          • Well, I would rather have the code print out the UI line directly (something like "button = Button(340, 100, 20, 30, 'Ex. case')"), but thinking about it, since I can (and know how to) run os commands on python, get and parse the output, this is really helpful. Thanks.

            – Locked
            Mar 22 at 23:15

















          Well, I would rather have the code print out the UI line directly (something like "button = Button(340, 100, 20, 30, 'Ex. case')"), but thinking about it, since I can (and know how to) run os commands on python, get and parse the output, this is really helpful. Thanks.

          – Locked
          Mar 22 at 23:15






          Well, I would rather have the code print out the UI line directly (something like "button = Button(340, 100, 20, 30, 'Ex. case')"), but thinking about it, since I can (and know how to) run os commands on python, get and parse the output, this is really helpful. Thanks.

          – Locked
          Mar 22 at 23:15














          1














          I Don't know how far you are OK with OpenCV .



          If your ready to use openCV , you can use the findContours to get the desired things .



          Below is the code:



           import cv2
          readImage= cv2.imread(r"<ImagePath>oKvDi.png")
          img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

          #Code to Find edges of Square using Canny edge detection method and finding Contours and drawing in Back Line

          edges = cv2.Canny(img_gray, 0, 100)
          contours, hierarchy = cv2.findContours(edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

          #Just for your reference to show all rectangles are found
          cv2.drawContours(readImage, contours, -1, (0, 0, 0), 5)
          cv2.imwrite(r"<ImageSavePath>/a.png",readImage)


          Hope this solves your problem






          share|improve this answer























          • Thanks, I have no problem with using OpenCV, just said PIL in the question because I have a better idea of what I'm doing, so how can I get the data about the rectangles? again, I'm pretty much of a newbie in OpenCV. If I got it right contours are the key, but I have little to no idea what do do from here

            – Locked
            Mar 22 at 3:10












          • As you have only rectangles in image , you just print contours to know the co-ordinates

            – ashtav
            Mar 22 at 3:44











          • Well, after using print(contours) in another image with just 1 rectangle, I have this: prntscr.com/n1g2md , and there is the problem, I have no idea how to process all this data. It seems to be split in groups of 7, which is really confusing me

            – Locked
            Mar 22 at 12:51











          • @Locked What actually your are trying to do with that co-ordinate?

            – ashtav
            Mar 22 at 12:53











          • Just to have the top-left co-ordinates and size of the rectangles on the image, and print them, for a UI i'm making, and I don't want to have to re-check every time I change an element's position or size, so I'd just make the UI in a image-editing software, put it into this program, and it would output all I need to know to get the UI the way I want it

            – Locked
            Mar 22 at 13:11
















          1














          I Don't know how far you are OK with OpenCV .



          If your ready to use openCV , you can use the findContours to get the desired things .



          Below is the code:



           import cv2
          readImage= cv2.imread(r"<ImagePath>oKvDi.png")
          img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

          #Code to Find edges of Square using Canny edge detection method and finding Contours and drawing in Back Line

          edges = cv2.Canny(img_gray, 0, 100)
          contours, hierarchy = cv2.findContours(edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

          #Just for your reference to show all rectangles are found
          cv2.drawContours(readImage, contours, -1, (0, 0, 0), 5)
          cv2.imwrite(r"<ImageSavePath>/a.png",readImage)


          Hope this solves your problem






          share|improve this answer























          • Thanks, I have no problem with using OpenCV, just said PIL in the question because I have a better idea of what I'm doing, so how can I get the data about the rectangles? again, I'm pretty much of a newbie in OpenCV. If I got it right contours are the key, but I have little to no idea what do do from here

            – Locked
            Mar 22 at 3:10












          • As you have only rectangles in image , you just print contours to know the co-ordinates

            – ashtav
            Mar 22 at 3:44











          • Well, after using print(contours) in another image with just 1 rectangle, I have this: prntscr.com/n1g2md , and there is the problem, I have no idea how to process all this data. It seems to be split in groups of 7, which is really confusing me

            – Locked
            Mar 22 at 12:51











          • @Locked What actually your are trying to do with that co-ordinate?

            – ashtav
            Mar 22 at 12:53











          • Just to have the top-left co-ordinates and size of the rectangles on the image, and print them, for a UI i'm making, and I don't want to have to re-check every time I change an element's position or size, so I'd just make the UI in a image-editing software, put it into this program, and it would output all I need to know to get the UI the way I want it

            – Locked
            Mar 22 at 13:11














          1












          1








          1







          I Don't know how far you are OK with OpenCV .



          If your ready to use openCV , you can use the findContours to get the desired things .



          Below is the code:



           import cv2
          readImage= cv2.imread(r"<ImagePath>oKvDi.png")
          img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

          #Code to Find edges of Square using Canny edge detection method and finding Contours and drawing in Back Line

          edges = cv2.Canny(img_gray, 0, 100)
          contours, hierarchy = cv2.findContours(edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

          #Just for your reference to show all rectangles are found
          cv2.drawContours(readImage, contours, -1, (0, 0, 0), 5)
          cv2.imwrite(r"<ImageSavePath>/a.png",readImage)


          Hope this solves your problem






          share|improve this answer













          I Don't know how far you are OK with OpenCV .



          If your ready to use openCV , you can use the findContours to get the desired things .



          Below is the code:



           import cv2
          readImage= cv2.imread(r"<ImagePath>oKvDi.png")
          img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

          #Code to Find edges of Square using Canny edge detection method and finding Contours and drawing in Back Line

          edges = cv2.Canny(img_gray, 0, 100)
          contours, hierarchy = cv2.findContours(edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

          #Just for your reference to show all rectangles are found
          cv2.drawContours(readImage, contours, -1, (0, 0, 0), 5)
          cv2.imwrite(r"<ImageSavePath>/a.png",readImage)


          Hope this solves your problem







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 22 at 2:56









          ashtavashtav

          338




          338












          • Thanks, I have no problem with using OpenCV, just said PIL in the question because I have a better idea of what I'm doing, so how can I get the data about the rectangles? again, I'm pretty much of a newbie in OpenCV. If I got it right contours are the key, but I have little to no idea what do do from here

            – Locked
            Mar 22 at 3:10












          • As you have only rectangles in image , you just print contours to know the co-ordinates

            – ashtav
            Mar 22 at 3:44











          • Well, after using print(contours) in another image with just 1 rectangle, I have this: prntscr.com/n1g2md , and there is the problem, I have no idea how to process all this data. It seems to be split in groups of 7, which is really confusing me

            – Locked
            Mar 22 at 12:51











          • @Locked What actually your are trying to do with that co-ordinate?

            – ashtav
            Mar 22 at 12:53











          • Just to have the top-left co-ordinates and size of the rectangles on the image, and print them, for a UI i'm making, and I don't want to have to re-check every time I change an element's position or size, so I'd just make the UI in a image-editing software, put it into this program, and it would output all I need to know to get the UI the way I want it

            – Locked
            Mar 22 at 13:11


















          • Thanks, I have no problem with using OpenCV, just said PIL in the question because I have a better idea of what I'm doing, so how can I get the data about the rectangles? again, I'm pretty much of a newbie in OpenCV. If I got it right contours are the key, but I have little to no idea what do do from here

            – Locked
            Mar 22 at 3:10












          • As you have only rectangles in image , you just print contours to know the co-ordinates

            – ashtav
            Mar 22 at 3:44











          • Well, after using print(contours) in another image with just 1 rectangle, I have this: prntscr.com/n1g2md , and there is the problem, I have no idea how to process all this data. It seems to be split in groups of 7, which is really confusing me

            – Locked
            Mar 22 at 12:51











          • @Locked What actually your are trying to do with that co-ordinate?

            – ashtav
            Mar 22 at 12:53











          • Just to have the top-left co-ordinates and size of the rectangles on the image, and print them, for a UI i'm making, and I don't want to have to re-check every time I change an element's position or size, so I'd just make the UI in a image-editing software, put it into this program, and it would output all I need to know to get the UI the way I want it

            – Locked
            Mar 22 at 13:11

















          Thanks, I have no problem with using OpenCV, just said PIL in the question because I have a better idea of what I'm doing, so how can I get the data about the rectangles? again, I'm pretty much of a newbie in OpenCV. If I got it right contours are the key, but I have little to no idea what do do from here

          – Locked
          Mar 22 at 3:10






          Thanks, I have no problem with using OpenCV, just said PIL in the question because I have a better idea of what I'm doing, so how can I get the data about the rectangles? again, I'm pretty much of a newbie in OpenCV. If I got it right contours are the key, but I have little to no idea what do do from here

          – Locked
          Mar 22 at 3:10














          As you have only rectangles in image , you just print contours to know the co-ordinates

          – ashtav
          Mar 22 at 3:44





          As you have only rectangles in image , you just print contours to know the co-ordinates

          – ashtav
          Mar 22 at 3:44













          Well, after using print(contours) in another image with just 1 rectangle, I have this: prntscr.com/n1g2md , and there is the problem, I have no idea how to process all this data. It seems to be split in groups of 7, which is really confusing me

          – Locked
          Mar 22 at 12:51





          Well, after using print(contours) in another image with just 1 rectangle, I have this: prntscr.com/n1g2md , and there is the problem, I have no idea how to process all this data. It seems to be split in groups of 7, which is really confusing me

          – Locked
          Mar 22 at 12:51













          @Locked What actually your are trying to do with that co-ordinate?

          – ashtav
          Mar 22 at 12:53





          @Locked What actually your are trying to do with that co-ordinate?

          – ashtav
          Mar 22 at 12:53













          Just to have the top-left co-ordinates and size of the rectangles on the image, and print them, for a UI i'm making, and I don't want to have to re-check every time I change an element's position or size, so I'd just make the UI in a image-editing software, put it into this program, and it would output all I need to know to get the UI the way I want it

          – Locked
          Mar 22 at 13:11






          Just to have the top-left co-ordinates and size of the rectangles on the image, and print them, for a UI i'm making, and I don't want to have to re-check every time I change an element's position or size, so I'd just make the UI in a image-editing software, put it into this program, and it would output all I need to know to get the UI the way I want it

          – Locked
          Mar 22 at 13:11


















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291381%2fdivide-image-into-rectangles-information-in-python%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript