Commit e1e46ce5 authored by moon's avatar moon

Potential error handling for creating multi threads

parent 87e96a6b
......@@ -18,6 +18,8 @@ import org.scijava.plugin.Plugin;
import java.io.File;
import static de.mpicbg.scf.mincostsurface.img_utils.createOffset;
/**
* Author: HongKee Moon (moon@mpi-cbg.de), Scientific Computing Facility
* Organization: MPI-CBG Dresden
......@@ -103,6 +105,10 @@ public class MinCost2ZSurfaceMT_Ops<T extends RealType<T> & NativeType<T>> exten
image_cost_ds.dimensions(dims);
if(dims[1] < numThreads) {
numThreads = (int) dims[1];
}
// Setup the number of dimension in the input image except the height part
// The height will be the original height divided by the number of threads
dims[1] = image_cost_ds.dimension(1) / numThreads;
......@@ -142,22 +148,7 @@ public class MinCost2ZSurfaceMT_Ops<T extends RealType<T> & NativeType<T>> exten
<T extends RealType<T> & NativeType<T>> Img<T>[] processMT(final Img<T> inputSource, final Interval interval, final int numThreads) {
// Setup the offset arrays for multi threads
final long[][] offset = new long[numThreads][inputSource.numDimensions()];
// Offset is stored by changing the height value
for (int d = 0; d < offset.length; d++) {
offset[d] = new long[inputSource.numDimensions()];
for (int i = 0; i < offset[d].length; i++) {
offset[d][i] = 0;
}
// width
// offset[d][0] = inputSource.dimension( 0 ) / numThreads * d;
// height
offset[d][1] = inputSource.dimension(1) / numThreads * d;
// depth
// offset[d][2] = 0;
}
final long[][] offset = createOffset(inputSource, numThreads);
// Initialize depth maps
final Img<T> globalDepthMap1 = inputSource.factory().create(inputSource.dimension(0), inputSource.dimension(1));
......
......@@ -21,6 +21,8 @@ import org.scijava.plugin.Plugin;
import java.io.File;
import static de.mpicbg.scf.mincostsurface.img_utils.createOffset;
/**
* Author: HongKee Moon (moon@mpi-cbg.de), Scientific Computing Facility
* Organization: MPI-CBG Dresden
......@@ -107,6 +109,10 @@ public class MinCostZSurfaceMT_Ops< T extends RealType<T> & NativeType< T >> ext
image_cost_ds.dimensions(dims);
if(dims[1] < numThreads) {
numThreads = (int) dims[1];
}
// dims[0] = image_cost_ds.dimension(0);
dims[1] = image_cost_ds.dimension(1) / numThreads;
......@@ -138,22 +144,24 @@ public class MinCostZSurfaceMT_Ops< T extends RealType<T> & NativeType< T >> ext
< T extends RealType< T >> Img< T > processMT(final Img< T > inputSource, final Interval interval, final int numThreads )
{
final long[][] offset = new long[ numThreads ][inputSource.numDimensions()];
for ( int d = 0; d < offset.length; d++ )
{
offset[d] = new long[inputSource.numDimensions()];
for (int i = 0; i < offset[d].length; i++) {
offset[d][i] = 0;
}
// width
// offset[d][0] = inputSource.dimension( 0 ) / numThreads * d;
// height
offset[d][1] = inputSource.dimension( 1 ) / numThreads * d;
// depth
// offset[d][2] = 0;
}
final long[][] offset = createOffset(inputSource, numThreads);
// final long[][] offset = new long[ numThreads ][inputSource.numDimensions()];
//
// for ( int d = 0; d < offset.length; d++ )
// {
// offset[d] = new long[inputSource.numDimensions()];
//
// for (int i = 0; i < offset[d].length; i++) {
// offset[d][i] = 0;
// }
// // width
//// offset[d][0] = inputSource.dimension( 0 ) / numThreads * d;
// // height
// offset[d][1] = inputSource.dimension( 1 ) / numThreads * d;
// // depth
//// offset[d][2] = 0;
// }
final Img< T > globalDepthMap = inputSource.factory().create(inputSource.dimension(0), inputSource.dimension(1));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment