How to do image warping with intensity conservation?

Hello,

for image warping Igor brings a nice example that warps an example image using a source and destination mesh definition.
(Linked at the end of the ImageInterpolate help)

I would like to implement the same with the modification that the intensity in the image is conserved on a per pixel basis.
So whenever the warping doubles a source pixel I want to half the intensity in both destination pixels and whenever several source pixels contribute to a destination pixel the intensity is added up.

A solution would be to reimplement the warping algorithm and extract the relevant pixel mapping information, which would allow to modify the pixel intensity in the destination image accordingly.

Though, I was wondering if there is a way to do that more conveniently in Igor?

 

Best regards,
Michael

Hello Michael,

I'm not sure what you mean by conserving the intensity on a "per pixel basis".  Do you expect to conserve the total integrated intensity for the image?

Consider the following simplified situation: you have one row of 4 pixels that you stretch by a factor of 2 to 8 pixels.  The total integrated intensity will be approximately a factor of 2.  Not exactly because the linear interpolation may get truncated to the integer pixel levels, but still, this is probably not conserving anything...  

Could you please explain exactly what you need to compute.

 

AG

 

Hello,

yes, I want to conserve the total integrated intensity of the image.

Let's say that for the image warping I set the control point grid such way that the splines intersect only at the control points. So I have no areas with ambiguity.

Then I want to conserve the intensity such way that a pixel intensity that is mapped to a stretched area of the destination image is divided by the number it appears there.
A very simple 1D example with 2 pixels with intesity 4 and 6 stretched to 3 pixels:

If the first pixel gets duplicated:
4, 6 -> 2, 2, 6

If the second pixel gets duplicated also valid would be:
4, 6 -> 4, 3, 3

If the destination is compressed 3 -> 2 then the pixels get added up:

4, 3, 3 -> 7, 3
or also valid:
4, 3, 3 -> 4, 6

Thats what I mean on a per pixel basis. Of course one could extend this further and introduce some interpolation.

The important thing is that the total intensity is conserved. I would like to accomplish that by conserving the intensity as local as possible.


Best regards,
Michael

Hello Michael,

None of the warping methods conserves intensity in the manner that you describe because it would lead to sharp jumps around any deformation.  In fact, I think it may not be easy to implement for a general 2D deformation.  If you would like to exchange some ideas about this application please contact me at support@wavemetrics.com.

AG

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More