<br>Hi Harvey,<br><br>Thanks for you additional clarification.<br><br><br>The Bad News:<br><br>The reason why you are having trouble finding a way of assigning<br>graylevel values to the structuring element is that... this funcitonality<br>
is not available.<br><br><br><br>The Good News:<br><br>Please find attached a modified version of the Shaped iterator that <br>now provides such functionality.<br><br>The additional API is:<br><br> SetPixelWeight( i, value )<br>
GetPixelWeight( i )<br><br>The types are the same as the pixel type of the image.<br><br>The numeral "i" matches the same offsets that you have<br>activated in order to create the Shape of the iterator.<br>
<br>Also, for your convenience, we have attached here a <br>skeleton (compiling, but not functional yet) of a filter<br>that should get you started with implementing the Hit<br>or Miss filter.<br><br>Attached is also a minimal example of usage for that<br>
filter.<br><br>Please note that this is just to help you get started.<br><br>We are not claiming that any of these classes are<br>ready for prime-time, but we hope that they will save<br>you a lot of time.<br><br><br>Please let us know if you have any questions,<br>
<br><br> Thanks,<br><br><br> Luis<br><br><br><br>------------------------------------------------------------------------------<br><div class="gmail_quote">On Wed, Jul 29, 2009 at 12:56 PM, Neal R. Harvey <span dir="ltr"><<a href="mailto:harve@lanl.gov">harve@lanl.gov</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;">Luis Ibanez wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Hi Harvey,<br>
<br><div class="im">
Thanks for the clarification.<br>
<br>
Let's go back to the basics then.<br>
<br>
It seems that you are interested in writing<br>
a Grayscale morphological filter where the<br>
structuring element has:<br>
<br>
A) Arbitrary shape, and<br>
B) Values assigned to its own pixels.<br>
<br>
If that's the case,<br>
then the major ITK elements that you need are:<br>
<br>
1) itk::ShapedNeighborhoodIterator<br>
2) itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<br>
<br>
You will find examples on these classes at:<br>
<br>
Insight/Examples/<br>
ShapedNeighborhoodIterators1.cxx<br>
ShapedNeighborhoodIterators2.cxx<br>
</div></blockquote>
These are the examples in the book, right. As I said previously, I have read through these<br>
but have been unable to determine exactly how to assign grayscale values to a neigborhood<br>
iterator, as these examples do not show how to do this. They only show how to use pre-defined<br>
kernels (such as for the Sobel and Gaussian: NeighborhoodIterators4.cxx and<br>
NeighborhoodIterators3.cxx) or how to implement Binary Morphological operators<br>
(ShapedNeighborhoodIterators1.cxx and ShapedNeighborhoodIterators2.cxx) which, by definition,<br>
do not have any grayscale values, and are therefore not much help.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The rule of "hit" or "miss" will have to be implemented in<br>
the inner loop where each one of the pixels in the neighbor<br>
is visited.<br>
</blockquote></div>
OK, but that supposes I know how to define the grayscale structuring element's values, which I don't.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
This will be a great filter to contribute to the Insight Journal :-)<br>
</blockquote></div>
I would love to be in that position. However, I think I am quite some way away from that at the moment.<br>
<br>
Thanks for your help and suggestions, though.<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
Please let us know if you have any questions regarding<br>
the details of the implementation.<br>
<br>
<br>
Thanks<br>
<br>
<br>
Luis<br>
<br>
<br>
---------------------------------------------------------------------<br></div><div><div></div><div class="h5">
On Wed, Jul 29, 2009 at 12:30 PM, Neal R. Harvey <<a href="mailto:harve@lanl.gov" target="_blank">harve@lanl.gov</a> <mailto:<a href="mailto:harve@lanl.gov" target="_blank">harve@lanl.gov</a>>> wrote:<br>
<br>
Luis Ibanez wrote:<br>
<br>
<br>
Hi Harvey,<br>
<br>
For your convenience, we just added an example on the use of<br>
the GrayscaleFunctionDilateImageFilter to:<br>
<br>
Insight/Examples/Filtering/GrayscaleFunctionDilateImageFilter.cxx<br>
<br>
Please also find it attached to this email.<br>
<br>
<br>
The code is quite straight forward:<br>
<br>
* read an image<br>
* instantiate filter<br>
* create structuring element<br>
* connect pipeline : reader, filter, writer<br>
* run<br>
<br>
<br>
Please give it try and let us know if you have any questions.<br>
<br>
Luis.<br>
<br>
Thanks for this. However, this isn't solving the problem that I<br>
have.<br>
I want to create a very specific structuring element, where I<br>
have control<br>
over what grayscale values are in each position of the<br>
structuring element,<br>
and can define, within the overall envelope of the structuring<br>
element, what<br>
positions are within and outwith the structuring element's<br>
region of support.<br>
<br>
For example, I may want to implement a grayscale hit-or-miss<br>
algorithm, in<br>
which the "hit" and "miss" structuring elements are actual<br>
images of targets<br>
and background. Say I am looking for a tank and I have an image<br>
of a tank<br>
which I am going to use for the "hit" and "miss" structuring<br>
elements.<br>
I only want the foreground (i.e. "hit") structuring element to<br>
be defined<br>
where the actual tank pixels are located and I want the<br>
grayscale values of<br>
this structuring element to be the same as the grayscale values<br>
of the actual<br>
tank pixels in the image. Similarly, for the background (i.e.<br>
"miss") structuring<br>
element, I only want this structuring element to be defined<br>
where there are<br>
no actual tank pixels and I want the grayscale values of this<br>
structuring element<br>
to be the same as the grayscale values of the actual background<br>
(i.e. non-tank)<br>
pixels in the image<br>
<br>
Thus, having a pre-defined "ball" structuring element is not<br>
much help, certainly<br>
in the example describe above. Obviously, there are certain<br>
situations where<br>
a ball structuring element will be useful. However, one of the<br>
strengths of<br>
mathematical morphology is its ability to probe an image with a<br>
structuring element<br>
that has both spatial and "grayscale" extent and the ability to<br>
tailor the spatial and<br>
grayscale values of the structuring element to meet your<br>
particular needs.<br>
If you know of a way that I can do this, any information in<br>
this regard would be<br>
very much appreciated.<br>
<br>
Thanks again and kindest regards<br>
<br>
Harve<br>
<br>
<br>
<br>
Thanks<br>
<br>
<br>
Luis<br>
<br>
<br>
<br>
---------------------------------------------------------------------------------------<br>
<br>
<br>
On Tue, Jul 28, 2009 at 6:40 PM, Neal R. Harvey<br></div></div>
<<a href="mailto:harve@lanl.gov" target="_blank">harve@lanl.gov</a> <mailto:<a href="mailto:harve@lanl.gov" target="_blank">harve@lanl.gov</a>> <mailto:<a href="mailto:harve@lanl.gov" target="_blank">harve@lanl.gov</a><div>
<div></div><div class="h5"><br>
<mailto:<a href="mailto:harve@lanl.gov" target="_blank">harve@lanl.gov</a>>>> wrote:<br>
<br>
I am still struggling to implement grayscale morphological<br>
operators.<br>
The basic functions have been written:<br>
e.g.<br>
<a href="http://www.itk.org/Doxygen310/html/classitk_1_1GrayscaleFunctionDilateImageFilter.html" target="_blank">http://www.itk.org/Doxygen310/html/classitk_1_1GrayscaleFunctionDilateImageFilter.html</a><br>
Unfortunately there are no nice papers or tutorials, or<br>
even test<br>
code to provide insight as to exactly<br>
how to go about using them.<br>
<br>
It appears that they use a neighborhood kernel and I<br>
haven't been<br>
able to figure out how to create a<br>
grayscale kernel. I have gone through the book - the part that<br>
describes neighborhood iterators, but<br>
so far that hasn't been a great deal of help. The examples they<br>
provide don't exactly show how to<br>
assign "grayscale" values to your kernel neighborhood iterator.<br>
The examples are for sobel and gaussian<br>
kernels, where there is code in the background that<br>
calculates the<br>
values for you. You never see the details<br>
of how it is used. The other examples they show in the book are<br>
for binary morphology, but that doesn't<br>
require graylevel values kernels, so also isn't much use.<br>
<br>
Basically, I think I need to be able to read in an input image<br>
that is to be processed and two images that<br>
define the grayscale structuring element (SE), and output a<br>
processed image. One of the SE images<br>
defines the region of support of the SE (i.e. anywhere<br>
where the<br>
values are greater than 0 are in the<br>
SE's region of support). The other SE image defines the<br>
grayscale<br>
values in the SE. I then have to use<br>
these two SE images to create a suitable kernel.<br>
<br>
Below is the code that I have written so far, in attempting to<br>
write my own Grayscale Morphological<br>
Operator based on the examples provided in the book. As you can<br>
see, it's not working and I am not<br>
sure how to solve that problem.<br>
<br>
If anyone has any suggestions or ideas of how to get this<br>
working,<br>
or where to look to get information<br>
that could lead in that direction, it would be very much<br>
appreciated.<br>
<br>
Kindest regards<br>
<br>
Harve<br>
<br>
<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a> <<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>><br>
<<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>><br>
<br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br>
<br>
<br>
<br>
</div></div></blockquote>
<br>
</blockquote></div><br>