Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Is it possible to vectorize a for loop with if statements?
Date: Mon, 9 Aug 2010 01:25:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 25
Message-ID: <i3nldh$77s$1@fred.mathworks.com>
References: <i3mn29$32n$1@fred.mathworks.com> <3a845205-9d1b-4a51-9141-692ffe07e647@u26g2000yqu.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1281317105 7420 172.30.248.37 (9 Aug 2010 01:25:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 9 Aug 2010 01:25:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1461393
Xref: news.mathworks.com comp.soft-sys.matlab:660191

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <3a845205-9d1b-4a51-9141-692ffe07e647@u26g2000yqu.googlegroups.com>...
> It appears that your disease image is zero in places other than where
> you have leaves, hence the if's in your code and the and's in Jan and
> Roger's code.  Any of that code should work but I'm wondering why you
> want a disease image that has disease in places other than the
> leaves?  Does it also identify disease on areas classified as stems or
> trunks?  If not, and teh disease exists only within the leaf areas,
> then you can do away with and'ing with the leaf image and just work
> directly on the disease image to speed it up even more.
> 
> If it does have disease on other areas then you might want to separate
> the classes into different images just to clarify and avoid confusion
> leafDiseaseImage = not(diseaseImage) & not(leafImage);
> stemDiseaseImage = not(diseaseImage) & not(stemImage);
> trunkDiseaseImage = not(diseaseImage) & not(trunkImage);
> You'd have to do this anyway if you ever wanted to display or analyze
> the stem and trunk diseased regions.
----------------------------------------------------------------------------------------------------------------------

Thank you everyone for the quick replies! It really did speed up the program, it now takes only 0.0093 seconds per iteration. Amazing. 

@ImageAnalyst
I wish i knew how to write codes that good =/ Unfortunately my algorithm detects random particles outside the leaf. That's why i resorted to such. Thanks anyway, maybe when i get good at it, i'll be able to do that.

I know it's off-topic, but anyone has experience with what functions, codes,books to read, etc, would be recommended for detecting leaf diseases? Maybe it can help improve my code. Thanks.