0

I'm making a very basic Image Processing program in Java and I have a few pre-defined 3x3 matrices for various convolutions (sharpens, blurs, edge detections etc) I have them hard coded for now for testing purposes but am trying to put them in a more appropriate format like enum but I'm not sure how to use 2D arrays as enums. When I try to access the kernels indices I just get a warning that the expected type is array but resolved to kernel.

    
    IDENTITY(new  double[][] {
            {0, 0, 0},
            {0, 1, 0},
            {0, 0, 0}
    }),

    EDGE_DETECTION_1(new double[][]  {
            {-1, -1, -1},
            {-1, 8, -1},
            {-1, -1, -1}
    }),
    
    
    EDGE_DETECTION_2(new double[][] {
            {1, 0, -1},
            {0, 0, 0},
            {-1, 0, 1}
    }),

Kernel array

I'm a little new to using enums more complicated than basic Strings etc so I could be missing very obvious things but I would appreciate any pointers.

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
Conor Timlin
  • 100
  • 8
  • May this help https://mvnrepository.com/artifact/com.gitlab.cdc-java.kernel/cdc-kernel-enums and https://gitlab.com/cdc-java/cdc-kernel/-/tree/master/cdc-kernel-enums – aran Jun 08 '21 at 00:21

1 Answers1

0

Figured it out just needed to use a getter to access the actual indicies rather than accessing them from the kernel directly. So obvious.

 red+=  (R*k.getKernels()[yOffset + k.getKernels().length/2][xOffset +k.getKernels().length/2]);

rather than

public static Kernel k = Kernel.LAPLACIAN;
k[0][0];
Conor Timlin
  • 100
  • 8