Commit c5431a27 authored by Andrey Filippov's avatar Andrey Filippov

Refactoring, incompatible data file

parent 32292d3b
package com.elphel.imagej.orthomosaic;
import java.awt.Rectangle;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
import com.elphel.imagej.common.PolynomialApproximation;
import com.elphel.imagej.readers.ElphelTiffReader;
import com.elphel.imagej.tileprocessor.ImageDtt;
public class FloatImageData {
public int width;
public int height;
public int zoom_lev;
private double [] vert = new double[2]; // x,y offset (in meters) of the point under the camera
public float[] data;
import ij.ImagePlus;
public class FloatImageData implements Serializable {
private static final long serialVersionUID = 1L;
public static boolean FIX_VERT_Y = false; // true; // temporarily fix vertical Y coordinate bug (use -GCORR in the filename?)
public int width;
public int height;
public int zoom_lev;
private boolean zoom_valid;
public String path;
public Properties properties; // serializable
private double [] lla; // lat/long/alt
public LocalDateTime dt;
private double [] vert = new double[2]; // x,y offset (in meters) of the point under the camera
private double pix_meters;
private double averagePixel=Double.NaN;
private transient float[] data; // make transient
public FloatImageData (
int width,
int height,
int zoom_lev,
double [] vert, // x,y pixel offset of the point under the camera
float[] data) {
this.width = width;
this.height = height;
this.zoom_lev = zoom_lev;
this.vert = vert.clone();
this.data = data;
String path) {
this.path = path;
try {
properties = ElphelTiffReader.getTiffMeta(path);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
lla = ElphelTiffReader.getLLA(properties);
} catch (NullPointerException e) {
System.out.println("No GPS data in "+path);
// TODO Auto-generated catch block
e.printStackTrace();
}
dt = ElphelTiffReader.getLocalDateTime(properties);
vert = ElphelTiffReader.getXYOffsetMeters(properties);
pix_meters = ElphelTiffReader.getPixelSize(properties)[0];
if (FIX_VERT_Y) {
int height_pix = ElphelTiffReader.getHeight(properties);
double height_meters = height_pix * pix_meters;
vert[1] = height_meters-vert[1];
}
width = ElphelTiffReader.getWidth(properties);
height = ElphelTiffReader.getHeight(properties);
zoom_lev = getZoomLevel(pix_meters);
zoom_valid = isZoomValid(pix_meters);
}
public int getWidth() {
return width;
private void writeObject(ObjectOutputStream oos) throws IOException {
oos.defaultWriteObject();
}
public int getHeight() {
return height;
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
ois.defaultReadObject();
data = null;
}
public void updateLLA() {
try {
properties = ElphelTiffReader.getTiffMeta(path);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
lla = ElphelTiffReader.getLLA(properties);
} catch (NullPointerException e) {
System.out.println("No GPS data in "+path);
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public double[] getVertMeters() {
return vert;
float [] readFData() {
if (data == null) {
ImagePlus imp = new ImagePlus(path);
int width = imp.getWidth();
int height = imp.getHeight();
if ((width != this.width) || (height != this.height)) {
throw new IllegalArgumentException (String.format("IJ image size does not match Exif one: (%d,%d) != (%d,%d)",
width,height, this.width,this.height));
}
data = (float[]) (imp.getProcessor().getPixels());
}
return data;
}
public double [] getDData() {
if (data==null) {
readFData();
if (data== null) {
return null;
}
}
final double [] ddata = new double [data.length];
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
......@@ -53,6 +124,103 @@ public class FloatImageData {
return ddata;
}
public double [] getLLA() {
return lla; // null if does not exist, saved with data file
}
public LocalDateTime getDT() {
return dt;
}
public boolean isZoomValid() {
if (!zoom_valid) {
System.out.println("Original zoom level is invalid, need_extra_zoom = "+needZoomIn(pix_meters));
}
return zoom_valid;
}
/**
* Get vertical point offset from the top-left corner of the original orthoimage in pixels
* of the original resolution
* @return vertical point X,Y offset in pixels from the top-left image corner in original resolution
*/
public int [] getVertPixels() {
double [] vm = getVertMeters();
return new int [] {
(int) Math.round(vm[0]/pix_meters),
(int) Math.round(vm[1]/pix_meters)};
}
public double getPixMeters() {
return pix_meters;
}
public FloatImageData (
FloatImageData master,
int zoom_level,
float[] data) {
this.width = master.width;
this.height = master.height;
this.zoom_valid = master.zoom_valid;
this.path = master.path;
this.properties = master.properties;
this.lla = master.lla;
this.dt = master.dt;
this.vert = master.vert;
this.pix_meters = master.pix_meters;
this.averagePixel = master.averagePixel;
this.zoom_lev = zoom_level;
this.data = data;
}
public double getAveragePixel() {
if (Double.isNaN(averagePixel)) {
final float [] pixels = readFData();
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
final AtomicInteger ati = new AtomicInteger(0);
final double [] avg_arr = new double [threads.length];
final double [] npix_arr = new double [threads.length];
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
int thread_num = ati.getAndIncrement();
for (int ipix = ai.getAndIncrement(); ipix < pixels.length; ipix = ai.getAndIncrement()) {
float p = pixels[ipix];
if (!Float.isNaN(p)) {
avg_arr[thread_num] += p;
npix_arr[thread_num] +=1;
}
}
}
};
}
ImageDtt.startAndJoin(threads);
double avg=0, num=0;
for (int i = 0; i < avg_arr.length; i++) {
avg+=avg_arr[i]; // *npix_arr[i];
num+=npix_arr[i];
}
averagePixel = avg/num;
}
return averagePixel;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public double[] getVertMeters() {
return vert;
}
public static int getZoomLevel(
double pix_in_meters) {
return getZoomLevel (pix_in_meters, null, null);
......@@ -70,6 +238,10 @@ public class FloatImageData {
return extra_zoom[0];
}
public int getZoomLevel() {
return zoom_lev;
}
/**
* Find scale level (0: 1pix/cm, 1 - 2pix/cm, -1 - 0.5 pix/cm) from pixel size in meters
* If scale does not match, provide false in optional valid_zoom[0]
......
......@@ -49,7 +49,7 @@ public class ObjectLocation {
OrthoMap [] ortho_maps=maps_collection.getMaps();
final int width = ortho_maps[nmap].getImageData().width;
final int height = ortho_maps[nmap].getImageData().height;
final float [] src_img = ortho_maps[nmap].getImageData().data;
final float [] src_img = ortho_maps[nmap].getImageData().readFData();
double [] dcrop = new double [size*size];
Arrays.fill(dcrop, Double.NaN);
int hsize = size/2;
......
......@@ -115,20 +115,12 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
// coordinates relative to vert_meters
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 double orig_pix_meters;
@Deprecated
private double [] vert_meters; // offset of the image vertical in meters (scale-invariant), right (X) and down (Y)
@Deprecated
public int orig_width;
@Deprecated
public int orig_height;
public transient FloatImageData orig_image;
public transient FloatImageData alt_image;
public int orig_zoom_level;
public boolean orig_zoom_valid;
public double need_extra_zoom;
public double averageRawPixel = Double.NaN; // measure of scene temperature
public transient double averageImagePixel = Double.NaN; // average image pixel value (to combine with raw)
transient HashMap <Integer, FloatImageData> images;
HashMap <String, PairwiseOrthoMatch> pairwise_matches;
public transient SensorTemperatureData[] temp_data;
......@@ -137,27 +129,10 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
public transient double sfm_gain = Double.NaN; // maximal SfM gain of this map
public transient double [] equalize = {1,0}; // rectified value = equalize[0]*source_value+equalize[1]
public transient double [] qorient = null; // quternion representing orientation+scale of the scene
private void writeObject(ObjectOutputStream oos) throws IOException {
// temporary fix:
// double [][] affine_clone = {affine[0].clone(), affine[1].clone()};
// affine = affine_clone;
oos.defaultWriteObject();
oos.writeObject(path);
// oos.writeObject(scenes_path);
// lla is not transient
// dt is not transient
// affine is not transient
// orig_pix_meters is not transient
// vert_meters is not transient
// orig_width is not transient
// orig_height is not transient
// orig_image does not need to be saved
// alt_image does not need to be saved
// orig_zoom_level is not transient
// orig_zoom_valid is not transient
// need_extra_zoom is not transient
// images is not saved
// pairwise_matches is not transient
oos.writeObject(temp_data); // temporary, while transient
oos.writeObject(agl);
oos.writeObject(num_scenes);
......@@ -167,38 +142,21 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
}
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
// sfm_gain = Double.NaN;
// num_scenes = -1;
ois.defaultReadObject();
path = (String) ois.readObject();
name = getNameFromPath(path);
ts= Double.parseDouble(name.replace("_", "."));
// scenes_path= (String) ois.readObject();
// lla is not transient
// dt is not transient
// affine is not transient
// orig_pix_meters is not transient
// vert_meters is not transient
// orig_width is not transient
// orig_height is not transient
// orig_image was not saved
// alt_image was not saved
temp_data = (SensorTemperatureData[]) ois.readObject();
agl = (double) ois.readObject();
num_scenes = (int) ois.readObject();
sfm_gain = (double) ois.readObject();
// equalize = new double[] {1,0};
equalize = (double []) ois.readObject();
if (OrthoMapsCollection.CURRENT_VERSION >= OrthoMapsCollection.VERSION_POST_ORIENT) {
qorient = (double[]) ois.readObject();
}
images = new HashMap <Integer, FloatImageData>(); // field images was not saved
averageImagePixel = Double.NaN; // average image pixel value (to combine with raw)
// averageImagePixel = Double.NaN; // average image pixel value (to combine with raw)
// pairwise_matches is not transient
// pairwise_matches = new HashMap<Double, PairwiseOrthoMatch>();
}
public double [] getQOrinet() {
......@@ -366,8 +324,6 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
return sfm_gain;
}
public String getLatestFilePath(String suffix) {
String model_dir = getModelPathFromPath(this.path);
File [] subdirs = (new File(model_dir)).listFiles();
......@@ -389,7 +345,19 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
return null;
}
/**
* For debuggig, updating after lla generation fixed
*/
public void updateLLA() {
if (orig_image != null) {
orig_image.updateLLA();
}
if (alt_image != null) {
alt_image.updateLLA();
}
}
/*
public void updateLLA() {
Properties imp_prop = null;
try {
......@@ -400,6 +368,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
}
lla = ElphelTiffReader.getLLA(imp_prop);
}
*/
/**
* Gets average pixel value of all sensors of the reference scene
......@@ -518,10 +487,122 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
public OrthoMap (
String path) {
// String scenes_path) {
this.path = path;
// this.scenes_path = scenes_path; // will not be used
String path) {
this.path = path;
name = getNameFromPath(path);
ts= Double.parseDouble(name.replace("_", "."));
// initialize and read Exif for the images
orig_image = new FloatImageData(path);
dt = orig_image.getDT();
/*
Properties imp_prop = null;
try {
imp_prop = ElphelTiffReader.getTiffMeta(path);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
lla = ElphelTiffReader.getLLA(imp_prop);
} catch (NullPointerException e) {
System.out.println("No GPS data in "+path);
// TODO Auto-generated catch block
e.printStackTrace();
}
dt = ElphelTiffReader.getLocalDateTime(imp_prop);
vert_meters = ElphelTiffReader.getXYOffsetMeters(imp_prop);
orig_pix_meters = ElphelTiffReader.getPixelSize(imp_prop)[0];
if (FIX_VERT_Y) {
int height_pix = ElphelTiffReader.getHeight(imp_prop);
double height_meters = height_pix * orig_pix_meters;
vert_meters[1] = height_meters-vert_meters[1];
}
orig_width = ElphelTiffReader.getWidth(imp_prop);
orig_height = ElphelTiffReader.getHeight(imp_prop);
orig_zoom_level = FloatImageData.getZoomLevel(orig_pix_meters);
orig_zoom_valid = FloatImageData.isZoomValid(orig_pix_meters);
need_extra_zoom = FloatImageData.needZoomIn(orig_pix_meters);
*/
images = new HashMap <Integer, FloatImageData>();
pairwise_matches = new HashMap<String, PairwiseOrthoMatch>();
averageRawPixel = Double.NaN; // measure of scene temperature
// averageImagePixel = Double.NaN; // average image pixel value (to combine with raw)
}
/**
* Update filename (different version), update image and alt data
* @param filename
* @return true if OK, false - error
*/
public boolean setFileName(String filename) {
int p1 = path.lastIndexOf(Prefs.getFileSeparator());
if (p1 < 0) {
return false;
}
path= path.substring(0, p1+1) + filename;
if (orig_image != null) {
File image_file = new File(path);
if (!image_file.exists()) {
System.out.println("Image file does not exist: "+path);
return false;
}
orig_image = new FloatImageData(path);
dt = orig_image.getDT();
}
if (alt_image != null) {
String alt_path = getAltPath(path);
File alt_file = new File(alt_path);
if (!alt_file.exists()) {
System.out.println("Altitudes file does not exist: "+alt_path);
return false;
}
alt_image = new FloatImageData(alt_path);
}
return true;
}
/**
* Initialize and return image data instance, do not read image data, only the metadata
* @return image data instance with read metadata
*/
public FloatImageData getImage() {
if (orig_image == null) {
File image_file = new File(path);
if (!image_file.exists()) {
System.out.println("Image file does not exist: "+path);
return null;
}
orig_image = new FloatImageData(path);
dt = orig_image.getDT();
}
return orig_image;
}
/**
* Initialize and return altitude data instance, do not read image data, only the metadata
* @return altitude data instance with read metadata
*/
public FloatImageData getAlt() {
if (alt_image == null) {
String alt_path = getAltPath(path);
File alt_file = new File(alt_path);
if (!alt_file.exists()) {
System.out.println("Altitudes file does not exist: "+alt_path);
return null;
}
alt_image = new FloatImageData(alt_path);
}
return orig_image;
}
/*
public OrthoMap (
String path) {
this.path = path;
name = getNameFromPath(path);
ts= Double.parseDouble(name.replace("_", "."));
Properties imp_prop = null;
......@@ -558,6 +639,11 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
averageRawPixel = Double.NaN; // measure of scene temperature
averageImagePixel = Double.NaN; // average image pixel value (to combine with raw)
}
*/
public double getTimeStamp() {
return ts;
......@@ -573,10 +659,12 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
public String getPath() {
return path;
}
/*
public void setPath(String path) {
this.path = path;
}
*/
public String getFileName() {
int p1 = path.lastIndexOf(Prefs.getFileSeparator());
if (p1 < 0) {
......@@ -585,15 +673,6 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
return path.substring(p1+1);
}
public boolean setFileName(String filename) {
int p1 = path.lastIndexOf(Prefs.getFileSeparator());
if (p1 < 0) {
return false;
}
path= path.substring(0, p1+1) + filename;
return true;
}
public void setAffine(double [][] affine) {
this.affine = new double[][] {affine[0].clone(),affine[1].clone()};
}
......@@ -631,87 +710,20 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
public FloatImageData getImageData() {
if (orig_image == null) {
readImageData();
}
getAveragePixel();
getImage();
orig_image.readFData();
// getAveragePixel();
return orig_image;
}
public FloatImageData getAltData() {
if (alt_image == null) {
readAltData();
}
getAlt();
alt_image.readFData();
return alt_image;
}
private boolean readImageData() {
ImagePlus imp = new ImagePlus(path);
int width = imp.getWidth();
int height = imp.getHeight();
// TODO: FIXME!
// vert_meters[1] = height-vert_meters[1];
orig_image = new FloatImageData (
width, // int width,
height, // int height,
orig_zoom_level, // int zoom_lev,
vert_meters, // double [] vert, // x,y pixel offset of the point under the camera
(float[]) (imp.getProcessor().getPixels())); // data);
if (orig_zoom_valid) {
images.put(orig_zoom_level, orig_image);
}
averageImagePixel = Double.NaN;
return true;
}
public double getAveragePixel() {
if (Double.isNaN(averageImagePixel)) {
if (orig_image == null) {
readImageData();
}
final float [] pixels = orig_image.data;
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
final AtomicInteger ati = new AtomicInteger(0);
final double [] avg_arr = new double [threads.length];
final double [] npix_arr = new double [threads.length];
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
int thread_num = ati.getAndIncrement();
for (int ipix = ai.getAndIncrement(); ipix < pixels.length; ipix = ai.getAndIncrement()) {
float p = pixels[ipix];
if (!Float.isNaN(p)) {
avg_arr[thread_num] += p;
npix_arr[thread_num] +=1;
}
}
}
};
}
ImageDtt.startAndJoin(threads);
double avg=0, num=0;
for (int i = 0; i < avg_arr.length; i++) {
avg+=avg_arr[i]; // *npix_arr[i];
num+=npix_arr[i];
}
averageImagePixel = avg/num;
}
return averageImagePixel;
}
private boolean readAltData() { // assuming the same scale as main image - WRONG
ImagePlus imp = new ImagePlus(getAltPath(path));
int width = imp.getWidth();
int height = imp.getHeight();
alt_image = new FloatImageData (
width, // int width,
height, // int height,
orig_zoom_level, // int zoom_lev,
vert_meters, // double [] vert, // x,y pixel offset of the point under the camera
(float[]) (imp.getProcessor().getPixels())); // data);
return true;
getImage();
return orig_image.getAveragePixel();
}
/**
......@@ -726,9 +738,9 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
return Double.NaN;
}
double average_asl = getMaskedAverage (
src_elev.data, // final double [] data,
src_elev.readFData(), // final double [] data,
null); // final boolean [] mask)
agl= lla[2] - average_asl;
agl= getLLA()[2] - average_asl;
}
return agl;
}
......@@ -738,7 +750,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
* @return {latitude(deg), longitude(deg), altitude(m)}
*/
public double [] getLLA() {
return lla;
return (orig_image == null) ? null : orig_image.getLLA();
}
/**
......@@ -746,23 +758,20 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
* @return image pixel size in meters
*/
public double getOrigPixMeters() {
return orig_pix_meters;
return getImage().getPixMeters(); // orig_pix_meters;
}
/**
* 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
*/
public double [] getVertMetersOld() {
return vert_meters;
}
public double [] getVertMeters() {
return getImageData().getVertMeters(); // ;
return getImage().getVertMeters(); // ;
}
public double [] getVertMetersAlt() {
return getAltData().getVertMeters(); // ;
return getAlt().getVertMeters(); // ;
}
/**
......@@ -771,20 +780,17 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
* @return vertical point X,Y offset in pixels from the top-left image corner in original resolution
*/
public int [] getVertPixels() {
double [] vm = getVertMeters();
return new int [] {
(int) Math.round(vm[0]/orig_pix_meters),
(int) Math.round(vm[1]/orig_pix_meters)};
return getImage().getVertPixels();
}
/*
public ImagePlus getOriginalImage(boolean show_markers) {
FloatImageData orig_image = getImageData();
double [] vm = getVertMeters();
if (orig_image != null) {
String full_name = path.substring(path.lastIndexOf(Prefs.getFileSeparator()) + 1);
ImagePlus imp = ShowDoubleFloatArrays.makeArrays(
orig_image.data, // float[] pixels,
orig_image.readFData(), // float[] pixels,
getWidth(),
getHeight(),
full_name);
......@@ -798,9 +804,9 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
}
return null;
}
*/
public double [] enuOffsetTo(OrthoMap other) {
return Imx5.enuFromLla(other.lla, lla);
return Imx5.enuFromLla(other.getLLA(), getLLA());
}
public static double getPixelSizeMeters (int zoom_level ) {
......@@ -826,12 +832,10 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
* @return double [4][2] array [corner number]{x,y}
*/
public double [][] get4SourceCornersMeters(){
// FloatImageData orig_image = getImageData();
if ((orig_width <=0) || (orig_height <=0)) {
getImageData();
}
double width_meters = orig_width * orig_pix_meters;
double height_meters = orig_height * orig_pix_meters;
getImage();
double width_meters = getWidth() * orig_image.getPixMeters();
double height_meters = getHeight() * orig_image.getPixMeters();
double [] vert_meters = orig_image.getVertMeters();
return new double[][] { // CW from TL
{ - vert_meters[0], - vert_meters[1]},
{width_meters - vert_meters[0], - vert_meters[1]},
......@@ -959,11 +963,11 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
System.out.println("Original image is null");
return false;
}
if (!orig_zoom_valid) {
if (!orig_image.isZoomValid()) {
System.out.println("Original zoom level is invalid, need_extra_zoom = "+need_extra_zoom);
return false;
}
if (zoom_level > orig_zoom_level) {
if (zoom_level > orig_image.getZoomLevel()) {
System.out.println("Requested zoom level is too high ("+zoom_level+" > "+orig_zoom_level+")");
return false;
}
......@@ -971,13 +975,13 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
return true; // already exists
}
int rscale = 1;
for (int i = orig_zoom_level; i > zoom_level; i--) {
for (int i = orig_image.getZoomLevel(); i > zoom_level; i--) {
rscale *= 2;
}
final int frscale = rscale;
int swidth = getWidth();
int sheight = getHeight();
final float [] spix = orig_image.data;
final float [] spix = orig_image.readFData();
if (swidth*sheight != spix.length) {
System.out.println ("downScaleForGPU(): swidth="+ swidth+", sheight="+sheight+", swidth*sheight="+(swidth*sheight)+", spix.length="+spix.length);
System.out.println ();
......@@ -1030,12 +1034,12 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
};
}
ImageDtt.startAndJoin(threads);
images.put(zoom_level, new FloatImageData (
width, // int width,
height, // int height,
zoom_level, // int zoom_lev,
vert_meters, // double [] vert, // x,y pixel offset of the point under the camera
opix)); // data);
orig_image, // FloatImageData master,
zoom_level, // int zoom_level,
opix)); // float[] data) {
return true;
}
......@@ -1068,7 +1072,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
}
final int src_width = src_elev.width;
final int src_height = src_elev.height;
final float [] felev = src_elev.data;
final float [] felev = src_elev.readFData();
final double [] elev = new double [tilesX*tilesY];
Arrays.fill(elev, Double.NaN);
final int diff_zoom_lev = zoom_level-orig_zoom_level;
......@@ -1138,7 +1142,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
final float [] padded_gpu = new float[gpu_width*gpu_height];
final int swidth = fid.width;
final int sheight = fid.height;
final float [] spix = fid.data;
final float [] spix = fid.readFData();
Arrays.fill(padded_gpu, Float.NaN);
final int cheight = Math.min(sheight,gpu_height);
final int cwidth = Math.min(swidth, gpu_width);
......@@ -3130,6 +3134,10 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
double [] tile_plane_elev, // null or double[2][] will return per-tile elevations
String debug_title) {
final int num_bins = 1024;
FloatImageData alt = getAlt();
int orig_zoom_level = alt.getZoomLevel();
double orig_pix_meters = alt.getPixMeters();
double [] vert_meters = alt.getVertMeters();
int diff_zoom_lev = zoom_lev - orig_zoom_level;
double pix_size = orig_pix_meters / getScale(diff_zoom_lev); // zoom_lev negative, pixel larger
double [] pix_vertical = {vert_meters[0]/pix_size,vert_meters[1]/pix_size}; // image center in pixels
......@@ -3379,7 +3387,11 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
int width,
double [] plane_metric, // tiltx,tilty, offs - in meters
double metric_error) {
double camera_height = lla[2]- plane_metric[2];
double camera_height = getLLA()[2]- plane_metric[2];
FloatImageData alt = getAlt();
int orig_zoom_level = alt.getZoomLevel();
double orig_pix_meters = alt.getPixMeters();
double [] vert_meters = alt.getVertMeters();
int diff_zoom_lev = zoom_lev - orig_zoom_level;
double pix_size = orig_pix_meters / getScale(diff_zoom_lev); // zoom_lev negative, pixel larger
double [] pix_vertical = {vert_meters[0]/pix_size,vert_meters[1]/pix_size}; // image center in pixels
......
......@@ -845,7 +845,7 @@ public class OrthoMapsCollection implements Serializable{
scaled_out_center[0], // double px0, // in render pixels
scaled_out_center[1]); // // double py0);
}
final float [] src_img = use_alt? ortho_maps[nmap].getAltData().data : ortho_maps[nmap].getImageData().data;
final float [] src_img = use_alt? ortho_maps[nmap].getAltData().readFData() : ortho_maps[nmap].getImageData().readFData();
final Rectangle warp_woi =((indx==1) && (warp != null))? warp.getRenderWOI():null;
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
......@@ -1011,8 +1011,8 @@ public class OrthoMapsCollection implements Serializable{
}
boolean tilt_alt = (ground_planes != null) && (ground_planes[indx] != null);
final float [] src_img = use_alt?
(tilt_alt? ortho_maps[nmap].getAltData().data.clone(): ortho_maps[nmap].getAltData().data) :
ortho_maps[nmap].getImageData().data;
(tilt_alt? ortho_maps[nmap].getAltData().readFData().clone(): ortho_maps[nmap].getAltData().readFData()) :
ortho_maps[nmap].getImageData().readFData();
final Rectangle warp_woi =((indx==1) && (warp != null))? warp.getRenderWOI():null;
final Thread[] threads = ImageDtt.newThreadArray();
......
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