Faster way to extract histogram from an image

后端 未结 2 1020
清酒与你
清酒与你 2021-02-13 21:45

I\'m looking for a faster way to extract histogram data from an image. I\'m currently using this piece of code that needs about 1200ms for a 6mpx JPEG image:

            


        
2条回答
  •  醉酒成梦
    2021-02-13 22:26

    You can use getSamples(int x, int y, int w, int h, int b, double[] dArray) method It's possible that this method have internal optimisations. Also, you can try to swap width and height.

    for (int i = 0; i < width; i++) 
       for (int j = 0; j < height; j++) {
       }
    }
    

    And

    for (int i = 0; i < height; i++) 
       for (int j = 0; j < width; j++) {
       }
    }
    

    Between this two variants performance difference will be huge. This is influence of the cpu cache

提交回复
热议问题