Background story:
This is an old script, I needed to compare two slightly different images of the same object to get data on the camera itself. I wrote this script in octave and tried it, later I found out matlab ran much faster with it so since than I used matlab instead of octave. I recently decided to check octave again, and I still got 1:1000 speed ratio.
Questions:
- How can I vectorize this algorithm?
- Does matlab (verses octave) have a way to Auto-vectorize this code to run 1000 times faster - 0.1s verses 100s for color images 420X420 pixels size?
script:
color_depth = 8;
number_of_colors = 3;
number_of_grey_levels = 2^color_depth;
Double_Distribution_0 =zeros(number_of_grey_levels,number_of_grey_levels,number_of_colors);
frame_A = 1+int16(imread('Path\image_A.tif'));
frame_1 = 1+int16(imread('Path\image_1.tif'));
[height,width]=size(frame_A(:,:,1));
number_of_pixels = width*height;
for k = 1:number_of_colors
tic
for i = 1:height
for j = 1:width
Double_Distribution_0(frame_1(i,j,k),frame_A(i,j,k),k) = 1 + Double_Distribution_0(frame_1(i,j,k),frame_A(i,j,k),k);
end
end
toc
end