voidを返す再帰メソッドを定義しました(少なくとも再帰的だと思います)。別のメソッドでそれを呼び出したいのですが、方法がわかりません。非常に基本的なことはわかっていますが、誰か助けてもらえますか?ありがとう。
再帰的な方法:
private static void recursiveWhiteToBlack(BufferedImage image, int width, int height){
image.getRaster().setPixel(width,height, new int [] {0, 0, 0, 0, 0, 0});
int[][] neighbors = neighborsXY(width,height);
for(int i = 0; i<neighbors.length; i++){
int neighborX = neighbors[i][0];
int neighborY = neighbors[i][1];
int[] neighborColor = image.getRaster().getPixel(neighborX, neighborY, new int[] {0, 0, 0, 0, 0, 0});
if(neighborColor[0] == 1){
recursiveWhiteToBlack(image, neighborX, neighborY);
}
}
}
それを呼び出す:
public static BufferedImage countObjects(BufferedImage image, BufferedImage original, ComponentPanel panel){
BufferedImage target = copyImage(image);
for(int width=1; width<image.getRaster().getWidth()-1; width++){ //Determine the dimensions for the width (x)
for(int height=1; height<image.getRaster().getHeight()-1; height++){ //Determine the dimensions for the height (y)
int[] pixel = image.getRaster().getPixel(width, height, new int[] {0, 0, 0, 0, 0, 0});
if(pixel[0] == 1){
none = recursiveWhitetoBlack(image, width, height); //HOW TO CALL IT HERE!!!//
}
System.out.println("countObjects method called");
return target;
}