Is .PNG no longer supported?

Good Afternoon,

I’m currently trying to create a program to read a given 3D image, perform one forward projection from a varying rotation (Only one slice is made), convert that to a 2D image and write it to a PNG file. I’ve modified the base rtkforwardprojection.cxx program by adding code from ImageReadExtractWrite.cxx to convert to a 2d image. However, when I attempt to output to a PNG file, I receive the error:

Description: Could not create IO object for writing file projectedImage.png
Tried to create one of the following:
DCMImagXImageIO
GDCMImageIO
HisImageIO
HncImageIO
HndImageIO
ImagXImageIO
MetaImageIO
OraImageIO
TIFFImageIO
XRadImageIO
XimImageIO
You probably failed to set a file suffix, or set the suffix to an unsupported type.

When I look on the ITK wiki, it states that png is a supported file type, so I’m wondering what I’m doing wrong

Henry

Yes, PNG should be supported. Could it be that your are explicitly listing the wanted modules in your CMakeLists.txt, and forgetting PNG in that list?

I think that’s the case. How exactly do I go about including it? I thought it would go in the find_package command like so:

# Find ITK with RTK
find_package(ITK REQUIRED COMPONENTS 
RTK 
IO)
include(${ITK_USE_FILE})

but I still receive an error.

Here is an example:

find_package(ITK REQUIRED COMPONENTS
  ITKIOImageBase
  ITKImageIO
  ITKImageIntensity
  ITKConnectedComponents
  ITKBinaryMathematicalMorphology
  ITKThresholding
  )

ITKImageIO meta-module requests all image IOs which are available in ITK build you are dealing with. Is IO one of your own modules?

No I mistakenly thought that since IO is the name of the directory that holds the ImageIOs, it would be the name I had to include.
I’ve added “ITKImageIO” to the find_package command and now I’m struck with a different error

ld: library not found for -l ITKCommon
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Actually I just built the common library again and now it gives me this error instead:

Undefined symbols for architecture x86_64:
“itk::BMPImageIOFactoryRegister__Private()”, referenced from:
itk::(anonymous namespace)::ImageIOFactoryRegisterRegisterList in rtkgeometry_and_projection.cxx.o
(I cut out this section but it essentially runs through all the image file types)
“itk::Bruker2dseqImageIOFactoryRegister__Private()”, referenced from:
itk::(anonymous namespace)::ImageIOFactoryRegisterRegisterList in rtkgeometry_and_projection.cxx.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

ld: symbol(s) not found for architecture x86_64

Make sure to build both ITK and your application for the x86_64 architecture – The CMake generator can default to the 32-bit architecture.

I just rebuilt ITK and my application adding this to the command line -DCMAKE_OSX_ARCHITECTURES=“x86_64”, however I still get the same error

Maybe try a clean build of ITK, RTK and then your example, making sure you choose x64 architecture?

I just configured, generated and made all of ITK, RTK and my program using git clones and specifying the MAKE_OSX_ARCHITECTURES = x86_64. I still receive the same error. Is there maybe something wrong with my makefile?

cmake_minimum_required (VERSION 3.9.5)
project (project1)

# Find ITK with RTK
find_package(ITK REQUIRED COMPONENTS 
    RTK
    ITKImageIO
   )
include(${ITK_USE_FILE})

#Executables

add_executable(rtkgeometry_and_projection rtkgeometry_and_projection.cxx)
target_link_libraries(rtkgeometry_and_projection RTK)

# Installation code
if(NOT RTK_INSTALL_NO_EXECUTABLES)
  foreach(EXE_NAME rtkgeometry_and_projection)
    install(TARGETS ${EXE_NAME}
      RUNTIME DESTINATION ${RTK_INSTALL_RUNTIME_DIR} COMPONENT Runtime
      LIBRARY DESTINATION ${RTK_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
      ARCHIVE DESTINATION ${RTK_INSTALL_ARCHIVE_DIR} COMPONENT Development)
  endforeach()
endif()

Are you building ITK with ITK_BUILD_DEFAULT_MODULES ON? If you are building ITK with only the modules required for RTK, then only the specified IOs get built, which does not include PNG and BMP. Still, the executable should not try to link to IO modules which were not enabled.

1 Like

Yes, I am building with ITK_BUILD_DEFAULT_MODULES on. Still getting the same undefined symbols for architecture error. Is there some way to set RTK to get all the required IO modules instead of only a subset? because none of the modules that are specified in the specified IOs are on the error list.

@simon.rit Can you try to figure out what is wrong?

This should be:

target_link_libraries(rtkgeometry_and_projection ${ITK_LIBRARIES})
2 Likes

Probably my mistake, sorry @Henco. I have fixed RTK example


Thanks @matt.mccormick!

1 Like

Success! Thank you all for your assistance.

1 Like