[Insight-users] Peel an image

Bradley Lowekamp blowekamp at mail.nih.gov
Fri May 24 08:54:42 EDT 2013


Gib,

What was the morphological operation you were doing?

ITK's grayscale morph operations are great. However, you need to keep in mind the cost of the different shapes of structuring elements. Unfortunately the binary methods use are single threaded algorithm with a complexity dependent on the number of boundary pixel. I am guessing this the algorithm you were using. If you have a binary image you should actually be able to use the grayscale morp ops to get the same results!

I am a little hesitant to share this because I haven't used it for a bit, so I'm not certain of it's current state. I spent a little time writing a new binary morph algorithm. It's only works for crosses and box/flat structuring elements. But one thread to one thread compared to the current algorithm is was more than 10X faster, and it didn't take much longer O(Radius/32) for larger structuring elements. It's also multi-threadeded so you could easily get 100X speedup compared to the current version. I've  had similar sized data set that I could run binary morphological operations in like a minute.

Also keep in mind you can resample to a lower resolution for some of these larger structures, when a course segmentation is needed.

Brad

On May 23, 2013, at 5:58 PM, Gib Bogle <g.bogle at auckland.ac.nz> wrote:

> Richard, in our images dx=dy=dz, so in principle the closing should work fine in 3D.  In fact I think the size of our images is going to make it impractical.  I ran a test last night on a partial image, which is 1300x1100x200, about 1/5 of a full image (still being generated by the microscopy rig).  It was still running after 9 hours this morning, when I stopped it, at 100% of the 8 cores on my PC.  This is not really practical.
> 
> I did implement the grayscale closing, but not exactly as in your code.  I've been using ITK for a while, but in a very naive way, and writing a lot of my own code.  I am not a C++ expert by any means, and in particular I do not know anything about templates.  It is not important (since I have something that works) but if you felt motivated to send me a simple example of a main program that calls doClosing() I'm sure I would find it very instructional.
> 
> It is not clear to me yet what radius to use for the structuring element.  I've tried 30, 40 and 50.  To generate the mask I guess I need to set the threshold level to something like 1 or 2 - some experimentation is needed.
> 
> To process the whole 3D image I'm thinking about using a slice-by-slice method, on the XY slices, then the YZ, then the XZ.  The idea is to process each 2D slice as if to peel it, but leaving the image unchanged and just recording all the voxels that are to be removed.  The final step will be to zero out all these voxels.  I think it is necessary to do it like this to avoid multiple peeling.
> 
> It will be interesting to compare the active contour approach with the grayscale closing method to generate the mask.
> 
> Best regards
> Gib
> 
> On 23/05/2013 10:04 p.m., Richard Beare wrote:
>> The steps I've given should also work in 3D if the slice thickness is low enough to provide the connectivity between slices. Personally, I haven't had much luck with the vesselness family. My rule of thumb is that if they happen to work, then a simple morphological approach will probably work too, more reliably and with fewer parameters to fiddle :-).
>> 
>> 
>> On Thu, May 23, 2013 at 5:36 PM, Dan Mueller <dan.muel at gmail.com> wrote:
>> Hi Gib,
>> 
>> Some more food for thought:
>> 
>> (1) If you have a 3D image (as opposed to 2D slices) you may consider
>> using Hessian-based vesselness enhancement:
>> http://www.itk.org/Doxygen/html/classitk_1_1Hessian3DToVesselnessMeasureImageFilter.html
>> http://www.itk.org/Doxygen/html/classitk_1_1MultiScaleHessianBasedMeasureImageFilter.html
>> http://www.insight-journal.org/browse/publication/314
>> http://www.insight-journal.org/browse/publication/175
>> http://www.insight-journal.org/browse/publication/163
>> 
>> This class of filters can enhance tube-like structures (e.g. vessels),
>> while suppressing sheet like structures i.e. the outer border of your
>> object.
>> 
>> (2) You could consider using an active contour method to segment the
>> outer structure (replacing step 1 in Richard's proposal above). You
>> could achieve this by initializing the contour as the edge of your
>> image, then shrink the contour until it attaches to the boundary of
>> the tissue. Then continue to follow Richard's second step and remove
>> the outer structure by erosion + masking.
>> 
>> Good luck.
>> 
>> Cheers, Dan
>> 
>> On 23 May 2013 11:16, Gib Bogle <g.bogle at auckland.ac.nz> wrote:
>> > Hi Richard,
>> >
>> > I don't have other staining.
>> >
>> > Thanks for your suggestion of a procedure.  I will have to study it and
>> > understand it, before I can comment on it.
>> >
>> > Gib
>> >
>> >
>> > On 23/05/2013 12:25 p.m., Richard Beare wrote:
>> >
>> > Hi,
>> > I'm not sure I understand completely, but here's my suggestion of an
>> > approach. It may turn out to be easier if you have other staining too.
>> >
>> > 1) Segment the entire tissue - i.e generate one large object that contains
>> > all your small vessels and a boundary on your layer that you need to peel.
>> > More on how this might be achieved later.
>> >
>> > 2) Erode this object and use the eroded version to mask out the accidental
>> > staining - i.e. do the peeling. Then apply your normal segmentation to what
>> > is left.
>> >
>> >  If you have another channel where all the tissue has contrast then
>> > segmenting the tissue will be relatively easy. Otherwise it will be a bit
>> > more of a challenge. My first guess if the latter is the case is to use 2
>> > markers in a watershed. One marker will be the image border (definitely
>> > outside the tissue). Create the marker image as follows.
>> >    a) Apply a large closing, say about 15% of the tissue size. This will
>> > connect your interior objects together. Threshold the result, choose the
>> > largest connected component, then erode that component a little to make sure
>> > it stays inside the tissue and use the result as your foreground marker. Use
>> > rectangular structuring elements for the closing so you can take advantage
>> > of fast operations.
>> >    b) put the two markers together in an image such that they have different
>> > voxel values - i.e. image border has value 2, inside marker from step a has
>> > value 1.
>> >
>> > Use the combined image as the marker image for the morphological markers
>> > filter, use the original as the control. You may need to smooth the original
>> > to close boundary gaps in faint areas. You shouldn't need to take a gradient
>> > because the staining forms a line which the watershed should find.
>> >
>> > Select the foreground label from the watershed result. Erode it a bit
>> > (you'll need to look to confirm how much).
>> >
>> > If there is a gap then the watershed will leak through, but this won't
>> > matter as you are going to erode the mask and areas with gaps don't need to
>> > be corrected anyway.
>> >
>> >
>> > On Thu, May 23, 2013 at 7:47 AM, Gib Bogle <g.bogle at auckland.ac.nz> wrote:
>> >>
>> >> I didn't think there would be a stock filter, but maybe somebody else has
>> >> addressed this.
>> >>
>> >> I have attached a typical frame.  I can't show the wanted result, but I
>> >> think it's obvious when you know that the interior of this piece of tissue
>> >> has the blood vessels stained, while the faint rim is clearly not blood
>> >> vessel.  The problem is that there will in general be many vessels stained
>> >> to a similar intensity as this rim.
>> >>
>> >> Gib
>> >>
>> >>
>> >> On 23/05/2013 8:53 a.m., Dženan Zukić wrote:
>> >>
>> >> I don't think there is any stock filter which does what you want. And I
>> >> still don't understand your situation. Can you show us an example slice and
>> >> wanted result?
>> >>
>> >>
>> >> On Wed, May 22, 2013 at 10:50 PM, Gib Bogle <g.bogle at auckland.ac.nz>
>> >> wrote:
>> >>>
>> >>> The reason why I don't think erode will work is that the part of the
>> >>> image that contains the information of interest is made up of many
>> >>> disconnected pieces, not very different from the boundary layer that I want
>> >>> to remove.  The only thing that I can use to distinguish the pixels that
>> >>> need to be removed is that they are near the outside of the region.  If I
>> >>> apply erosion I will remove many small but important features (this is
>> >>> labelled vasculature, and I do not want to lose fine capillaries).
>> >>>
>> >>> Gib
>> >>>
>> >>>
>> >>> On 22/05/2013 11:12 p.m., Dženan Zukić wrote:
>> >>>
>> >>>
>> >>> http://www.itk.org/Doxygen/html/group__MathematicalMorphologyImageFilters.html
>> >>>
>> >>> What you probably want to do is BinaryErode and BinaryDilate.
>> >>>
>> >>>
>> >>> On Wed, May 22, 2013 at 7:04 AM, gib <g.bogle at auckland.ac.nz> wrote:
>> >>>>
>> >>>> It's hard to know what to call the processing I want to apply.  I have a
>> >>>> set
>> >>>> of biological images (actually a 3D image, but for now I'm happy to
>> >>>> process
>> >>>> the frames one-by-one) in which the region of interest has an irregular
>> >>>> and
>> >>>> incomplete labelled layer around the boundary.  The staining of the
>> >>>> layer
>> >>>> was unintended, and its presence interferes with the segmentation that I
>> >>>> am
>> >>>> doing.  The part of the image that I want to extract is made up of many
>> >>>> disconnected objects, and there is not much difference in the intensity
>> >>>> ranges of the objects of interest and the unwanted edge.  I am willing
>> >>>> to
>> >>>> trim a few pixels off the boundary all the way around - this will not
>> >>>> cause
>> >>>> much loss of information.  What I need is way to determine a sequence of
>> >>>> pixels that in some sense defines the extent of the labelled region in
>> >>>> the
>> >>>> image, rather like a 2D shrink wrapping.  I could then use this to shave
>> >>>> or
>> >>>> peel off the outer layer of pixels.
>> >>>>
>> >>>> Does this process have a name?  Are there any existing filters or code
>> >>>> to do
>> >>>> this?  Any clever suggestions (I have some ideas)?
>> >>>>
>> >>>> Thanks
>> >>>> Gib
>> >>>>
>> >>>>
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130524/05205a81/attachment.htm>


More information about the Insight-users mailing list