Borrar filtros
Borrar filtros

How to vectorize matlab function poly2edgelist.m

2 visualizaciones (últimos 30 días)
Jessica
Jessica el 25 de Feb. de 2013
Hello, I was wondering if it's possible to vectorize this function? Mainly the for loop, but possibly the whole thing. I'm having trouble because of the 'k+1', I'm unsure of how to vectorize that type of indexing.
Thank you in advance! Any advice is helpful! (except for telling me to read up on vectorization, because I already did.) :)
x = round(scale*(x - 0.5) + 1);
y = round(scale*(y - 0.5) + 1);
num_segments = length(x) - 1;
x_segments = cell(num_segments,1);
y_segments = cell(num_segments,1);
for k = 1:num_segments
[x_segments{k},y_segments{k}] = iptui.intline(x(k),x(k+1),y(k),y(k+1));
end
x = cat(1,x_segments{:});
y = cat(1,y_segments{:});
d = diff(x);
edge_indices = find(d);
xe = x(edge_indices);

Respuestas (1)

Image Analyst
Image Analyst el 25 de Feb. de 2013
Why are you using iptui, an undocumented class? I haven't even used it, and I am not sure what it returns because the documentation does not say what it returns. I don't even know what you want to measure. If you want edges of signals or images, why not use more conventional documented methods?
  2 comentarios
Jessica
Jessica el 25 de Feb. de 2013
Editada: Jessica el 25 de Feb. de 2013
Hi Image Analyst. I wrote a program that calls on the function regionprops. The files that I run through this program are very large and contain many shape profiles obtained from a low resolution oceanographic instrument. This program is running pretty slowly. I analyzed the program and found that the slowest part of it is when regionprops calls on the function poly2edgelist.m. I was curious to see if I vectorized this function (poly2edgelist.m) if it would increase my program speed. Are there alternatives that you would recommend; these more conventional documented methods?
Thanks again!
Jess
Image Analyst
Image Analyst el 25 de Feb. de 2013
I don't know of any other methods that do the same thing as regionprops(). I just thought you were drawing lines or finding outlines/perimeters or something, but couldn't tell. You can speed up regionprops() by specifying what to measure. The default is 'all' which probably takes time to measure a bunch of things you will never care about.

Iniciar sesión para comentar.

Categorías

Más información sobre Numeric Types en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by