Thread Subject: vectorization - speed up

Subject: vectorization - speed up

From: francesco santi

Date: 3 Mar, 2009 09:55:04

Message: 1 of 2

Hello.
I need to speed up this function.
It is executed many times in my algorithm and it runs on big matrix.
I have used the profiler and it is the most called and the most time consuming function.
Any help would be appreciated.

function Singleton = singleton(classes, Parameters, ImageMatrix)
global HSV_rows HSV_cols

Singleton = cell(1,classes);
for l=1:classes
    temp = zeros(HSV_rows, HSV_cols);
    detSl = Parameters(l).DetermS;
    temp2 = -log(1/(sqrt(power(2*pi,3)*detSl)));
    Ml = Parameters(l).Med;
    invSl = Parameters(l).InverS;
    for r=1:HSV_rows
        for c=1:HSV_cols
            fl = double(cell2mat(ImageMatrix(r,c)));
            temp(r,c) = (fl - Ml) * invSl * (fl - Ml)';
        end
    end
    Singleton{l} = real(temp2+temp*.5);
end

Thank you very much in advance for any kind of help,
Francesco

Subject: vectorization - speed up

From: us

Date: 3 Mar, 2009 10:10:17

Message: 2 of 2

"francesco santi"
> fl = double(cell2mat(ImageMatrix(r,c)));

this syntax lets CSSMers assume that ImageMatrix itself contains r x c CELLS...
if this is correct
- what is the size of each CELL...
- are they of equal sizes...

us

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
vectorization francesco santi 3 Mar, 2009 05:00:21
code francesco santi 3 Mar, 2009 05:00:21
speed francesco santi 3 Mar, 2009 05:00:21
matrix francesco santi 3 Mar, 2009 05:00:21
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com