# how to do image transformation using distortion algorithm?

45 views (last 30 days)
soruba on 30 Dec 2014
Answered: Valeriy on 14 Jan 2020
I need to do a biometrics project by trnaforming the image using distortion algorithm. please provide me algorith and matlab coding for distortion algorithm

Image Analyst on 30 Dec 2014
See my attached demo. You can have it correct for both barrel and pincushion distortion.

Valeriy on 11 Jan 2020
@ImageAnalyst, thanks for your demo, it is clear and shows main principle of distortion compensation. I need to realize such compenstaion not for a few points, but for complete image. Of cource, it is possible to repeated such compensation for each pixel of final image, but, perhaps, is (are?) in Matlab functions that realize such operation in more efficient way?
By the way, I already many times used your efficient and valuable help with my issues and questions. Is it possible to express my appreciation of it to Matlab authorities?

#### 1 Comment

Image Analyst on 14 Jan 2020
You're welcome Valeriy. You can send an email to chenlin at mathworks dot com if you want the staff at Mathworks to know. Chen Lin, Ned Gulley (gulley at mathworks.com), David Wey, and John Kelly are some of the staff involved with the Answers forum of the MATLAB Central community.
What I do for background correction is to take a blank shot (no objects in the scene) and then fit a smooth 2-D 4th order polynomial to the surface. This will ignore small noise pixels and give you the smooth pattern due to the combination of lens shading and lighting non-uniformity. I'm attaching a demo. You'll need to download John D'Errico's polyfitn() function for 2-D polynomial fit from the File Exchange.

Valeriy on 14 Jan 2020
Thanks a lot, Image Analyst for your code and information. It is very related to my current project: I need to process microscopy image (measured), which needs such background intensity correction, as well as some dust subtraction. I'm doing this by FFt processing of "blank" shot, its low frequency FFT component I use as illumination distribution, intensity, while
dust = blank - intensity
and as processed image, (processed) I use
processed = (measured - dust) / intensity
Result is much better than raw "measured" data.
About distortion compensation, it seems that I found a way how to realize it without pixel to pixel calculations: exchange it by column to column calculations after realization cart2pol transformation: each image radius will corresponds to its column. So for such transformation I only needs to shift and interpolate columns' data. Recently I saw in Answers image of cart2pol transformation, but lost reference. It could save me some coding time, but this is not crytical
I'm writing a letter to ML authorities. Thanks again for your help.