pixels = image(sub2ind(size(image), rows, cols));]]>

As it is now I use

pixels = zeros(size(rows)); for i=1:2000 pixels(i) = image(rows(i),cols(i)); end

because that was the straight to use my input data (rows and cols) for indexing. And the indexing is the bottleneck of my algorithm – I have of cause checked this through profiling. It will take some extensive code modifications to get this right, so I was just asking you, in order to do it right from the start – you might have had a quick answer. But I guess I’ll just go with one of them and a new profiling will show whether the indexing is still the bottleneck.

Thanks,

Morten

]]>I need to index a number of pixels in an image, say 2000 locations in a 1024×1024 uint8 image. What is the fastest way to get the pixel values at these locations?

pixels = image(index); % size(index) = [1,2000]

or

pixels = image(binary); % size(binary) = [1024,1024]

Or maybe some smarter way? And does the choice of method depend on the ‘pixels_indexed/image_size’-ratio (a method might be the fastest when indexing a few pixels in a large picture but the slowest when indexing many pixels in a small picture)?

Hope you have an answer for this.

Morten

]]>L = linspace(0,2.*pi,6); xv = cos(L)';yv = sin(L)';

xv = [xv ; xv(1)]; yv = [yv ; yv(1)];

x = randn(250,1); y = randn(250,1);

in = inpolygon(x,y,xv,yv);

plot(xv,yv,x(in),y(in),’r+’,x(~in),y(~in),’bo’)

This function is useful,

Thank you,

Ronny

]]>w1 w2 w3

w4 w5 w6

w7 w8 w9

I defined my limits for every window, but I can’t to find the right operation, recently i apply logical operations and the result it doesn’t match with operation with filter on excel. I think that if I use find operator may be work, but I don’t know how can I to create the matrix from index.

If you know the best way please let me know,

Thank a lot,

Ronny

]]>B = A(xmin:xmax, ymin:ymax, zmin:zmax);]]>

I have a question, I am trying to do a function for to create a submatrix (X,Y,Z) from another bigger (X,Y,Z), I need to extract from a range (xmin,xmax; ymin,ymax), I tried for several ways, for example with “for cicle”, “find”, “logical”, but I can’t find the right code, please let me know if you know a best way.

Thank you so much,

RM

]]>Thanks for directing me to this. It is very well written.

]]>