私はJavaでいくつかの単純なエッジ検出を行うためのメソッドに取り組んでいます。1つのピクセルとそのすぐ下のピクセルの2つの色の強度の差を取得したいと思います。私が使用している画像は、メソッドにどのようなしきい値を設定しても、黒に着色されています。現在の方法が必要なものを計算していないかどうかはわかりませんが、問題を見つけるために何をトレースする必要があるのか途方に暮れています。
これまでの私の方法は次のとおりです。
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);
}
}
}