Repository navigation
Expand file tree
/
Copy pathPixel.cpp
More file actions
124 lines (91 loc) · 2.32 KB
/
Copy pathPixel.cpp
File metadata and controls
124 lines (91 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include "Pixel.h"
using namespace std;
Pixel Pixel::colorConverter(int hexValue)
{
Pixel trenton;
trenton.red = ((hexValue >> 16) & 0xFF) / 255.0; // Extract the RR byte
trenton.green = ((hexValue >> 8) & 0xFF) / 255.0; // Extract the GG bytez
trenton.blue = ((hexValue) & 0xFF) / 255.0; // Extract the BB byte
return trenton;
}
int Pixel::getRed(){
//cout<< "returned red" << endl;
return red;
}
int Pixel::getBlue(){
return blue;
}
int Pixel::getGreen(){
return green;
}
//if the Pixel is nearly black but not entirely
bool Pixel::isPrettyBlack(){
int variance = 20;
Pixel p=*this;
if ( abs( p.getGreen() - p.getBlue() )<variance && abs( p.getBlue() - p.getRed() )<variance && abs( p.getGreen() - p.getRed() )<variance && ( p.getBrightness()<45 ) ) {
return true;
}
else
return false;
}
//if the pixel is entirely black
bool Pixel::isActuallyBlack(){
//Pixel p = *this;
if(getBrightness()<3){
//cout<< "works"<< endl;
return true;
}
else {
return false;
}
}
bool Pixel::isPrettyWhite(){
int variance = 50;
Pixel p=*this;
if ( abs( p.getGreen() - p.getBlue() )<variance && abs( p.getBlue() - p.getRed() )<variance && abs( p.getGreen() - p.getRed() )<variance && ( p.getBrightness()>70) ) {
return true;
}
else
return false;
}
bool Pixel::isPrettySclera(){
int variance = 5;
Pixel p=*this;
if ( (p.getRed()-p.getGreen())> variance && (p.getRed()-p.getBlue()) >variance && ( p.getBrightness()>65) ) {
return true;
}
else
return false;
}
void Pixel::makeBlack(){
Pixel p=*this;
p.setBlue(0);
p.setGreen(0);
p.setBlue(0);
}
void Pixel::makeWhite(){
this->red=255;
this->blue=255;
this->green=255;
}
void Pixel::brighten(Pixel &x, double factor){
factor = 1/factor;
x.red=(int)((double)x.red*factor);
x.blue=(int)((double)x.blue*factor);
x.green= (int)((double)x.green*factor);
return;
}
int Pixel::getBrightness(){
int i = (int)(((double)getRed()+(double)getGreen()+(double)getBlue())/3);
return i;
}
Pixel::Pixel(int r, int g, int b) {
red=r;
green=g;
blue=b;
}
Pixel::Pixel() {
red= 0;
green= 0;
blue=0;
}