// clear the decks
window.getView().resetView();
- if (SegmentationContext.isContextFile(file)) {
+ if (SegmentationContext.isContextFile(file)) { // JP - minority case (opening an zip file to re-annotate)
// Load context
window.setContext(SegmentationContext.load(file));
status("Opened segmentation context %s successfully", name);
window.setContext(SegmentationContext.loadImageMap(file));
status("Opened segmentation context %s successfully", name);
}
- else { // JP - majority of cases (opening an img or zip file to annotate)
+ else { // JP - majority of cases (opening an img file to annotate)
// Create context
window.setContext(SegmentationContext.create(file));
status("Opened image file %s successfully", name);
BufferedImage image = ImageConverter.convert(ctx.getImageData());
// Setup exporter
- Exporter exporter = new Exporter(image);
+ Exporter exporter = new Exporter(image, ctx);
// save the annotated zip file
String zipFile = result.zipFile;
BufferedImage image = ImageConverter.convert(ctx.getImageData());
// Setup exporter
- Exporter exporter = new Exporter(image);
+ Exporter exporter = new Exporter(image, ctx);
// save the annotated zip file
String zipFile = result.zipFile;
package ie.dcu.apps.ist.export.imagemap;
+import ie.dcu.apps.ist.Application;
import ie.dcu.apps.ist.views.SegmentationView;
import ie.dcu.image.ContourTracer;
+import ie.dcu.segment.SegmentationContext;
import ie.dcu.segment.SegmentationMask;
import java.awt.Polygon;
private String zipFile = "";
private String imageFile = "image.png";
private String imageName = "image";
+ private String origImageFileName = "";
private String objectDescription = "";
private String objectLink = "";
private AreaShape exportShape = AreaShape.Polygon;
- public Exporter(BufferedImage image) {
+ public Exporter(BufferedImage image, SegmentationContext ctx) {
this.image = image;
+ this.origImageFileName = ctx.getFile().getName();
}
public RolloverEffect getEffect() {
try {
// Low (fast) compression.. most of data is PNG compressed anyway
- out.setLevel(0);
+ out.setLevel(9);
out.flush();
// Create an entry for the image
ZipEntry entryImage = new ZipEntry(imageFile);
}
// Low (fast) compression.. most of data is PNG compressed anyway
- out.setLevel(0);
+ //out.setLevel(0);
// Create an entry for the image
ZipEntry entryMaskImage = new ZipEntry(preloads.get(i).toString());
}
finally
{
- // Close
- out.close();
+ out.flush();
+ out.close(); // close the output zip file stream (makes the zip file)
}
}
{
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(o));
byte[] intensityValues = mask.values;
- boolean[] values = new boolean[intensityValues.length];
- for(int x =0; x < intensityValues.length;x++)
- {
- values[x] = (intensityValues[x] == 2 ? false:true);
- out.writeBoolean(values[x]);
- }
+ out.write(intensityValues);
}
private void saveMetadata(OutputStream o, List<SegmentationMask> masks) throws IOException
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.newDocument();
+
Element rootElement = document.createElement("image_data");
document.appendChild(rootElement);
-
- Element imageElement = document.createElement("image_filename");
+
+ Element versionElement = document.createElement("sia_version");
+ versionElement.setTextContent(Application.APP_VERSION);
+ rootElement.appendChild(versionElement);
+
+ Element imageElement = document.createElement("orig_image_filename");
+ imageElement.setTextContent(this.origImageFileName);
rootElement.appendChild(imageElement);
Element speciesElement = document.createElement("species");
{
DataInputStream input = new DataInputStream(new BufferedInputStream(in));
int length = width * height;
- boolean[] intensity = new boolean[length];
+ //boolean[] intensity = new boolean[length];
+ byte[] intensity = new byte[length];
int index = 0;
boolean EOF = false;
- // see code in export and something to do with sizes Array index out of bounds exception do it today completely
while(!EOF)
{
try
{
- intensity[index] = input.readBoolean();
+ intensity[index] = (byte)input.read();
}
catch(Exception e)
{
index = index+1;
}
int i = 0;
- for (int x=0;x<height;x++)
+ for (int y=0;y<height;y++)
{
- for (int y=0;y<width;y++)
+ for (int x=0;x<width;x++)
{
if(i <= index)
{
- byte type = (byte)(intensity[i] == false ? 2:1);
- mask.setPixel(y,x, (byte)type);
+ mask.setPixel(x,y, intensity[i]);
i++;
}
}