如何对2D图像做某些事情?

调用反转将图像从右向左转动,即它交换最后一列的第一列,第二列交换第二列,依此类推,直到整个图像反转。

对于从行索引50开始的相同大小的矩形和列索引260,调用交换交换由具有宽度180和高度130的矩形定义的图像区域,其开始于行索引50和列索引60。

通过保存位7,将位0-6向左移位一位,并将位0设置为先前保存的位7的值,调用移位找到隐藏在图像数据中的图像。

调用交换恢复一个图像,其中每个像素已经被加扰,通过用最前面的2位来排除最后2位。 为此,需要您的代码执行相同的交换以恢复映像。

注意:像素的最大值(Picture.MAXVAL)为255,因此每个像素只有8位有效。 这些是编号的位0-7,其中位0等于1而位7等于128.不允许负值。

我没有工作,但是,我把它颠倒过来而不是从右到左。有人可以帮助我如何让它从右到左? 喜欢我应该看哪一部分或者应该如何修复它。

至于交换,我很接近,但并不完全。

交换和转移,我不知道如何去做。

public class pictures { // Picture object Picture picture = null; // Image data int height; int width; int image[][]; // Constructor public pictures() { picture = new Picture(); } // Read the image public void readImage(String inFile) { System.out.println("Reading image: " + inFile); try { picture.readPGM(inFile); height = picture.getHeight(); width = picture.getWidth(); image = picture.getData(); } catch (Exception e) { System.out.println(e.getMessage()); } } // Write the image public void writeImage(String outFile) { System.out.println("Writing image: " + outFile); try { picture.setData(image); picture.writePGM(outFile); } catch (Exception e) { System.out.println(e.getMessage()); } } // Get image data public int[][] imageData() { return image; } // Invert the image public void invert() { int right; int left; for (right = 0, left = height - 1; right < left; right++, left--) { int[] pic = image[left]; image[left] = image[right]; image[right] = pic; } } // Exchange the image public void exchange() { for (int col = 60; col < 240; col++) { for (int row = 50; row < 180; row++) { int pic= image[row][col]; image[row][col] = image[row][col+240]; image[row][col+240] = pic; } } } // Swap public void swap() { for (int row = 0; row < height; row++) { for (int col = 0; col > 2; int bottom = (pic & 0b00001111) << 2; pic = top | bottom; image[row][col] = pic; } } } public void shift() {