Akash
Akash

Reputation: 103

Any other approach for Fasters implementation - matlab cell array

I have an image; I am running a loop over it and creating a cell array. But the process for all the values is very slow. Is it any way possible to fasten the process?

Or any other way to do this faster?

Any help would be appreciated.

  [a,b] = size(depth);
  for i=1:a   % a = 1024
   for j=1:b  %b = 1360

    if isfinite(depth(i,j))
                segId = (label(i,j));
                if (segId > 0)
                  mycell{1,idx,segId} = {i,j,depth(i,j)};
                  idx=idx+1;       
                end 
             end
           end
         end

Upvotes: 0

Views: 60

Answers (2)

Akash
Akash

Reputation: 103

This is much faster than earlier approach. Thanks for the help.

    [row,col] = find(~(isnan(depth)));

    len = length(row);

    for i= 1:len            
       segId = (label(row(i),col(i)));
       if (segId > 0)
            mycell{1,idx,segId} = {row(i),col(i),depth(row(i),col(i))};
            idx=idx+1;
       end
    end

Upvotes: 1

16per9
16per9

Reputation: 502

Instead of updating the size of mycell each interaction, create the cell structure beforehand. That should fasten it a bit.

Nevertheless, you are evaluating all the points of a image. Why not make some mathematical operations?

[rol,col] = find(depth(depth>0)) - I quick scan your code, your are looking for this values I think.

this gives you the positions in your image that you wanna find. Maybe you just need to put this on a for cycle and it will be faster.

Upvotes: 0

Related Questions