How to vectorize matlab function poly2edgelist.m
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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);
0 comentarios
Respuestas (1)
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
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.
Ver también
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!