Assume two grayscale images generated thus:
Code: Select all
magick -size 64x64 gradient: -blur 1x1 gradient_u.tif
magick -size 64x64 gradient: -rotate 90 -blur 1x1 gradient_v.tif
I calculate the ratio as follows, saving the output with double (FP64) precision:
Code: Select all
magick gradient_u.tif -define quantum:format=floating-point -depth 64 \
gradient_v.tif -define quantum:format=floating-point -depth 64 \
-fx 'u/v' quotient.tif
Code: Select all
u = im2double(imread('gradient_u.tif'));
v = im2double(imread('gradient_v.tif'));
q = u ./ v;
Code: Select all
Q = imread('quotient.tif');
assert(isequal(Q,q)); % assertion fails
Code: Select all
d = q-Q;
err = d./q;
max(err(:)); % 1.6550e-07
min(err(:)); % -1.4829e-07