[ITK] confused about itk io factory
Dženan Zukić
dzenanz at gmail.com
Tue Mar 22 10:14:41 EDT 2016
Hi Xie,
the purpose of CreateInstance method is to be implemented (over-ridden) by
sub-classes. Each sub-class would create instance of itself. I guess the
base class just creates an instance of the first registered factory.
Normally, reader->setImageio is not necessary. Try it. The reader asks all
the imageIOs whether they can read the file (based on the filename
extension) until one IO can read. If files have no extension or an
un-matching extension, than setting imageIO should be used. Also, if you
will only work with one type of files, you can manually set that imageIO to
save a few CPU cycles by not checking different imageIOs when opening files.
Regards,
Dženan
On Tue, Mar 22, 2016 at 4:14 AM, 谢玮宜 <weiehome at sina.com> wrote:
>
> Dear ITK experts,
>
> I recently have some problems with using ITK ImageIO factory functions.
> When I tried to use ObjectFactoryBase::CreateInstance(const char
> *itkclassname) with itkclassname like itkPNGImageIO, it is not working. The
> purpose is to create an image io instance by classname using RTTI.
> I did debug into the code and then I found itkclassname has to be
> itkImageIOBase, then it will create always the first ImageIO instance in
> override map. I got really confused what is the purpose of this API
> "CreateInstance(classname)".
>
> I also print out all registered ImageIO factories and I found gdcmImageIO
> is
> in it. So what is the purpose that in example of dicom images reading and
> write, everytime we have to manually call reader->setImageio(
> gdcmIO::New())?
> As I understood, if an imageIO is registered already, the reader will
> automatically check when it is reading a file to see if the format is
> supported by an underlying IO.
>
> Please correct me. I think I somehow got seriously wrong with the
> underlying
> concept of itk IO mechanism.
> Thank you all in advance!
>
> BR,xie
>
>
> _______________________________________________
> 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/20160322/0a63781a/attachment.html>
More information about the Community
mailing list