Hi Rolf,
Yeah, this will work when the holes are 1 voxel and not close to the
surface, i.e. at least 2 voxels deep I believe.
On the Octave trick, at least 2 dimensions are needed, even for 1 voxel
holes, but not always the same 2 dimensions (this depends on the local
configuration of the surface), so we have to cover all 3. The method may
still fail if the object has a very curled shape, like a spiraled whorl,
etc. For almond or C- or S-shape structures, it should work. But with
ANTS it may be easier and faster (its compiled I think, no?).
All the best,
Anderson
On 28/09/11 14:05, Rolf A. Heckemann wrote:
> Hi Ed, hi Anderson
>
> It is true that the closing operation (dilate and erode) can also fill
> crevices at the surface. If this is a worry, you can restore the
> original surface afterwards. Again, this is possible because the
> holes to fill are the size of one voxel, according to Ed.
>
> fslmaths mask -kernel 3D -dilM -ero mask-holefilled # as previously
> fslmaths mask-holefilled -kernel 3D -ero mask-hf-ero
> fslmaths mask -add mask-hf-ero -bin mask-holefilled-surfacecorrected
>
> This works for superficial crevices of a depth of up to one voxel.
>
> On the octave advice, I would contend that (again under the
> 1-voxel-holesize-constraint) it is only necessary to fill in one
> dimension.
>
> The ANTs package (http://picsl.upenn.edu/ANTS/) has a very capable
> holefilling function, integrated in the ImageMath tool. It works in
> two or three dimensions, and with holes of any size.
>
> Rolf
>
>
> On 28 September 2011 18:18, Anderson Winkler
> <[log in to unmask]> wrote:
>> Hi Ed and Rolf,
>>
>> Hmm, I'm afraid this dilation and erosion will fill the holes, but it will
>> also change a bit the external shape of the mask...
>>
>> It's difficult to accomplish automated filling without recursion and this
>> gets complicated with shell scripting only. Perhaps a faster solution, if
>> you have access to Matlab with the Image Processing toolbox, is to use the
>> "imfill", which works for both 2-D and 3-D images.
>>
>> If you don't have access to Matlab, you can use Octave. The following
>> function appears to do the trick:
>> http://www.irit.fr/PERSONNEL/SAMOVA/joly/Teaching/M2IRR/IRR05/Estrade-Mercadier/imfill.m
>> However, it works for 2D only. To make it work in 3D, you have to run it
>> sequentially for every slice in coronal, sagital and axial directions, which
>> will produce 3 filled volumes. Use the AND operator to combine all 3 into a
>> single volume, and you should have then the result you need.
>>
>> Hope this helps!
>>
>> All the best,
>>
>> Anderson
>>
>>
>> On 28/09/11 11:18, Rolf A. Heckemann wrote:
>>> Hi Ed
>>>
>>> If they're really that small, this should work:
>>>
>>> fslmaths mask.nii -kernel 3D -dilM -ero mask-holefilled
>>>
>>> Regards
>>>
>>> Rolf
>>>
>>>
>>> On 28 September 2011 16:44, Ed Gronenschild
>>> <[log in to unmask]> wrote:
>>>> Hi,
>>>>
>>>> I'm looking for a tool to fill holes of only 1 voxel in size
>>>> in a binary mask.
>>>>
>>>> Ed
>>>>
>>>
>
>
|