How to vectorize this nested for loop?
显示 更早的评论
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 个评论
Yuebin Zhou
2016-1-22
Please see the link below for some tips about MATLAB vectorization
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Read, Write, and Modify Image 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!