Computational Time Difference Between HxWxD Array and H*WxD Array

2 ビュー (過去 30 日間)
Batuhan Hangun
Batuhan Hangun 2017 年 7 月 24 日
回答済み: KSSV 2017 年 7 月 24 日
Hello there.
I have some images which are RGB images or Hyperspectral images. I do some distance calculations for pixels by using those images and pre-calculated cluster centers. Let's say my image has size of 519x540x200 which is shown by Image and there is a matrix has size of 280260x200 which is shown by PixValues and it is created by:
[Height, Width, Dim] = size(Image);
PixValues = zeros(Height * Width, Dim);
for i = 1: Height * Width
[X , Y] = ind2sub([Height, Width], i);
PixValues(i,:) = Image(X,Y,:);
end
Which of the below has better performance?
for i = 1: Height
for j = 1:Width
Distance = distancecalculation(Image(i,j,:), ClusterCentern);
end
end
or
for i = 1: Height * Width
Distance = distancecalculation(PixValues(i,:), ClusterCentern);
end

回答 (1 件)

KSSV
KSSV 2017 年 7 月 24 日
You can put a timer and you yourself can come to conclusion...read about tic , toc , timeit

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by