请注意,我是 Java 新手。我有一个类,这个类中有一个方法计算一些值,我想在第一类中返回它们。我有一个代码,但它返回 0。
那是在计算值的类
public class ImageProcessing{
int i,j;
int R[][]=new int[640][320];
int G[][]=new int[640][320];
int B[][]=new int[640][320];
public double meanR[]=new double[320];
public double meanG[]=new double[320];
public double meanB[]=new double[320];
public double varianceR[]=new double[320];
public double varianceG[]=new double[320];
public double varianceB[]=new double[320];
public double skewnessR[]=new double[320];
public double skewnessG[]=new double[320];
public double skewnessB[]=new double[320];
public double round(double value){
// int decimalPlace = 2;
BigDecimal bd = new BigDecimal(value);
bd = bd.setScale(2,BigDecimal.ROUND_UP);
return (bd.doubleValue());
}
public void Mean(Bitmap image){
int width = image.getWidth();
int height = image.getHeight();
int pixel = 0;
for (i=0; i<width;i++){
for (j=0; j<height; j++){
pixel = image.getPixel(i,j);
R[i][j] = Color.red(pixel);
G[i][j]= Color.green(pixel);
B[i][j] = Color.blue(pixel);
meanR[j]=meanR[j]+R[i][j];
meanG[j]=meanG[j]+G[i][j];
meanB[j]=meanB[j]+B[i][j];
}
}
在主要课程中,我有:
method.Mean(rescaledBitmap1);
meanR1=method.meanR;
meanG1=method.meanG;
meanB1=method.meanB;
System.out.println(meanR1);