Can't dewarp image using fitgeotform2d and imwarp
0 个评论
回答(1 个)
2 个评论
Hi JCD,
Let me break down your query and address the potential issues step by step.
1. Loading and Displaying Images:
load("calImg.mat") J = double(calImg); fixedPoints = W; movingPoints = I; figure(1) imagesc(J)
- Here, `calImg.mat` is loaded and stored as `J`. The `fixedPoints` and `movingPoints` define corresponding points in the images `W` and `I` respectively for the transformation.
2. Geometric Transformation Setup:
tform = fitgeotrans(movingPoints, fixedPoints, "projective"); Jregistered = imwarp(J, tform, 'OutputView', imref2d(size(J)));
- `fitgeotrans` is used to compute a projective transformation (`"projective"`) based on the corresponding points. - `imwarp` applies the transformation `tform` to image `J` using an `imref2d` object that specifies the output size (`size(J)`).
3. Visualization of Results:
figure(2) imshowpair(I, Jregistered)
- `imshowpair` is used to display both `I` (presumably the original image) and `Jregistered` (the transformed image) side by side for comparison.
Potential Issues Identified:
- *Image Data Type:* Ensure that `calImg.mat` contains the image data in a format compatible with `imwarp`. Converting to `double` (`J = double(calImg)`) may not always be necessary depending on the original data type.
- Transformation Accuracy:Verify that `fixedPoints` and `movingPoints` accurately correspond to points in `W` and `I`. Incorrect correspondence can lead to failed registration.
- OutputView Specification:Ensure that the `OutputView` parameter in `imwarp` is correctly defined (`imref2d(size(J))`). This specifies the spatial referencing information for the output image.
Revised Approach:
Based on the code snippet provided and the issues identified, make sure to:
- Check the correctness of point correspondences (`fixedPoints` and `movingPoints`).
- Verify the image data type and ensure it matches the requirements of `imwarp`.
- Double-check the `OutputView` parameter to ensure it accurately describes the output image dimensions.
-Also, double check the code you mentioned about two transformations: flip the image upside down and then correct the projective perspective
Hopefully, following these steps will help resolve your problems.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!