Compare the pixel of the two different images, takes too long time

前端 未结 3 1859
春和景丽
春和景丽 2021-01-16 12:11

I want to compare the pixel of the two different images. I am comparing the pixel of first image with all the pixels of the second Image. Here is my code stuff:



        
3条回答
  •  醉话见心
    2021-01-16 12:29

    The order of your algorithm is n^4.

    I guess that you could drive that down to n^3 if you

    1. loop over all possible colors.
    2. inside that loop, loop on each image
    3. find the occurances of color i in each image
    4. finally use an equation to increment Counter

    If color i occurs x times in bitmap and y times in bitmap2,

    Counter = Counter + x*y

提交回复
热议问题