Question: The following piece of code is given for recognizing hand - written digits. You are required to fill in the box which includes ?

The following piece of code is given for recognizing hand-written digits. You are required to
fill in the box which includes "?" as given below so that you find moments based on the set of
input images. Then, the moments will be classified thanks to the piece of code which follows
the box.
and i dont want you to cheng any thing in the given Q you can cheng in this cod that i well send and Merge codes solve it wath this methoed
1. Moments
Image moments help you to calculate some features like center of mass of the object, area of the object etc. Check out the wikipedia page on Image Moments
The function cv.moments() gives a dictionary of all moment values calculated. See below:
import numpy as np
import cv2 as cv
img = cv.imread('star.jpg', cv.IMREAD_GRAYSCALE)
assert img is not None, "file could not be read, check with os.path.exists()"
ret,thresh = cv.threshold(img,127,255,0)
im2,contours,hierarchy = cv.findContours(thresh,1,2)
cnt = contours[0]
M = cv.moments(cnt)
print( M )
From this moments, you can extract useful data like area, centroid etc. Centroid is given by the relations, Cx=M10M00 and Cy=M01M00. This can be done as follows:
cx = int(M['m10']/M['m00'])
cy = int(M['m01']/M['m00'])
The following piece of code is given for

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!