'improfile' is a missing function in octave, what other options could I use to make my loop works?

imshow(matrix(:,:,1))
%identify axes
[x, y] = ginput(2);
% preallocate matrices
cog = zeros(size(matrix,3),1);
% loop start
for i = 1:size(matrix,3)
I = matrix(:,:,i);
%what to do to make this code works in octave
test = improfile(I,[x(1) x(2)],[y(1) y(2)]);
cog(i) = sum((1:length(test)).*test')/sum(test);
% loop end
end
scog = (cog - min(cog)) / (max(cog) - min(cog));

4 comentarios

Jan
Jan el 28 de Jul. de 2022
Editada: Jan el 28 de Jul. de 2022
This is a Matlab forum. The code runs successfully in Matlab. What about asking this question in an Octave forum?
improfile is a 2D interpolation along a line. So get the coordinates of the line and call interp2.
I substitue the code with 'test = interp2(I, 2); instead of 'test = improfile(I,[x(1) x(2)],[y(1) y(2)]); and it works but not sure if it is right.
@Bilal Alsharif: Do you see the set of icons above the field for typing the text in the forum? They help you to apply a nice formatting. I've formatted the code for you in the question already. Please use these formatting tools to distinguish text, Matlab code and programs.
@Image Analyst: I've re-opened the question. Although Octave is off-topic, the answer works for Matlab users without the Image Processing Toolbox.

Iniciar sesión para comentar.

Respuestas (1)

The command interp2(I, 2) does not consider the selected line. Better:
n = ceil(norm([diff(x), diff(y)])); % A rough estimation of number of points
test = interp2(I, 2, linspace(x(1), x(2), n), linspace(y(1), y(2), n));

1 comentario

improfile figures out whether the row difference is greater than the column difference, and does the interp2 along the longer dimension.

Iniciar sesión para comentar.

Categorías

Preguntada:

BA
el 28 de Jul. de 2022

Comentada:

Jan
el 29 de Jul. de 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by