Date: Apr 5, 2013 12:06 PM
Author: kinor
Subject: Re: speeding up assigning values to a matrix

"Luca " <l.presottoRE@MOVE.campus.unimib.NOTit> wrote in message <kjmqpp$4r7$1@newscl01ah.mathworks.com>...
> "kinor" wrote in message <kjmptu$20a$1@newscl01ah.mathworks.com>...
>

> > Hi Luca,
> > i guess your mask(:,:,:,3) = (mask>4 &mask<7)*255;
> > should be maskC(:,:,:,3) = (mask>4 &mask<7)*255; ?

>
> Yes, of course!
>
>
> I'm going to try how faster your version is.
> I would not expect reducing the number of scalar multiplications to provide great improvements.
> You don't see either a way to use logical indexing, do you?


there is a way which is slower than

ts=tic;
maskC(:,:,:,1) = (mask==uint8(2));
% toc(ts);
% ts=tic;
maskC(:,:,:,2) = (mask==uint8(4));
% toc(ts);
% ts=tic;
maskC(:,:,:,3) = (mask==uint8(6));
% toc(ts);
% tic
maskC = maskC*255;
toc(ts)

still wonder how much time is needed on your system...