General pointer to start - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: General pointer to start (/thread-27978.html) |
General pointer to start - data4speed - Jun-30-2020 Let's say I have a large rectangular picture & each pixel s either 1 or 0 (white/black). How to write a function which takes 2 parameters: 1. Data structure holding the matix of black & white pixel 2. a tuple(x,y) for the position of the start pixel This function should return the size of black and while area to which that pixel belongs. any idea where to start? RE: General pointer to start - DPaul - Jun-30-2020 Your question is somewhat unclear to me. The first pixel is always at 0,0 And each pixel has 3+1 components, ([A]RGB), in the case of B&W they are (0,0,0) or (255,255,255) You are probably defining the image as a bitmap and that holds the array of pixels. The bitmap has a length and a width in pixels. Paul RE: General pointer to start - data4speed - Jul-01-2020 as an example, given the region of the image below and selecting the pixel in the middle as a starting point (2,2) (in bold), how do I calculate the area to which point (2,2) belongs? 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 1 0 1 0 0 0 0 0 0 RE: General pointer to start - DPaul - Jul-01-2020 Hi , So your question is to find a square region, when the middle is known (and the number of pixels in a row is not even.) Top left is 0,0, (2 - 2 = 0) Bottom right must be 4,4. (2 + 2 =4) 2 nested loops will find every pixel in the area. If you are talking about a selection in a large bitmap, then we do not have enough data. Paul |