2D-3D Image registration and Fusion with ImFusion SDK

To read the Image data (CT Image/3D Image data) I am using “ImFusion::NiftiIO” class to read the Image that return Unique pointer of SharedImgeSet.
static std::unique_ptr readImage(const std::string& filename, Progress* progress = nullptr);

I am using like
clSharedimageset = ImFusion::NiftiIO::readImage(nclSarCTImagePath, nullptr);
and getting run time error as "Exception thrown at 0x00007FF96A96AFDE (ImFusionLib.dll) in TwoD3DFusionWIP.exe: 0xC0000005: Access violation reading location 0x000004AF86B0958F.
"
(Here I am trying to read the Image with extension .nii or .nii.gz)
Suggest me the way how to resolve it as I explored.

Note: Other than this one more thing I want to know that how may I read the Image 3D and 2D with extensions like .mha, .nrrd. and .dcm

Thank you for the time

Hi,

Could you share the nifti image that you are trying to load, so that we can try to reproduce the issue?

Regarding the other formats, please have a look at MetaImageIoAlgorithm, NrrdIoAlgorithm and DicomIoAlgorithm. Actually you could have also used NiftiIoAlgorithm (but this is just a higher-level interface, so I don’t think it would solve your problem because it has the same underlying code).
Here is how to use an IoAlgorithm:

NrrdIoAlgorithm nrrdAlgo(nullptr, IoAlgorithm::IoMode::Read);
nrrdAlgo.setLocation(filename);
nrrdAlgo.compute();
auto ioOutput = nrrdAlgo.takeOutput();

Thank you for you reply,
Here I am attaching the 2D and 3D Image data that I am using to read the Data

https://drive.google.com/drive/folders/1uuAbP_AOb-Vg7iEXMnk2XAfYAD7b0LOQ?usp=drive_link

Share your code snippet for
DICOM (2D and 3D), .mha, png, jpeg

As it’s need of ImageDescriptor to create MemImage and Image and before having Read the Data How may I provide the details to the ImageDescriptor

I need help for the reading of the Image data in 2D and 3D case where I am want to use the
png, jpeg and .dcm image in case of 2D And .dcm, and .mha, nrrd, in image in case of 3D
and want to return the Image as in MemImage, I have some confusion because I tried as per the ImFusion SDK documentation but it;s not reading.
As the details i added into my above query.
Please share you code snippet, I have attached the data in the above query

Thank you

If you do not know the image format in advance, then you can use the more generic IO::FileLoader class:

for (std::string location : {"/CT Image Data/54141983.mha", "/2D Image Data/APShot_13.bmp"})
{
	IO::FileLoader ioAlgo;
	std::optional<OwningDataList> ioOutput = ioAlgo.load(location);
	if (ioOutput.has_value())
	{
		std::unique_ptr<SharedImageSet> img = ioOutput->extractFirstImage();
		if (img)
		{
			LOG_INFO("Image size = " << img->img()->dimensions().transpose());
		}
	}
}

It’s showing error in the std::unique_ptr img = ioOutput->extractFirstImage();

Hi, Prevost
I understand your points and got it,
But while initialization of the licence I am facing some issue, I tried with

         Method 1

if (!ImFusion::LicenseManagerSDK::isActivated())
{
ImFusion::LicenseManagerSDK::setKeyAndCode(“xxxxxxxxxxxxxxxxx”);
ImFusion::Framework::init(); // Initialize
ImFusion::Framework::loadedPlugins();

   }

as well as

                  Method 2
ImFusion::Framework::InitConfig initconfig;
try
{
    initconfig.licenseInitFunction = []() {
        if (!ImFusion::LicenseManagerSDK::isActivated())
            ImFusion::LicenseManagerSDK::setKeyAndCode("xxxxxxxxxx");
    };
}
catch (const std::exception& error )
{
    std::cout << "Error Found in the Lincence Key and Code activation" << std::endl;
}

initconfig.loadPlugins = true;
ImFusion::Framework::init(std::move(initconfig));

        and load plugins like 

bool bPluginTest = ImFusion::Framework::loadPlugin(“PluginLocal address of dll”); // DICOM Plugin
if (bPluginTest == 1)
{
std::cout << “LoadPlugin successfull” << std::endl;
}
else
{
std::cout << “LoadPlugin unsuccessfull” << std::endl;
}

as well as tried with Standalone application example from ImFusion Github

Actually I am trying to test a standalone application so,
my step is to first initialize the licence and then execute the ImFusion algorithm

please share your view and code snippet to initialize the ImFusion licence.
Thank you