[英]java change image colour pixels
编写一个程序,将每个像素的颜色隔离到最亮的通道。 例如: • 亮红色将保持亮红色 • 黑色将保持黑色 • 带有蓝色调的近白色将仅是亮蓝色 对于“最亮通道”有平局的像素,您如何打破平局并不重要.
while ( aPic.hasNext() ) {
p = aPic.next(); // set p to the next pixel
r = p.getRed();
g = p.getGreen();
b = p.getBlue();
int maxChannelValue = Math.max(r, g, b); // figure out the value of the brightest channel
// maxChannelValue is an int that equals one (or more) of r, g, or b
if (maxChannelValue == r) { // if red is the brightest channel
p.setGreen(0);
p.setBlue(0); // turn off the non red values
} else if (maxChannelValue == g) { // same but for green
p.setRed(0);
p.setBlue(0);
} else { // same but for blue
p.setRed(0);
p.setGreen(0);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.