H
harryos
hi
while using colt matrices( (http://acs.lbl.gov/~hoschek/colt/)) to do
some image processing calculations i ran into some problems
I am trying to normalise(i don't know if that is the right word) a 1D
array of doubles by dividing each element with the max element of the
array using primitive arrays i can do it like below
<snippet>
double[] origArray=new double[]{....//some double values//..};
double arraymax=Double.MIN_VALUE;
for(int i=0;i<origArray.length;i++){
arraymax=(origArray>arraymax)? origArray:arraymax;
}
for(int i=0;i<origArray.length;i++){
origArray/=arraymax;
}
</snippet>
in the modified origArray a sample value i got using debug option in
eclipse is 0.1450980392156863
I did the same using colt matrices
<snippet>
DoubleMatrix1D origmat=new DenseDoubleMatrix1D(origArray);
cern.jet.math.Functions F = cern.jet.math.Functions.functions;
origmat.assign(F.div(inputfacemax));
</snippet>
this does the job,but i found that the corresponding sample value is
0.14509803921568626..this happens in some elements only. ..most
elements are identical to those when primitive arrays were
used ..This difference causes a difference in final results in my
program..
for example i need to get minimum value from a double[] that has some
values of distances (of a comparison of images)calculated using
matrices (or for loops in the case of primitive arrays..)
suppose the array is
[0.0, 0.0234567, 0.567834,0.134234] it means that min distance is 0.0
and the image is a perfect match..This was the case when i used
primitive arrays and loops to do the calculation
but if i use colt matrices as above ..i get
[6.162975822039155E-33,0.0234567, 0.567834,0.134234]
so for a perfect match of images i will be reporting the distance as
6.162975822039155E-33 instead of 0.0.
This is frustrating...Can someone tell me how i can solve this..
while using colt matrices( (http://acs.lbl.gov/~hoschek/colt/)) to do
some image processing calculations i ran into some problems
I am trying to normalise(i don't know if that is the right word) a 1D
array of doubles by dividing each element with the max element of the
array using primitive arrays i can do it like below
<snippet>
double[] origArray=new double[]{....//some double values//..};
double arraymax=Double.MIN_VALUE;
for(int i=0;i<origArray.length;i++){
arraymax=(origArray>arraymax)? origArray:arraymax;
}
for(int i=0;i<origArray.length;i++){
origArray/=arraymax;
}
</snippet>
in the modified origArray a sample value i got using debug option in
eclipse is 0.1450980392156863
I did the same using colt matrices
<snippet>
DoubleMatrix1D origmat=new DenseDoubleMatrix1D(origArray);
cern.jet.math.Functions F = cern.jet.math.Functions.functions;
origmat.assign(F.div(inputfacemax));
</snippet>
this does the job,but i found that the corresponding sample value is
0.14509803921568626..this happens in some elements only. ..most
elements are identical to those when primitive arrays were
used ..This difference causes a difference in final results in my
program..
for example i need to get minimum value from a double[] that has some
values of distances (of a comparison of images)calculated using
matrices (or for loops in the case of primitive arrays..)
suppose the array is
[0.0, 0.0234567, 0.567834,0.134234] it means that min distance is 0.0
and the image is a perfect match..This was the case when i used
primitive arrays and loops to do the calculation
but if i use colt matrices as above ..i get
[6.162975822039155E-33,0.0234567, 0.567834,0.134234]
so for a perfect match of images i will be reporting the distance as
6.162975822039155E-33 instead of 0.0.
This is frustrating...Can someone tell me how i can solve this..