【问题标题】:How to perform despeckle operation without using JAI,ImageJ,jhlab libraries?如何在不使用 JAI、ImageJ、jhlab 库的情况下执行去斑操作?
【发布时间】:2023-03-31 16:54:01
【问题描述】:

我正在使用 Java Swing 在 Netbeans 中制作应用程序。我想在我的应用程序中实现一些图像处理功能(如在 ImageJ 中),而不使用 ImageJ、JAI 和 jhlab 库。

例如:ImageJ>>Process>>Noise>>Despeckle。

那么,我该怎么做呢?

【问题讨论】:

    标签: java image-processing noise-reduction imagej


    【解决方案1】:

    这可能会有所帮助

    private void removeNoise() {
        int iterator;
    
        for (int row = 0; row < x1; row++) {
            for (int column = 0; column < y1; column++) {
                if (row == 0 || row == x1 - 1 || column == 0
                        || column == y1 - 1) {
                    result[row][column] = result[row][column];
                    continue;
                } else {
                    iterator = 0;
                    for (int r = row - 1; r < row + 2; r++) {
                        for (int c = column - 1; c < column + 2; c++) {
                            surround[iterator] = result[r][c];
                            iterator++;
                        }
                    }
                    result[row][column] =
                            sortMedian(surround, 9);  //calls the sorting method
    
                }
    
            }
        }
        setPixel();
    }
    
    private int sortMedian(int[] surround1, int x) {
        int i, j, t = 0;
        for (i = 0; i < 9; i++) {
            for (j = 1; j < (9 - i); j++) {
                if (surround1[j - 1] > surround1[j]) {
                    t = surround1[j - 1];
                    surround1[j - 1] = surround1[j];
                    surround1[j] = t;
                }
            }
        }
        return surround1[4];
    }
    
    private void setPixel() {
        int[] pixel = new int[1];
    
        for (int x = 0; x < bi.getWidth(); x++) {
            for (int y = 0; y < bi.getHeight(); y++) {
    
                pixel[0] = (int) result[x][y];
    
    
                  rnImage.getRaster().setPixel(x, y, pixel);
    
                }
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-13
      • 2017-12-10
      • 2013-10-04
      • 2019-11-22
      • 2017-08-01
      • 2012-09-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多