<jupyter_start><jupyter_text>Get scale limit for a mobile re-captured image1. Zoom in initial scale.2. Crop image w/ current scale.3. Execute FFT & calculate wave length of the cropped image.4. Get pixel width in x-y axes.5. Optimize scale to obtain 10-pixel width and 10-pixel height (iterate Step 2 to 4).<jupyter_code>from pre_process import *
import cv2
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from skimage.feature import peak_local_max

dirName = "snipping"
imFilename = os.path.join(dirName, "source.png")

print("Reading image to align : ", imFilename);  
im = cv2.imread(imFilename, cv2.IMREAD_COLOR)

pim = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
height, width = pim.shape
n_pixel = 15
        
coordinates = np.array(peak_local_max(pim, min_distance=3))
M = np.ceil(np.sqrt(coordinates.shape[0]))
N = coordinates.shape[0]

d = np.sqrt(width*height/N)
    
nx, ny = tuple(np.array([width, height]) // int(d * n_pixel))

height, width = pim.shape

y_off, x_off = (500, 1000)
h, w = (height//ny, width//nx)
rect = patches.Rectangle((y_off, x_off), h, w, linewidth=3, edgecolor='b', facecolor='none')

_, axes = plt.subplots(ncols=2, figsize=(15,15))
for y, x in coordinates:
    pim[y, x] = 0
axes[0].imshow(pim[y_off:y_off+h, x_off:x_off+w], 'gray')
axes[1].imshow(im)
axes[1].add_patch(rect)
plt.tight_layout()
plt.savefig('pixel_monitor_to_camera.pdf', bbox_inches='tight', pad_inches=0, dpi=300)<jupyter_output>Reading image to align :  snipping\source.png<jupyter_text>Peak coordinates<jupyter_code>coordinates<jupyter_output><empty_output><jupyter_text>Camera pixel size per Monitor pixel<jupyter_code>d<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13051146384479717, 'fraction_numerical': 0.025279247501469725, 'mean_word_length': 5.596899224806202, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '568623', 'license': 'MIT', 'n_tokens_mistral': 680, 'n_tokens_neox': 646, 'n_words': 154, 'path': 'data/etc/pre_process/main.ipynb', 'repo_name': 'snucvpip/MopReM', 'size': '1701'}