Computer >> 컴퓨터 >  >> 프로그램 작성 >> Python

Pillow 라이브러리를 사용하여 이미지의 각 밴드에 대한 모든 픽셀의 제곱 평균 제곱근 계산

<시간/>

이 프로그램에서는 Pillow 라이브러리를 사용하여 각 채널의 모든 픽셀의 rms(제곱평균제곱근)를 계산합니다. 이미지에는 총 3개의 채널이 있으므로 3개의 값 목록이 표시됩니다.

원본 이미지

Pillow 라이브러리를 사용하여 이미지의 각 밴드에 대한 모든 픽셀의 제곱 평균 제곱근 계산

알고리즘

Step 1: Import the Image and ImageStat libraries.
Step 2: Open the image.
Step 3: Pass the image to the stat function of the imagestat class.
Step 4: Print the root mean square of the pixels.

예시 코드

from PIL import Image, ImageStat

im = Image.open('image_test.jpg')
stat = ImageStat.Stat(im)
print(stat.rms)

출력

[104.86876722259062, 96.13661429330132, 91.8480515464677]