我現在正在使用ITK庫進行圖像註冊。我用OpenCV讀取源圖像,然後將它們轉換爲ITKImage;註冊後,我將結果轉換爲CVMat並使用imwrite存儲它。ITKImageToCVMat返回白色圖像
但是,ITKOmageToCVMat總是給出一個白色圖像(通過imshow顯示),並且在imwrite之後,結果不存儲在文件夾中。這太奇怪了......
下面是我的代碼:
cv::Mat img1 = imread(argv[1], IMREAD_GRAYSCALE);
cv::Mat img2 = imread(argv[2], IMREAD_GRAYSCALE);
typedef float PixelType;
const unsigned int Dimension = 2;
typedef itk::Image< PixelType, Dimension > FixedImageType;
typedef itk::Image< PixelType, Dimension > MovingImageType;
typedef itk::OpenCVImageBridge BridgeType;
FixedImageType::Pointer fixedImage = BridgeType::CVMatToITKImage<FixedImageType>(img1);
MovingImageType::Pointer movingImage = BridgeType::CVMatToITKImage<MovingImageType>(img2);
Mat img3 = itk::OpenCVImageBridge::ITKImageToCVMat<MovingImageType>(movingImage);
display("moving image", img3);
string filename3 = "img3";
imwrite(filename3, img3);
即使沒有註冊,只是從轉換CvMat中的圖像ITKImage,再轉換回,這是行不通的....你有什麼想法?謝謝:)