Shift rows in an image

Hi all,

I use images which are 10 pixel high. Basically I have an image looking like this / // //// // which I need to transform to I II IIII II. I need to shift each row based on a linear function. The shifts will be fractions of pixels but are necessary to align the rows before binning. I have been searching for a plugin doing so (like astigmatism correction) but didn’t found one. Is there a simple way to shift entire rows by pre-calculated pixel fractions?

Thanks,
Stefan

Good day Stefan,

why not select an image row and translate it?

Of course you may wish to wrap the row around which could be performed by using an IJ-macro…

HTH

Herbie

Hi @soertel

there is Plugins > Transform > Interactive Affine that might be suitable for your task. After interactively adjusting the image, just press Enter and the affine transformation matrix will be output in the log window.

To reapply a given transformation matrix onto an image, you can use TransformJ Affine (from the ImageScience update site).

Before: After:

If you know the exact amount to be tilted, you can build your affine transformation matrix like this:

1 A 0
0 1 0    with A being the amount to tilt in x direction relative to y direction
0 0 1

Hi Jan.

thats basically what I am looking for. The shift I need is 0.125 pixels, so I created the matrix for that but the shift I measure is very close to one. Is the plugin able to use fractions of a pixel?

Thanks,
Stefan

Stefan,

of course TransformJ is able to deal with fractions otherwise the various interpolation schemes wouldn’t make sense.

Best

Herbie

Herbie, but why is my first line then shifted by 1 and not by 0.125 as entered in the matrix?

Best,
Stefan

Stefan,

for me it works perfectly, but perhaps you have a different idea of what a pixel really is.

In case you think it is a little square, you are wrong. In fact it has no spatial extension, because it is a number (gray value). The little square you see is simply caused by a method to make a infinitely small point (gray value) visible on your display. You may think of the little square as the zero-order interpolation of such points …

HTH

Herbie

Herbie, no, my idea of a pixel is fine. It is just a (in my case) two dimensional value pair. I think I found the flaw: the value A is the shift value per line, not the total shift between the first and last line. Is that true? With entering 0.0125 instead of 0.125 the result looks good.

Can I call affine directly out of a plugin without the user interface?

Thanks,
Stefan

Stefan,

you may record the action from ImageJ wich gives you the desired call, depending on your preferred language, Java, IJ-macro, etc.

HTH

Herbie

Thanks Herbie. Problem solved!

Cheers,
Stefan