Loading src/main/java/com/elphel/imagej/orthomosaic/FloatImageData.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -11,7 +11,7 @@ public class FloatImageData { public int width; public int width; public int height; public int height; public int zoom_lev; public int zoom_lev; public double [] vert = new double[2]; // x,y offset (in meters) of the point under the camera private double [] vert = new double[2]; // x,y offset (in meters) of the point under the camera public float[] data; public float[] data; public FloatImageData ( public FloatImageData ( int width, int width, Loading @@ -26,6 +26,16 @@ public class FloatImageData { this.data = data; this.data = data; } } public int getWidth() { return width; } public int getHeight() { return height; } public double[] getVertMeters() { return vert; } public double [] getDData() { public double [] getDData() { final double [] ddata = new double [data.length]; final double [] ddata = new double [data.length]; final Thread[] threads = ImageDtt.newThreadArray(); final Thread[] threads = ImageDtt.newThreadArray(); Loading src/main/java/com/elphel/imagej/orthomosaic/OrthoMap.java +27 −13 Original line number Original line Diff line number Diff line Loading @@ -116,8 +116,11 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ public double [][] affine = new double[][] {{1,0,0},{0,1,0}}; // relative to vert_meters[], positive Y is down (as in images) public double [][] affine = new double[][] {{1,0,0},{0,1,0}}; // relative to vert_meters[], positive Y is down (as in images) public transient double [][] ers_affine = new double[][] {{1,0},{0,1}}; // orientation only for remaining ERS, positive Y is down (as in images) public transient double [][] ers_affine = new double[][] {{1,0},{0,1}}; // orientation only for remaining ERS, positive Y is down (as in images) public double orig_pix_meters; public double orig_pix_meters; public double [] vert_meters; // offset of the image vertical in meters (scale-invariant), right (X) and down (Y) @Deprecated private double [] vert_meters; // offset of the image vertical in meters (scale-invariant), right (X) and down (Y) @Deprecated public int orig_width; public int orig_width; @Deprecated public int orig_height; public int orig_height; public transient FloatImageData orig_image; public transient FloatImageData orig_image; public transient FloatImageData alt_image; public transient FloatImageData alt_image; Loading Loading @@ -237,10 +240,16 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ } } public int getWidth() { public int getWidth() { return orig_width; return getImageData().getWidth(); // orig_width; } } public int getHeight() { public int getHeight() { return orig_height; return getImageData().getHeight(); //orig_height; } public int getAltWidth() { return getAltData().getWidth(); // orig_width; } public int getAltHeight() { return getAltData().getHeight(); //orig_height; } } public void setMatch( public void setMatch( Loading Loading @@ -692,7 +701,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ } } private boolean readAltData() { // assuming the same scale as main image private boolean readAltData() { // assuming the same scale as main image - WRONG ImagePlus imp = new ImagePlus(getAltPath(path)); ImagePlus imp = new ImagePlus(getAltPath(path)); int width = imp.getWidth(); int width = imp.getWidth(); int height = imp.getHeight(); int height = imp.getHeight(); Loading Loading @@ -744,24 +753,34 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ * Get vertical point offset from the top-left corner of the original orthoimage in meters (right and down) * Get vertical point offset from the top-left corner of the original orthoimage in meters (right and down) * @return vertical point X,Y offset in meters from the top-left image corner * @return vertical point X,Y offset in meters from the top-left image corner */ */ public double [] getVertMeters() { public double [] getVertMetersOld() { return vert_meters; return vert_meters; } } public double [] getVertMeters() { return getImageData().getVertMeters(); // ; } public double [] getVertMetersAlt() { return getAltData().getVertMeters(); // ; } /** /** * Get vertical point offset from the top-left corner of the original orthoimage in pixels * Get vertical point offset from the top-left corner of the original orthoimage in pixels * of the original resolution * of the original resolution * @return vertical point X,Y offset in pixels from the top-left image corner in original resolution * @return vertical point X,Y offset in pixels from the top-left image corner in original resolution */ */ public int [] getVertPixels() { public int [] getVertPixels() { double [] vm = getVertMeters(); return new int [] { return new int [] { (int) Math.round(vert_meters[0]/orig_pix_meters), (int) Math.round(vm[0]/orig_pix_meters), (int) Math.round(vert_meters[0]/orig_pix_meters)}; (int) Math.round(vm[1]/orig_pix_meters)}; } } public ImagePlus getOriginalImage(boolean show_markers) { public ImagePlus getOriginalImage(boolean show_markers) { FloatImageData orig_image = getImageData(); FloatImageData orig_image = getImageData(); double [] vm = getVertMeters(); if (orig_image != null) { if (orig_image != null) { String full_name = path.substring(path.lastIndexOf(Prefs.getFileSeparator()) + 1); String full_name = path.substring(path.lastIndexOf(Prefs.getFileSeparator()) + 1); ImagePlus imp = ShowDoubleFloatArrays.makeArrays( ImagePlus imp = ShowDoubleFloatArrays.makeArrays( Loading @@ -771,7 +790,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ full_name); full_name); if (show_markers) { if (show_markers) { PointRoi roi = new PointRoi(); PointRoi roi = new PointRoi(); roi.addPoint(orig_image.vert[0],orig_image.vert[1]); roi.addPoint(vm[0],vm[1]); roi.setOptions("label"); roi.setOptions("label"); imp.setRoi(roi); imp.setRoi(roi); } } Loading Loading @@ -1001,16 +1020,11 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ System.out.println("downScaleForGPU(): indx = "+indx+" ("+spix.length+"), tileX= "+ System.out.println("downScaleForGPU(): indx = "+indx+" ("+spix.length+"), tileX= "+ tileX+", tileY="+tileY+", px="+px+", py="+py+", ls="+ls); tileX+", tileY="+tileY+", px="+px+", py="+py+", ls="+ls); } } // if (sw > 0) { // opix[tileY * width + tileX] = (float) (swd/sw); // } } } } } if (sw > 0) { if (sw > 0) { opix[tileY * width + tileX] = (float) (swd/sw); opix[tileY * width + tileX] = (float) (swd/sw); } } } } } } }; }; Loading src/main/java/com/elphel/imagej/orthomosaic/OrthoMapsCollection.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -1346,7 +1346,7 @@ public class OrthoMapsCollection implements Serializable{ double [][] tlo_source_pixel = new double[tlo_src_metric.length][2]; double [][] tlo_source_pixel = new double[tlo_src_metric.length][2]; for (int n=0; n <tlo_source_pixel.length; n++) { for (int n=0; n <tlo_source_pixel.length; n++) { for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) { tlo_source_pixel[n][i] = (tlo_src_metric[n][i] + ortho_maps[gpu_pair[n]].vert_meters[i])/pix_size; tlo_source_pixel[n][i] = (tlo_src_metric[n][i] + ortho_maps[gpu_pair[n]].getVertMeters()[i])/pix_size; } } } } Loading Loading @@ -1862,7 +1862,7 @@ public class OrthoMapsCollection implements Serializable{ double [] tlo_src_metric_other = new double[2]; // check affines[][][] here - double [] tlo_src_metric_other = new double[2]; // check affines[][][] here - for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) { tlo_src_metric_other[i] = affines_gpu[1][i][2] * pix_size - ortho_maps[gpu_pair[1]].vert_meters[i]; tlo_src_metric_other[i] = affines_gpu[1][i][2] * pix_size - ortho_maps[gpu_pair[1]].getVertMeters()[i]; for (int j = 0; j < 2; j++) { for (int j = 0; j < 2; j++) { affines[1][i][j] = affines_gpu[1][i][j]; affines[1][i][j] = affines_gpu[1][i][j]; } } Loading Loading
src/main/java/com/elphel/imagej/orthomosaic/FloatImageData.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -11,7 +11,7 @@ public class FloatImageData { public int width; public int width; public int height; public int height; public int zoom_lev; public int zoom_lev; public double [] vert = new double[2]; // x,y offset (in meters) of the point under the camera private double [] vert = new double[2]; // x,y offset (in meters) of the point under the camera public float[] data; public float[] data; public FloatImageData ( public FloatImageData ( int width, int width, Loading @@ -26,6 +26,16 @@ public class FloatImageData { this.data = data; this.data = data; } } public int getWidth() { return width; } public int getHeight() { return height; } public double[] getVertMeters() { return vert; } public double [] getDData() { public double [] getDData() { final double [] ddata = new double [data.length]; final double [] ddata = new double [data.length]; final Thread[] threads = ImageDtt.newThreadArray(); final Thread[] threads = ImageDtt.newThreadArray(); Loading
src/main/java/com/elphel/imagej/orthomosaic/OrthoMap.java +27 −13 Original line number Original line Diff line number Diff line Loading @@ -116,8 +116,11 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ public double [][] affine = new double[][] {{1,0,0},{0,1,0}}; // relative to vert_meters[], positive Y is down (as in images) public double [][] affine = new double[][] {{1,0,0},{0,1,0}}; // relative to vert_meters[], positive Y is down (as in images) public transient double [][] ers_affine = new double[][] {{1,0},{0,1}}; // orientation only for remaining ERS, positive Y is down (as in images) public transient double [][] ers_affine = new double[][] {{1,0},{0,1}}; // orientation only for remaining ERS, positive Y is down (as in images) public double orig_pix_meters; public double orig_pix_meters; public double [] vert_meters; // offset of the image vertical in meters (scale-invariant), right (X) and down (Y) @Deprecated private double [] vert_meters; // offset of the image vertical in meters (scale-invariant), right (X) and down (Y) @Deprecated public int orig_width; public int orig_width; @Deprecated public int orig_height; public int orig_height; public transient FloatImageData orig_image; public transient FloatImageData orig_image; public transient FloatImageData alt_image; public transient FloatImageData alt_image; Loading Loading @@ -237,10 +240,16 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ } } public int getWidth() { public int getWidth() { return orig_width; return getImageData().getWidth(); // orig_width; } } public int getHeight() { public int getHeight() { return orig_height; return getImageData().getHeight(); //orig_height; } public int getAltWidth() { return getAltData().getWidth(); // orig_width; } public int getAltHeight() { return getAltData().getHeight(); //orig_height; } } public void setMatch( public void setMatch( Loading Loading @@ -692,7 +701,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ } } private boolean readAltData() { // assuming the same scale as main image private boolean readAltData() { // assuming the same scale as main image - WRONG ImagePlus imp = new ImagePlus(getAltPath(path)); ImagePlus imp = new ImagePlus(getAltPath(path)); int width = imp.getWidth(); int width = imp.getWidth(); int height = imp.getHeight(); int height = imp.getHeight(); Loading Loading @@ -744,24 +753,34 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ * Get vertical point offset from the top-left corner of the original orthoimage in meters (right and down) * Get vertical point offset from the top-left corner of the original orthoimage in meters (right and down) * @return vertical point X,Y offset in meters from the top-left image corner * @return vertical point X,Y offset in meters from the top-left image corner */ */ public double [] getVertMeters() { public double [] getVertMetersOld() { return vert_meters; return vert_meters; } } public double [] getVertMeters() { return getImageData().getVertMeters(); // ; } public double [] getVertMetersAlt() { return getAltData().getVertMeters(); // ; } /** /** * Get vertical point offset from the top-left corner of the original orthoimage in pixels * Get vertical point offset from the top-left corner of the original orthoimage in pixels * of the original resolution * of the original resolution * @return vertical point X,Y offset in pixels from the top-left image corner in original resolution * @return vertical point X,Y offset in pixels from the top-left image corner in original resolution */ */ public int [] getVertPixels() { public int [] getVertPixels() { double [] vm = getVertMeters(); return new int [] { return new int [] { (int) Math.round(vert_meters[0]/orig_pix_meters), (int) Math.round(vm[0]/orig_pix_meters), (int) Math.round(vert_meters[0]/orig_pix_meters)}; (int) Math.round(vm[1]/orig_pix_meters)}; } } public ImagePlus getOriginalImage(boolean show_markers) { public ImagePlus getOriginalImage(boolean show_markers) { FloatImageData orig_image = getImageData(); FloatImageData orig_image = getImageData(); double [] vm = getVertMeters(); if (orig_image != null) { if (orig_image != null) { String full_name = path.substring(path.lastIndexOf(Prefs.getFileSeparator()) + 1); String full_name = path.substring(path.lastIndexOf(Prefs.getFileSeparator()) + 1); ImagePlus imp = ShowDoubleFloatArrays.makeArrays( ImagePlus imp = ShowDoubleFloatArrays.makeArrays( Loading @@ -771,7 +790,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ full_name); full_name); if (show_markers) { if (show_markers) { PointRoi roi = new PointRoi(); PointRoi roi = new PointRoi(); roi.addPoint(orig_image.vert[0],orig_image.vert[1]); roi.addPoint(vm[0],vm[1]); roi.setOptions("label"); roi.setOptions("label"); imp.setRoi(roi); imp.setRoi(roi); } } Loading Loading @@ -1001,16 +1020,11 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ System.out.println("downScaleForGPU(): indx = "+indx+" ("+spix.length+"), tileX= "+ System.out.println("downScaleForGPU(): indx = "+indx+" ("+spix.length+"), tileX= "+ tileX+", tileY="+tileY+", px="+px+", py="+py+", ls="+ls); tileX+", tileY="+tileY+", px="+px+", py="+py+", ls="+ls); } } // if (sw > 0) { // opix[tileY * width + tileX] = (float) (swd/sw); // } } } } } if (sw > 0) { if (sw > 0) { opix[tileY * width + tileX] = (float) (swd/sw); opix[tileY * width + tileX] = (float) (swd/sw); } } } } } } }; }; Loading
src/main/java/com/elphel/imagej/orthomosaic/OrthoMapsCollection.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -1346,7 +1346,7 @@ public class OrthoMapsCollection implements Serializable{ double [][] tlo_source_pixel = new double[tlo_src_metric.length][2]; double [][] tlo_source_pixel = new double[tlo_src_metric.length][2]; for (int n=0; n <tlo_source_pixel.length; n++) { for (int n=0; n <tlo_source_pixel.length; n++) { for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) { tlo_source_pixel[n][i] = (tlo_src_metric[n][i] + ortho_maps[gpu_pair[n]].vert_meters[i])/pix_size; tlo_source_pixel[n][i] = (tlo_src_metric[n][i] + ortho_maps[gpu_pair[n]].getVertMeters()[i])/pix_size; } } } } Loading Loading @@ -1862,7 +1862,7 @@ public class OrthoMapsCollection implements Serializable{ double [] tlo_src_metric_other = new double[2]; // check affines[][][] here - double [] tlo_src_metric_other = new double[2]; // check affines[][][] here - for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) { tlo_src_metric_other[i] = affines_gpu[1][i][2] * pix_size - ortho_maps[gpu_pair[1]].vert_meters[i]; tlo_src_metric_other[i] = affines_gpu[1][i][2] * pix_size - ortho_maps[gpu_pair[1]].getVertMeters()[i]; for (int j = 0; j < 2; j++) { for (int j = 0; j < 2; j++) { affines[1][i][j] = affines_gpu[1][i][j]; affines[1][i][j] = affines_gpu[1][i][j]; } } Loading