Changeset 3489


Ignore:
Timestamp:
12/20/07 09:49:02 (12 years ago)
Author:
curtis
Message:

Add suggestion from Ville Rantanen to improve performance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/utils/bfopen.m

    r3488 r3489  
    11function [result] = bfopen(id) 
    22 
    3 % portions of this code were adapted from: 
     3% Portions of this code were adapted from: 
    44% http://www.mathworks.com/support/solutions/data/1-2WPAYR.html?solution=1-2WPAYR 
     5% 
     6% Thanks to Ville Rantanen for his performance improvements. 
    57 
    68r = loci.formats.ChannelSeparator(); 
     
    1315    h = r.getSizeY(); 
    1416    numImages = r.getImageCount(); 
    15     arr = double(zeros([h, w, 1])); % use uint8 with imshow? 
     17    arr = double(zeros([h, w, 1])); 
    1618    for i = 0:numImages-1 
    1719        fprintf('.'); 
     
    1921        % convert Java BufferedImage to MATLAB image 
    2022        B = img.getData.getPixels(0, 0, w, h, []); 
    21         ndx = 1; 
    22         for y = 1:h 
    23             for x = 1:w 
    24                 arr(y,x,1) = B(ndx); 
    25                 ndx = ndx + 1; 
    26             end 
    27         end 
     23        arr = reshape(B, [w h])'; 
    2824        % plot the image plane in a new figure 
    2925        figure; 
Note: See TracChangeset for help on using the changeset viewer.