Skewing an image based off a function

  • Thread starter Thread starter m1ke_
  • Start date Start date
  • Tags Tags
    Function Image
Click For Summary
SUMMARY

The discussion focuses on skewing an image using the mathematical function x = A*log(B*y), where A and B are constants, y represents the height of a pixel row, and x indicates the translation of that row. The user shares their method for implementing this function in code to minimize distortion, specifically using a custom transformation function in MATLAB. They detail the creation of a transformation structure (Tform) with the functions 'functf' and its inverse 'functi', and demonstrate how to apply this transformation to an image using the 'imtransform' function.

PREREQUISITES
  • Understanding of image processing concepts in MATLAB
  • Familiarity with custom transformation functions in MATLAB
  • Knowledge of logarithmic functions and their applications
  • Experience with MATLAB's 'maketform' and 'imtransform' functions
NEXT STEPS
  • Explore MATLAB's 'cp2tform' for polynomial transformations
  • Learn about inverse mapping techniques in image processing
  • Investigate advanced image distortion correction methods
  • Study the effects of different logarithmic functions on image transformation
USEFUL FOR

This discussion is beneficial for image processing developers, MATLAB users, and anyone interested in implementing custom image transformations to achieve specific visual effects without distortion.

m1ke_
Messages
21
Reaction score
0
Hello,

Suppose I have the function x = A*log(B*y) where A and B are constants, y is the height of a row of pixels, and x is how much that row of pixels needs to be translate right or left. How would you recommend incorporating this into code as to minimize distortion?

I have tried writing my own programs, however the images come out with lines where you can see the shifting as well as pixelated in regions. I have also looked into polynomial version of cp2tform but have had little success (possibly from not understanding it fully, it seems like there are only a few examples of how to use it).
 
Physics news on Phys.org
I figured out how to do it, and figured I would post my method for those who are curious or may be struggling with the same experience.

You need to create a Tform that performs the mapping T(x,y) = (u,v). In my case T(x,y) = ( x + A*log(B*y), y).

You must create a function (lets says its called functf) that does this, it may look as follows:

function U = functf(X, unused)

x = X(:,1);
y = X(:,2);

d = @y A*log(B*y);

U(:,1) = x + d(y);
U(:,2) = y;

end

You must then make a second function that is the inverse mapping(lets say functi)

You now make a tform as follows:

>> tform = maketform( 'custom', 2, 2, @functf, @functi, []);

the tform should be created, if not make sure you have the @ sign (screwed me up for a bit). Then to apply it to the image is the same as normal.

>> imnew = imtransform(image, tform);
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
Replies
1
Views
8K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 226 ·
8
Replies
226
Views
16K
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K