Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: speeding up assigning values to a matrix
Replies: 7   Last Post: Apr 8, 2013 3:52 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
kinor

Posts: 181
Registered: 11/19/09
Re: speeding up assigning values to a matrix
Posted: Apr 8, 2013 3:52 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Luca " <l.presottoRE@MOVE.campus.unimib.NOTit> wrote in message <kjmuap$gaq$1@newscl01ah.mathworks.com>...
> I do not understand what you are saying.
> What does it mean "there is a way which is slower than" ? Is it a question for me to find a slower way?
> Now...
> I tried a lot of different operations and I discovered that it is extremely slow to do
> A=(mask==num)*255; (1)
> (casting or not num to uint8 changes less than 0.1%)
>
> I found it insted to be very fast, acceptably for my scope, to do
> A= uint8(mask==num)*uint8(255); (2)
>
> the difference between the (1) and (2) is 300ms for the first one and 15ms for the second one!!!
> A factor 20.
> Very curious indeed.
>
> That works for now.
> (still wondering wether I can use logical indexing to do something like:
> aa = (mask==num);
> maskC(aa,1)= 250;
> and get the best performances of "vectorialized" matlab)


Hi Luca

i wanted to say there is a way of logical indexing which is not faster lately this version was slightly faster than all others i tested:

tic
t = uint8(cat(4,(mask==uint8(2)),(mask==uint8(4)),(mask==uint8(6)))) * uint8(255);
toc

best
kinor



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.