[ITK] Decode a medical image from memory buffer in ITK
Francois Budin
francois.budin at kitware.com
Mon Oct 24 13:18:03 EDT 2016
Hi Fijoy,
ITK will need the image information such as the size and the dimension to
know what your buffer corresponds to. If you do have these informations
then you can use the import filter Dženan mentioned. If you do not have
these informations, then
there is no way for ITK to know if your image has dimension (x*y*z)*(1)*(1)
or (x*y)*(z)*(1) or any possible combination that would lead to the same
buffer size.
Hope this helps,
Francois
On Mon, Oct 24, 2016 at 11:23 AM, Dženan Zukić <dzenanz at gmail.com> wrote:
> Hi Fijoy,
>
> as far as I am aware, there is no class to read an image from buffer
> instead of file. But the possible workaround is to write that buffer into a
> file in temp folder and read that file.
>
> HTH,
> Dženan
>
> On Mon, Oct 24, 2016 at 11:13 AM, Fijoy Vadakkumpadan <tofijoy at gmail.com>
> wrote:
>
>> Hi Dženan,
>>
>> Correct me if I'm wrong, but the Import filter assumes that I have the
>> medical image metadata (size, resolution, etc.), and the decompressed data
>> (the C-array). However, I do not have these.
>>
>> All I have is a buffer *buf* containing the encoded image, i.e., *buf* is
>> filled like so:
>>
>> unsigned char buf[MAX_FILE_SIZE];
>> f = fopen("myImage.dcm", "rb");
>> n = fread(buf, MAX_FILE_SIZE, 1, f);
>>
>> In other words, I'm looking for a class that can read an image from a
>> buffer, just like ImageFileReader reads from a file. Does such a class
>> exist?
>>
>> Thanks,
>> Fijoy
>>
>> On Mon, Oct 24, 2016 at 10:57 AM, Dženan Zukić <dzenanz at gmail.com> wrote:
>>
>>> Hi Fijoy,
>>>
>>> that is the job of Import
>>> <https://itk.org/Doxygen/html/classitk_1_1ImportImageFilter.html>
>>> filter.
>>>
>>> Regards,
>>> Dženan
>>>
>>> On Mon, Oct 24, 2016 at 10:50 AM, Fijoy Vadakkumpadan <tofijoy at gmail.com
>>> > wrote:
>>>
>>>> Hi all,
>>>>
>>>> I'm wondering if ITK can decode a medical image from a buffer.
>>>>
>>>> For example, if I have a DICOM file read into a buffer buf using
>>>> fread(), is there an API in ITK that I can use to get an itk::Image pointer
>>>> from buf?
>>>>
>>>> Thank you,
>>>> Fijoy
>>>>
>>>> _______________________________________________
>>>> Community mailing list
>>>> Community at itk.org
>>>> http://public.kitware.com/mailman/listinfo/community
>>>>
>>>>
>>>
>>
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20161024/6d0a69a0/attachment.html>
More information about the Community
mailing list