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!