Skip to content
Snippets Groups Projects
Commit 181b721d authored by Vojtech Moravec's avatar Vojtech Moravec
Browse files

getMinMax utility function.

parent 8c14ff72
No related branches found
No related tags found
No related merge requests found
package azgracompress.utilities;
public class MinMaxResult<T> {
private final T min;
private final T max;
MinMaxResult(T min, T max) {
this.min = min;
this.max = max;
}
public T getMin() {
return min;
}
public T getMax() {
return max;
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
public class Utils {
public static double calculatePsnr(final double mse, final int signalMax) {
......@@ -83,6 +84,22 @@ public class Utils {
}
public static MinMaxResult<Integer> getMinAndMax(final int[] data) {
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
for (int i = 0; i < data.length; i++) {
if (data[i] < min) {
min = data[i];
}
if (data[i] > max) {
max = data[i];
}
}
return new MinMaxResult<Integer>(min, max);
}
public static double calculateMse(final int[] difference) {
double sum = 0.0;
for (final int val : difference) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment