[R] Calculating diameters of cirkels in a picture.

Moshe Olshansky m_olshansky at yahoo.com
Fri Aug 24 04:20:11 CEST 2007


Hi Bart,

One more comment:

You do not really need the morphological closing to
close the "holes" inside the circles. Another
possibility is to reverse the black-and-withe picture,
i.e. make the holes and background be 1 and the
circles 0, label the connected components and then
only the component which touches the boundaries is the
background while all other components are "holes" and
you can make them white (1) in the original
black-and-white image.

--- Moshe Olshansky <m_olshansky at yahoo.com> wrote:

> Hi Bart,
> 
> I have never used image processing software in R (I
> was doing this with Matlab), but here is what I
> would
> have done algorithmically:
> 1) convert the picture to gray-scale
> 2) find a threshold value which separates the
> circles
> from the background and convert your image to black
> and white
> 3) if the circles are far apart use morphological
> closing to fill in small holes inside the circles
> (may
> be do this several times)
> 4) use labeling to split the image into connected
> components
> 5) for each connected component get it's area (the
> number of pixels) and use the formula S = Pi*R^2 to
> find the approximate radii.
> 
> Regards,
> 
> Moshe.
> 
> --- Julian Burgos <jmburgos at u.washington.edu> wrote:
> 
> > Hi Bart,
> > 
> > If you only have 36 circles, the fastest way would
> > be to use some image 
> > processing software and measure the circles "by
> > hand".  One option is to 
> > use ImageJ, which you can download here
> > 
> > http://rsb.info.nih.gov/ij/
> > 
> > Julian
> > 
> > Bart Joosen wrote:
> > > Hi,
> > >
> > > Maybe this is more a programming questions than
> a
> > specific R-project question, but maybe there is
> > someone who can point me in the right direction.
> > >
> > > I have a picture of cirkels which I took with a
> > digital camera.
> > > Now I want to use the diameter of the cirkels on
> > the picture for analysis in R.
> > > I can use pixmap to import the picture, but how
> do
> > I find the outside cirkels and calculate the
> > diameter?
> > > I pointed out that I can use the edci package,
> but
> > then I need to preprocess the data to reduce the
> > points, otherwise it takes a long time, and my
> > computer crashes.
> > >
> > > If you want to see such a picture, I cropped a
> > larger one, and highlighted the cirkel which is of
> > interest.
> > > In a real world, this is a plate with 36
> cirkels,
> > which all should be measured.
> > > www.users.skynet.be/fa244930/fotos/outlined.jpg
> > >
> > >
> > > Thanks for your time
> > >
> > > Bart
> > > 	[[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > R-help at stat.math.ethz.ch mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained,
> > reproducible code.
> > >
> > >
> > 
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained,
> > reproducible code.
> >
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>



More information about the R-help mailing list