Repository navigation
Replies: 8 comments 3 replies
|
Hi @Kunyadav, First things first, it is generally adviced when calling this might give a better indication of what the actual error is. In addition to that, can you write to disk and inspect the |
|
Hi, #include <itkElastixRegistrationMethod.h> using namespace std; int CADBasedCoarseEdgeRecipeParams *recipe_params = new CADBasedCoarseEdgeRecipeParams(); if( itkFixedImage.IsNull()==true || itkMovingImage.IsNull()==true) const auto filter = itk::ElastixRegistrationMethod<ImageType, ImageType>::New(); } } // end main() Regards |
|
I am afraid that checking for nulls is not sufficient in this case because that check just regards if the image pointers point to any location not if the underlying pixel array is correctly setup and populated. Even if not needed for your code, you could do I think that ensuring that your images are converted correctly is the first step to debugging this code. |
|
Hi, #include <itkElastixRegistrationMethod.h> int CADBasedCoarseEdgeRecipeParams *recipe_params = new CADBasedCoarseEdgeRecipeParams(); using WriterType = itk::ImageFileWriter; writer->SetFileName("F:\elast\fixed_image.tif"); if( itkFixedImage.IsNull()==true || itkMovingImage.IsNull()==true) const auto filter = itk::ElastixRegistrationMethod<ImageType, ImageType>::New(); } } // end main() |
|
Hi N-Dekker, |
|
Hi N-Dekker, Regards |
|
Hi N-Dekker, |

Uh oh!
There was an error while loading. Please reload this page.
Hi All,
i have modified ElastixTranslationExample.cxx example by adding open cv api to read the moving and fixed image and below is my sample code. exceptions is getting thrown at line highlighted in bold below:
exception:Exception thrown at 0x00007FF606726D2D in elastix_translation_example.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
Please advice and assist me in resolving this error.
#include <itkElastixRegistrationMethod.h>
#include <elxParameterObject.h>
#include <Core/elxVersionMacros.h>
#include
#include <itkImage.h>
#include "itkImageFileReader.h"
#include "itkOpenCVImageBridge.h"
#include <itkSize.h>
#include
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/opencv.hpp"
#include "param.h"
using namespace std;
int main()
{
enum
{
imageSizeX = 6,
imageSizeY = 5
};
typedef itk::Image<unsigned char, 2> ImageType;
cout << "Built with OpenCV 0" << CV_VERSION << endl;
cv::Mat sem_input= cv::imread("C:/Users/e182000/Documents/cad2semm/waveform/B79Y22ADD/wf9_Meas.tif");
cv::Mat cad_input = cv::imread("C:/Users/e182000/Documents/cad2semm/waveform/B79Y22ADD/wf9_Model.tif");
ImageType::Pointer itkFixedImage = ImageType::New();
ImageType::Pointer itkMovingImage = ImageType::New();
CADBasedCoarseEdgeRecipeParams *recipe_params = new CADBasedCoarseEdgeRecipeParams();
recipe_params->setMaxNumOfIerationsFactor(0.1);
cout << "Built with OpenCV 1-> " << CV_VERSION << endl;
itkFixedImage = itk::OpenCVImageBridge::CVMatToITKImage< ImageType >(sem_input);
cout << "Built with OpenCV 2-> " << CV_VERSION << endl;
itkMovingImage = itk::OpenCVImageBridge::CVMatToITKImage< ImageType >(cad_input);
cout << "Built with OpenCV 3->" << CV_VERSION << endl;
cv::imshow("Sample", sem_input);
cv::waitKey(0);
cv::Mat image_blurred_with_3x3_kernel;
cv::GaussianBlur(sem_input, image_blurred_with_3x3_kernel, cv::Size(3, 3), 0);
cv::imshow("Blurred", image_blurred_with_3x3_kernel);
cv::waitKey(0);
const auto parameterObject = elx::ParameterObject::New();
parameterObject->SetParameterMap(
elx::ParameterObject::ParameterMapType{ { "ImageSampler", { "Full" } },
{ "MaximumNumberOfIterations", { "44" } },
{ "Metric", { "AdvancedNormalizedCorrelation" } },
{ "Optimizer", { "AdaptiveStochasticGradientDescent" } },
{ "Transform", { "TranslationTransform" } } });
const auto filter = itk::ElastixRegistrationMethod<ImageType, ImageType>::New();
filter->SetFixedImage(itkFixedImage);
filter->SetMovingImage(itkMovingImage);
filter->SetParameterObject(parameterObject);
filter->Update();
// filter->UpdateLargestPossibleRegion();
} // end main()
Regards
Kunal
All reactions