Commit f5e788ec authored by Sehoon Yea's avatar Sehoon Yea Committed by David Flynn
Browse files

attr/m49601: use attr_t (uint16_t) for all attributes

In order to support bit depths higher than 8bit, this commit adds
an attr_t type to represent attribute data.  Existing uses of
uint8_t and uint16_t are converted to attr_t.
parent d2718fae
......@@ -254,7 +254,7 @@ AttributeDecoder::computeReflectancePredictionWeights(
int64_t minValue = 0;
int64_t maxValue = 0;
for (int i = 0; i < predictor.neighborCount; ++i) {
const uint16_t reflectanceNeighbor = pointCloud.getReflectance(
const attr_t reflectanceNeighbor = pointCloud.getReflectance(
indexes[predictor.neighbors[i].predictorIndex]);
if (i == 0 || reflectanceNeighbor < minValue) {
minValue = reflectanceNeighbor;
......@@ -303,7 +303,7 @@ AttributeDecoder::decodeReflectancesPred(
computeReflectancePredictionWeights(
aps, pointCloud, indexesLOD, predictor, decoder);
const uint32_t pointIndex = indexesLOD[predictorIndex];
uint16_t& reflectance = pointCloud.getReflectance(pointIndex);
attr_t& reflectance = pointCloud.getReflectance(pointIndex);
uint32_t attValue0 = 0;
if (zero_cnt > 0) {
zero_cnt--;
......@@ -316,8 +316,8 @@ AttributeDecoder::decodeReflectancesPred(
const int64_t delta = divExp2RoundHalfUp(
quant[0].scale(UIntToInt(attValue0)), kFixedPointAttributeShift);
const int64_t reconstructedQuantAttValue = quantPredAttValue + delta;
reflectance = uint16_t(
PCCClip(reconstructedQuantAttValue, int64_t(0), maxReflectance));
reflectance =
attr_t(PCCClip(reconstructedQuantAttValue, int64_t(0), maxReflectance));
}
}
......@@ -338,7 +338,7 @@ AttributeDecoder::computeColorPredictionWeights(
int64_t minValue[3] = {0, 0, 0};
int64_t maxValue[3] = {0, 0, 0};
for (int i = 0; i < predictor.neighborCount; ++i) {
const Vec3<uint8_t> colorNeighbor =
const Vec3<attr_t> colorNeighbor =
pointCloud.getColor(indexes[predictor.neighbors[i].predictorIndex]);
for (size_t k = 0; k < 3; ++k) {
if (i == 0 || colorNeighbor[k] < minValue[k]) {
......@@ -398,8 +398,8 @@ AttributeDecoder::decodeColorsPred(
zero_cnt = decoder.decodeZeroCnt(pointCount);
}
const uint32_t pointIndex = indexesLOD[predictorIndex];
Vec3<uint8_t>& color = pointCloud.getColor(pointIndex);
const Vec3<uint8_t> predictedColor =
Vec3<attr_t>& color = pointCloud.getColor(pointIndex);
const Vec3<attr_t> predictedColor =
predictor.predictColor(pointCloud, indexesLOD);
int64_t clipMax = (1 << desc.attr_bitdepth) - 1;
......@@ -409,7 +409,7 @@ AttributeDecoder::decodeColorsPred(
const int64_t residual = divExp2RoundHalfUp(
q.scale(UIntToInt(values[k])), kFixedPointAttributeShift);
const int64_t recon = predictedColor[k] + residual + residual0;
color[k] = uint8_t(PCCClip(recon, int64_t(0), clipMax));
color[k] = attr_t(PCCClip(recon, int64_t(0), clipMax));
if (!k && aps.inter_component_prediction_enabled_flag)
residual0 = residual;
......@@ -466,8 +466,8 @@ AttributeDecoder::decodeReflectancesRaht(
const int64_t minReflectance = 0;
for (int n = 0; n < voxelCount; n++) {
int64_t val = attributes[attribCount * n];
const uint16_t reflectance =
(uint16_t)PCCClip(val, minReflectance, maxReflectance);
const attr_t reflectance =
attr_t(PCCClip(val, minReflectance, maxReflectance));
pointCloud.setReflectance(packedVoxel[n].index, reflectance);
}
......@@ -531,10 +531,10 @@ AttributeDecoder::decodeColorsRaht(
const int r = attributes[attribCount * n];
const int g = attributes[attribCount * n + 1];
const int b = attributes[attribCount * n + 2];
Vec3<uint8_t> color;
color[0] = uint8_t(PCCClip(r, 0, clipMax));
color[1] = uint8_t(PCCClip(g, 0, clipMax));
color[2] = uint8_t(PCCClip(b, 0, clipMax));
Vec3<attr_t> color;
color[0] = attr_t(PCCClip(r, 0, clipMax));
color[1] = attr_t(PCCClip(g, 0, clipMax));
color[2] = attr_t(PCCClip(b, 0, clipMax));
pointCloud.setColor(packedVoxel[n].index, color);
}
......@@ -635,9 +635,9 @@ AttributeDecoder::decodeColorsLift(
for (size_t f = 0; f < pointCount; ++f) {
const auto color0 =
divExp2RoundHalfInf(colors[f], kFixedPointAttributeShift);
Vec3<uint8_t> color;
Vec3<attr_t> color;
for (size_t d = 0; d < 3; ++d) {
color[d] = uint8_t(PCCClip(color0[d], int64_t(0), clipMax));
color[d] = attr_t(PCCClip(color0[d], int64_t(0), clipMax));
}
pointCloud.setColor(indexesLOD[f], color);
}
......@@ -727,7 +727,7 @@ AttributeDecoder::decodeReflectancesLift(
const auto refl =
divExp2RoundHalfInf(reflectances[f], kFixedPointAttributeShift);
pointCloud.setReflectance(
indexesLOD[f], uint16_t(PCCClip(refl, int64_t(0), maxReflectance)));
indexesLOD[f], attr_t(PCCClip(refl, int64_t(0), maxReflectance)));
}
}
......
......@@ -507,7 +507,7 @@ AttributeEncoder::encodeReflectancesPred(
const uint32_t pointIndex = indexesLOD[predictorIndex];
const uint64_t reflectance = pointCloud.getReflectance(pointIndex);
const uint16_t predictedReflectance =
const attr_t predictedReflectance =
predictor.predictReflectance(pointCloud, indexesLOD);
const int64_t quantAttValue = reflectance;
const int64_t quantPredAttValue = predictedReflectance;
......@@ -518,8 +518,8 @@ AttributeEncoder::encodeReflectancesPred(
divExp2RoundHalfUp(quant[0].scale(delta), kFixedPointAttributeShift);
const int64_t reconstructedQuantAttValue =
quantPredAttValue + reconstructedDelta;
const uint16_t reconstructedReflectance =
uint16_t(PCCClip(reconstructedQuantAttValue, int64_t(0), clipMax));
const attr_t reconstructedReflectance =
attr_t(PCCClip(reconstructedQuantAttValue, int64_t(0), clipMax));
if (!attValue0)
++zero_cnt;
......@@ -558,8 +558,8 @@ AttributeEncoder::encodeReflectancesPred(
Vec3<int64_t>
AttributeEncoder::computeColorResiduals(
const Vec3<uint8_t> color,
const Vec3<uint8_t> predictedColor,
const Vec3<attr_t> color,
const Vec3<attr_t> predictedColor,
const Quantizers& quant)
{
Vec3<int64_t> residuals;
......@@ -597,7 +597,7 @@ AttributeEncoder::computeColorPredictionWeights(
int64_t minValue[3] = {0, 0, 0};
int64_t maxValue[3] = {0, 0, 0};
for (int i = 0; i < predictor.neighborCount; ++i) {
const Vec3<uint8_t> colorNeighbor =
const Vec3<attr_t> colorNeighbor =
pointCloud.getColor(indexesLOD[predictor.neighbors[i].predictorIndex]);
for (size_t k = 0; k < 3; ++k) {
if (i == 0 || colorNeighbor[k] < minValue[k]) {
......@@ -614,12 +614,11 @@ AttributeEncoder::computeColorPredictionWeights(
predictor.maxDiff = maxDiff;
if (maxDiff >= aps.adaptive_prediction_threshold) {
Vec3<uint8_t> attrValue =
pointCloud.getColor(indexesLOD[predictorIndex]);
Vec3<attr_t> attrValue = pointCloud.getColor(indexesLOD[predictorIndex]);
// base case: weighted average of n neighbours
predictor.predMode = 0;
Vec3<uint8_t> attrPred = predictor.predictColor(pointCloud, indexesLOD);
Vec3<attr_t> attrPred = predictor.predictColor(pointCloud, indexesLOD);
Vec3<int64_t> attrResidualQuant =
computeColorResiduals(attrValue, attrPred, quant);
......@@ -694,11 +693,11 @@ AttributeEncoder::encodeColorsPred(
aps, pointCloud, indexesLOD, predictorIndex, predictor, encoder, context,
quant);
const auto pointIndex = indexesLOD[predictorIndex];
const Vec3<uint8_t> color = pointCloud.getColor(pointIndex);
const Vec3<uint8_t> predictedColor =
const Vec3<attr_t> color = pointCloud.getColor(pointIndex);
const Vec3<attr_t> predictedColor =
predictor.predictColor(pointCloud, indexesLOD);
Vec3<uint8_t> reconstructedColor;
Vec3<attr_t> reconstructedColor;
int64_t residual0 = 0;
for (int k = 0; k < 3; ++k) {
const auto& q = quant[std::min(k, 1)];
......@@ -721,7 +720,7 @@ AttributeEncoder::encodeColorsPred(
values[k] = uint32_t(IntToUInt(long(residualQ)));
int64_t recon = predictedColor[k] + residualR;
reconstructedColor[k] = uint8_t(PCCClip(recon, int64_t(0), clipMax));
reconstructedColor[k] = attr_t(PCCClip(recon, int64_t(0), clipMax));
}
pointCloud.setColor(pointIndex, reconstructedColor);
......@@ -819,8 +818,8 @@ AttributeEncoder::encodeReflectancesTransformRaht(
const int64_t minReflectance = 0;
for (int n = 0; n < voxelCount; n++) {
int64_t val = attributes[attribCount * n];
const uint16_t reflectance =
(uint16_t)PCCClip(val, minReflectance, maxReflectance);
const attr_t reflectance =
attr_t(PCCClip(val, minReflectance, maxReflectance));
pointCloud.setReflectance(packedVoxel[n].index, reflectance);
}
......@@ -892,10 +891,10 @@ AttributeEncoder::encodeColorsTransformRaht(
const int r = attributes[attribCount * n];
const int g = attributes[attribCount * n + 1];
const int b = attributes[attribCount * n + 2];
Vec3<uint8_t> color;
color[0] = uint8_t(PCCClip(r, 0, clipMax));
color[1] = uint8_t(PCCClip(g, 0, clipMax));
color[2] = uint8_t(PCCClip(b, 0, clipMax));
Vec3<attr_t> color;
color[0] = attr_t(PCCClip(r, 0, clipMax));
color[1] = attr_t(PCCClip(g, 0, clipMax));
color[2] = attr_t(PCCClip(b, 0, clipMax));
pointCloud.setColor(packedVoxel[n].index, color);
}
......@@ -1001,9 +1000,9 @@ AttributeEncoder::encodeColorsLift(
for (size_t f = 0; f < pointCount; ++f) {
const auto color0 =
divExp2RoundHalfInf(colors[f], kFixedPointAttributeShift);
Vec3<uint8_t> color;
Vec3<attr_t> color;
for (size_t d = 0; d < 3; ++d) {
color[d] = uint8_t(PCCClip(color0[d], 0.0, clipMax));
color[d] = attr_t(PCCClip(color0[d], 0, clipMax));
}
pointCloud.setColor(indexesLOD[f], color);
}
......@@ -1097,7 +1096,7 @@ AttributeEncoder::encodeReflectancesLift(
const int64_t refl =
divExp2RoundHalfInf(reflectances[f], kFixedPointAttributeShift);
pointCloud.setReflectance(
indexesLOD[f], uint16_t(PCCClip(refl, int64_t(0), maxReflectance)));
indexesLOD[f], attr_t(PCCClip(refl, int64_t(0), maxReflectance)));
}
}
......
......@@ -108,8 +108,8 @@ protected:
PCCResidualsEncoder& encoder);
static Vec3<int64_t> computeColorResiduals(
const Vec3<uint8_t> color,
const Vec3<uint8_t> predictedColor,
const Vec3<attr_t> color,
const Vec3<attr_t> predictedColor,
const Quantizers& quant);
static void computeColorPredictionWeights(
......
......@@ -51,6 +51,13 @@
#include "PCCMisc.h"
namespace pcc {
//============================================================================
// The type used for internally representing attribute data
typedef uint16_t attr_t;
//============================================================================
class PCCPointSet3 {
public:
typedef Vec3<double> PointType;
......@@ -259,32 +266,32 @@ public:
assert(index < positions.size());
return positions[index];
}
Vec3<uint8_t> getColor(const size_t index) const
Vec3<attr_t> getColor(const size_t index) const
{
assert(index < colors.size() && withColors);
return colors[index];
}
Vec3<uint8_t>& getColor(const size_t index)
Vec3<attr_t>& getColor(const size_t index)
{
assert(index < colors.size() && withColors);
return colors[index];
}
void setColor(const size_t index, const Vec3<uint8_t> color)
void setColor(const size_t index, const Vec3<attr_t> color)
{
assert(index < colors.size() && withColors);
colors[index] = color;
}
uint16_t getReflectance(const size_t index) const
attr_t getReflectance(const size_t index) const
{
assert(index < reflectances.size() && withReflectances);
return reflectances[index];
}
uint16_t& getReflectance(const size_t index)
attr_t& getReflectance(const size_t index)
{
assert(index < reflectances.size() && withReflectances);
return reflectances[index];
}
void setReflectance(const size_t index, const uint16_t reflectance)
void setReflectance(const size_t index, const attr_t reflectance)
{
assert(index < reflectances.size() && withReflectances);
reflectances[index] = reflectance;
......@@ -495,8 +502,8 @@ public:
private:
std::vector<Vec3<double>> positions;
std::vector<Vec3<uint8_t>> colors;
std::vector<uint16_t> reflectances;
std::vector<Vec3<attr_t>> colors;
std::vector<attr_t> reflectances;
std::vector<uint8_t> frameidx;
bool withColors;
bool withReflectances;
......
......@@ -105,21 +105,21 @@ struct PCCPredictor {
int8_t predMode;
int64_t maxDiff;
Vec3<uint8_t> predictColor(
Vec3<attr_t> predictColor(
const PCCPointSet3& pointCloud, const std::vector<uint32_t>& indexes) const
{
Vec3<int64_t> predicted(0);
if (predMode > neighborCount) {
/* nop */
} else if (predMode > 0) {
const Vec3<uint8_t> color =
const Vec3<attr_t> color =
pointCloud.getColor(indexes[neighbors[predMode - 1].predictorIndex]);
for (size_t k = 0; k < 3; ++k) {
predicted[k] += color[k];
}
} else {
for (size_t i = 0; i < neighborCount; ++i) {
const Vec3<uint8_t> color =
const Vec3<attr_t> color =
pointCloud.getColor(indexes[neighbors[i].predictorIndex]);
const uint32_t w = neighbors[i].weight;
for (size_t k = 0; k < 3; ++k) {
......@@ -131,7 +131,7 @@ struct PCCPredictor {
divExp2RoundHalfInf(predicted[k], kFixedPointWeightShift);
}
}
return Vec3<uint8_t>(predicted[0], predicted[1], predicted[2]);
return Vec3<attr_t>(predicted[0], predicted[1], predicted[2]);
}
int64_t predictReflectance(
......
......@@ -801,11 +801,8 @@ ParseParameters(int argc, char* argv[], Parameters& params)
attr_aps.attr_encoding == AttributeEncoding::kPredictingTransform
|| attr_aps.attr_encoding == AttributeEncoding::kLiftingTransform;
if (it.first == "color") {
// todo(??): permit relaxing of the following constraint
if (attr_sps.attr_bitdepth > 8)
err.error() << it.first << ".bitdepth must be less than 9\n";
}
if (attr_sps.attr_bitdepth > 16)
err.error() << it.first << ".bitdepth must be less than 17\n";
if (it.first == "reflectance") {
if (attr_sps.attr_bitdepth > 16)
......
......@@ -387,9 +387,12 @@ PCCTMC3Encoder3::compressPartition(
// NB: recolouring is required if points are added / removed
if (_gps->geom_unique_points_flag || _gps->trisoup_node_size_log2 > 0) {
recolour(
params->recolour, originPartCloud, _sps->seq_source_geom_scale_factor,
_sps->seq_bounding_box_xyz0, _sliceOrigin, &pointCloud);
for (const auto& attr_sps : _sps->attributeSets) {
recolour(
attr_sps, params->recolour, originPartCloud,
_sps->seq_source_geom_scale_factor, _sps->seq_bounding_box_xyz0,
_sliceOrigin, &pointCloud);
}
}
// dump recoloured point cloud
......
......@@ -142,7 +142,7 @@ ply::write(
const Vec3<double>& position = cloud[i];
fout << position.x() << " " << position.y() << " " << position.z();
if (cloud.hasColors()) {
const Vec3<uint8_t>& color = cloud.getColor(i);
const Vec3<attr_t>& color = cloud.getColor(i);
fout << " " << static_cast<int>(color[0]) << " "
<< static_cast<int>(color[1]) << " "
<< static_cast<int>(color[2]);
......@@ -164,11 +164,12 @@ ply::write(
fout.write(
reinterpret_cast<const char* const>(&position), sizeof(double) * 3);
if (cloud.hasColors()) {
const Vec3<uint8_t>& color = cloud.getColor(i);
fout.write(reinterpret_cast<const char*>(&color), sizeof(uint8_t) * 3);
const Vec3<attr_t>& c = cloud.getColor(i);
Vec3<uint8_t> val8b{uint8_t(c[0]), uint8_t(c[1]), uint8_t(c[2])};
fout.write(reinterpret_cast<const char*>(&val8b), sizeof(uint8_t) * 3);
}
if (cloud.hasReflectances()) {
const uint16_t& reflectance = cloud.getReflectance(i);
const attr_t& reflectance = cloud.getReflectance(i);
fout.write(
reinterpret_cast<const char*>(&reflectance), sizeof(uint16_t));
}
......@@ -447,14 +448,17 @@ ply::read(
position[2] = z;
}
} else if (a == indexR && attributeInfo.byteCount == 1) {
auto& color = cloud.getColor(pointCounter);
ifs.read(reinterpret_cast<char*>(&color[2]), sizeof(uint8_t));
uint8_t val8b;
ifs.read(reinterpret_cast<char*>(&val8b), sizeof(uint8_t));
cloud.getColor(pointCounter)[2] = val8b;
} else if (a == indexG && attributeInfo.byteCount == 1) {
auto& color = cloud.getColor(pointCounter);
ifs.read(reinterpret_cast<char*>(&color[0]), sizeof(uint8_t));
uint8_t val8b;
ifs.read(reinterpret_cast<char*>(&val8b), sizeof(uint8_t));
cloud.getColor(pointCounter)[0] = val8b;
} else if (a == indexB && attributeInfo.byteCount == 1) {
auto& color = cloud.getColor(pointCounter);
ifs.read(reinterpret_cast<char*>(&color[1]), sizeof(uint8_t));
uint8_t val8b;
ifs.read(reinterpret_cast<char*>(&val8b), sizeof(uint8_t));
cloud.getColor(pointCounter)[1] = val8b;
} else if (a == indexReflectance && attributeInfo.byteCount <= 2) {
if (attributeInfo.byteCount == 1) {
uint8_t reflectance;
......
......@@ -36,6 +36,7 @@
#include "pointset_processing.h"
#include "colourspace.h"
#include "hls.h"
#include "KDTreeVectorOfVectorsAdaptor.h"
#include <cstddef>
......@@ -197,6 +198,7 @@ clampVolume(Box3<double> bbox, PCCPointSet3* cloud)
bool
recolourColour(
const AttributeDescription& attrDesc,
const RecolourParams& params,
const PCCPointSet3& source,
double sourceToTargetScaleFactor,
......@@ -217,9 +219,11 @@ recolourColour(
3, source, 10);
target.addColors();
std::vector<Vec3<uint8_t>> refinedColors1;
std::vector<Vec3<attr_t>> refinedColors1;
refinedColors1.resize(pointCountTarget);
double clipMax = (1 << attrDesc.attr_bitdepth) - 1;
double maxGeometryDist2Fwd = params.maxGeometryDist2Fwd < 512
? params.maxGeometryDist2Fwd
: std::numeric_limits<double>::max();
......@@ -277,7 +281,7 @@ recolourColour(
break;
}
std::vector<Vec3<uint8_t>> colors;
std::vector<Vec3<attr_t>> colors;
colors.resize(0);
colors.resize(nNN);
for (int i = 0; i < nNN; ++i) {
......@@ -318,7 +322,7 @@ recolourColour(
}
for (int k = 0; k < 3; ++k) {
refinedColors1[index][k] =
uint8_t(PCCClip(round(refinedColor[k]), 0.0, 255.0));
attr_t(PCCClip(round(refinedColor[k]), 0.0, clipMax));
}
isDone = true;
}
......@@ -333,13 +337,13 @@ recolourColour(
struct DistColor {
double dist;
Vec3<uint8_t> color;
Vec3<attr_t> color;
};
std::vector<std::vector<DistColor>> refinedColorsDists2;
refinedColorsDists2.resize(pointCountTarget);
for (size_t index = 0; index < pointCountSource; ++index) {
const Vec3<uint8_t> color = source.getColor(index);
const Vec3<attr_t> color = source.getColor(index);
resultSetBwd.init(&indicesBwd[0], &sqrDistBwd[0]);
Vec3<double> posInTgt =
......@@ -363,7 +367,7 @@ recolourColour(
}
for (size_t index = 0; index < pointCountTarget; ++index) {
const Vec3<uint8_t> color1 = refinedColors1[index];
const Vec3<attr_t> color1 = refinedColors1[index];
auto& colorsDists2 = refinedColorsDists2[index];
if (colorsDists2.empty()) {
target.setColor(index, color1);
......@@ -484,22 +488,21 @@ recolourColour(
Vec3<double> color0;
for (size_t k = 0; k < 3; ++k) {
color0[k] = PCCClip(
round(w * centroid1[k] + oneMinusW * centroid2[k]), 0.0, 255.0);
round(w * centroid1[k] + oneMinusW * centroid2[k]), 0.0, clipMax);
}
const double rSource = 1.0 / double(pointCountSource);
const double rTarget = 1.0 / double(pointCountTarget);
const double maxValue = std::numeric_limits<uint8_t>::max();
double minError = std::numeric_limits<double>::max();
Vec3<double> bestColor(color0);
Vec3<double> color;
for (int32_t s1 = -params.searchRange; s1 <= params.searchRange; ++s1) {
color[0] = PCCClip(color0[0] + s1, 0.0, maxValue);
color[0] = PCCClip(color0[0] + s1, 0.0, clipMax);
for (int32_t s2 = -params.searchRange; s2 <= params.searchRange;
++s2) {
color[1] = PCCClip(color0[1] + s2, 0.0, maxValue);
color[1] = PCCClip(color0[1] + s2, 0.0, clipMax);
for (int32_t s3 = -params.searchRange; s3 <= params.searchRange;
++s3) {
color[2] = PCCClip(color0[2] + s3, 0.0, maxValue);
color[2] = PCCClip(color0[2] + s3, 0.0, clipMax);
double e1 = 0.0;
for (size_t k = 0; k < 3; ++k) {
......@@ -528,9 +531,8 @@ recolourColour(
}
target.setColor(
index,
Vec3<uint8_t>(
uint8_t(bestColor[0]), uint8_t(bestColor[1]),
uint8_t(bestColor[2])));
Vec3<attr_t>(
attr_t(bestColor[0]), attr_t(bestColor[1]), attr_t(bestColor[2])));
}
}
return true;
......@@ -559,6 +561,7 @@ recolourColour(
bool
recolourReflectance(
const AttributeDescription& attrDesc,
const RecolourParams& cfg,
const PCCPointSet3& source,
double sourceToTargetScaleFactor,
......@@ -577,9 +580,11 @@ recolourReflectance(
KDTreeVectorOfVectorsAdaptor<PCCPointSet3, double> kdtreeSource(
3, source, 10);
target.addReflectances();
std::vector<uint16_t> refinedReflectances1;
std::vector<attr_t> refinedReflectances1;
refinedReflectances1.resize(pointCountTarget);
double clipMax = (1 << attrDesc.attr_bitdepth) - 1;
double maxGeometryDist2Fwd = (cfg.maxGeometryDist2Fwd < 512)
? cfg.maxGeometryDist2Fwd
: std::numeric_limits<double>::max();
......@@ -637,7 +642,7 @@ recolourReflectance(
continue;
}
std::vector<uint16_t> reflectances;
std::vector<attr_t> reflectances;
reflectances.resize(0);
reflectances.resize(nNN);
for (int i = 0; i < nNN; ++i) {
......@@ -670,7 +675,7 @@ recolourReflectance(
refinedReflectance /= nNN;
}
refinedReflectances1[index] =
uint8_t(PCCClip(round(refinedReflectance), 0.0, 255.0));
attr_t(PCCClip(round(refinedReflectance), 0.0, clipMax));
isDone = true;
}
}
......@@ -684,13 +689,13 @@ recolourReflectance(
struct DistReflectance {
double dist;
uint16_t reflectance;
attr_t reflectance;
};
std::vector<std::vector<DistReflectance>> refinedReflectancesDists2;
refinedReflectancesDists2.resize(pointCountTarget);
for (size_t index = 0; index < pointCountSource; ++index) {
const uint16_t reflectance = source.getReflectance(index);
const attr_t reflectance = source.getReflectance(index);
resultSetBwd.init(&indicesBwd[0], &sqrDistBwd[0]);
Vec3<double> posInTgt =
......@@ -717,7 +722,7 @@ recolourReflectance(
}
for (size_t index = 0; index < pointCountTarget; ++index) {
const uint16_t reflectance1 = refinedReflectances1[index];
const attr_t reflectance1 = refinedReflectances1[index];
auto& reflectancesDists2 = refinedReflectancesDists2[index];
if (reflectancesDists2.empty()) {
target.setReflectance(index, reflectance1);
......@@ -822,15 +827,14 @@ recolourReflectance(
const double oneMinusW = 1.0 - w;
double reflectance0;
reflectance0 =
PCCClip(round(w * centroid1 + oneMinusW * centroid2), 0.0, 255.0);
PCCClip(round(w * centroid1 + oneMinusW * centroid2), 0.0, clipMax);
const double rSource = 1.0 / double(pointCountSource);
const double rTarget = 1.0 / double(pointCountTarget);
const double maxValue = std::numeric_limits<uint8_t>::max();
double minError = std::numeric_limits<double>::max();
double bestReflectance = reflectance0;
double reflectance;