[英]why is my java program not returning anything?
For some reason, I don't get an output with the main method when I try to run the convolution2d program.出于某种原因,当我尝试运行卷积 2d 程序时,我没有使用 main 方法获得输出。 What am I doing wrong here?
我在这里做错了什么? The program is supposed to look at the convolution 2d method in another file and return it in the next one.
该程序应该在另一个文件中查看卷积 2d 方法并在下一个文件中返回它。
import java.applet.*;
import java.awt.*;
import java.awt.image.*;
import java.net.*;
import java.util.*;
import java.io.*;
import java.lang.Math.*;
import java.awt.Color.*;
/**
* Convolution is the code for applying the convolution operator.
*/
public class convolution {
//convolution 2d program
public static double [][] convolution2D(double [][] input,
int width, int height,
double [][] kernel,
int kernelWidth,
int kernelHeight){
int smallWidth = width - kernelWidth + 1;
int smallHeight = height - kernelHeight + 1;
double [][] output = new double [smallWidth][smallHeight];
for(int i=0;i<smallWidth;++i){
for(int j=0;j<smallHeight;++j){
output[i][j]=0;
}
}
for(int i=0;i<smallWidth;++i){
for(int j=0;j<smallHeight;++j){
output[i][j] = singlePixelConvolution(input,i,j,kernel,
kernelWidth,kernelHeight);
//if (i==32- kernelWidth + 1 && j==100- kernelHeight + 1) System.out.println("Convolve2D: "+output[i][j]);
}
}
return output;
}
//main program
public class driverconv {
public static void main(String[] args) {
// TODO Auto-generated method stub
convolution ce = new convolution();
double[][] m1= {{1,2},{3,4}};
double[][] m2= {{1,1},{1,1}};
System.out.println(convolution.convolution2D(m1, 2, 2, m2, 2, 2));
}
}
System.out.println() cannot print an array. System.out.println() 无法打印数组。 If you want to print the values of the array you should create a String first (with a for loop you can iterate the array and construct the string)
如果你想打印数组的值,你应该先创建一个字符串(使用 for 循环你可以迭代数组并构造字符串)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.