From: Ethan on 14 Jun 2010 04:53 Hello is there any better way to read the points in the 3d matrices 'x_mat' and 'y_mat' out of the intensity image 'img' and put the elements into another 3d matrix function prob=imgmatprob(x_mat,y_mat,img) [i_max,ii_max,iii_max] = size(x_mat); [xres yres]=size(img); xround = round(x_mat); %round matrices yround = round(y_mat); prob = zeros(size(x_mat)); %dimension output matrix disp('starting loop') for i = 1:i_max %go through each element for ii = 1:ii_max for iii = 1:iii_max xcur=xround(i,ii,iii); ycur=yround(i,ii,iii); if (1<=xcur)&&(xcur<=xres)&&(1<=ycur)&&(ycur<=yres) %check image bounds prob(i,ii,iii)=img(xcur,ycur); %read point else prob(i,ii,iii) = 0; %default if pt is out of bounds end end end end end This is what i came up with but it seems terribly inefficient. Any help is greatly appreciated.
|
Pages: 1 Prev: replace one char using its index Next: help for Contour plot |