Hi Alberto,<br><br>I'll explain what I'm doing in a bit. It may not be best for the purpose intended, however, the problem that I've observed still should not be there. The closed structure always contains the original structure. However, if
you look closely at the images I have posted, the closed structure is thinner than the original one.<br>
<br>The structure that I'm working with is a mandible. There are several issues with these images - holes, teeth, etc. The slices that I've posted do not have holes, but the error can be seen more easily here. Further, the particular image that I produced is developed by a structuring element of radius 1. I'll use structuring elements of larger radii if there are larger holes.<br>
<br>The object is long and thin in some areas and blob-like in others. Further the direction in which the object is thin is not constant; so, I feel that using the same long thin structuring element everywhere may make things worse.<br>
<br>Rohit<br>
<br><br><div class="gmail_quote">On Tue, Mar 2, 2010 at 5:15 AM, Gomez, Alberto <span dir="ltr"><<a href="mailto:alberto.gomez@kcl.ac.uk">alberto.gomez@kcl.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello,<br>
<br>
I don't know if I had understood what you want to do. The original image you are using is "already closed", unless you want to link the two white figures. If that is the case, you wont be able to do that; a morphological close will only "fill" blanks or holes which are smaller than the full figure (and that the structuring element). You are using an structuring element (ball) of size 1, which means that you will not be able to close spaces bigger than 1.<br>
<br>
Apart from that, I think the results you are getting are coherent, although it is difficult to say without knowing the image resolution.<br>
<br>
Please, can you explain in more detail what you expect to get?<br>
<br>
Finally, If you want to close long and thin objects, the ball is probably not the best kernel, try something with the same shape as the object.<br>
<br>
hth<br>
<br>
Alberto<div><div></div><div class="h5"><br>
<br>
<br>
Rohit Saboo wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello:<br>
<br>
I'm trying to do a morphological close by dilating the input image and then following it with the input image. However, it seems that I'm not using the filters properly because the results don't look like the result of a close operation. Can someone point out to me what I'm doing wrong.<br>
<br>
Axial slices of the images (at the same position) are at the following locations:<br>
1. original image - <a href="http://www.cs.unc.edu/%7Erohit/stuff/original.png" target="_blank">http://www.cs.unc.edu/~rohit/stuff/original.png</a><br>
2. (intermediate) dilated image - <a href="http://www.cs.unc.edu/%7Erohit/stuff/dilated.png" target="_blank">http://www.cs.unc.edu/~rohit/stuff/dilated.png</a><br>
3. (final) closed image - <a href="http://www.cs.unc.edu/%7Erohit/stuff/closed.png" target="_blank">http://www.cs.unc.edu/~rohit/stuff/closed.png</a><br>
<br>
I'm including the parts of the code related to the close operation. The function below is called with a radius of 1.<br>
<br>
typedef unsigned short Pixel;<br>
typedef Image<Pixel, 3> ImageType;<br>
typedef ImageType::Pointer ImagePointer;<br>
<br>
ImagePointer closeImage( ImagePointer image, const unsigned int radius )<br>
{<br>
// The ball structuring element:<br>
typedef BinaryBallStructuringElement<Pixel, 3> Kernel;<br>
// The dilation filter<br>
typedef DilateObjectMorphologyImageFilter<ImageType, ImageType, Kernel> DilateFilter;<br>
// The erosion filter<br>
typedef ErodeObjectMorphologyImageFilter<ImageType, ImageType, Kernel> ErodeFilter;<br>
<br>
// Create the structuring element:<br>
cout << "Creating structuring element ... " << flush;<br>
Kernel ball;<br>
ball.SetRadius(radius);<br>
ball.CreateStructuringElement();<br>
cout << "done" << endl;<br>
<br>
writeImage<ImageType>(image, "original.mhd");<br>
<br>
// Now do the close operation<br>
cout << "Dilating ... " << flush;<br>
DilateFilter::Pointer closeDilate = DilateFilter::New();<br>
closeDilate->SetObjectValue(1);<br>
closeDilate->SetKernel(ball);<br>
closeDilate->SetInput(image);<br>
closeDilate->Update();<br>
cout << "done" << endl;<br>
writeImage<ImageType>(closeDilate->GetOutput(), "dilated.mhd");<br>
<br>
cout << "Eroding ... " << flush;<br>
ErodeFilter::Pointer closeErode = ErodeFilter::New();<br>
closeErode->SetObjectValue(1);<br>
closeErode->SetKernel(ball);<br>
closeErode->SetInput(closeDilate->GetOutput());<br>
closeErode->Update();<br>
cout << "done" << endl;<br>
writeImage<ImageType>(closeErode->GetOutput(), "closed.mhd");<br>
<br>
return closeErode->GetOutput();<br>
}<br>
<br>
<br>
Rohit<br>
<br>
<br>
</blockquote>
<br>
<br></div></div>
-- <br>
<br>
Alberto Gómez<br>
<br>
/Division of Imaging Sciences<br>
The Rayne Institute<br>
4th Floor, Lambeth Wing<br>
St Thomas' Hospital<br>
London SE1 7EH /<br>
<br>
phone: +44 (0) 20 718 88364<br>
email: <a href="mailto:alberto.gomez@kcl.ac.uk" target="_blank">alberto.gomez@kcl.ac.uk</a> <mailto:<a href="mailto:alberto.gomez@kcl.ac.uk" target="_blank">alberto.gomez@kcl.ac.uk</a>><br>
<br>
</blockquote></div><br>