Getting all points which are inside of the convexhull

I have an image in 3D. I'd like to get all points which are inside its convexhull, but don't belong to the image. So I'd like to do something like this:
[K, V] = convhull(image);
result= zeros(size(image));
result(K == 1 & granule == 0) = 2;
It doesn't work, because K is of size x (the number of rectangles which create the convex hull) by 3.
How can I do it properly?

 Accepted Answer

Don't use image as the name of your variable because it's the name of a built-in function.
Don't use convhull(). Use bwconvhull() instead. Then do an XOR with the binary image.

6 Comments

Thanks! This is exactly what I am looking for!
Unfortunately, this function also returns the convex hull of the size x (the number of rectangles which create the convex hull) by 3.
I don't know what you mean that the convex hull is three times the size of x. And I don't know what you mean that the convex hull is created by rectangles. Rectangles don't create it, though it will have a bounding box. Post your image and illustrate what you mean and point out how something is three times as big as it should be.
I didn't say my convex hull is three times the size of x. I said that the size of the convex hull is x by 3, what is the result of the following code:
[K, V] = convhull(image);
disp(num2str(size(K)));
For instance, the above conde prints out "1242 3". So, nothing is three times as big as it should be.
Sorry, I didn't mean rectangles, I meant polygons. And what I was trying to say is that it consists of polygons. But I guess it has nothing to do with the question. Sorry for the confusion.
In principle, when my image is of the size, let's say 100 by 100 by 100, I expect my convex hull to be of size 100 by 100 by 100. And it is of size x (i.e. 1242 ) by 3.
I can't post my data, because it doesn't belong to me and I shouldn't publish it. It also is very huge (1024^3 points). But I'll try to generate an example to illustrate the problem.
You need to use convhulln(), not convhull().
Why? convhull() should also work in 3D, shouldn't it? And it still doesn't solve my problem.

Sign in to comment.

More Answers (0)

Categories

Tags

Asked:

on 9 Oct 2015

Commented:

on 13 Oct 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!