How to vectorize this nested for loop?
Ältere Kommentare anzeigen
Hello everyone! I have a question about a function. First of all I have to say that I'm implementing on Matlab the Seam Carving technique by Shai Avidan and Ariel Shamir (you can see here what is there: http://www.faculty.idc.ac.il/arik/SCWeb/imret/) and I need a function that, given an Image and a number, calculate the cumulative energy map. The number says that the function have to use a particular energy function. The name of the function is "imenergy" and there are three only possible calls of this function:
- imenergy(I, 1) calculate the cumulative energy map with gradient
- imenergy(I, 2) calculate the cumulative energy map with L1 norm of gradient
- imenergy(I, 3) calculate the cumulative energy map with entropy
where I is the image in input.
The problem on this function are 2 nested for loops contained in the if. I'm asking if someone is able to vectorize this nested for loops because they make my function be very very slow on big images.
Here you can download the code from my dropbox: https://www.dropbox.com/s/k2z17rusia3nkrx/imenergy.m?dl=0
Thanks to all very much!
1 Kommentar
Yuebin Zhou
am 22 Jan. 2016
Please see the link below for some tips about MATLAB vectorization
Antworten (0)
Kategorien
Mehr zu Read, Write, and Modify Image finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!