Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!l31g2000yqb.googlegroups.com!not-for-mail
From: Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: HOWTO: Accelerate processing algorithm
Date: Sun, 5 Jul 2009 04:57:35 -0700 (PDT)
Organization: http://groups.google.com
Lines: 48
Message-ID: <ba375d4c-4d1d-4deb-a3f2-40c581f519c8@l31g2000yqb.googlegroups.com>
References: <32955484.75385.1246792760370.JavaMail.jakarta@nitrogen.mathforum.org>
NNTP-Posting-Host: 77.16.131.111
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1246795055 374 127.0.0.1 (5 Jul 2009 11:57:35 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 5 Jul 2009 11:57:35 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: l31g2000yqb.googlegroups.com; posting-host=77.16.131.111; 
	posting-account=VAp5gAkAAAAmkCze5hvZtMeedpZWNthI
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; 
	Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 
	3.5.21022),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:552872


On 5 Jul, 13:18, Jose Antonio <jurig...@gmail.com> wrote:

> I am thinking of trying to implement the for loop in C, and then use a MEX implementation. But I really have no idea how to do this.
>
> More than an explanation of MEX, that I think I can learn from the documentation, I would like to know if anybody has a different suggestion, or even if somebody knows wether the MEX solution would accelerate things.

Memory managent is the first thing to check.
If you have many images in memory at the same time,
and do a global search over all frames for all pixels
with some value, cache misses etc might cause your
algorithm to take a lot longer than you think it
would.

So the first work-around would be to accumulate
whatever information you are looking for, from
single frame to single frame.

This approach has the added benefit that you don't
push memory requirements as much as you do now,
since only one frame is passed between functions,
and less space is needed for temporary internal
variables. Which in turn means less probability
of needing disk swap spaces etc, which would
significantly slow you down.

This goes for both matlab and a C(++) MEX implementation.

As for MEX - do you know how to program C or C++?

If 'yes', then check out the 'External Interfaces'
parts of the matlab documentation. There are a few
example files there, on how to achieve what you want.

If you don't already know C or C++ - be aware that
these languages are demanding to learn. You need to
know and understand the inner workings of the computer
in some detail before you can start programming C
with any benefit, compared to matlab. Similarly,
you will not be able to exploit the power of C++
until you learn how to select and use algorithms
and data structures in some detail.

So depending on previous programming experience and
available time, your best choise might be to stick
with matlab but leave the computer to do its job
in your time off; over night, over weekends, etc.

Rune