Hi,

I observed 2 bugs in imtranslate.m from the 'image' package. They are
both described below

============== 1st bug ========================================
function Y = imtranslate(X, x_shift, y_shift, bbox_in)
suppose to shift/translate image but if  (x_shift+y_shift) is odd
the resulting image get multiplied by -1.

Here is the test:
octave:103> it=ones(3)

it =

   1   1   1
   1   1   1
   1   1   1

% below correct behavior
octave:104> im_sm_trsl=imtranslate(it, 1, 1)
im_sm_trsl =

   1   1   1
   1   1   1
   1   1   1

%now incorrect behavior
octave:110> it=ones(4)
it =

   1   1   1   1
   1   1   1   1
   1   1   1   1
   1   1   1   1

octave:111> im_sm_trsl=imtranslate(it, 1, 0)
im_sm_trsl =

  -1  -1  -1  -1
  -1  -1  -1  -1
  -1  -1  -1  -1
  -1  -1  -1  -1

%notice -1 sign.

=== suggested fix: multiply the final result by (-1)^(shift_x+shift_y)


============== 2nd bug ========================================
Severe precision drop for small images:

octave:112> it=ones(3)
it =

   1   1   1
   1   1   1
   1   1   1

octave:113> im_sm_trsl=imtranslate(it, 2, 0)
im_sm_trsl =

  -0.50000  -0.50000  -0.50000
  -0.50000  -0.50000  -0.50000
  -0.50000  -0.50000  -0.50000

# instead of resulting matrix ones we get negative 1/2.

============
Looks like problem is actually in the fft which used for translation,
since imtranslate algorithm
seems to be correct one. But I do not see an easy fix for second problem.
==========================================================================

It is a bit unclear to me why use fft is used for translation. Since
integer shift could be done in a simpler way, fractional shift is
another story.






-- 
Eugeniy

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to