Skip to content
This repository was archived by the owner on Jan 14, 2023. It is now read-only.

Commit d1ad152

Browse files
committed
[depthMap][imageIO] ensure range is not null when normalizing depth
1 parent 09b4f0c commit d1ad152

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/depthMapEntity/DepthMapEntity.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ void DepthMapEntity::loadDepthMap()
328328
}
329329
else
330330
{
331-
float normalizedDepthValue = (depthValue - stats.min[0]) / (stats.max[0] - stats.min[0]);
331+
const float range = stats.max[0] - stats.min[0];
332+
float normalizedDepthValue = range != 0.0f ? (depthValue - stats.min[0]) / range : 1.0f;
332333
Color32f color = getColor32fFromJetColorMapClamp(normalizedDepthValue);
333334
colors.push_back(color);
334335
}

src/imageIOHandler/QtOIIOHandler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ bool QtOIIOHandler::read(QImage *image)
216216
{
217217
float depthValue = 0.0f;
218218
inBuf.getpixel(x, y, &depthValue, 1);
219-
float normalizedDepthValue = (depthValue - stats.min[0]) / (stats.max[0] - stats.min[0]);
219+
const float range = stats.max[0] - stats.min[0];
220+
const float normalizedDepthValue = range != 0.0f ? (depthValue - stats.min[0]) / range : 1.0f;
220221
Color32f color;
221222
if(isDepthMap)
222223
color = getColor32fFromJetColorMap(normalizedDepthValue);

0 commit comments

Comments
 (0)