Polygon Detection

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Polygon Detection

gabian82
Hello all,

I am trying to detect polygon shape from my picture. Are there some ways to extract polygon shape from my picture. I will attache an example of my picture. I greatly appreciate for some help.

Reply | Threaded
Open this post in threaded view
|

Re: Polygon Detection

Michael Schmid
Hi Gabian,

the human eye+brain combination has been optimized in a massively parallel
evolution-type optimization algorithm for millions of years, nevertheless
I am not certain which lines to select in your image, and which to ignore.
So don't expect too much from image processing algorithms that have a much
shorter history ;-)

Anyhow, I think that you should probably do some more processing before
thresholding. I have tried smoothing your image to undo the thresholding
and at least I could make the lines stand out more clearly:

rename("Montage.jpg");
run("Smooth");
run("32-bit");
run("Duplicate...", "title=Montage-1.jpg");
run("Variance...", "radius=2");
selectWindow("Montage.jpg");
run("Duplicate...", "title=Montage-2.jpg");
run("Gaussian Blur...", "sigma=2");
run("Convolve...", "text1=[-1 -1 -1 -1 -1\n-1 -1 -1 -1 -1\n-1 -1 24 -1
-1\n-1 -1 -1 -1 -1\n-1 -1 -1 -1 -1\n] normalize");
run("Multiply...", "value=-10");
imageCalculator("Subtract", "Montage-2.jpg","Montage-1.jpg");
run("Unsharp Mask...", "radius=2 mask=0.60");
run("Subtract Background...", "rolling=.002 light sliding disable");

Some tweaking with the parameters will be necessary for your unthresholded
image.

If you manage to get the lines more clear in a binary image, you may use
'Analyze Particles' to get rid of the small dots (set a suitable range of
size and circularity), and then 'Process>Binary>Skeletonize'.

I am not aware of any plugin that enhances straight lines, although it
would be nice to have one (maybe based on a 3D Hough transform, and with
selectable weights for pixel value and variance along a line). Without
such an algorithm, I think you will have to do the final step to close
your polygons manually.

If manual work is not feasible due to the large number of images, and if
you can get rid of a all of the small dots, an approximation might come
through the following. It needs a thresholded image with the lines as
foreground:

run("Invert");
run("Distance Map");
run("Find Maxima...", "noise=8 output=[Segmented Particles] light");
run("Invert");

The 'noise' threshold should be smaller than the radius of the inscribed
circle of the smallest polygon that can occur. If you have very large
polygons (>512 pixels radius), set the EDM output to 32-bit in the Binary
Options.


Michael

________________________________________________

On Thu, September 12, 2013 10:18, gabian82 wrote:
> Hello all,
>
> I am trying to detect polygon shape from my picture. Are there some ways
> to
> extract polygon shape from my picture. I will attache an example of my
> picture. I greatly appreciate for some help.
> <http://imagej.1557.x6.nabble.com/file/n5004765/Montage-4.jpg>
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Polygon Detection

Kenneth Sloan-2
In reply to this post by gabian82
I have been working with very similar images (well, similar in what I think are the important ways).

Mine are images of cytoskeleton around RPE cells in human retina, if it matters…

My first point is: if you really need polygons, in order to proceed with a larger project, then your best bet
is an interactive program where you can use ImageJ to enhance the image and do your bookkeeping and a "trained observer" to identify the salient features (i.e., draw the polygons).   If, instead, you are looking for a challenging career-length research project involving advanced computer vision and scene analysis techniques, then this is a very appropriate problem domain.

But, assuming that you want to try anyway - here are some ideas.  The features you want to extract from the image are the solid, moderately broad, fairly long and straight objects.  The trick is to design a detector that reliably identifies these (and rejects everything else).  This is well short of "polygons" - but it is a necessary first step.  We are having some initial success with this - the basic idea is to find small coherent hunks of these "walls" and then connect co-linear, overlapping (or very nearly so) pieces into larger ones.  This is very similar to classical edge-element detection followed by edge-linking, except that the lowest level model of "edge" is slightly different.

Once you can get a reasonably clean collection of "wall segments", it is time to leave the image domain and step (up?) into the symbolic domain.  You will need a model of your prototypical "polygon".  Do you have a priori expectations of the size?  the number of sides? the range of values for the length of a side?  The more you know about the reality you are imaging, the better job you will do of taking the broken sketches of polygons that you have extracted (above) and producing a collection of polygons.  A key problem here will be the "broken edges".  You will NEVER connect these as long as you stay in the image domain - you need to extract low-to-medium level features and then write a program that "understands" the scene.  Scene understanding is NOT the same thing as image processing!

Finally - what do you want to know about these "polygons"?  Do you need precise locations for the vertices?  Do you really need to know the precise locations of the edges?  If so, it's going to be hard.  If not - perhaps you only want to know "how many" polygons there are, and "roughly where they are" (perhaps characterized by the CENTERS of each polygon (or, more precisely, the regions bounded by the polygons.  In that case, you might look into
"distance maps" generated from the cleaned-up images of the walls.  This is what we are doing now - but still augmented by a trained observer who either accepts or edits the answers at this level.

I recommend a series of ImageJ plugins - written in Java (I'm afraid I'm not a good enough macro hacker to do this sort of thing in anything less capable than full-scale Java).

a) work on detecting the "walls" and cleaning up the images.  We are building custom filters to do this.
b) a plugin that allows a trained observer to sketch polygons and do the bookkeeping (this you CAN do with
standard ImageJ features and a macro - but I don't recommend that, because later you will want to do more)
c) a plugin that allows a trained observer to annotate the image with polygon centers.  With luck, you can then feed this to a Voronoi Diagram program to draw polygons around the centers.  These will not PRECISELY match your imaged walls - you will have to decide if this matters to you, or not.
d) a hybrid plugin that first generates an automatic answer to the questions in b) or c), and then allows
the trained observer to edit the result.  

In reasonably clean images, the approach in d) has the most promise - if your goal is to extract information from the images and then actually do something with that information. This is our approach - it is labor intensive at first, but has the advantage that actual science gets done with the (primarily manual) scene analysis.

I expect to have a really good solution to this problem….but probably long after the (first) motivating research project has ended.  At least, that's been my experience for the past 40 years.  The good news is that sometimes a similar project ones along later and one actually gets to use the solution.  Cross your fingers!

--
Kenneth Sloan
[hidden email]


On Sep 12, 2013, at 03:18 , gabian82 <[hidden email]> wrote:

> Hello all,
>
> I am trying to detect polygon shape from my picture. Are there some ways to
> extract polygon shape from my picture. I will attache an example of my
> picture. I greatly appreciate for some help.
> <http://imagej.1557.x6.nabble.com/file/n5004765/Montage-4.jpg>
>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Polygon-Detection-tp5004765.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Polygon Detection

gabian82
In reply to this post by Michael Schmid
Hi Michael,

First, thank you for your great helpful comments.  I tried to work on my image which are some bubbles in a foam. I will send the original image and the result which I obtained after your recommendations. I wanted to ask whether there are some possibilities to create automatically mask on interested bubbles area to measure their area which I want to obtain about size distribution.

Thank you again,
Ladan


Reply | Threaded
Open this post in threaded view
|

Re: Polygon Detection

Michael Schmid
Hi Ladan,

looking at your original, to me it looks like an impossible task to find the boundaries of the bubbles.  What I would try is a different strategy for lighting - avoiding all the reflections of various objects in the room, i.e. taking a photo in a room with no windows and only indirect lighting evenly illuminating the ceiling and all walls.

If all the reflections are gone, maybe something like the following could help:

//noise reduction
run("Thresholded Blur", "radius=1 threshold=10 softness=0.50 strength=3");
//background
run("Subtract Background...", "rolling=30");
//tophat filter
run("Duplicate...", "title=Original-1.jpg");
run("Minimum...", "radius=5");
run("Maximum...", "radius=5");
selectWindow("Original.jpg");
imageCalculator("Subtract create", "Original.jpg","Original-1.jpg");

'Thresholded Blur' is available at
http://imagejdocu.tudor.lu/doku.php?id=plugin:filter:thresholded_blur:start

Nevertheless, it will be difficult because not all bubble walls are aligned with the line of sight to the camera.

Best wishes,

Michael
________________________________________________________________
On Sep 15, 2013, at 14:12, gabian82 wrote:

> Hi Michael,
>
> First, thank you for your great helpful comments.  I tried to work on my
> image which are some bubbles in a foam. I will send the original image and
> the result which I obtained after your recommendations. I wanted to ask
> whether there are some possibilities to create automatically mask on
> interested bubbles area to measure their area which I want to obtain about
> size distribution.
>
> Thank you again,
> Ladan
>
> <http://imagej.1557.x6.nabble.com/file/n5004786/Result.jpg>
> <http://imagej.1557.x6.nabble.com/file/n5004786/Original.jpg>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Polygon Detection

Dakhil
Dear Michael

I am suffering from counting and estimating the cells coverage area in my brightfield images. I am trying with imagej but I have no clue it is the right way to count the cells and roughly estimate the coverage area of these cells. Firstly, I am doing trial and error auto local threshold with different parameters until get something better then using the Analyze particles but it still unbelievable data. Could you please give me a piece of advise to overcome this big issue.

Regards. Haider12.jpg 
Reply | Threaded
Open this post in threaded view
|

Re: Polygon Detection

Dakhil
In reply to this post by gabian82
I am suffering from counting and estimating the cells coverage area in my brightfield images. I am trying with imagej but I have no clue it is the right way to count the cells and roughly estimate the coverage area of these cells. Firstly, I am doing trial and error auto local threshold with different parameters until get something better then using the Analyze particles but it still unbelievable data. Could you please give me a piece of advise to overcome this big issue.
12.jpg