I have a binary image of one granule in Matlab. I can find the convex hull of the granule with the following function:
[K, V] = convhull(granule);
How can I find all pixels which belong to the convex hull, but don't belong to the granule in the original image? I mean I'd like to do something like that:
granule2 = zeros(size(granule));
granule2(K == 1 & granule == 0) = 2;
It doesn't work, because K is of size x by 3, where x is the number of triangles in the convex hull.
Edit: according to the documentation, the convex hull should be an array with the indexes of points making up the convex hull in each row. So how can I find all points which are inside of the volume determined by these points.
Edit2: Let me put it in another words: I have an image which is a 3D array of points. It's not a sphere and it has some indents (so the convex hull doesn't lay on the surface of my image).
I want to find the convex hull and after that find all points which are inside the convex hull, but are outside the granule. Here is how it would look like in 2D (I want to find the red pixels):
Edit3: NicolaSysnet, Your algorithm should return all the pixels (their indexes) which are red in my picture (the picture is in 2D,because it was easier to draw).