Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Centerline of 2D stacked objects

Subject: Centerline of 2D stacked objects

From: Derrick

Date: 4 Jan, 2011 17:28:04

Message: 1 of 8

Hello, I have a question which has eluded me for some time. I am trying to take a tiff stack of binary images (which make up a volume) and find a way to create 'centerlines' through the objects that exists through the volume.
In other words, I have a bunch of objects in each frame and I want to connect objects together to create a solid object through all of the slices of the stack.

I have some basic code I can through up. I have been working with regionprops and some for loops, I just need to take the next step to 'connect' the objects in some sort of metadata perhaps/

Any ideas?

Cheers.

Subject: Centerline of 2D stacked objects

From: Sean de

Date: 4 Jan, 2011 18:05:20

Message: 2 of 8

"Derrick" wrote in message <ifvlb4$jh2$1@fred.mathworks.com>...
> Hello, I have a question which has eluded me for some time. I am trying to take a tiff stack of binary images (which make up a volume) and find a way to create 'centerlines' through the objects that exists through the volume.
> In other words, I have a bunch of objects in each frame and I want to connect objects together to create a solid object through all of the slices of the stack.
>
> I have some basic code I can through up. I have been working with regionprops and some for loops, I just need to take the next step to 'connect' the objects in some sort of metadata perhaps/
>
> Any ideas?
>
> Cheers.

Define "connect"? Do you want to create a true line in the binary stack? In that case I'd use the formula for a line given by x1,x2,y1,y2 to give you the 2-dimensional line, divide by the number of slices apart to figure out the depth increment. Set the values on the line to true. ROUND and SUB2IND would be your friends for this task.

Or if you're viewing it as a PATCH object in a figure with ISOSURFACEs you could use the LINE command directly.

Good Luck
-Sean

Subject: Centerline of 2D stacked objects

From: Derrick

Date: 5 Jan, 2011 16:10:23

Message: 3 of 8

"Sean de " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <ifvnh0$fno$1@fred.mathworks.com>...
> "Derrick" wrote in message <ifvlb4$jh2$1@fred.mathworks.com>...
> > Hello, I have a question which has eluded me for some time. I am trying to take a tiff stack of binary images (which make up a volume) and find a way to create 'centerlines' through the objects that exists through the volume.
> > In other words, I have a bunch of objects in each frame and I want to connect objects together to create a solid object through all of the slices of the stack.
> >
> > I have some basic code I can through up. I have been working with regionprops and some for loops, I just need to take the next step to 'connect' the objects in some sort of metadata perhaps/
> >
> > Any ideas?
> >
> > Cheers.
>
> Define "connect"? Do you want to create a true line in the binary stack? In that case I'd use the formula for a line given by x1,x2,y1,y2 to give you the 2-dimensional line, divide by the number of slices apart to figure out the depth increment. Set the values on the line to true. ROUND and SUB2IND would be your friends for this task.
>
> Or if you're viewing it as a PATCH object in a figure with ISOSURFACEs you could use the LINE command directly.
>
> Good Luck
> -Sean

Thanks for the response. I believe this will help, although to clarify what I mean I will explain:
I have a tif stack in binary(bw) that is filled with cells (roughly line-like pixels of intensity 1) going through all the slices of the tif stack. I am working on creating an orientation mapping in 2D and then using the values of each orientation from each cell do a 'best fit' to connect the cells from above and below any given slice. This I hope will allow me to find an object on a slice, find its orientation (or directionality) and find in the slice above or below what this same object must be in order for it to logically be there in terms of a weight or some arbitrary user defined value. Since objects in each slice of the .TIF stack are not static and are dynamically 'moving' or different from slice to slice this seems to be the way forward. The question is, how does on connect data from one slice to another given n amount of 'objects' per slice in x amount of slices with some
constraint as to the most likely fit for that objects continuance above and below slice x.

Thanks.

Subject: Centerline of 2D stacked objects

From: ImageAnalyst

Date: 5 Jan, 2011 17:16:10

Message: 4 of 8

We still don't know what you mean by "connect". Do you mean "connect"
as in you want some sort of 3D model, like a Delaunay surface model,
or do you just want to align centerlines of some mass using
imtransform to translate each slice? For example, you could find
centroid of the slice and use imtransform to shift each slice to a
predefined center location.

Subject: Centerline of 2D stacked objects

From: Derrick

Date: 5 Jan, 2011 17:56:20

Message: 5 of 8

I apologize for the difficulty or vagueness of my response. I suppose what I mean by 'connect' is to count each object found via centroid per slice as a unique object. Objects in hight or lower slices that overlap via area or centroid proximity will be defined as the same object in the starting slice. For a strict example if there are 30 objects per slice in each slice, I want to have only 30 objects that are in the entire volume. The slices each contain the same structures at different depths. Thus they are connected in the sense that when all the id#s for each object are counted the objects themselves are present in multiple slices.

Subject: Centerline of 2D stacked objects

From: ImageAnalyst

Date: 5 Jan, 2011 18:07:25

Message: 6 of 8

Well, heck, that's easy. Just make sure all your slices are in in 3D
array, binarize your 3D image, then call bwlabel or bwconncomp.

Subject: Centerline of 2D stacked objects

From: Derrick

Date: 6 Jan, 2011 18:13:04

Message: 7 of 8

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <fd376565-d92b-4b7e-af99-8a5d9b5600a3@s9g2000vby.googlegroups.com>...
> Well, heck, that's easy. Just make sure all your slices are in in 3D
> array, binarize your 3D image, then call bwlabel or bwconncomp.

I am using version 7.5.0 (R2007b), so I do not believe there is a bwconncomp function. In addition, bwlabeln would be the only way to support this, but do I still need to use a regionprops (or some bwarea or something) to get something out of the data?

On a unrelated note, how does on display this data using implay?
Here is some code to load a 3d array then try to use regionprops...

I= zeros([2496 1000 30],'uint8'); % preallocate 3-D array
for S=1:30
 [I(:,:,S),map] = imread('Stack30.tif',S);
end
%Convert to Binary
BW = bwlabeln(I);

s = regionprops(BW,I, {'Centroid'});

for k = 1 : numObj
      plot(s(k).Centroid(1), s(k).Centroid(2), 'bo');
end
implay(S); <---- confused here

Subject: Centerline of 2D stacked objects

From: ImageAnalyst

Date: 6 Jan, 2011 19:56:41

Message: 8 of 8

If you just want a count, you only need bwlabeln(). If you want
measurements, then you need regionprops(). You don't use implay there
- not sure what you were trying to accomplish. S is probably 30 or 31
- left over from your for loop over capital S in the beginning of your
code. You also don't enclose 'Centroid' in braces when sending it to
regionprops().

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us