Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Circular neighborhood for ImageApply

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115022] Circular neighborhood for ImageApply
  • From: Adrian Boyko <adrianboyko at gmail.com>
  • Date: Tue, 28 Dec 2010 06:52:36 -0500 (EST)

Usual disclaimer:  I'm a casual home user of Mathematica, so please 
forgive what might seem like silly questions.

I'm using ImageFilter like this:

      ImageFilter[1.0*Count[Flatten[#], 0.]/Length[Flatten[#]] &, 
ColorConvert[binaryImage, "Grayscale"], r]

I.e. I'm trying to replace each pixel with the ratio of 0 pixels and 1 
pixels in its square neighborhood.  I'm doing this because I'm trying to 
find the center of disks (of an expected radius) in a scanned image, and 
this works reasonably well.  But, since I'm actually looking for disks I 
think it would be better to find the ratio in the pixel's _disk_ (not 
square) neighborhood.  It seems like there ought to be a simple way to 
work DiskMatrix[3] into my expression, and extra processing time isn't 
an issue.

Any ideas?  Is there some operator I can apply to # and DiskMatrix[3] 
which would mask out the neighborhood values outside the disk?  I think 
ImageMultiply ought to work like an ImageAnd if all my pixel values are 
0 or 1, but I haven't had any luck with it.

On a tangent, I have another filter that ought to be looking for the 
ratio in a ring neighborhood between r1 and r2.  Maybe the answer to my 
first question will also tell me how to combine DiskMatrix[r1] and 
DiskMatrix[r2] to get RingMatrix[r1,r2].

Any help will be greatly appreciated.

Thanks,
Adrian

P.S.  I'm considering the upgrade to Mathematica 8.  Since I have a 
CUDA-compatible graphics card, is it safe to assume that version 8 will 
_automatically_ utilize it when executing these sorts of operations?  Or 
would I need to code differently to take advantage of it?


  • Prev by Date: Re: Mathematica daily WTF
  • Next by Date: Re: Counting
  • Previous by thread: Re; newbie list question
  • Next by thread: Re: Circular neighborhood for ImageApply