간단한 가장자리 감지를 수행하기 위해 Java의 메소드로 작업 중입니다. 나는 한 픽셀에 두 개의 컬러 강도 차이를 가져오고 그 바로 아래 픽셀에 다른 색 농도를 적용하고 싶습니다. 내가 사용하고있는 그림은 검정색으로 검정색으로 칠해져 있습니다. 나는 현재의 방법이 내가 필요한 것을 계산하지 않고 있지만, 문제를 찾기 위해 무엇을 추적해야 하는지를 놓치고 있는지 확실하지 않다.간단한 가장자리 감지 방법 Java
public void edgeDetection(double threshold)
{
Color white = new Color(1,1,1);
Color black = new Color(0,0,0);
Pixel topPixel = null;
Pixel lowerPixel = null;
double topIntensity;
double lowerIntensity;
for(int y = 0; y < this.getHeight()-1; y++){
for(int x = 0; x < this.getWidth(); x++){
topPixel = this.getPixel(x,y);
lowerPixel = this.getPixel(x,y+1);
topIntensity = (topPixel.getRed() + topPixel.getGreen() + topPixel.getBlue())/3;
lowerIntensity = (lowerPixel.getRed() + lowerPixel.getGreen() + lowerPixel.getBlue())/3;
if(Math.abs(topIntensity - lowerIntensity) < threshold)
topPixel.setColor(white);
else
topPixel.setColor(black);
}
}
}
가 나는 생성자의 설명서를 읽어보고 싶어요, 감사 : 당신이
Color(float,float,float)
생성자를 사용하려면, 당신은 부동 소수점 리터럴이 필요합니다. –