fixed bit masking

changed distance calculation
master
Sascha Nitsch 2022-01-19 18:35:25 +01:00
parent e3b55ac4fa
commit 613092f3ee
1 changed files with 4 additions and 4 deletions

View File

@ -35,8 +35,8 @@ DistancePath::~DistancePath() {
inline void DistancePath::processPixel(uint8_t* inRAW, float* outRow, uint16_t x, uint16_t y, float lastValue, uint16_t width, std::list<uint32_t>* next, uint16_t* outPixels, uint16_t iteration) { inline void DistancePath::processPixel(uint8_t* inRAW, float* outRow, uint16_t x, uint16_t y, float lastValue, uint16_t width, std::list<uint32_t>* next, uint16_t* outPixels, uint16_t iteration) {
float *oR = &outRow[x]; float *oR = &outRow[x];
uint32_t offset = (y * width + x) * 3; uint32_t offset = (y * width + x) * 3;
float avg = 255 - (0.3333 * (inRAW[offset] + inRAW[offset + 1] + inRAW[offset + 2])); float avg = (inRAW[offset] + inRAW[offset + 1] + inRAW[offset + 2]) / 765.0;
float newValue = lastValue + avg * m_weightBlock + (255.0 - avg) * m_weightPath; float newValue = lastValue + (1.0 - avg) * (m_weightBlock - m_weightPath) + m_weightPath;
if (newValue > m_maxDistance) newValue = m_maxDistance; if (newValue > m_maxDistance) newValue = m_maxDistance;
if (newValue < *oR) { if (newValue < *oR) {
next->push_back((x << 16) + y); next->push_back((x << 16) + y);
@ -72,7 +72,7 @@ int8_t DistancePath::process(Image* input, Image* output) {
uint16_t* outPixels = output->getPixels16(); uint16_t* outPixels = output->getPixels16();
for (uint32_t coordinate : m_queue1) { for (uint32_t coordinate : m_queue1) {
uint16_t x = coordinate >> 16; uint16_t x = coordinate >> 16;
uint16_t y = coordinate & 0xFFFFFFFF; uint16_t y = coordinate & 0xFFFF;
outRAW[(width * y + x)] = 0; outRAW[(width * y + x)] = 0;
} }
uint16_t iteration = 1; uint16_t iteration = 1;
@ -80,7 +80,7 @@ int8_t DistancePath::process(Image* input, Image* output) {
// process pixel from last time // process pixel from last time
for (uint32_t coordinate : *last) { for (uint32_t coordinate : *last) {
uint16_t x = coordinate >> 16; uint16_t x = coordinate >> 16;
uint16_t y = coordinate & 0xFFFFFFFF; uint16_t y = coordinate & 0xFFFF;
float lastValue = outRAW[y * width + x]; float lastValue = outRAW[y * width + x];
if (y > 0) { // process row on top if (y > 0) { // process row on top
processRow(inRAW, outRAW, x, y-1, lastValue, width, next, outPixels, iteration); processRow(inRAW, outRAW, x, y-1, lastValue, width, next, outPixels, iteration);