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:
2D Interpolation Using 3D Information

Subject: 2D Interpolation Using 3D Information

From: Erik

Date: 20 Jul, 2010 20:24:04

Message: 1 of 14

The simplest way to describe my problem is using a cylinder. I essentially have cross sections of a cylinder at discrete, regular intervals along the Z axis. The Z axis is defined here as the axis running through the center of the cylinder length wise. Looking at an XY cross section you would see a circle.

The cross sections in my case however have been defined by me using a masking program. All cross sections are the convex hull of a set of points and are not a perfect circle. Additionally, the "cylinder" is tapered such that it is wider at the top than at the bottom.

Occasionally, my current masking program will not define the slice correctly and I end up with a line through part of the circle. In an extreme case, it would look like a half circle due to the line cutting through the cross section.

I want to attempt to fill in the rest of this circle that has been cut off using interpolation. I have already implemented 2D interpolation by defining the points using polar coordinates relative to the center. I then interpolate using "interp1" with input arguments as "interp1(theta, radius, [0:0.5:2*pi], 'cubic')". Variable 'theta' and 'radius' are column vectors and have been replicated on either side such that boundary conditions are met.

While this works decently, it seems that there is information from other slices that would benefit the interpolation here. At the end of my masking program, I have a large matrix in which I store all of the XYZ coordinates defining the boundary of the tapered cylinder. I would like to be able to use the information from other slices to interpolate a single slice. I eventually need to end up with the correct XYZ coordinates where no slice will contain a cut.

Any help with this problem will be much appreciated. I already have looked at interp2 and interp3, but was unable to figure out how to apply them to my situation. If you believe one of these is the answer to this problem, please provide a specific example of input arguments. If you would like additional information, just let me know.

Thanks

Subject: 2D Interpolation Using 3D Information

From: us

Date: 20 Jul, 2010 20:42:04

Message: 2 of 14

"Erik " <stevesmith121@gmail.com> wrote in message <i250l4$4h8$1@fred.mathworks.com>...
> The simplest way to describe my problem is using a cylinder. I essentially have cross sections of a cylinder at discrete, regular intervals along the Z axis. The Z axis is defined here as the axis running through the center of the cylinder length wise. Looking at an XY cross section you would see a circle.
>
> The cross sections in my case however have been defined by me using a masking program. All cross sections are the convex hull of a set of points and are not a perfect circle. Additionally, the "cylinder" is tapered such that it is wider at the top than at the bottom.
>
> Occasionally, my current masking program will not define the slice correctly and I end up with a line through part of the circle. In an extreme case, it would look like a half circle due to the line cutting through the cross section.
>
> I want to attempt to fill in the rest of this circle that has been cut off using interpolation. I have already implemented 2D interpolation by defining the points using polar coordinates relative to the center. I then interpolate using "interp1" with input arguments as "interp1(theta, radius, [0:0.5:2*pi], 'cubic')". Variable 'theta' and 'radius' are column vectors and have been replicated on either side such that boundary conditions are met.
>
> While this works decently, it seems that there is information from other slices that would benefit the interpolation here. At the end of my masking program, I have a large matrix in which I store all of the XYZ coordinates defining the boundary of the tapered cylinder. I would like to be able to use the information from other slices to interpolate a single slice. I eventually need to end up with the correct XYZ coordinates where no slice will contain a cut.
>
> Any help with this problem will be much appreciated. I already have looked at interp2 and interp3, but was unable to figure out how to apply them to my situation. If you believe one of these is the answer to this problem, please provide a specific example of input arguments. If you would like additional information, just let me know.
>
> Thanks

since it's a cylinder
- why interpolate the circles(?)...
- why not interpolate the missing Zs along a given X/Y(?)...

us

Subject: 2D Interpolation Using 3D Information

From: Erik

Date: 20 Jul, 2010 20:49:04

Message: 3 of 14

"All cross sections are the convex hull of a set of points and are not a perfect circle."

The cross sections are actually of a breast using ultrasound tomagraphy. The "circles" are not nearly perfect enough for 2D interpolation to be effective. It's better than doing nothing, but using information from other slices I believe would greatly improve the accuracy.

Subject: 2D Interpolation Using 3D Information

From: us

Date: 20 Jul, 2010 20:58:08

Message: 4 of 14

"Erik " <stevesmith121@gmail.com> wrote in message <i25240$8q4$1@fred.mathworks.com>...
> "All cross sections are the convex hull of a set of points and are not a perfect circle."
>
> The cross sections are actually of a breast using ultrasound tomagraphy. The "circles" are not nearly perfect enough for 2D interpolation to be effective. It's better than doing nothing, but using information from other slices I believe would greatly improve the accuracy.

hmm... some CSSMers most certainly will frown upon the fact that you compare a breast with a cylinder...

us

Subject: 2D Interpolation Using 3D Information

From: Walter Roberson

Date: 20 Jul, 2010 22:17:27

Message: 5 of 14

us wrote:

> hmm... some CSSMers most certainly will frown upon the fact that you
> compare a breast with a cylinder...

Modeling as just a hemi-sphere is fairly common in serious medical journals.


An interesting article on stress modeling for brasseries:

http://autospeed.com/A_1260/cms/article.html

Subject: 2D Interpolation Using 3D Information

From: Erik

Date: 20 Jul, 2010 22:32:04

Message: 6 of 14

I believe i compared a breast to a "tapered cylinder". For the purposes of this problem, I think its an adequate description. I'd appreciate help much more than criticism of my word choice.

The problem remains. How to interpolate these slices using information from other slices.

Subject: 2D Interpolation Using 3D Information

From: Walter Roberson

Date: 20 Jul, 2010 22:55:16

Message: 7 of 14

Erik wrote:
> I believe i compared a breast to a "tapered cylinder". For the purposes
> of this problem, I think its an adequate description. I'd appreciate
> help much more than criticism of my word choice.

You've been dealing with the problem for a while, Erik; we onlookers are still
trying to figure out what is needed to be done.

In my experience, small differences in word choice often hint that the person
posing the problem is trying to do something that hasn't been described, or
something more specific than has been described. When we do not probe around
wording oddities, people can end up spending a fair bit of time working out or
describing inapplicable solutions or solutions to a problem more difficult
than the situation calls for.


Besides... we get nine to ten thousand postings here every month. If we can't
banter a bit about some of them, we'd go "stir crazy".

Subject: 2D Interpolation Using 3D Information

From: us

Date: 20 Jul, 2010 23:16:05

Message: 8 of 14

Walter Roberson <roberson@hushmail.com> wrote in message <i259ni$f9u$1@canopus.cc.umanitoba.ca>...
> Erik wrote:
> > I believe i compared a breast to a "tapered cylinder". For the purposes
> > of this problem, I think its an adequate description. I'd appreciate
> > help much more than criticism of my word choice.
>
> You've been dealing with the problem for a while, Erik; we onlookers are still
> trying to figure out what is needed to be done.
>
> In my experience, small differences in word choice often hint that the person
> posing the problem is trying to do something that hasn't been described, or
> something more specific than has been described. When we do not probe around
> wording oddities, people can end up spending a fair bit of time working out or
> describing inapplicable solutions or solutions to a problem more difficult
> than the situation calls for.
>
>
> Besides... we get nine to ten thousand postings here every month. If we can't
> banter a bit about some of them, we'd go "stir crazy".

i FULLY second walter (as usual, i might add)...
if you cannot take it - better don't visit this NG...
after all, MLbbers ARE living human beings...

us

Subject: 2D Interpolation Using 3D Information

From: Erik

Date: 21 Jul, 2010 03:34:04

Message: 9 of 14

It's no problem. I just felt it was being picky about the wording when we both knew what I meant. If there was a misunderstanding due to the wording that's another story.

Anyways, I guess to help clear up the problem think of an MRI in the coronal view. Cross sections of the breast are taken such that the breast appears as an ellipsoid. To be more specific, cross sections are taken approximately every millimeter. I am trying to mask the breast so as to eliminate information outside of the breast.

So I have these slices every millimeter that each have a set of XYZ coordinates where Z is simply the slice number multiplied by 1mm. These coordinates are eventually converted to binary masks. Occasionally the masking program outputs XYZ coordinates such that the ellipsoid shape is cut by a line. I would like to interpolate the ellipsoid to accurately identify the boundary of the breast.

Because the total volume represents a continuous surface, using information from all of the other slices to interpolate this region, which is missing points, should be much more accurate than doing simple 2D interpolation.

Hopefully this additional information helps. I've been working on this for 2 months now and this small problem is keeping me from calling the project finished. Thanks again for any help anyone can provide.

Subject: 2D Interpolation Using 3D Information

From: Sean

Date: 21 Jul, 2010 13:55:24

Message: 10 of 14

"Erik " <stevesmith121@gmail.com> wrote in message <i25prc$7bq$1@fred.mathworks.com>...
> It's no problem. I just felt it was being picky about the wording when we both knew what I meant. If there was a misunderstanding due to the wording that's another story.
>
> Anyways, I guess to help clear up the problem think of an MRI in the coronal view. Cross sections of the breast are taken such that the breast appears as an ellipsoid. To be more specific, cross sections are taken approximately every millimeter. I am trying to mask the breast so as to eliminate information outside of the breast.
>
> So I have these slices every millimeter that each have a set of XYZ coordinates where Z is simply the slice number multiplied by 1mm. These coordinates are eventually converted to binary masks. Occasionally the masking program outputs XYZ coordinates such that the ellipsoid shape is cut by a line. I would like to interpolate the ellipsoid to accurately identify the boundary of the breast.

%%%%
Are the lines always in the same location? Are the lines usually in the same orientation?
I think a morphological closing on the binary mask would help you. If the lines are always in the same location (detector non-linearities, blemishes etc.) then you could mask them individually and cover them.
>>help imclose
Note the structuring element can be tuned to specific orientations shapes that your gaps may have. That's why I was wondering about orientation.
%%%%

> Because the total volume represents a continuous surface, using information from all of the other slices to interpolate this region, which is missing points, should be much more accurate than doing simple 2D interpolation.

%%%%
For interpolation with missing points
>>help griddata

%%%%

> Hopefully this additional information helps. I've been working on this for 2 months now and this small problem is keeping me from calling the project finished. Thanks again for any help anyone can provide.

%%%%
So you know I (and I'm sure others) clicked on this thread because of the "humor" tag. They're not always a bad thing.

Subject: 2D Interpolation Using 3D Information

From: Steven_Lord

Date: 21 Jul, 2010 17:38:19

Message: 11 of 14



"Erik " <stevesmith121@gmail.com> wrote in message
news:i25prc$7bq$1@fred.mathworks.com...
> It's no problem. I just felt it was being picky about the wording when we
> both knew what I meant. If there was a misunderstanding due to the wording
> that's another story.
> Anyways, I guess to help clear up the problem think of an MRI in the
> coronal view. Cross sections of the breast are taken such that the breast
> appears as an ellipsoid. To be more specific, cross sections are taken
> approximately every millimeter. I am trying to mask the breast so as to
> eliminate information outside of the breast.
> So I have these slices every millimeter that each have a set of XYZ
> coordinates where Z is simply the slice number multiplied by 1mm. These
> coordinates are eventually converted to binary masks. Occasionally the
> masking program outputs XYZ coordinates such that the ellipsoid shape is
> cut by a line. I would like to interpolate the ellipsoid to accurately
> identify the boundary of the breast.

This sounds like a pretty hard problem without doing something like ellipse
fitting (which is a topic I know has been discussed on this newsgroup in the
past.) Using an analogy:

x = 0:20;
y = sin(x);
plot(x, y, 'o')

At this point, all this looks like is a bunch of circles. If you
connect-the-dots:

hold on
plot(x, y, '-')

then it becomes clearer that this is probably a sine curve, but
connect-the-dots simply gives straight lines -- there's not enough
information to get the curved shape of the actual sine curve. Only if you
fit a curve, evaluate it on a finer grid, and plot the interpolated data
like:

xcol = x';
coeffs = [ones(size(xcol)), sin(xcol), cos(xcol)] \ y';
xinterp = 0:0.1:20;
yfitted = coeffs(1) + coeffs(2)*sin(xinterp) + coeffs(3)*cos(xinterp);
plot(xinterp, yfitted, '+')

do you really get a smooth picture.

> Because the total volume represents a continuous surface, using
> information from all of the other slices to interpolate this region, which
> is missing points, should be much more accurate than doing simple 2D
> interpolation.

If you're looking to try this approach, using INTERPN may be sufficient for
your needs. The V input to INTERPN would indicate whether the known points
given by your initial X, Y, and Z grids are inside or outside the breast,
and you'd interpolate on a finer grid.

> Hopefully this additional information helps. I've been working on this for
> 2 months now and this small problem is keeping me from calling the project
> finished. Thanks again for any help anyone can provide.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: 2D Interpolation Using 3D Information

From: Erik

Date: 21 Jul, 2010 18:08:05

Message: 12 of 14

I have an idea that I'm going to try, but I thought I'd throw it on here first to spark possible other ideas.

I'm considering turning this into a 1D interpolation. Using polar coordinates I believe this problem becomes a little simpler. By keeping theta fixed, I can look at the radii down the edge of the breast as a function of Z. The Z axis will be defined to be through the center of the breast running the entire length of the breast.

Now, slices that are cut off will be missing points at that particular theta. Then it will be such that I can do 1D interpolation where I interpolate the radius over the particular Z that I'm at. I will then repeat this process over a number of thetas.

One problem I foresee is that in order for this to work, there must be particular thetas for which on each slice I have a point. To do this, I will try to interpolate the radius over particular thetas for all slices beforehand. I will have to look for large gaps in these data sets however so as to not use this form of interpolation on the slices that are missing points. That would defeat the entire purpose.

I'll report back if this works. I think I just wanted to type out my idea before trying it. If anyone sees a problem with this or generates other ideas from it, please let me know.

Subject: 2D Interpolation Using 3D Information

From: Erik

Date: 21 Jul, 2010 18:39:05

Message: 13 of 14

Actually, it seems like I could just use interp2 and switch around the arguments. I could use something of the form:

radiiI = interp2(Theta, Z, radii, ThetaI, ZI);

I'll post the findings in the next few hours...

Subject: 2D Interpolation Using 3D Information

From: Walter Roberson

Date: 22 Jul, 2010 02:54:31

Message: 14 of 14

Erik wrote:

> So I have these slices every millimeter that each have a set of XYZ
> coordinates where Z is simply the slice number multiplied by 1mm. These
> coordinates are eventually converted to binary masks. Occasionally the
> masking program outputs XYZ coordinates such that the ellipsoid shape is
> cut by a line. I would like to interpolate the ellipsoid to accurately
> identify the boundary of the breast.

Is it possible to characterize the conditions under which the line is
produced?

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