Commit f7a5a66a authored by lafabregue's avatar lafabregue

fix about mask application

parent a21a3fbb
......@@ -73,6 +73,7 @@ public class ImageSampler extends Sampler {
imageHeight = readers.get(0).getImageHeight();
imageWidth = readers.get(0).getImageWidth();
dataSize = imageHeight * imageWidth;
dataUnmaskedSize = dataSize;
if(imagesPaths.size() > 1) {
for(int i = 1; i < imagesPaths.size() ; i++) {
......@@ -128,6 +129,7 @@ public class ImageSampler extends Sampler {
this.startX = startX;
this.startY = startY;
this.dataSize = this.imageWidth * this.imageHeight;
dataUnmaskedSize = dataSize;
this.geoTranslateVectors = geoTranslateVectors;
if(imagesPaths.size() > 1) {
......@@ -155,6 +157,7 @@ public class ImageSampler extends Sampler {
imageHeight = readers.get(0).getImageHeight();
imageWidth = readers.get(0).getImageWidth();
dataSize = imageHeight * imageWidth;
dataUnmaskedSize = dataSize;
// by default the sample is the whole image
setSizeByCount(dataSize);
......@@ -176,6 +179,7 @@ public class ImageSampler extends Sampler {
imageHeight = sampler.imageHeight;
imageWidth = sampler.imageWidth;
dataSize = imageHeight * imageWidth;
dataUnmaskedSize = dataSize;
// by default the sample is the whole image
setSizeByCount(dataSize);
......@@ -401,19 +405,25 @@ public class ImageSampler extends Sampler {
for(int j= 0 ; j < readers.size() ; j++) {
// reverse compute the image coordinate
int imgX = (int) ((geoX - geoTranslateVectors.get(j)[0]) /geoTranslateVectors.get(j)[2]);
int imgY = (int) ((geoY - geoTranslateVectors.get(j)[1]) /geoTranslateVectors.get(j)[3]);;
int imgY = (int) ((geoY - geoTranslateVectors.get(j)[1]) /geoTranslateVectors.get(j)[3]);
// check if the pixel is not partially masked by a sequence mask
if (maskSequence == null || maskSequence.get(j) == null ||
!maskSequence.get(j).isMasked(imgX+imgY*readers.get(j).getImageWidth())) {
values.add(readers.get(j).getPixel(imgX, imgY));
}
}
double[][] buffer = new double[values.size()][channelCount];
buffer = values.toArray(buffer);
result.get(i).setAttribute(
0,
new AttributeMultiDimSequence(Arrays.copyOf(
buffer, buffer.length)));
if (values.size() > 0) {
double[][] buffer = new double[values.size()][channelCount];
buffer = values.toArray(buffer);
result.get(result.size()-1).setAttribute(
0,
new AttributeMultiDimSequence(Arrays.copyOf(
buffer, buffer.length)));
} else {
result.remove(result.size()-1);
}
} else {
for(int j= 0 ; j < readers.size() ; j++) {
if (maskSequence == null || maskSequence.get(j) == null ||
......@@ -421,17 +431,24 @@ public class ImageSampler extends Sampler {
values.add(readers.get(j).getPixel(x, y));
}
}
double[][] buffer = new double[values.size()][channelCount];
buffer = values.toArray(buffer);
result.get(i).setAttribute(
0,
new AttributeMultiDimSequence(Arrays.copyOf(
buffer, buffer.length)));
if (values.size() > 0) {
double[][] buffer = new double[values.size()][channelCount];
buffer = values.toArray(buffer);
result.get(result.size()-1).setAttribute(
0,
new AttributeMultiDimSequence(Arrays.copyOf(
buffer, buffer.length)));
} else {
result.remove(result.size()-1);
}
}
} catch (FormatException | IOException e) {
e.printStackTrace();
}
}
// we need to update in case of elements completely masked by masSequence
sizeByCount = result.size();
updatePercentage();
return result;
}
......@@ -503,20 +520,25 @@ public class ImageSampler extends Sampler {
for(int j= 0 ; j < readers.size() ; j++) {
// reverse compute the image coordinate
int imgX = (int) ((geoX - geoTranslateVectors.get(j)[0]) /geoTranslateVectors.get(j)[2]);
int imgY = (int) ((geoY - geoTranslateVectors.get(j)[1]) /geoTranslateVectors.get(j)[3]);;
int imgY = (int) ((geoY - geoTranslateVectors.get(j)[1]) /geoTranslateVectors.get(j)[3]);
// check if the pixel is not partially masked by a sequence mask
if (maskSequence == null || maskSequence.get(j) == null ||
!maskSequence.get(j).isMasked(imgX+imgY*readers.get(j).getImageWidth())) {
values.add(readers.get(j).getPixel(imgX, imgY));
}
}
double[][] buffer = new double[values.size()][channelCount];
buffer = values.toArray(buffer);
result.get(i).setAttribute(
0,
new AttributeMultiDimSequence(Arrays.copyOf(
buffer, buffer.length)));
if (values.size() > 0) {
double[][] buffer = new double[values.size()][channelCount];
buffer = values.toArray(buffer);
result.get(i).setAttribute(
0,
new AttributeMultiDimSequence(Arrays.copyOf(
buffer, buffer.length)));
} else {
values.remove(result.size()-1);
}
} else {
for(int j= 0 ; j < readers.size() ; j++) {
if (maskSequence == null || maskSequence.get(j) == null ||
......@@ -524,17 +546,24 @@ public class ImageSampler extends Sampler {
values.add(readers.get(j).getPixel(x, y));
}
}
double[][] buffer = new double[values.size()][channelCount];
buffer = values.toArray(buffer);
result.get(i).setAttribute(
0,
new AttributeMultiDimSequence(Arrays.copyOf(
buffer, buffer.length)));
if (values.size() > 0) {
double[][] buffer = new double[values.size()][channelCount];
buffer = values.toArray(buffer);
result.get(i).setAttribute(
0,
new AttributeMultiDimSequence(Arrays.copyOf(
buffer, buffer.length)));
} else {
values.remove(result.size()-1);
}
}
} catch (FormatException | IOException e) {
e.printStackTrace();
}
}
// we need to update in case of elements completely masked by masSequence
sizeByCount = result.size();
updatePercentage();
return result;
}
......
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