简体   繁体   中英

MATLAB: how to transform one image to another image

I am trying to transform one image to another in MATLAB, and in the meantime also get the transformation function T(x,y) from this operation (eg. T(x,y) = (x + a(x,y), y + b(x,y)) ). Let's use the following figures as an example. I want to transform the square in the first figure to the circle in the other figure, and output gives me a transformation function, so whenever I use the function on the square I will get the circle.

在此输入图像描述

在此输入图像描述

Functions I have looked into:

I have looked into imwarp , but it should be only for geometric transformation (scaling, rotating, shearing). I don't think this is useful in transforming a square to a circle, while not providing any transformation matrix beforehand.

I have looked into using imregconfig and imregister from a MATLAB example , but it seems to only work for images with same structure but different intensities. Plus, it doesn't give out any transformation function. Please correct me if I am wrong.

Thank you in advance for any help!

The solution space for valid transformations is infinite. How do we choose the "right" one?

One possible transformation for those inputs is to translate the square -0.5 in x and -0.5 in y . Then scale it to double the size ( x' = 2x , y' = 2y ) and apply a square-to-circle mapping function . (Solution 1)

Another completely valid transformation function could run all the points in the input through the expression

( (x == 0 || x == 1) && (0 <= y <= 1) || ( (y == 0 || y == 1) && (0 <= x <= 1) )

and if all points pass, simply print out "x^2 + y^2 = 1" . (Solution 2)

Solutions (1) and (2) both produce code that seems to satisfy the case you've presented, but clearly (2) is so non-general as to be useless. I think you need to define the problem more precisely before we can start writing a solution in code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM