<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi,<br>
<br>
2nd attempt using approach 1) (see below). What about typos in
comments I removed during bug fixing? Include into this patch as
well or keep them separate?<br>
<br>
Additionally you find a small application creating an image with a
bright square on dark background which displays the image together
with the result of ApproximateSignedDistanceMapImageFilter. The
pixel value of the square is 1 by default but can be changed via
command line.<br>
<br>
Regards,<br>
Christina<br>
<br>
<br>
On 29.03.2017 15:12, Francois Budin wrote:<br>
</div>
<blockquote
cite="mid:CAHwLD2V_SJ6toyNvCOpbMiFeW-gJ0AVr2Pt9xfCvA4ydqtV6qg@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>Hello Christina,<br>
<br>
</div>
I see different paths to try to solve this issue
and I am not sure which one is the best one:<br>
</div>
1) You could modify the
itkIsoContourDistanceImageFilter class so that
m_LevelSetValue is of some real type. When looking
in the implementation of this filter, you can see
that sometimes, m_LevelSetValue is casted to a
real type [1], so maybe it makes sense to do that.<br>
</div>
2) Casting is one solution, but you have to be
careful if you want to cast to float or double. If
you cast to float, and the input is of type double,
you will loose precision. If you always cast to
double, you might use a lot of memory. Sadly, in the
itkNumericTraits, there is no way of asking for "the
smallest floating type that contains my current
type". You can call "RealType" which will be
"double", or "FloatType" which will be float. One
strength of casting, is that if you perform it in
place, it can actually not do anything if it doesn't
need to [2].<br>
</div>
3) To avoid casting when you don't need to (your type
is float or double), you could use the SFINAE concept
like it is used here [3]. This is more complex and may
not be worth it.<br>
<br>
</div>
Beware that images may contain pixels that are not only
scalar values, but also RGB, RGBA, vectors. I am not
sure if the ApproximateDistance filter supports these
types, but it is good to be careful, when modifying the
code, to not restrict the usage of a filter to scalar if
not required. To avoid that kind of issues, and to
answer your original question, you can use the Rebind
structure [4].<br>
<br>
</div>
I hope this helps.<br>
</div>
I will be out of town for a week, and most likely will have
limited to no access to the internet, so don't be surprised
if I do not answer your next message within the next week.<br>
<br>
</div>
Thanks for helping!<br>
</div>
Francois<br>
<div>
<div>
<div>
<div>
<div>
<div>
<div><br>
[1] <a moz-do-not-send="true"
href="https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/DistanceMap/include/itkIsoContourDistanceImageFilter.hxx#L314">https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/DistanceMap/include/itkIsoContourDistanceImageFilter.hxx#L314</a><br>
[2] <a moz-do-not-send="true"
href="https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/ImageFilterBase/include/itkCastImageFilter.hxx#L42">https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/ImageFilterBase/include/itkCastImageFilter.hxx#L42</a><br>
[3] <a moz-do-not-send="true"
href="https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/IO/ImageBase/include/itkConvertPixelBuffer.h#L153-L161">https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/IO/ImageBase/include/itkConvertPixelBuffer.h#L153-L161</a><br>
[4] <a moz-do-not-send="true"
href="https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/Smoothing/include/itkSmoothingRecursiveGaussianImageFilter.h#L84-L85">https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/Smoothing/include/itkSmoothingRecursiveGaussianImageFilter.h#L84-L85</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Mar 29, 2017 at 7:10 AM, Chr.
Rossmanith <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:cr@neuro.ma.uni-heidelberg.de"
target="_blank">cr@neuro.ma.uni-heidelberg.de</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div class="m_3859778017652307664moz-cite-prefix">Hi
Francois,<br>
<br>
I'm getting back to this issue. I'll introduce an
intermediate image in the mini pipeline used in
ApproximateSignedDistanceMapIm<wbr>ageFilter which has a
floating type for pixel values. Given<br>
<br>
/** Type for input image. */<br>
typedef TInputImage InputImageType;<br>
<br>
how can I define a corresponding image type
FloatImageType replacing the unknown pixel type by
float? I can't write itk::Image< float, xxx >
because I don't know xxx. <br>
<br>
Is there a way to query the pixel type to avoid applying
the CastImageFilter in case we already get floating
valued pixels?<br>
<br>
Christina
<div>
<div class="h5"><br>
<br>
<br>
On 03.03.2017 14:58, Francois Budin wrote:<br>
</div>
</div>
</div>
<div>
<div class="h5">
<blockquote type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>Hi Christina,<br>
<br>
</div>
Maybe your idea was good but needs more work
(e.g. cast the input image to the output
type? at least if input is not a float, or
maybe something else). I am glad you found a
solution that works for you. If you need
your software to be faster, you can also
replace the SignedDanielssonDistanceMap with
the SignedMauerDistanceMap [1].<br>
<br>
</div>
Hope this helps, and thanks for your
contribution. Do not hesitate to submit a new
patch to solve your original problem if you
find a solution.<br>
</div>
<br>
</div>
Francois<br>
[1] <a moz-do-not-send="true"
href="https://itk.org/Doxygen/html/classitk_1_1SignedMaurerDistanceMapImageFilter.html"
target="_blank">https://itk.org/Doxygen/html/<wbr>classitk_1_<wbr>1SignedMaurerDistanceMapImageF<wbr>ilter.html</a><br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Fri, Mar 3, 2017 at
8:23 AM, Chr. Rossmanith <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:cr@neuro.ma.uni-heidelberg.de"
target="_blank">cr@neuro.ma.uni-heidelberg.de</a><wbr>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0
0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div
class="m_3859778017652307664m_1181073176616590407moz-cite-prefix">Hi
Francois,<br>
<br>
really strange, on Wednesday changing the
data type made my application work as
expected (but obviously there must have
been an additional change which really
made the application work...). When trying
to build a small example for you, I
failed. I still think that feeding a 0/1
image into ApproximateSignedDistanceMapIm<wbr>ageFilter
makes sense. <br>
<br>
Originally I'm interested in
ContourExtractor2D, which operates on a
distance map using 0 as contour level.
Unlike in the ContourExtractor2D example
I've decided to use
SignedDanielssonDistanceMap which works
fine without any patches.<br>
<br>
So send the patch to /dev/null for the
moment...<br>
<br>
Christina
<div>
<div class="m_3859778017652307664h5"><br>
<br>
On 02.03.2017 16:17, Francois Budin
wrote:<br>
</div>
</div>
</div>
<div>
<div class="m_3859778017652307664h5">
<blockquote type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>Hello Christina,<br>
<br>
</div>
I just reviewed you patch.
You are changing the type
of the variable
levelSetValue to
OutputPixelType which is
suppose to be a floating
point value.<br>
</div>
However, the computation is
done with InputPixelType
variables (m_InsideValue and
m_OutsideValue) and divided
by an integer. Additionally,
the resulting value is used
in:<br>
m_IsoContourFilter->SetLevelSe<wbr>tValue(levelSetValue);<br>
<br>
</div>
which accepts values of
InputPixelType [1] since
IsoContourType is defined as:<br>
typedef
IsoContourDistanceImageFilter<
InputImageType,
OutputImageType >
IsoContourType;<br>
<br>
</div>
I am not sure if your patch
solves the problem that you
mentioned. Do you have a test
that would verify that the new
behavior corresponds to your
expectations? Based on the code
review I have done, I would not
expect the behavior of the
filter to change.<br>
<br>
</div>
Let me know if I missed a detail.
Thank you for your contribution!<br>
</div>
Francois<br>
<div>
<div>
<div><br>
[1] <a moz-do-not-send="true"
href="https://itk.org/Doxygen/html/classitk_1_1IsoContourDistanceImageFilter.html"
target="_blank">https://itk.org/Doxygen/html/c<wbr>lassitk_1_1IsoContourDistanceI<wbr>mageFilter.html</a><br>
</div>
</div>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Mar
1, 2017 at 8:12 AM, Chr.
Rossmanith <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:cr@neuro.ma.uni-heidelberg.de"
target="_blank">cr@neuro.ma.uni-heidelberg.de</a><wbr>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="margin:0 0 0
.8ex;border-left:1px #ccc
solid;padding-left:1ex">For
binary images with 0 for
background and 1 for objects
with an integer input pixel type
there is a problem representing
the average of 0 and 1 = 0.5
with the input pixel type. The
output pixel type is required to
be a floating pixel type (filter
documentation), so it should be
safe to change the type of
levelSetValue to
OutputPixelType.<br>
<br>
Regards,<br>
Christina<br>
<br>
<br>
______________________________<wbr>_______<br>
Powered by <a
moz-do-not-send="true"
href="http://www.kitware.com"
rel="noreferrer"
target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source
projects at<br>
<a moz-do-not-send="true"
href="http://www.kitware.com/opensource/opensource.html"
rel="noreferrer"
target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
<br>
Kitware offers ITK Training
Courses, for more information
visit:<br>
<a moz-do-not-send="true"
href="http://www.kitware.com/products/protraining.php"
rel="noreferrer"
target="_blank">http://www.kitware.com/product<wbr>s/protraining.php</a><br>
<br>
Please keep messages on-topic
and check the ITK FAQ at:<br>
<a moz-do-not-send="true"
href="http://www.itk.org/Wiki/ITK_FAQ"
rel="noreferrer"
target="_blank">http://www.itk.org/Wiki/ITK_FA<wbr>Q</a><br>
<br>
Follow this link to
subscribe/unsubscribe:<br>
<a moz-do-not-send="true"
href="http://public.kitware.com/mailman/listinfo/insight-users"
rel="noreferrer"
target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/insight-users</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<p><br>
</p>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<p><br>
</p>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<p><br>
</p>
</body>
</html>