Login  Register

Re: Help dividing area measures lengthwise

Posted by sibert on Jun 08, 2013; 6:42am
URL: http://imagej.273.s1.nabble.com/Help-dividing-area-measures-lengthwise-tp5003289p5003291.html

It isn't exactly clear to me what you are looking for or what the
difficulty is.  Perhaps something like this macro would be useful for you?

   orig = roiManager("index"); //gives index of current selection
   array = newArray(orig,roiManager("
count")-1); //initialize array variable
   getSelectionBounds(x,y,w,h); //returns rectangle containing original ROI
   width = w/5; //divide width into 5 even slices

   function myFunction(foo, bar) {

      makeRectangle(foo,y,width,h); //draw rectangle encompassing 1/5th
width of original
      roiManager("Add"); //add rectangle to ROI manager
      bar[1] += 1; //add index of new rectangle to array
      roiManager("select", bar); //select array
      roiManager("AND"); //find overlap of original and new rectangle
      roiManager("Add"); //add new ROI containing only overlap
      roiManager("deselect"); //deselect all ROIs
      roiManager("select", bar[1]); //select 1/5th rectangle
      roiManager("Delete"); //delete 1/5th rectangle
      return bar[1]
   }

   for (i=0; i<5; i++) {

      array[1] = myFunction(x+(i*width), array);

   }

   roiManager("deselect"); //deselect all ROIs
   roiManager("Measure"); //measure all ROIs (original and each 5th)


On Fri, Jun 7, 2013 at 3:56 PM, Madi Feil <[hidden email]> wrote:

> I am looking for some help trying to make a specific type of area measure.
> The problem is this: I have an irregular shape that goes from left to right
> lengthwise. What I would like to be able to do is divide the shape into 5
> even pieces lengthwise, and then measure only the area of the shape that is
> within each of the five segments. When doing this by drawing boxes around
> segments, some of the area is lost due to the lines which restrict us from
> selecting the full area within the section. I believe there should be a
> simple way to do this, and would appreciate if anyone has guidance!
>
> Thanks
> - [hidden email]
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html