<commit_before>#include "vision_color.h"

#include "vision_line_blobber.h"
#include "vision.h"
#include "vision_util.h"	// for HSB, HSL
#include <math.h>		// for sqrt
#include <stdlib.h>		// for abs

// ------------------------------------------------------------------------

// If 0, HSB.brightness is used to detect white
// If 1, HSL.lightness is used instead
#define USE_LIGHTNESS_INSTEAD_OF_BRIGHTNESS 1

/* higher values look for brighter orange */
// XXX: chosen default value is arbitrary; subsequent adjustment recommended
const int ORANGE_PIXEL_DETECTION_THRESHOLD =
	/*new IntFilterParam("Orange Pixels (Red-Green) - Threshold (High)", -255, 255,*/ 30;

/* lower values look for cleaner (less dirty) white */
// >=90 for low-light conditions     bigger->more red
const int WHITE_PIXEL_SATURATION_THRESHOLD =
	/*new IntFilterParam("White Pixel Saturation - Threshold (Low)", 0, 255,*/ 75;//85; //50;

/* HSB only: higher values look for brighter white */
// >=40 to eliminate black
const int WHITE_PIXEL_BRIGHTNESS_THRESHOLD =
	/*new IntFilterParam("White Pixel Brightness - Threshold (High)", 0, 255,*/ 100; //60;

/* HSL only: higher values look for brighter white */
// >=40 to eliminate black   bigger->less blue
const int WHITE_PIXEL_LIGHTNESS_THRESHOLD =
	/*new IntFilterParam("White Pixel Lightness - Threshold (High)", 0, 255,*/ 140; //140; //100; //60;


const Pixel ORANGE_PIXEL_ANNOTATION_COLOR = Pixel(255, 128, 0);		// bright orange
const Pixel WHITE_PIXEL_ANNOTATION_COLOR = Pixel(255, 255, 255);	// bright white
//const Pixel YELLOW_PIXEL_ANNOTATION_COLOR = Pixel(0, 255, 255);	// bright yellow???
const Pixel AMBIGUOUS_PIXEL_ANNOTATION_COLOR = Pixel(130, 62, 240);	// bright purple

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

const int YELLOW_PIXEL_TARGET_HSL_HUE = 42;
const int YELLOW_PIXEL_TARGET_HSL_SATURATION = 255;
const int YELLOW_PIXEL_TARGET_HSL_LIGHTNESS = 127;

// increase this to force the hue to more closely correspond to the target yellow hue
const double YELLOW_PIXEL_HUE_SIGNIFICANCE = 2.5;

const int YELLOW_PIXEL_TARGET_RADIUS = 64;

// ------------------------------------------------------------------------

// public
Buffer2D<bool> pixelIsOrange;
Buffer2D<bool> pixelIsWhite;
//Buffer2D<bool> pixelIsYellow;



// public
Buffer2D<Pixel> visWhiteDetectionCalibration;
Buffer2D<Pixel> visWhiteCondition;

// public
Buffer2D<unsigned char> visRedMinusGreen;

// public
Buffer2D<u8> visHSBHue;
Buffer2D<u8> visHSBSaturation;
Buffer2D<u8> visHSBBrightness;

// public
Buffer2D<u8> visHSLHue;
Buffer2D<u8> visHSLSaturation;
Buffer2D<u8> visHSLLightness;

// private
Buffer2D<int> pixelOrangeness;
Buffer2D<HSB> pixelHSB;
Buffer2D<HSL> pixelHSL;

// ------------------------------------------------------------------------

bool pixelIsOrange_calc(int off);
bool pixelIsWhite_calc(int off);
inline bool pixelIsWhite_calc_condition1(int off);
inline bool pixelIsWhite_calc_condition2(int off);
//bool pixelIsYellow_calc(int off);

Buffer2D<bool> pixelIsWhiteTemp;
bool pixelIsYellow_calcFromHSL(HSL hsl);

// ------------------------------------------------------------------------
void visGenPath();
Buffer2D<Pixel> visPathView;
// ------------------------------------------------------------------------


void visGenPath(void){
	int width = visRaw.width;
	int height = visRaw.height;
	int good = 1;
	visPathView.resize(width, height);
	//visPathView.copyFrom(paulBlob);
	Pixel p;
	for(int x = 0; x < width; x++){
		good = 1;
		for(int y = 0; y < height; y++){
		
			if(good){
	
				p = paulBlob.get(x,y);
			
				// 200: from vision line blobber
				if (p.red==200 && p.green==0 && p.blue==0){
					good = 0;
				}
				// orange from shader
				else if (p.red==255 && p.green==127 && p.blue==0){
					good = 0;
				}
				// sand from shader
				else if (p.red==0 && p.green==127 && p.blue==0){
					good = 0;
				}
				// probably good
				else{
					p.red=p.green=p.blue=255;
					visPathView.set(x,y,p);
				}
				<commit_msg>fixed scanning wrong way in visGenPath()<commit_after>#include "vision_color.h"

#include "vision_line_blobber.h"
#include "vision.h"
#include "vision_util.h"	// for HSB, HSL
#include <math.h>		// for sqrt
#include <stdlib.h>		// for abs

// ------------------------------------------------------------------------

// If 0, HSB.brightness is used to detect white
// If 1, HSL.lightness is used instead
#define USE_LIGHTNESS_INSTEAD_OF_BRIGHTNESS 1

/* higher values look for brighter orange */
// XXX: chosen default value is arbitrary; subsequent adjustment recommended
const int ORANGE_PIXEL_DETECTION_THRESHOLD =
	/*new IntFilterParam("Orange Pixels (Red-Green) - Threshold (High)", -255, 255,*/ 30;

/* lower values look for cleaner (less dirty) white */
// >=90 for low-light conditions     bigger->more red
const int WHITE_PIXEL_SATURATION_THRESHOLD =
	/*new IntFilterParam("White Pixel Saturation - Threshold (Low)", 0, 255,*/ 75;//85; //50;

/* HSB only: higher values look for brighter white */
// >=40 to eliminate black
const int WHITE_PIXEL_BRIGHTNESS_THRESHOLD =
	/*new IntFilterParam("White Pixel Brightness - Threshold (High)", 0, 255,*/ 100; //60;

/* HSL only: higher values look for brighter white */
// >=40 to eliminate black   bigger->less blue
const int WHITE_PIXEL_LIGHTNESS_THRESHOLD =
	/*new IntFilterParam("White Pixel Lightness - Threshold (High)", 0, 255,*/ 140; //140; //100; //60;


const Pixel ORANGE_PIXEL_ANNOTATION_COLOR = Pixel(255, 128, 0);		// bright orange
const Pixel WHITE_PIXEL_ANNOTATION_COLOR = Pixel(255, 255, 255);	// bright white
//const Pixel YELLOW_PIXEL_ANNOTATION_COLOR = Pixel(0, 255, 255);	// bright yellow???
const Pixel AMBIGUOUS_PIXEL_ANNOTATION_COLOR = Pixel(130, 62, 240);	// bright purple

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

const int YELLOW_PIXEL_TARGET_HSL_HUE = 42;
const int YELLOW_PIXEL_TARGET_HSL_SATURATION = 255;
const int YELLOW_PIXEL_TARGET_HSL_LIGHTNESS = 127;

// increase this to force the hue to more closely correspond to the target yellow hue
const double YELLOW_PIXEL_HUE_SIGNIFICANCE = 2.5;

const int YELLOW_PIXEL_TARGET_RADIUS = 64;

// ------------------------------------------------------------------------

// public
Buffer2D<bool> pixelIsOrange;
Buffer2D<bool> pixelIsWhite;
//Buffer2D<bool> pixelIsYellow;



// public
Buffer2D<Pixel> visWhiteDetectionCalibration;
Buffer2D<Pixel> visWhiteCondition;

// public
Buffer2D<unsigned char> visRedMinusGreen;

// public
Buffer2D<u8> visHSBHue;
Buffer2D<u8> visHSBSaturation;
Buffer2D<u8> visHSBBrightness;

// public
Buffer2D<u8> visHSLHue;
Buffer2D<u8> visHSLSaturation;
Buffer2D<u8> visHSLLightness;

// private
Buffer2D<int> pixelOrangeness;
Buffer2D<HSB> pixelHSB;
Buffer2D<HSL> pixelHSL;

// ------------------------------------------------------------------------

bool pixelIsOrange_calc(int off);
bool pixelIsWhite_calc(int off);
inline bool pixelIsWhite_calc_condition1(int off);
inline bool pixelIsWhite_calc_condition2(int off);
//bool pixelIsYellow_calc(int off);

Buffer2D<bool> pixelIsWhiteTemp;
bool pixelIsYellow_calcFromHSL(HSL hsl);

// ------------------------------------------------------------------------
void visGenPath();
Buffer2D<Pixel> visPathView;
// ------------------------------------------------------------------------


void visGenPath(void){
	int width = visRaw.width;
	int height = visRaw.height;
	int good = 1;
	visPathView.resize(width, height);
	//visPathView.copyFrom(paulBlob);
	Pixel p;
	
	//scan up in columns; white = path; black = bad
	for(int x = 0; x < width; x++){
	
		good = 1;
		for(int y = height-1; y >=0 ; y--){
		
			if(good){
	
				p = paulBlob.get(x,y);
			
				// 200: from vision line blobber
				if (p.red==200 && p.green==0 && p.blue==0){
					good = 0;
				}
				// orange from shader
				else if (p.red==255 && p.green==127 && p.blue==0){
					good = 0;
				}
				// sand from shader
				else if (p.red==0 && p.green==127 && p.blue==0){
					good = 0;
				}
				// probably good
				else{
					p.red=p.green=p.blue=255;
					visPathView.set(x,y,p);
				}
				
{'fraction_non_alphanumeric': 0.20985063572398469, 'fraction_numerical': 0.03690902357733613, 'mean_word_length': 2.528745644599303, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7227475', 'n_tokens_mistral': 3153, 'n_tokens_neox': 2726, 'n_words': 699}