logo

Crowdly

Browser

Add to Chrome

import cv2 class Image:     def __init__(self):         self.image = None ...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

import cv2

class Image:

    def __init__(self):

        self.image = None

    def read(self, path, flag):

        self.image = cv2.imread(path, flag)

    def show(self, caption = 'Image'):

        cv2.imshow(caption, self.image)

    def write(self, path = = 'image_threshold.png'):

        cv2.imwrite(path, self.image)

    def threshold(self, thresh, max_value, thresh_const):

        th, dst = cv2.threshold(self.image, thresh, max_value, thresh_const)

        self.image = dst

    def __del__(self):

        cv2.waitKey(0)

        cv2.destroyAllWindows()

def main():

    src = Image()

    src.read('image.png', cv2.IMREAD_GRAYSCALE)

    src.show('Origin image')

    src.threshold(0, 255, cv2.THRESH_BINARY)

    ...

    src.show('Threshold image')

    del src

if __name__ == '__main__':

    main()

Для наведеного вище коду вкажіть рядок, який треба вставити на місці ..., щоб комп’ютерна програма мовою Python за допомогою бібліотеки OpenCV реалізовувала до файлу з іменем “image.png” з поточної папки застосування бінарного порогового перетворення при thresh_value = 0 та max_value = 255 та зберігала результат у файлі з іменем “image_threshold.jpg” у поточній папці:

0%
100%
0%
0%
0%
0%
More questions like this

Want instant access to all verified answers on exam.nuwm.edu.ua?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome