SLIC 图像标记

问题描述

我是 Python 新手。我正在尝试开发一个 GUI 来使用 tknter 标记分类图像。如图所示,我需要将普通图像转换为 SLIC 超像素图像。获得 SLIC 图像后,我应该能够选择该图像的各个片段并相应地标记。我只有两节课。 目前我从 path 加载图像,然后将它们转换为 SLIC 图像。然后单击任意点以捕获该特定点上的 RGB 值和 X、Y 坐标以进行标记。这是我正在使用的代码

def _load_image(path):
        """
        Loads and resizes an image from a given path using the Pillow library
        :param path: Path to image
        :return: Resized or original image 
        """
        #head,tail = os.path.split(path)
        #tail.replace('.jpg','.txt')
        def click_event(event,x,y,flags,params):
            if event == cv2.EVENT_LBUTTONDOWN or event==cv2.EVENT_RBUTTONDOWN:
                file = open('resultee.txt','a+')
                file.write("Root at Co-Ordinates ({},{}) with RGB {} in file {}\n".format(x,image[x][y],path))
                file.close()
                    
        image = cv2.imread(path)
        segments = slic(img_as_float(image),n_segments = 100,compactness=30,sigma = 1)
        pimg=mark_boundaries(img_as_float(cv2.cvtColor(image,cv2.COLOR_BGR2RGB)),segments)
        cv2.imshow('image',pimg)
        cv2.setMouseCallback('image',click_event)
        cv2.waitKey()
        cv2.destroyAllWindows()
        return pimg

SLIC image

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)