4
$\begingroup$

I'm working on a method for measuring the relative lengths of the objects, with the intention of showing that the objects are longer in the center of the image that at the top/bottom.

The image is binarized, with some small dots that look like noise. Measuring the object lengths is made more difficult by the fact that some are broken. (I can use dilation to fix this)

ImageTake[b, {390, 660}, {733, 1016}] // ColorNegate

TOP

enter image description here

BOTTOM

The original image is taken from the blue channel and looks almost identical to the above

A quick method I have tried is to use the ComponentsMeasurements[] function that can return the longest axis of the best shape ellipse - but I'm not sure if that function works on the individual objects in the image.

Question 1 - Does the above method measure the best fit ellipse for each object (line) or does it do for groups of lines in the image instead?

Question 2 - I was going to use a iterative search in each row to identify the start end end locations for each object for measuring their relative lengths (longest axis in pixels). Doing this for all objects is not necessary, only to show that objects get longer towards the centre of the image. If you have a better idea then I would be very grateful if you would share your thoughts.

Regards,


Thanks Carmullion. I would prefer not to use ComponentMeasurements as I am not sure if it measures individuals or small groups of objects (used an image with different dimensions to get the following results):

test3 = ComponentMeasurements[MorphologicalComponents[bResize], "Length"];

ListPlot[data, PlotRange -> {{0, 397}, {0, 35}}, AxesLabel -> {"Height/pxls", "Length"}]

Small objects (noise) accounts for the points that span the scatter plot close to the axes. I can get rid / minimize these by adjusting the Binarize parameter

![enter image description here][2]

$\endgroup$
3
  • $\begingroup$ Can you put your original image? Can you be more specific in you question. What properties you would like to get for each rectangle? Give us some example. $\endgroup$
    – Murta
    Oct 14, 2013 at 23:28
  • $\begingroup$ Hi Murta. Thanks for getting back. I have changed the post and tried to make it clearer. Thanks. $\endgroup$
    – user10003
    Oct 14, 2013 at 23:49
  • $\begingroup$ Are you still looking for an answer? If you are, you should probably define what the 'objects' are - I was assuming that the different colors in the Colorize were showing the objects - but are you looking for subdivisions of those? $\endgroup$
    – cormullion
    Oct 15, 2013 at 12:26

1 Answer 1

6
$\begingroup$

You can try making the objects of interest white, then finding the components:

mc = MorphologicalComponents[
          MorphologicalBinarize[ColorNegate[i]]];
Colorize[mc]

morphological components

measurements = ComponentMeasurements[mc, {"CaliperLength", "Centroid"}]

{1 -> {3.16228, {111.25, 270.25}}, 2 -> {2.23607, {171., 270.5}},
 3 -> {5.83095, {152.688, 261.938}}, 4 -> {11.1803, {96.125, 254.375}}, ...

From here, you should be able to plot the results.

widthdata = {First[#1], Last[#1[[2]]]} & /@ measurements[[All, 2]]

ListPlot[widthdata, PlotMarkers -> {Automatic, Medium}]

listplot

which is probably not the best way of presenting the data, but at least it suggests that the longer objects are closer to the centre.

$\endgroup$
3
  • $\begingroup$ Hi Cormullion - really appreciate you getting back. I did try a similar approach (below) but I wasn't really sure if the ComponentsMeasurements was identifying small clusters or individual objects. $\endgroup$
    – user10003
    Oct 15, 2013 at 8:40
  • $\begingroup$ You have a response below (see deleted post). $\endgroup$
    – rm -rf
    Oct 18, 2013 at 13:35
  • $\begingroup$ @rm-rf thanks. I think OP must do some more work on the question. $\endgroup$
    – cormullion
    Oct 18, 2013 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.