Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
General pointer to start
#1
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?
Reply
#2
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
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply
#3
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
Reply
#4
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
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pointer in the right direction? Viking 5 2,676 Apr-22-2020, 06:14 PM
Last Post: Viking
  VM address (C pointer) of Python object Skaperen 1 2,013 Apr-21-2019, 10:57 PM
Last Post: hshivaraj
  trace invalid pointer simon149 7 4,997 Apr-16-2019, 07:05 AM
Last Post: simon149
  What's the difference b/w assigning start=None and start=" " Madara 1 2,276 Aug-06-2018, 08:23 AM
Last Post: buran
  How to use python to receive Gobject.pointer stephenwei 0 2,533 Oct-30-2017, 04:56 PM
Last Post: stephenwei

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020