[Image-SIG] Locate The Center of WhiteDot from a Image

Chris Mitchell chris.mit7 at gmail.com
Sat Jan 8 02:24:34 CET 2011


use numpy.  This is taken from a data analysis program I wrote for
analyzing single molecule fluorescent events.  So should be similar to
what you want, a white spot of a given intensity surrounded by noise.
array being your image stored as a numpy array, threshhold is your
value to be greater then

                self.thresharray = np.where(array>threshhold,array, 0)
                for i,v in np.ndenumerate(self.thresharray):
        #                print i,v
                    if v > 0:
                        #find the outside to draw our box around, look
around and color the outside of it green
                        for k in xrange(-2,2):
                            for j in xrange(-2,2):
                                try:
                                    if self.thresharray[i[0]-k,i[1]-j] == 0:
                                        picture.SetRGB(i[1]-j,i[0]-k,0,255,0)
                                except wx._core.PyAssertionError:
                                    pass
                                except IndexError:
                                    pass

On Fri, Jan 7, 2011 at 6:41 PM, Garrett Davis <garrettdaviscpa at gmail.com> wrote:
>  Narendra Sisodiya wrote:
>
>> Now, I want to locate the center of whitedot.
>> I want to get center based on density of whitepixel. basically center
>> where white pixel density is very high.
>> Also, I am applying this algorithm on every frame taken from camera at
>> 2fps. So I want a high speed algorithm.
>
> I would recommend using the getbbox() method, as Christopher Barker has
> already pointed out, along with one of these two techniques:
>
> a) shrinking the size of the image to, say, 16x16, so that the smaller
> 'noise' dots disappear or turn into small grey dots, and then apply, or
> re-apply, the 'point' method discussed in an earlier thread to erase them;
>
> b) using a 'centroid' algorithm to determine a 'center of mass' which would
> not be affected much by small amounts of 'noise'.
>
> Fred Lundh had kindly provided this list with such an algorithm, here:
> http://mail.python.org/pipermail/image-sig/2008-August/005149.html
>
> I use both methods in my application - detection of cars on a racetrack for
> timing and scoring purposes - with good results, and with no performance
> problems when processing larger images at 10 frames/second.
>
> Garrett Davis
>
>
> _______________________________________________
> Image-SIG maillist  -  Image-SIG at python.org
> http://mail.python.org/mailman/listinfo/image-sig
>


More information about the Image-SIG mailing list