ofColor 로 화소 가지고 놀기. egtColor(), setColor()
void ofApp::mousePressed(int x, int y, int button){
// 채널 정보를 위해
ofPixels & pixels = img1.getPixels(); // 모든 픽셀 취득
int numChannels = pixels.getNumChannels();
int w = img1.getWidth();
int h = img1.getHeight();
ofColor rgb, gray; // 컬러 변수
if(numChannels >= 3){
for (int x=0; x< w ; x++){
for(int y=0; y< h; y++){
rgb = img1.getColor(x, y);
gray=(int)(0.3*rgb.r + 0.6*rgb.g + 0.1*rgb.b);
//gray= rgb.getBrightness();
img1.setColor(x, y, gray);
}
}// for
}// if
img1.update();
}
// 채널 정보를 위해
ofPixels & pixels = img1.getPixels(); // 모든 픽셀 취득
int numChannels = pixels.getNumChannels();
int w = img1.getWidth();
int h = img1.getHeight();
ofColor rgb, gray; // 컬러 변수
if(numChannels >= 3){
for (int x=0; x< w ; x++){
for(int y=0; y< h; y++){
rgb = img1.getColor(x, y);
gray=(int)(0.3*rgb.r + 0.6*rgb.g + 0.1*rgb.b);
//gray= rgb.getBrightness();
img1.setColor(x, y, gray);
}
}// for
}// if
img1.update();
}
댓글
댓글 쓰기