<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Gib,<div><br></div><div>What was the morphological operation you were doing?</div><div><br></div><div>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!</div><div><br></div><div>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.</div><div><br></div><div>Also keep in mind you can resample to a lower resolution for some of these larger structures, when a course segmentation is needed.</div><div><br></div><div>Brad</div><div><br></div><div><div><div>On May 23, 2013, at 5:58 PM, Gib Bogle <<a href="mailto:g.bogle@auckland.ac.nz">g.bogle@auckland.ac.nz</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">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.<br>
<br>
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.<br>
<br>
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.<br>
<br>
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.<br>
<br>
It will be interesting to compare the active contour approach with
the grayscale closing method to generate the mask.<br>
<br>
Best regards<br>
Gib<br>
<br>
On 23/05/2013 10:04 p.m., Richard Beare wrote:<br>
</div>
<blockquote cite="mid:CA+V7QS9h44V+7y0NA+MgJWrvP9nqsJmxs8AOjjbHmp8iUY9KVA@mail.gmail.com" type="cite">
<div dir="ltr">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 :-).</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Thu, May 23, 2013 at 5:36 PM, Dan
Mueller <span dir="ltr"><<a moz-do-not-send="true" href="mailto:dan.muel@gmail.com" target="_blank">dan.muel@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Gib,<br>
<br>
Some more food for thought:<br>
<br>
(1) If you have a 3D image (as opposed to 2D slices) you may
consider<br>
using Hessian-based vesselness enhancement:<br>
<a moz-do-not-send="true" href="http://www.itk.org/Doxygen/html/classitk_1_1Hessian3DToVesselnessMeasureImageFilter.html" target="_blank">http://www.itk.org/Doxygen/html/classitk_1_1Hessian3DToVesselnessMeasureImageFilter.html</a><br>
<a moz-do-not-send="true" href="http://www.itk.org/Doxygen/html/classitk_1_1MultiScaleHessianBasedMeasureImageFilter.html" target="_blank">http://www.itk.org/Doxygen/html/classitk_1_1MultiScaleHessianBasedMeasureImageFilter.html</a><br>
<a moz-do-not-send="true" href="http://www.insight-journal.org/browse/publication/314" target="_blank">http://www.insight-journal.org/browse/publication/314</a><br>
<a moz-do-not-send="true" href="http://www.insight-journal.org/browse/publication/175" target="_blank">http://www.insight-journal.org/browse/publication/175</a><br>
<a moz-do-not-send="true" href="http://www.insight-journal.org/browse/publication/163" target="_blank">http://www.insight-journal.org/browse/publication/163</a><br>
<br>
This class of filters can enhance tube-like structures (e.g.
vessels),<br>
while suppressing sheet like structures i.e. the outer
border of your<br>
object.<br>
<br>
(2) You could consider using an active contour method to
segment the<br>
outer structure (replacing step 1 in Richard's proposal
above). You<br>
could achieve this by initializing the contour as the edge
of your<br>
image, then shrink the contour until it attaches to the
boundary of<br>
the tissue. Then continue to follow Richard's second step
and remove<br>
the outer structure by erosion + masking.<br>
<br>
Good luck.<br>
<br>
Cheers, Dan<br>
<div class="HOEnZb">
<div class="h5"><br>
On 23 May 2013 11:16, Gib Bogle <<a moz-do-not-send="true" href="mailto:g.bogle@auckland.ac.nz">g.bogle@auckland.ac.nz</a>>
wrote:<br>
> Hi Richard,<br>
><br>
> I don't have other staining.<br>
><br>
> Thanks for your suggestion of a procedure. I will
have to study it and<br>
> understand it, before I can comment on it.<br>
><br>
> Gib<br>
><br>
><br>
> On 23/05/2013 12:25 p.m., Richard Beare wrote:<br>
><br>
> Hi,<br>
> I'm not sure I understand completely, but here's my
suggestion of an<br>
> approach. It may turn out to be easier if you have
other staining too.<br>
><br>
> 1) Segment the entire tissue - i.e generate one
large object that contains<br>
> all your small vessels and a boundary on your layer
that you need to peel.<br>
> More on how this might be achieved later.<br>
><br>
> 2) Erode this object and use the eroded version to
mask out the accidental<br>
> staining - i.e. do the peeling. Then apply your
normal segmentation to what<br>
> is left.<br>
><br>
> If you have another channel where all the tissue
has contrast then<br>
> segmenting the tissue will be relatively easy.
Otherwise it will be a bit<br>
> more of a challenge. My first guess if the latter
is the case is to use 2<br>
> markers in a watershed. One marker will be the
image border (definitely<br>
> outside the tissue). Create the marker image as
follows.<br>
> a) Apply a large closing, say about 15% of the
tissue size. This will<br>
> connect your interior objects together. Threshold
the result, choose the<br>
> largest connected component, then erode that
component a little to make sure<br>
> it stays inside the tissue and use the result as
your foreground marker. Use<br>
> rectangular structuring elements for the closing so
you can take advantage<br>
> of fast operations.<br>
> b) put the two markers together in an image such
that they have different<br>
> voxel values - i.e. image border has value 2,
inside marker from step a has<br>
> value 1.<br>
><br>
> Use the combined image as the marker image for the
morphological markers<br>
> filter, use the original as the control. You may
need to smooth the original<br>
> to close boundary gaps in faint areas. You
shouldn't need to take a gradient<br>
> because the staining forms a line which the
watershed should find.<br>
><br>
> Select the foreground label from the watershed
result. Erode it a bit<br>
> (you'll need to look to confirm how much).<br>
><br>
> If there is a gap then the watershed will leak
through, but this won't<br>
> matter as you are going to erode the mask and areas
with gaps don't need to<br>
> be corrected anyway.<br>
><br>
><br>
> On Thu, May 23, 2013 at 7:47 AM, Gib Bogle <<a moz-do-not-send="true" href="mailto:g.bogle@auckland.ac.nz">g.bogle@auckland.ac.nz</a>>
wrote:<br>
>><br>
>> I didn't think there would be a stock filter,
but maybe somebody else has<br>
>> addressed this.<br>
>><br>
>> I have attached a typical frame. I can't show
the wanted result, but I<br>
>> think it's obvious when you know that the
interior of this piece of tissue<br>
>> has the blood vessels stained, while the faint
rim is clearly not blood<br>
>> vessel. The problem is that there will in
general be many vessels stained<br>
>> to a similar intensity as this rim.<br>
>><br>
>> Gib<br>
>><br>
>><br>
>> On 23/05/2013 8:53 a.m., Dženan Zukić wrote:<br>
>><br>
>> I don't think there is any stock filter which
does what you want. And I<br>
>> still don't understand your situation. Can you
show us an example slice and<br>
>> wanted result?<br>
>><br>
>><br>
>> On Wed, May 22, 2013 at 10:50 PM, Gib Bogle
<<a moz-do-not-send="true" href="mailto:g.bogle@auckland.ac.nz">g.bogle@auckland.ac.nz</a>><br>
>> wrote:<br>
>>><br>
>>> The reason why I don't think erode will
work is that the part of the<br>
>>> image that contains the information of
interest is made up of many<br>
>>> disconnected pieces, not very different
from the boundary layer that I want<br>
>>> to remove. The only thing that I can use
to distinguish the pixels that<br>
>>> need to be removed is that they are near
the outside of the region. If I<br>
>>> apply erosion I will remove many small but
important features (this is<br>
>>> labelled vasculature, and I do not want to
lose fine capillaries).<br>
>>><br>
>>> Gib<br>
>>><br>
>>><br>
>>> On 22/05/2013 11:12 p.m., Dženan Zukić
wrote:<br>
>>><br>
>>><br>
>>> <a moz-do-not-send="true" href="http://www.itk.org/Doxygen/html/group__MathematicalMorphologyImageFilters.html" target="_blank">http://www.itk.org/Doxygen/html/group__MathematicalMorphologyImageFilters.html</a><br>
>>><br>
>>> What you probably want to do is BinaryErode
and BinaryDilate.<br>
>>><br>
>>><br>
>>> On Wed, May 22, 2013 at 7:04 AM, gib <<a moz-do-not-send="true" href="mailto:g.bogle@auckland.ac.nz">g.bogle@auckland.ac.nz</a>>
wrote:<br>
>>>><br>
>>>> It's hard to know what to call the
processing I want to apply. I have a<br>
>>>> set<br>
>>>> of biological images (actually a 3D
image, but for now I'm happy to<br>
>>>> process<br>
>>>> the frames one-by-one) in which the
region of interest has an irregular<br>
>>>> and<br>
>>>> incomplete labelled layer around the
boundary. The staining of the<br>
>>>> layer<br>
>>>> was unintended, and its presence
interferes with the segmentation that I<br>
>>>> am<br>
>>>> doing. The part of the image that I
want to extract is made up of many<br>
>>>> disconnected objects, and there is not
much difference in the intensity<br>
>>>> ranges of the objects of interest and
the unwanted edge. I am willing<br>
>>>> to<br>
>>>> trim a few pixels off the boundary all
the way around - this will not<br>
>>>> cause<br>
>>>> much loss of information. What I need
is way to determine a sequence of<br>
>>>> pixels that in some sense defines the
extent of the labelled region in<br>
>>>> the<br>
>>>> image, rather like a 2D shrink
wrapping. I could then use this to shave<br>
>>>> or<br>
>>>> peel off the outer layer of pixels.<br>
>>>><br>
>>>> Does this process have a name? Are
there any existing filters or code<br>
>>>> to do<br>
>>>> this? Any clever suggestions (I have
some ideas)?<br>
>>>><br>
>>>> Thanks<br>
>>>> Gib<br>
>>>><br>
>>>>
</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
</div>
_____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br>http://www.kitware.com/products/protraining.php<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-users<br></blockquote></div><br></div></body></html>