Commit 8d0998f2 authored by Andrey Filippov's avatar Andrey Filippov

working snapshot, improving clusterization

parent 2f3efffd
...@@ -32,6 +32,9 @@ class TileCluster{ ...@@ -32,6 +32,9 @@ class TileCluster{
// <0 - outside, 0 - inner /true disparity, border_int_max - outer border layer, ... // <0 - outside, 0 - inner /true disparity, border_int_max - outer border layer, ...
int [] border_int; // will replace border? Provide on-the-fly? int [] border_int; // will replace border? Provide on-the-fly?
int border_int_max; // outer border value int border_int_max; // outer border value
int [] stitch_stitched; // +1 - stitch, +2 - stitched
int [] no_connect; // bit mask of prohibited directions
double [] disparity; // all and only unused - NaN double [] disparity; // all and only unused - NaN
int [] cluster_index = null; // for debug purposes, index of the source cluster int [] cluster_index = null; // for debug purposes, index of the source cluster
int index = -1; int index = -1;
...@@ -54,9 +57,11 @@ class TileCluster{ ...@@ -54,9 +57,11 @@ class TileCluster{
public TileCluster ( public TileCluster (
Rectangle bounds, Rectangle bounds,
int index, // <0 to skip int index, // <0 to skip
boolean [] border, // boolean [] border,
int [] border_int, // will replace border? Provide on-the-fly? int [] border_int, // will replace border? Provide on-the-fly?
int border_int_max, // outer border value int border_int_max, // outer border value
int [] stitch_stitched, // +1 - stitch, +2 - stitched
int [] no_connect, // bit mask of prohibited directions
double [] disparity, double [] disparity,
boolean is_sky){ boolean is_sky){
this.bounds = bounds; this.bounds = bounds;
...@@ -68,15 +73,14 @@ class TileCluster{ ...@@ -68,15 +73,14 @@ class TileCluster{
} }
this.disparity = disparity; this.disparity = disparity;
if (border == null) { // boolean []
border = new boolean[bounds.width * bounds.height]; border = new boolean[bounds.width * bounds.height];
if (border_int != null) { if (border_int != null) {
for (int i = 0; i < border_int.length; i++) { for (int i = 0; i < border_int.length; i++) {
border[i] = border_int[i] == border_int_max; border[i] = border_int[i] == border_int_max;
} }
} }
} // this.border = border;
this.border = border;
// for back compatibility // for back compatibility
if (border_int == null) { if (border_int == null) {
border_int = new int [bounds.width * bounds.height]; border_int = new int [bounds.width * bounds.height];
...@@ -90,9 +94,19 @@ class TileCluster{ ...@@ -90,9 +94,19 @@ class TileCluster{
} }
} }
} }
this.border_int = border_int; this.border_int = border_int;
this.border_int_max = border_int_max; this.border_int_max = border_int_max;
if (stitch_stitched == null) {
stitch_stitched = new int [bounds.width * bounds.height];
} }
this.stitch_stitched = stitch_stitched;
if (no_connect == null) {
no_connect = new int [bounds.width * bounds.height];
}
this.no_connect = no_connect;
}
public boolean isSky() { public boolean isSky() {
return is_sky; return is_sky;
} }
...@@ -123,6 +137,8 @@ class TileCluster{ ...@@ -123,6 +137,8 @@ class TileCluster{
} }
public boolean [] getBorder() {return border;} // Modify to use border_int (==border_int_max)? public boolean [] getBorder() {return border;} // Modify to use border_int (==border_int_max)?
public int [] getBorderInt() {return border_int;} public int [] getBorderInt() {return border_int;}
public int [] getStitchStitched() {return stitch_stitched;}
public int [] getNoConnect() {return no_connect;}
public int getBorderIntMax() {return border_int_max;} public int getBorderIntMax() {return border_int_max;}
public double [] getDisparity() {return disparity;} public double [] getDisparity() {return disparity;}
public void setDisparity(double [] disparity) {this.disparity = disparity;} public void setDisparity(double [] disparity) {this.disparity = disparity;}
...@@ -209,6 +225,46 @@ class TileCluster{ ...@@ -209,6 +225,46 @@ class TileCluster{
return sub_border_int; return sub_border_int;
} }
public int [] getSubStitchStitched(int indx) {
if (clust_list == null) {
return null;
}
Rectangle sub_bounds = clust_list.get(indx).bounds;
int [] sub_stitch_stitched = new int [sub_bounds.width * sub_bounds.height];
int src_x = sub_bounds.x - bounds.x;
for (int dst_y = 0; dst_y < sub_bounds.height; dst_y++) {
int src_y = dst_y + sub_bounds.y - bounds.y;
System.arraycopy(
stitch_stitched,
src_y * bounds.width + src_x,
sub_stitch_stitched,
dst_y * sub_bounds.width,
sub_bounds.width);
}
return sub_stitch_stitched;
}
public int [] getSubNoConnect(int indx) {
if (clust_list == null) {
return null;
}
Rectangle sub_bounds = clust_list.get(indx).bounds;
int [] sub_no_connect = new int [sub_bounds.width * sub_bounds.height];
int src_x = sub_bounds.x - bounds.x;
for (int dst_y = 0; dst_y < sub_bounds.height; dst_y++) {
int src_y = dst_y + sub_bounds.y - bounds.y;
System.arraycopy(
no_connect,
src_y * bounds.width + src_x,
sub_no_connect,
dst_y * sub_bounds.width,
sub_bounds.width);
}
return sub_no_connect;
}
// returns selected for all non-NAN, so it is possible to use NEGATIVE_INFINITY for non-NaN // returns selected for all non-NAN, so it is possible to use NEGATIVE_INFINITY for non-NaN
public boolean [] getSubSelected(int indx) { // disparity should be NaN for unused ! public boolean [] getSubSelected(int indx) { // disparity should be NaN for unused !
...@@ -223,10 +279,6 @@ class TileCluster{ ...@@ -223,10 +279,6 @@ class TileCluster{
return sub_selection; return sub_selection;
} }
public boolean [] getSelected() { public boolean [] getSelected() {
if (disparity == null) { if (disparity == null) {
return null; return null;
...@@ -356,6 +408,18 @@ class TileCluster{ ...@@ -356,6 +408,18 @@ class TileCluster{
disparity, disparity,
dst_y * bounds.width + dst_x, dst_y * bounds.width + dst_x,
tileCluster.bounds.width); tileCluster.bounds.width);
System.arraycopy(
tileCluster.stitch_stitched,
src_y * tileCluster.bounds.width,
stitch_stitched,
dst_y * bounds.width + dst_x,
tileCluster.bounds.width);
System.arraycopy(
tileCluster.no_connect,
src_y * tileCluster.bounds.width,
no_connect,
dst_y * bounds.width + dst_x,
tileCluster.bounds.width);
} }
return; return;
} }
......
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