1
$\begingroup$

I program function to calculate the overlap area between 2 images (which is called fixed and floating) after transformation but it takes much time and it's complex for me to combine more than one transformation parameter together.

In Matlab, the built in functions affine2d can make affine transformation (rotation, translation, and scaling) that can solve my problem. However, this function depends on imwarp which fills the empty space with new pixel (default: black).

As you can see the below image, my ROI inside the red box in the both images.

enter image description here

How can extract this area from the transformed image (float)?

Update: the hardest part is to find the ROI coordinator in the transformed image.

$\endgroup$
8
  • $\begingroup$ find the index of your ROI corners and extract it from the transformed image! $\endgroup$ – Mohammad M Aug 28 '17 at 10:06
  • $\begingroup$ I update my question $\endgroup$ – Mohammad nagdawi Aug 29 '17 at 6:14
  • $\begingroup$ how do you define your ROI? how did you plot those red lines? $\endgroup$ – Mohammad M Aug 29 '17 at 6:19
  • $\begingroup$ I draw this rect manually $\endgroup$ – Mohammad nagdawi Aug 29 '17 at 6:20
  • $\begingroup$ if you want a rectangular region with no black pixel, you could find the coordinate of 4 colored dots using the imwarp reference output, then sort each component of those coordinates after sorting discard the minimum and maximum and keep 2 mid component. $\endgroup$ – Mohammad M Aug 29 '17 at 6:26
2
$\begingroup$

To find coordinate or index of drew region, first you have to find the coordinate of 4 colored dots, which is easily obtained by using the transformPointsForward function over the intrinsic coordinate of these 4 points in your original image. intrinsic coordinate is the index of your image matrix.

then you have to do some geometric calculations. first, find the length of one of red lines which are the (length of full warped image)/(sin(theta) + cos(theta)), then distance of red line to the nearest colored point is (length of red line)*cos(theta)*sin(theta). theta is the rotation angle. using this distance and the coordinate of 4 colored points you could find the coordinate of your ROI corners.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.