I am trying to isolate the odd fields and even field from a interlaced frame. The algorithm that I use is simply matrix slicing.
When I display the images, I see that there are remanants of odd field in even field image and vice versa.
What could be the reason? How to avoid this? Am I doing something wrong here?
Here is the Python code I am using. PFA the images. To better visualize the problem, I plotted a line trace of a colum and one can see the jagged trend on the right end of the plot.
import numpy as np
import cv2
import matplotlib.pyplot as plt
file_path=r'E:\DCIM\101D5200\DSC_2689.MOV'
vid=cv2.VideoCapture(file_path)
ret,frame=vid.read()
cropped_frame=cv2.cvtColor(frame[450:650,500:600,:],cv2.COLOR_BGR2GRAY)
even_fields=cropped_frame[::2,:];
odd_fields=cropped_frame[1::2,:];
cv2.imshow('cropped frame',cropped_frame);
cv2.imshow('even rows',even_fields);
cv2.imshow('odd rows',odd_fields);
cv2.waitKey(0)
plt.plot(cropped_frame[3::2,50],'*-');
plt.show()
In the image below, the interlaced frame on the left; even field on the top right; odd field on the bottom left.
Plot of a single colum data from the isolated odd field
The frame used from the video is also attached for reference.Here is the link