Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: 3D matrix operation speed up
Date: Tue, 17 Feb 2009 09:32:01 +0000 (UTC)
Organization: FZ-Juelich
Lines: 29
Message-ID: <gne06h$kid$1@fred.mathworks.com>
References: <gn1h7l$qs0$1@fred.mathworks.com> <gn1hml$19n$1@fred.mathworks.com> <gn1m72$r6k$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1234863121 21069 172.30.248.37 (17 Feb 2009 09:32:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 17 Feb 2009 09:32:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1088664
Xref: news.mathworks.com comp.soft-sys.matlab:518774


"francesco santi" <fpsanti@gmail.com> wrote in message <gn1m72$r6k$1@fred.mathworks.com>...
> > is this the loop you used?
> > 
> > for n = 1:3
> >     im(:,:,n) = im(:,:,n)-vec(n);
> > end
> > 
> > then maybe you can accelerate it with imsubtract if you have the image processing toolbox
> 
> % this generates the cell which contains the image
> HSV = hsv2rgb(im);
> ImageMatrix = cell(HSV_rows, HSV_cols);
> for r=1:HSV_rows
>     for c=1:HSV_cols
>         ImageMatrix{r,c} = [HSV(r,c,1) HSV(r,c,2) HSV(r,c,3)];
>     end
> end
> %this is the loop to compute the subtraction between a pixel and its mean
> for r=1:HSV_rows
>     for c=1:HSV_cols
>         fl = double(cell2mat(ImageMatrix(r,c))); %pixel color components 1x3
>         temp(r,c) = (fl - Ml); %Ml=mean vector 1x3
>      end
> end

Hi Francesco,
work on whole matrices, for example with the solution of 'us'  or with the loop i proposed. Changing names should be your business. The matlab help is really nice indeed, have fun.

kinor