[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] [PATCH] fix incorrect behavior and performance in mask.get_bounding_rects()
- To: pygame-users@xxxxxxxx
- Subject: [pygame] [PATCH] fix incorrect behavior and performance in mask.get_bounding_rects()
- From: "Nirav Patel" <olpc@xxxxxxxxxxxxxx>
- Date: Sat, 12 Jul 2008 15:28:38 +0900
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sat, 12 Jul 2008 02:28:43 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:mime-version:content-type:x-google-sender-auth; bh=FmAWtXeXnX/6QcXJ1n5DhcZzo5+/KTdh+k7bE1dlpPI=; b=WXsr1xkzbpbflTjMlaenX0uo+8JjeixXkKqEgtTcVLNmzkZGWNP0541kTNedvjGCQg ZP1rULP7Se4BPiAwfA/l1TZEWfHWvid5vjdRv4AB5OvBuV7b14IVQw9WAI7b3CyDlwuy /oF0j6c52OD2VSEb6aBzR6Uno/QRdJ47ePYFM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:mime-version:content-type :x-google-sender-auth; b=OHz7SK+oZVs9nFA1XvUny4X5tDYFUJQ50P+N7Dh2BAaG7ZaKev5+eoAri1DGB3riEN a8gEKyr0z5BZEyU4hHryZSlTe7/dOC5GJ9tbdrhhCNVi84FCTDOPAjjy8+hF5Szv7lot icDymp+9iYtsKTva7GuAQQcU7T/KtQlATXt7E=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
In testing some computer vision stuff I was writing, I found that
mask.get_bounding_rects() often split a connected component into
multiple bounding boxes. Specifically in the following case:
0011
1111
It would split the 11 in the first row and the 1111 in the second row
into separate connected components, and therefore separate bounding
boxes.
I wrote a new version of it based on the algorithm I used in
mask.connected_component. It correctly detects connected components,
and there is also a side benefit of an, on average, 2x increase in
performance.
I attached the functions that I changed, and the full mask.c is
available in my repo, though it also contains other functions that I'm
proposing for 1.9.
http://git.n0r.org/?p=pygame-nrp;a=blob;f=src/mask.c
Nirav
Attachment:
get_bounding_rects
Description: Binary data