16bit support for ortho merge

Former-commit-id: 677370dd50
pull/1161/head
Piero Toffanin 2019-10-28 15:13:00 -04:00
rodzic 6e0440b559
commit dce9759129
2 zmienionych plików z 7 dodań i 7 usunięć

Wyświetl plik

@ -306,11 +306,6 @@ void OdmOrthoPhoto::printHelp()
log_.setIsPrintingInCout(false);
}
template <typename T>
inline int maxRange(){
return static_cast<int>(pow(2, sizeof(T) * 8) - 1);
}
void OdmOrthoPhoto::createOrthoPhoto()
{
if(inputFile_.empty())
@ -1079,7 +1074,7 @@ void OdmOrthoPhoto::renderPixel(int row, int col, float s, float t, const cv::Ma
photo_.at<cv::Vec<T, 4> >(row,col) = cv::Vec<T, 4>(static_cast<T>(b),
static_cast<T>(g),
static_cast<T>(r),
static_cast<T>(maxRange<T>()));
static_cast<T>(255)); // Alpha should always be in the 255 range
}
void OdmOrthoPhoto::getBarycentricCoordinates(pcl::PointXYZ v1, pcl::PointXYZ v2, pcl::PointXYZ v3, float x, float y, float &l1, float &l2, float &l3) const

Wyświetl plik

@ -102,6 +102,7 @@ def merge(input_ortho_and_ortho_cuts, output_orthophoto, orthophoto_vars={}):
inputs = []
bounds=None
precision=7
divider=255.0
for o, c in input_ortho_and_ortho_cuts:
if not io.file_exists(o):
@ -121,6 +122,10 @@ def merge(input_ortho_and_ortho_cuts, output_orthophoto, orthophoto_vars={}):
dtype = first.dtypes[0]
profile = first.profile
# Handle 16bit rasters
if dtype == 'uint16':
divider = 65535.0
log.ODM_INFO("%s valid orthophoto rasters to merge" % len(inputs))
sources = [(rasterio.open(o), rasterio.open(c)) for o,c in inputs]
@ -214,7 +219,7 @@ def merge(input_ortho_and_ortho_cuts, output_orthophoto, orthophoto_vars={}):
# For each band, average alpha values between
# destination raster and cut raster
for b in range(0, 3):
blended = temp[3] / 255.0 * temp[b] + (1 - temp[3] / 255.0) * dstarr[b]
blended = temp[3] / divider * temp[b] + (1 - temp[3] / divider) * dstarr[b]
np.copyto(dstarr[b], blended, casting='unsafe', where=temp[3]!=0)
dstrast.write(dstarr, window=dst_window)