help-octave
[Top][All Lists]

## Re: where is area?

 From: James Sherman Jr. Subject: Re: where is area? Date: Thu, 8 Sep 2011 17:29:21 -0400

On Thu, Sep 8, 2011 at 5:11 PM, Luiz Portella wrote:
Hi,

I´m working in project for computed tomography.
I get matrix 5x5, rotate it with bilinear interpolation (it now is
7x7) and sum elements of columns and get for 0, 45, 90, 135 and 180
degrees counterclockwise:

0.00000   0.00000   0.00000   0.00000   0.00000
0.00000   0.34315   0.00000   0.00000   0.00000
2.00000   0.50000   1.00000   0.00000   1.00000
1.00000   1.05025   0.00000   1.89340   1.00000
1.00000   1.29289   3.00000   1.29289   2.00000
0.00000   0.34315   0.00000   0.34315   0.00000
0.00000   0.00000   0.00000   0.00000   0.00000

For 0, 90 and 180 the sum of this numbers are 4, but not for 45 and
1350! What? I dont understand.... All for cell with 1 (there are 4) is
inside matrix 5x5, away from border.
Thanks a lot.

My code:

#! /home/dijz/ola -qf
# a sample Octave program
printf ("Hello, world!, como é que vai esta força?\n");

a = zeros(7,7); # faz uma matriz 7x7 cheia de zeros
a(3,3) = 1;
a(5,3) = 1;
a(5,4) = 1;
a(5,5) = 1; # monta a imagem
disp(a); #imprime a matriz

xmap = colormap('gray');
img01 = imagesc(a);
print( gcf, '-dpng', fullfile( pwd, 'img01.png' ) );
#imwrite(a, 'img01.gif', 'gif'); #imprime a imagem original
#b = rand( 3, 3);
#imwrite( b, 'test.gif', 'gif');

npro = 5;
apro = [0, 45, 90, 135, 180];
disp(npro); #imprime o número de projeções
disp(apro); #imprime os ângulos de projeções

projecao = zeros(7,5);
for i = 1:npro
temp = imrotate(a, apro(i), "bilinear", "crop", 0);
projecao(:,i) = (sum(temp))';
end

disp(projecao); #imprime as projecoes

img02 = imagesc(projecao);
print( gcf, '-dpng', fullfile( pwd, 'img02.png' ) );

--
_______________________________________________
Help-octave mailing list
https://mailman.cae.wisc.edu/listinfo/help-octave

I'm not sure why you would expect them to be equal.  Bilinear interpolation is not linear.

http://en.wikipedia.org/wiki/Bilinear_interpolation

It "works" in your case for 0, 90, and 180 because these are degenerate cases were the rotated image points lie on the original grid so the points are linear interpolations of two pixels and not a function of all 4 neighboring pixels.