[ITK-users] Convert image, part 2

Dženan Zukić dzenanz at gmail.com
Thu Sep 8 09:43:11 EDT 2016


Hi Tammy,

I think a better way would be to add support for IPL_DEPTH_32S and (if
allowed by OpenCV) IPL_DEPTH_32U. It should not be hard, follow what is
being done for IPL_DEPTH_16U and IPL_DEPTH_16S (unsigned and signed short)
in ITK's BridgeOpenCV module and add analogous code for int. Once you are
satisfied with how it works, contribute
<https://itk.org/Wiki/ITK/Git/Develop> a patch to ITK so others can benefit
from your improvements.

Regards,
Dženan

On Thu, Sep 8, 2016 at 9:34 AM, Tammy Diprima <tammy.diprima at stonybrook.edu>
wrote:

> I've just been told that I'm not allowed to convert the 32U to 16U because
> of risk of distortion.
>
> I figured it *should* be ok, since it's one channel.
>
> So what I've been tasked to do, is iterate through the pixels and copy
> each to a new cv::Mat_<int> image.  And I'm doing this conversion in order
> to pass this ITK image as a parameter to someone else's program that takes
> an opencv image as a parameter.
>
> Right now I'm an image-processing noobie, so I'd like your option.  *Do*
> I have to worry about distortion in this case?  How can I prove it?  It's
> grayscale.  *Is* the pixel iteration a good idea?  I don't know why we're
> using 32U for grayscale in the first place; there's no way we're going to
> have more than 255 objects...
>
> Thanks,
> Tammy
>
>
> On 5 September 2016 at 18:46, Tammy wrote:
>
> Hi Dženan,
>>
>>
>> Yes, that makes sense.  Thanks very much for your help.
>>
>>
>> - Tammy
>>
>>
>> On 5 September 2016 at 15:07, Dženan Zukić wrote:
>>
>>> Hi Tammy,
>>>
>>> the docs
>>> <http://docs.opencv.org/2.4/modules/core/doc/basic_structures.html>
>>> list unsigned short and int, but not unsigned int. I don't know whether
>>> this int is equal to short or long. But from \ITK-git\Modules\Video\BridgeO
>>> penCV\include\itkOpenCVImageBridge.hxx, line 50 these are supported
>>> cases:
>>> IPL_DEPTH_8U
>>> IPL_DEPTH_8S
>>> IPL_DEPTH_16U
>>> IPL_DEPTH_16S
>>> IPL_DEPTH_32F
>>> IPL_DEPTH_64F
>>>
>>> To convert to 16U (which is closest to your 32U), you should use cast
>>> filter <https://itk.org/Doxygen/html/classitk_1_1CastImageFilter.html> (that's
>>> your option A).
>>>
>>> Regards,
>>> Dženan
>>>
>>> On Mon, Sep 5, 2016 at 1:31 PM, Tammy wrote:
>>>
>>>> Greetings!  Hope everyone is having a good day...
>>>>
>>>> So... we are passing around a grayscale image... and we're using
>>>> unsigned int (as opposed to unsigned char):
>>>> typedef itk::Image<unsigned int, ImageDimension> itkUIntImageType;
>>>> typedef itkUIntImageType itkLabelImageType;
>>>>
>>>> I need to convert it to cv::Mat in order to pass it to another program:
>>>> cv::Mat resultImage = itk::OpenCVImageBridge::ITKImageToCVMat<
>>>> itkLabelImageType >( m_objectLabelImage );
>>>>
>>>> The problem is, the compiler is telling me "OpenCV does not support the
>>>> input pixel type".
>>>>
>>>> So my question is -- is this true?  Can I only convert from unsigned
>>>> char?
>>>> Would a good solution be to:
>>>> A) Convert from one pixel type to another, or
>>>> B) Or can I just read in the m_objectLabelImage to an Image::Pointer
>>>> thing that is of type unsigned char?
>>>>
>>>> Thanks!
>>>>
>>>>
>
> _____________________________________
> 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://public.kitware.com/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160908/f0adf01f/attachment.html>


More information about the Insight-users mailing list