problem, with an array

Hy, I'm working on an image processing project, and I have a big problem. I have an array, it have to be increased, if some statements are all true. But it is very slow. The whole code is 349 line long, and it work well, but if I add a line like this:

myarray(x,y)=myarray(x,y)+1;

Than it would be very very slow... But if I change the type of the array to uint32, run the code, break the progress and change back the array into double, than work it well. But only if I make this whole procedure manually... I don't want to do this all the time I run the program. myarray is created by:

myarray=zeros(24, 32, 'double');

Is anything wrong with it??? (sorry for my bad english, I'm hungarian)

I made a few printed screen of my running code's profile This is ig I just run it (it is slow)

If I change the type of the array into uint32 (this is slow too)

 And this is if I change back thy type of the array into double again...: (and this is fast enough)

Please someone help me!

4 commentaires

bym
bym le 23 Fév 2011
are you adding 1 to the entire matrix? why not just myarray = myarray+1
Jan
Jan le 24 Fév 2011
The question has to few details to be answered. Please use the PROFILEr to find out, which operations produce the delay.
Imre Nagy
Imre Nagy le 24 Fév 2011
Okay I'll try, but i have an other array like this, I use the same procedure with it, and it work well. I really don't understeand...
Jan
Jan le 25 Fév 2011
I cannot read the pictures created by your profiler because they exceed the right edge of the browser window. Anyhow, please use the debugger by your own to find out, which lines need the additional time.

Connectez-vous pour commenter.

 Réponse acceptée

Jan
Jan le 25 Fév 2011

1 vote

The timings from the profile pictures look almost equal for the two runs using the DOUBLE format, but slower for the UINT32 type. What exactly is the problem? You can use the profiler to find out, which lines consumes the most time. Then post these lines and the relevant other part of the program. Without seeing the code, there is nothing we can advice.

1 commentaire

Imre Nagy
Imre Nagy le 25 Fév 2011
Well there is a webcamera. I have to process the acquered images. The algorythm is mine. And it is very-very slow without doing the method wich I have written down. But if I did it. It runs well again. (the program runs with 20% CPU using.)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Operators and Elementary Operations dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by