Getting Greyscale pixel value from RGB colourspace in Java using BufferedImage

前端 未结 3 1460
抹茶落季
抹茶落季 2021-01-14 03:54

Anyone know of a simple way of converting the RGBint value returned from getRGB(i,j) into a greyscale value?

I was going to simply

3条回答
  •  佛祖请我去吃肉
    2021-01-14 04:42

    this isn't as simple as it sounds because there is no 100% correct answer for how to map a colour to greyscale.

    the method i'd use is to convert RGB to HSL then 0 the S portion (and optionally convert back to RGB) but this might not be exactly what you want. (it is equivalent to the average of the highest and lowest rgb value so a little different to the average of all 3)

提交回复
热议问题