Straighten a distorted square to analyse particles

Dear all,

I am a more-than-beginner to imageJ. I am using Fiji. I am trying to analyse (many) pictures of a square on the ground taken from above but not horizontally, resulting in distortion. I want to analyse the proportion of the image covered with vegetation, I thus need to straighten the image to have an accurate measurement. As the particle measurements will count pixels, the pixels of the final image should not be distorted.

I already had a look at TransformJ (http://www.imagescience.org/meijering/software/transformj/) but the plugins ask for entering rotation angles, which I don’t know precisely and which vary from one image to another. The ideal way would be to indicate the four corners of the square and to turn it into an actual square, but I could not find how to do it.

I would appreciate any help, and I beg your pardon for noob questions !

Thanks,
Marypop

Hi @Marypop

And welcome to the forum!

As far as I understand the problem you want to apply image rectification. I guess if you take a plane picture of the square you could find the transformation which maps this image to the plane picture of the square.

But to do so you need to know the intrinsic parameters of the camera, which means you have to do a camera calibration. And there seems to be some radial distortion in your images which should be corrected too.

If it is possible I would try a fixed imaging set up where the reference square is above the ground and the camera has always the same distance and rotation relative to the square. Then the results can be compared without any reconstruction and the segmentation of the blue square and the red wires, which currently are partly covered), will be much easier.

If you always have the same distance to the ground you can even get rid of the blue square and use a virtual square for the analysis.

2 Likes

In principle you can use the ‘Plugins->Transfom’ tools.

Rotate the image and then make a perspective correction.

However to be honest in the spirit of OpenSource software I used Gimp to get the following result in very short time (rotation and perpspective correction):

If you have an reference undistorted image you can add the image as an layer to the distorted image and then use it to correct your distorted layer or you can also use guidelines (see video below).

Here is a nice video tutorial with Gimp which uses guidelines to correct the image:

If you have a systematic error (angle, lens, etc.) it makes definetely sense to calculate the distortion parameters but I guess you have very different fotos and the described method is one of the fastest and I think sufficient to estimate the vegetation cover.

2 Likes

Dear @tibuch,

Many thanks for your reply.
There is probably a radial distortion, but I think most of the curve you see in the image is due to the frame being not perfectly a square.

The plan was obviously to have the same distance and angle from the ground to the camera, but unfortunately it was not possible due to field conditions. I think I will give a try to Bio7’s suggestion.

Best,
Marypop

Dear @Bio7,

This tool is really what I was looking for, thank you. Do you know if the pixels will be distorted using this method? If pixels in the area that I make bigger to fit the frame are indeed bigger, and if the particle analysis counts pixels (instead of “actual” area), the correction will not solve the problem.

All the best,
Marypop

Well the best thing of course is if you have fotos without distortion. In the past I made similar fotos by constructing a kind of pyramid metal frame to get straight top down vegetation fotos.

But even then if I look at your vegetation you don’t get precise results but an estimation of the vegetation cover which might be sufficient if the images are not to much distorted.

1 Like

Marypop,

be assured that it is impossible to distort pixels because pixels are numbers. What you mean are representations of numbers on a display and they are always in a rectagular grid and have the same size …

HTH

Herbie

@anon96376101

hahaha.
I warned I would ask noob questions.
Thank you!