두 개의 유사한 이미지에서 노이즈를 추출하는 방법은 무엇입니까? (How to extract noise from two similar images?)


문제 설명

두 개의 유사한 이미지에서 노이즈를 추출하는 방법은 무엇입니까? (How to extract noise from two similar images?)

두 개의 유사한(동일하지 않은) 이미지가 있습니다. 하나는 노이즈가 있고 다른 하나는 노이즈가 없는 원본입니다. 두 이미지의 차이로 노이즈를 추출하고 원본 이미지에 추출한 노이즈를 추가하여 두 이미지가 동일하게 만들고 싶습니다. 원본 이미지는 디지털 카메라로 캡처됩니다. 웹캠을 사용하여 모니터(원본 이미지 표시)에서 노이즈가 있는 이미지를 캡처합니다.

원본 이미지

원본 이미지를 표시하는 모니터를 가리키는 웹캠을 사용하여 캡처함


참조 솔루션

방법 1:

In order to find the differences between two images, you can utilize the Structural Similarity Index (SSIM) which was introduced in Image Quality Assessment: From Error Visibility to Structural Similarity. This method is already implemented in the scikit‑image library for image processing. You can install scikit‑image with pip install scikit‑image.

Using the compare_ssim() function from scikit‑image, it returns a score and a difference image, diff. The score represents the structual similarity index between the two input images and can fall between the range [‑1,1] with values closer to one representing higher similarity. But since you're only interested in where the two images differ, the diff image what you're looking for. The diff image contains the actual image differences between the two images.

Here are the actual differences between the two images. Consider using .png images since they are lossless. .jpg images are lossy and have noise due to image compression.

enter image description here

Code

from skimage.measure import compare_ssim
import cv2

# Load images
image1 = cv2.imread('1.jpg')
image2 = cv2.imread('2.jpg')

# Convert images to grayscale
image1_gray = cv2.cvtColor(image1, cv2.COLOR_BGR2GRAY)
image2_gray = cv2.cvtColor(image2, cv2.COLOR_BGR2GRAY)

# Compute SSIM between two images
(score, diff) = compare_ssim(image1_gray, image2_gray, full=True)
# The diff image contains the actual image differences between the two images
# and is represented as a floating point data type in the range [0,1] 
# so we must convert the array to 8‑bit unsigned integers in the range
# [0,255] before we can use it with OpenCV
diff = (diff * 255).astype("uint8")

cv2.imshow('diff',diff)
cv2.waitKey()

Note: Your two input images are not exactly the same, they are slightly shifted so SSIM picks up the shifted pixels

방법 2:

I'm not sure if you are aware of the complexity of your problem. Your issues are: ‑ Different resolution of the original and the 'noisy' image ‑ Translational error ‑ Perspective distortion when taking the photo of the original

Theoretically you can find tools for image processing in cv2 that can handle those problems. When you are able to get rid of the distortions you can simply apply the code that you posted to see the noise as a result of the systematic errors of the camera, monitor and all calculations that you did.

(by Mitesh PatelnathancyMeredith Hesketh Fortescue)

참조 문서

  1. How to extract noise from two similar images? (CC BY‑SA 2.5/3.0/4.0)

#Python #noise #image-processing #OpenCV #computer-vision






관련 질문

Python - 파일 이름에 특수 문자가 있는 파일의 이름을 바꿀 수 없습니다. (Python - Unable to rename a file with special characters in the file name)

구조화된 배열의 dtype을 변경하면 문자열 데이터가 0이 됩니다. (Changing dtype of structured array zeros out string data)

목록 목록의 효과적인 구현 (Effective implementation of list of lists)

for 루프를 중단하지 않고 if 문을 중지하고 다른 if에 영향을 줍니다. (Stop if statement without breaking for loop and affect other ifs)

기본 숫자를 10 ^ 9 이상으로 늘리면 코드가 작동하지 않습니다. (Code fails to work when i increase the base numbers to anything over 10 ^ 9)

사용자 지정 대화 상자 PyQT5를 닫고 데이터 가져오기 (Close and get data from a custom dialog PyQT5)

Enthought Canopy의 Python: csv 파일 조작 (Python in Enthought Canopy: manipulating csv files)

학생의 이름을 인쇄하려고 하는 것이 잘못된 것은 무엇입니까? (What is wrong with trying to print the name of the student?)

다단계 열 테이블에 부분합 열 추가 (Adding a subtotal column to a multilevel column table)

여러 함수의 변수를 다른 함수로 사용 (Use variables from multiple functions into another function)

리프 텐서의 값을 업데이트하는 적절한 방법은 무엇입니까(예: 경사하강법 업데이트 단계 중) (What's the proper way to update a leaf tensor's values (e.g. during the update step of gradient descent))

Boto3: 조직 단위의 AMI에 시작 권한을 추가하려고 하면 ParamValidationError가 발생합니다. (Boto3: trying to add launch permission to AMI for an organizational unit raises ParamValidationError)







코멘트