\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Plus5754} \pdfinfo{ /Title (opencv-notes.pdf) /Creator (Cheatography) /Author (Plus5754) /Subject (opencv-notes Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{opencv-notes Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Plus5754} via \textcolor{DarkBackground}{\uline{cheatography.com/183380/cs/38184/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Plus5754 \\ \uline{cheatography.com/plus5754} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 13th May, 2023.\\ Updated 11th April, 2023.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Drawing on Images:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{cv2.line(img,(0,0),(200,300),(255,0,0),5) \#Draw a blue line with thickness of 5 \newline cv2.rectangle(img,(50,50),(200,300),(0,255,0),3) \#Draw a green rectangle with thickness of 3 \newline cv2.circle(img,(200,200), 50, (0,0,255), -1) \#Draw a filled red circle \newline cv2.putText(img,'OpenCV',(10,500), \seqsplit{cv2.FONT\_HERSHEY\_SIMPLEX}, 4,(255,255,255),2,cv2.LINE\_AA) \#Add text} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Feature Detection:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\# identify distinct regions of an image that contain important information. Used for object \newline \# recognition, image registration, and 3D reconstruction. Common methods: Harris corner \newline \# detection, Shi-Tomasi corner detection, FAST, SURF, SIFT. \newline img = cv2.imread('image.jpg', 0) \#Read image in grayscale \newline fast = \seqsplit{cv2.FastFeatureDetector\_create()} \#\#FAST feature detection \newline keypoints\_fast = fast.detect(img) \newline orb = cv2.ORB\_create() \#\#ORB feature detection \newline keypoints\_orb, descriptors = orb.detectAndCompute(img, None) \newline sift = \seqsplit{cv2.xfeatures2d.SIFT\_create()} \#\#SIFT feature detection \newline keypoints\_sift, descriptors = \seqsplit{sift.detectAndCompute(img}, None) \newline surf = \seqsplit{cv2.xfeatures2d.SURF\_create()} \#\#SURF feature detection \newline keypoints\_surf, descriptors = \seqsplit{surf.detectAndCompute(img}, None) \newline \newline cv2.drawKeypoints(img, keypoints\_fast, img, color=(255, 0, 0)) \newline cv2.drawKeypoints(img, keypoints\_orb, img, color=(0, 255, 0)) \newline cv2.drawKeypoints(img, keypoints\_sift, img, color=(0, 0, 255)) \newline cv2.drawKeypoints(img, keypoints\_surf, img, color=(255, 255, 0))} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Perspective Transformation:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{img = cv2.imread('image.jpg', cv2.IMREAD\_COLOR) \newline pts1 = np.float32({[}{[}56,65{]},{[}368,52{]},{[}28,387{]},{[}389,390{]}{]}) \#Four points on original image \newline pts2 = np.float32({[}{[}0,0{]},{[}300,0{]},{[}0,300{]},{[}300,300{]}{]}) \#Four points on destination image \newline M = \seqsplit{cv2.getPerspectiveTransform(pts1},pts2) \#Perspective transformation matrix \newline dst = cv2.warpPerspective(img,M,(300,300)) \#Apply perspective transformation \newline cv2.imshow('image',dst) \newline cv2.waitKey(0) \newline cv2.destroyAllWindows()} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Feature Description:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\# extract numerical representation of detected feature in image. Important for object \newline \# recognition and image matching. Common methods: BRIEF, ORB, SIFT, SURF. \newline img = cv2.imread('image.jpg', 0) \# Read image in grayscale \newline fast = \seqsplit{cv2.FastFeatureDetector\_create()} \#FAST feature detection \newline brief = \seqsplit{cv2.xfeatures2d.BriefDescriptorExtractor\_create()} \#BRIEF descriptor \newline keypoints\_fast = fast.detect(img) \newline keypoints\_fast, descriptors\_fast = brief.compute(img, keypoints\_fast) \newline orb = cv2.ORB\_create() \#ORB feature detection and descriptor \newline keypoints\_orb, descriptors\_orb = orb.detectAndCompute(img, None) \newline sift = \seqsplit{cv2.xfeatures2d.SIFT\_create()} \#SIFT feature detection and descriptor \newline keypoints\_sift, descriptors\_sift = \seqsplit{sift.detectAndCompute(img}, None) \newline surf = \seqsplit{cv2.xfeatures2d.SURF\_create()} \#SURF feature detection and descriptor \newline keypoints\_surf, descriptors\_surf = \seqsplit{surf.detectAndCompute(img}, None)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Haar Cascade Classifiers (Object Detection):}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\# object detection using image patterns. Trains on features of positive and negative samples. \newline \# Identifies object in new images by matching pattern. Can detect faces, eyes, and other objects. \newline face\_cascade = \seqsplit{cv2.CascadeClassifier('haarcascade\_frontalface\_default.xml')} \#Load face cascade classifier \newline img = cv2.imread('image.jpg', cv2.IMREAD\_COLOR) \newline gray = cv2.cvtColor(img, cv2.COLOR\_BGR2GRAY) \#Convert to grayscale \newline faces = \seqsplit{face\_cascade.detectMultiScale(gray}, 1.3, 5) \#Detect faces \newline for (x,y,w,h) in faces: \newline cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) \#Draw rectangle around face} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Contour Detection:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{gray = cv2.cvtColor(img, cv2.COLOR\_BGR2GRAY) \#Convert to grayscale \newline ret, thresh = cv2.threshold(gray, 127, 255, cv2.THRESH\_BINARY) \#Threshold \newline contours, hierarchy = cv2.findContours(thresh, cv2.RETR\_TREE, \seqsplit{cv2.CHAIN\_APPROX\_SIMPLE)} \#Find contours \newline cv2.drawContours(img, contours, -1, (0,255,0), 3) \#Draw contours} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Loading and Saving Images:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{img = cv2.imread('image.jpg', cv2.IMREAD\_COLOR) \#Load image \newline cv2.imshow('image',img) \#Show image \newline cv2.imwrite('output.jpg',img) \#Save image \newline cv2.waitKey(0) \#Wait for a keyboard event \newline cv2.destroyAllWindows() \#Close all windows} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Image Properties:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{img = cv2.imread('image.jpg', cv2.IMREAD\_COLOR) \newline print('Image Shape:', img.shape) \#Prints (height, width, channels) \newline print('Image Size:', img.size) \#Prints the total number of pixels \newline print('Image Datatype:', img.dtype) \#Prints the datatype of the pixels} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Accessing a Camera/ Video Capture:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{cap = cv2.VideoCapture(0) \#Open default camera \newline while(True): \newline ret, frame = cap.read() \#Read frame from camera \newline cv2.imshow('frame',frame) \#Show frame \newline if cv2.waitKey(1) \& 0xFF == ord('q'): \#Quit when 'q' is pressed \newline break} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Accessing a Video File:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{cap = \seqsplit{cv2.VideoCapture('video.mp4')} \#Open video file \newline while(cap.isOpened()): \newline ret, frame = cap.read() \#Read frame from video \newline cv2.imshow('frame',frame) \#Show frame \newline if cv2.waitKey(25) \& 0xFF == ord('q'): \#Quit when 'q' is pressed \newline break} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Video Writer:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{cap = cv2.VideoCapture(0) \newline fourcc = \seqsplit{cv2.VideoWriter\_fourcc(*'XVID')} \#Codec \newline out = \seqsplit{cv2.VideoWriter('output.avi'},fourcc, 20.0, (640,480)) \#Create video writer \newline while(cap.isOpened()): \newline ret, frame = cap.read() \#Capture frame-by-frame \newline if ret==True: \newline out.write(frame) \#Write frame to output video \newline cv2.imshow('frame',frame) \#Display frame \newline if cv2.waitKey(1) \& 0xFF == ord('q'): \#Exit loop on 'q' key press \newline break \newline else: \newline break \newline cap.release() \#Release camera \newline out.release() \#Release video writer \newline cv2.destroyAllWindows()} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Colorspace Conversion:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{img = cv2.imread('image.jpg', cv2.IMREAD\_COLOR) \newline gray\_img = cv2.cvtColor(img, cv2.COLOR\_BGR2GRAY) \#Convert to grayscale \newline hsv\_img = cv2.cvtColor(img, cv2.COLOR\_BGR2HSV) \#Convert to HSV colorspace} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Blurring:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\# reduces image noise and sharpness by averaging pixel values in a neighborhood. \newline gaussian\_blur = cv2.GaussianBlur(img, (5, 5), 0) \newline median\_blur = cv2.medianBlur(img, 5) \newline bilateral\_filter = cv2.bilateralFilter(img, 9, 75, 75)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Image Filtering:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\# modifies pixel values to improve image quality. Common methods include 2D convolution, \newline \#blurring, and edge detection. \newline img = cv2.imread('image.jpg') \newline kernel = np.ones((5,5),np.float32)/25 \newline convolution = cv2.filter2D(img,-1,kernel) \#2D Convolution \newline blur = cv2.blur(img,(5,5)) \# Image Blurring (averaging) \newline gaussian\_blur = cv2.GaussianBlur(img, (5,5),0) \# Gaussian Blurring \newline median\_blur = cv2.medianBlur(img, 5) \# Median Blurring \newline bilateral\_filter = cv2.bilateralFilter(img, 9, 75, 75) \#Bilateral Filtering} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Edge Detection:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{img = cv2.imread('image.jpg', 0) \# Read image in grayscale \newline \# Canny edge detection \newline edges\_canny = cv2.Canny(img, 100, 200) \newline \# Sobel operator \newline edges\_sobel = cv2.Sobel(img, cv2.CV\_64F, 1, 0) + cv2.Sobel(img, cv2.CV\_64F, 0, 1) \newline \# Laplacian of Gaussian (LoG) \newline edges\_log = \seqsplit{cv2.Laplacian(cv2.GaussianBlur(img}, (3, 3), 0), cv2.CV\_64F) \newline cv2.imshow('Original', img) \newline cv2.imshow('Canny Edges', edges\_canny) \newline cv2.imshow('Sobel Edges', edges\_sobel) \newline cv2.imshow('LoG Edges', edges\_log) \newline cv2.waitKey(0) \newline cv2.destroyAllWindows()} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Morphological Operations:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{kernel = np.ones((5,5),np.uint8) \#5x5 kernel \newline erosion = cv2.erode(img,kernel,iterations = 1) \#Erosion \newline dilation = cv2.dilate(img,kernel,iterations = 1) \#Dilation \newline opening = cv2.morphologyEx(img, cv2.MORPH\_OPEN, kernel) \#Opening \newline closing = cv2.morphologyEx(img, cv2.MORPH\_CLOSE, kernel) \#Closing} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Histogram Equalization:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\# improves contrast by redistributing pixel values in an image. \newline \# It's useful for image preprocessing and analysis \newline eq\_img = cv2.equalizeHist(img) \#Apply histogram equalization} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Hough Transform:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\# detect simple shapes such as lines, circles, and ellipses in an image \newline img = cv2.imread('image.jpg', cv2.IMREAD\_GRAYSCALE) \newline edges = cv2.Canny(img,50,150,apertureSize = 3) \#Canny edge detection \newline lines = cv2.HoughLines(edges,1,np.pi/180,200) \#Hough transform \newline for rho,theta in lines{[}0{]}: \newline a = np.cos(theta) \newline b = np.sin(theta) \newline x0 = a{\emph{rho \newline y0 = b}}rho \newline x1 = int(x0 + 1000{\emph{(-b)) \newline y1 = int(y0 + 1000}}(a)) \newline x2 = int(x0 - 1000*(-b)) \newline y2 = int} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Thresholding:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\# Thresholding separates object from background by setting pixel values above or below a \newline \# threshold. It creates a binary image. Helps with object detection, segmentation, and feature \newline \# extraction. Methods: global, adaptive, and Otsu's. \newline img = cv2.imread('image.jpg', cv2.IMREAD\_GRAYSCALE) \newline ret,thresh1 = cv2.threshold(img,127,255,cv2.THRESH\_BINARY) \#Binary thresholding \newline ret,thresh2 = cv2.threshold(img,127,255,cv2.THRESH\_BINARY\_INV) \#Inverse binary thresholding \newline ret,thresh3 = cv2.threshold(img,127,255,cv2.THRESH\_TRUNC) \#Truncated thresholding \newline ret,thresh4 = cv2.threshold(img,127,255,cv2.THRESH\_TOZERO) \#Threshold to zero \newline ret,thresh5 = cv2.threshold(img,127,255,cv2.THRESH\_TOZERO\_INV) \#Inverse threshold to zero \newline adaptive\_thresh = \seqsplit{cv2.adaptiveThreshold(img},255,cv2.ADAPTIVE\_THRESH\_GAUSSIAN\_C,cv2.THRESH\_BINARY,11,2) \#Adaptive thresholding} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Image Pyramids:}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{img = cv2.imread('image.jpg', cv2.IMREAD\_COLOR) \newline lower\_reso = cv2.pyrDown(img) \#Reduce resolution \newline higher\_reso = cv2.pyrUp(img) \#Increase resolution} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \end{document}