Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Reduce the computation time

Subject: Reduce the computation time

From: Vaishali

Date: 23 Sep, 2012 11:51:08

Message: 1 of 2

Im doing a project on comparing consecutive frames and storing its threshold in an array. But the computation time is very high. Is there any way to reduce the computation time ??

Framerate=get(trafficObj,'FrameRate');

     ht=trafficObj.Height;
    wd=trafficObj.Width;
    max=0;
    Y=eye(numFrames,numFrames)
i=1;
while(i<numFrames)
    im=read(trafficObj,i)
    img=imresize(im,'Outputsize',[ht wd])
    x=double(img);
    hg=hist(x);
    j=i+1;
    
    
    while(j<=numFrames)
        a=0;
        b=0;
        img1=read(trafficObj,j)
        x1=double(img1)
        hg1=hist(x1)
        histdiff=(abs(hg-hg1))
        thresh=histdiff>3
        a=sum(thresh)
        b=sum(a)
        Y(i,j)=b;
       
    
        if Y(i,j)<Y(i,j-1)
            i=j-1;
            break;
            
        end
        j=j+1;
            
   
    end
    
    
end

Subject: Reduce the computation time

From: Kristin

Date: 2 Oct, 2012 05:08:09

Message: 2 of 2

"Vaishali " <vaishu.mssoftyengg@gmail.com> wrote in message <k3mt3c$b4u$1@newscl01ah.mathworks.com>...
> Im doing a project on comparing consecutive frames and storing its threshold in an array. But the computation time is very high. Is there any way to reduce the computation time ??
>
> Framerate=get(trafficObj,'FrameRate');
>
> ht=trafficObj.Height;
> wd=trafficObj.Width;
> max=0;
> Y=eye(numFrames,numFrames)
> i=1;
> while(i<numFrames)
> im=read(trafficObj,i)
> img=imresize(im,'Outputsize',[ht wd])
> x=double(img);
> hg=hist(x);
> j=i+1;
>
>
> while(j<=numFrames)
> a=0;
> b=0;
> img1=read(trafficObj,j)
> x1=double(img1)
> hg1=hist(x1)
> histdiff=(abs(hg-hg1))
> thresh=histdiff>3
> a=sum(thresh)
> b=sum(a)
> Y(i,j)=b;
>
>
> if Y(i,j)<Y(i,j-1)
> i=j-1;
> break;
>
> end
> j=j+1;
>
>
> end
>
>
> end

run the profiler on it to see where the major loss comes from.

profile off; profile on; your_code_here; profile off; profile viewer;

Tags for this Thread

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.

Contact us