我已将图像的灰度存储到双数组中,现在我需要执行以下任务,但我不知道从哪里开始:
The contents of the image in <infile> will be converted into an ASCII image.
Use the following (approximate!) grayscale-to-character mappings. You are free
to adjust the numeric ranges a little bit in order to make programming easier:
o 0 to 25:‘M’
o 26 to 50:‘$’
o 51 to 76:‘o’
o 77 to 102:‘|’
o 103 to 127: ‘*’
o 128 to 152: ‘:’
o 153 to 178: ‘=’
o 179 to 204: ‘\’’ (note the escape character before the single-quote) o 205 to 230: ‘.’
o 231 to 255: ‘ ’ (i.e., a single space)
答案 0 :(得分:0)
Aren你在数组中保留了一些值吗?你可以通过if或switch语句来做到这一点。
public char[][] transform(int[][] gray)
{
int row = gray[0].length;
int column = gray[1].length;
char[][] mapedImage = new char[row][column];
for (int i= 0; i < row ;i++)
{
for(int k = 0; k < column ;k++)
{
if(0<gray[i][k]<25)
char[i][k] = 'M';
.
.
.
}
}
return mapedImage;
}
答案 1 :(得分:0)