Skip to content
Snippets Groups Projects
Commit f41c4a32 authored by Jakub Kolman's avatar Jakub Kolman
Browse files

[#81] fix: removed comparison procrustesAnalysis files in development from incorrect branch

parent b77711c4
No related branches found
No related tags found
No related merge requests found
package cz.fidentis.analyst.procrustes;
import cz.fidentis.analyst.feature.FeaturePoint;
import cz.fidentis.analyst.procrustes.exceptions.ProcrustesAnalysisException;
import cz.fidentis.analyst.procrustes.utils.ProcrustesAnalysisUtils;
import java.util.List;
/**
*
* @author Jakub Kolman
*/
public class ProcrustesAnalysis {
private final List<FeaturePoint> orderedFpList1;
private final List<FeaturePoint> orderedFpList2;
/**
*
* @param fpList1
* @param fpList2
* @throws ProcrustesAnalysisException
*/
public ProcrustesAnalysis(List<FeaturePoint> fpList1, List<FeaturePoint> fpList2) throws ProcrustesAnalysisException {
if (fpList1.size() != fpList2.size()) {
throw new ProcrustesAnalysisException("Lists of feature points do not have the same size");
}
orderedFpList1 = ProcrustesAnalysisUtils.sortByFeaturePointType(fpList1);
orderedFpList2 = ProcrustesAnalysisUtils.sortByFeaturePointType(fpList2);
if (!ProcrustesAnalysisUtils.checkfeaturePointsType(orderedFpList1, orderedFpList2)) {
throw new ProcrustesAnalysisException("Lists of feature points do not have the same feature point types");
}
}
/**
* Calculate scaling ratio of how much the appropriate object corresponding to the second feature
* point list has to be scale up or shrunk.
*
* If returned ratioValue is greater 1 then it means that the second object should be scaled up ratioValue times.
* If returned ratioValue is smaller 1 than the second object should be shrunk.
*
* @return ratioValue
*/
private double calculateScalingValue() {
double[] distancesOfList1 = ProcrustesAnalysisUtils.calculateMeanDistancesFromOrigin(orderedFpList1);
double[] distancesOfList2 = ProcrustesAnalysisUtils.calculateMeanDistancesFromOrigin(orderedFpList2);
double[] ratioArray = new double[distancesOfList1.length];
double ratioValue = 0;
for (int i = 0; i < distancesOfList1.length; i++) {
ratioArray[i] += distancesOfList1[i] / distancesOfList2[i];
}
for (double ratio: ratioArray) {
ratioValue += ratio;
}
return ratioValue / distancesOfList1.length;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package cz.fidentis.analyst.procrustes.exceptions;
/**
*
* @author Jakub Kolman
*/
public class ProcrustesAnalysisException extends RuntimeException {
/**
* throws run time exception with message
* @param message
*/
public ProcrustesAnalysisException(String message) {
super(message);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment