Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Tomato Maturity Grading System / Machine Learning - Python / Deep Learning comment on each lines of the code so that i can understand which

Tomato Maturity Grading System / Machine Learning - Python / Deep Learning

comment on each lines of the code so that i can understand which lines mean what

import cv2 import numpy as np #to mask an image

#img = cv2.imread('test.png') #img = cv2.imread('tmt.jpeg') img = cv2.imread('tmt2.jpg') #to load an image

img = np.array(img, dtype=np.uint8) #numpy arrays, convert(16-bit unit) dtypes and properly rescale image intensities

gs = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) red_lower_hsv = np.array([0,0,0]) #hue, saturation, value red_upper_hsv = np.array([10,255,255]) #parameters hsv=cv2.cvtColor(img, cv2.COLOR_BGR2HSV)

#Masking initial_mask = cv2.inRange(hsv, red_lower_hsv, red_upper_hsv)

kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(45,45)) closing = cv2.morphologyEx(initial_mask, cv2.MORPH_CLOSE, kernel)

kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(40,40)) erosion = cv2.erode(closing,kernel,iterations = 2) dilation = cv2.dilate(erosion,kernel,iterations = 2)

kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(10,10)) opening = cv2.morphologyEx(dilation, cv2.MORPH_OPEN, kernel)

mask = opening

initial_segment = cv2.bitwise_and(img, img, mask=initial_mask)

segment = cv2.bitwise_and(img, img, mask=mask)

#Show Image List show_imagename = ['Original Image', 'GrayScale', 'Initial mask', 'Erosion', 'Dilation', 'Closing', 'Opening', 'Final mask', 'hsv', 'Initial_segment', 'Segment' ] show_image = [img, gs, initial_mask, erosion, dilation, closing, opening, mask, hsv, initial_segment, segment ]

n_showimg = len(show_image)

resize = True rwidth = 450 rheight = 500 #Image Showing Sequencing for k in range (0,n_showimg): if resize == True: cv2.namedWindow(show_imagename[k],cv2.WINDOW_NORMAL) cv2.resizeWindow(show_imagename[k],rwidth,rheight) cv2.imshow(show_imagename[k],show_image[k])

# SHOWING IMAGE ALGORITHMS ---------------------------------------------------------------------- END

cv2.waitKey(0) cv2.destroyAllWindows()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions

Question

What is dividend payout ratio ?

Answered: 1 week ago

Question

Explain the factors affecting dividend policy in detail.

Answered: 1 week ago

Question

4. Does cultural aptitude impact ones emotional intelligence?

Answered: 1 week ago

Question

7. Do the organizations social activities reflect diversity?

Answered: 1 week ago