Path: news.mathworks.com!newsfeed-00.mathworks.com!panix!bloom-beacon.mit.edu!llnews!53ab2750!not-for-mail
From: Peter Boettcher <boettcher@ll.mit.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: load & display multichannel images quickly
References: <fvviut$kf3$1@fred.mathworks.com>
Message-ID: <muy1w4bhbur.fsf@G99-Boettcher.llan.ll.mit.edu>
Organization: MIT Lincoln Laboratory
User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/23.0.0 (gnu/linux)
Cancel-Lock: sha1:HNzUZaLLqzj0DhSHJjUYcpavGaQ=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Lines: 34
Date: Fri, 09 May 2008 08:59:40 -0400
NNTP-Posting-Host: 155.34.163.114
X-Complaints-To: news@ll.mit.edu
X-Trace: llnews 1210337337 155.34.163.114 (Fri, 09 May 2008 08:48:57 EDT)
NNTP-Posting-Date: Fri, 09 May 2008 08:48:57 EDT
Xref: news.mathworks.com comp.soft-sys.matlab:467588


"jay vaughan" <jvaughan5.nospam@gmail.com> writes:

> thanks for the suggestions. I tried to implement them but it
> didn't improve things. Perhaps I implemented them
> incorrectly? (See attempts 3 & 4.)
>
> % attempt 1: speed ok (0.0137 sec) but poor gain resolution
> f1 = 10; 
> c1 = 10;
> ch1 = (fread(fid1, frame_size, '*uint8')-f1)*(255/(c1-f1));
>
> % attempt 2: slow (0.025 sec) but poor gain resolution
> f1 = 10; 
> c1 = 10;
> ch1=(fread(fid1,frame_size,'*uint8')-f1)*(255/double(c1-f1));
>
> % attempt 3: slow (0.025 sec) but poor gain resolution
> f1 = uint32(10);
> c1 = uint32(10);
> ch1 =
> uint8(uint32(255)*(uint32(fread(fid1,frame_size,'*uint8')-f1)/(c1-f1)));
>
> % attempt 4: slow (0.025 sec) but has good gain resolution
> f1 = uint32(10); % MATLAB f1 & c1 to be uint32 not uint8
> c1 = uint32(10);
> gain = uint32(256*256)/(channel_ceiling-channel_floor);
> ch1=uint8(gain*(uint32(fread(fid,frame_size,'*uint8'))-f)/256);

Try bitshift(gain*(uint32(fread(fid,frame_size,'*uint8'))-f), -8)
instead of /256

Other than that, your only other option might be a MEX file

-Peter