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 个评论

are you adding 1 to the entire matrix? why not just myarray = myarray+1
The question has to few details to be answered. Please use the PROFILEr to find out, which operations produce the delay.
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...
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.

请先登录,再进行评论。

 采纳的回答

Jan
Jan 2011-2-25

1 个投票

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 个评论

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.)

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Operators and Elementary Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by