【发布时间】:2014-07-01 10:56:04
【问题描述】:
我在完成 Java 编程课程的作业时遇到了问题。我要做的是对具有纯色背景的图像执行色度键技术。更多信息可以找到here。当我为该方法放置两个对象参数时,我创建的方法有效。但是,当我将参数放入构造函数中,然后尝试使用该方法时,会出现编译器错误。我在下面有我的类(我必须使用两个不同的类,一个用于方法,一个用于测试)。任何帮助将不胜感激,我是 java 新手,最简单的路线是最好的。
public class ChromaKey
{
public ChromaKey(Picture backgroundDelete, Picture backgroundImage)
{
}
public void chromaKey()
{
int redValue = 0; int greenValue = 0; int blueValue = 0;
Color pixelColor = null;
Color pixelColor1 = null;
for(int y = 0; y < backgroundImage.getHeight(); y++)
{
for(int x = 0; x < backgroundImage.getWidth(); x++)
{
Pixel targetPixel = new Pixel(backgroundImage,x,y);
Pixel targetPixel1 = new Pixel(backgroundDelete,x,y);
targetPixel = backgroundImage.getPixel(x,y);
pixelColor = targetPixel.getColor();
targetPixel1 = backgroundDelete.getPixel(x,y);
pixelColor1 = targetPixel1.getColor();
int targetRed = pixelColor1.getRed();
int targetBlue = pixelColor1.getGreen();
int targetGreen = pixelColor1.getBlue();
int backgroundRed = pixelColor.getRed();
int backgroundGreen = pixelColor.getGreen();
int backgroundBlue = pixelColor.getBlue();
if(targetRed >= 200 && targetBlue >= 200 && targetGreen >= 200)
{
targetPixel1.setRed(backgroundRed);
targetPixel1.setGreen(backgroundGreen);
targetPixel1.setBlue(backgroundBlue);
}
}
}
backgroundImage.show();
backgroundDelete.show();
}
}
【问题讨论】:
-
编译时错误是什么?
-
在您的示例中,
backgroundDelete和backgroundImage似乎没有被初始化。那是你正在使用的真实课程吗?
标签: java constructor find symbols