Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: 3D matrix operation speed up
Date: Thu, 12 Feb 2009 16:03:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 8
Message-ID: <gn1h7l$qs0$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 1234454581 27520 172.30.248.37 (12 Feb 2009 16:03:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 12 Feb 2009 16:03:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1612112
Xref: news.mathworks.com comp.soft-sys.matlab:517887


Hello, I have the following problem.
I have a MxNx3 matrix (an image) and I would like to subtract to each pixel the mean value of each color component.
I have a 1x3 vector which contains the mean value of the R G B components.
I've done it with a for loop but it's very slow for big images (i.e. matrix) and I'm pretty sure there's a faster way to do it.
I've tried also to put all the 3 RGB components in a cell, so I have in position r,c a vector of 3 color components. Then I am using a for loop and cell2mat to do the same operation as above. But again I need to replace the for loop for speed.
Any help would be appreciated.
Thanks in advance,
Francesco