Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function unknow #46

Open
vangjin opened this issue Dec 7, 2022 · 2 comments
Open

function unknow #46

vangjin opened this issue Dec 7, 2022 · 2 comments

Comments

@vangjin
Copy link

vangjin commented Dec 7, 2022

    Hi,

thanks for your interest!

You can refer to the code below for visual analysis.

def plot_seg_result(img, mask, type=None, size=500, alpha=0.5, anns='mask'):
    assert type in ['red', 'blue', 'yellow']
    if type == 'red':
        color = (255, 50, 50)     # red  (255, 50, 50) (255, 90, 90) (252, 60, 60)
    elif type == 'blue':
        color = (90, 90, 218)   # blue (102, 140, 255) (90, 90, 218) (90, 154, 218)
    elif type == 'yellow':
        color = (255, 218, 90)  # yellow
    color_scribble = (255, 218, 90) # (255, 218, 90) (0, 0, 255)

    img_pre = img.copy()

    if anns == 'mask':
        for c in range(3):
            img_pre[:, :, c] = np.where(mask[:,:,0] == 1,
                                        img[:, :, c] * (1 - alpha) + alpha * color[c],
                                        img[:, :, c])            
    elif anns == 'scribble':
        mask[mask==255]=0
        mask = mask[:,:,0]
        dilated_size = 5
        Scribble_Expert = ScribblesRobot()
        scribble_mask = Scribble_Expert.generate_scribbles(mask)
        scribble_mask = ndimage.maximum_filter(scribble_mask, size=dilated_size) # 
        for c in range(3):
            img_pre[:, :, c] = np.where(scribble_mask == 1,
                                        color_scribble[c],
                                        img[:, :, c])                    
    elif anns == 'bbox':
        mask[mask==255]=0
        mask = mask[:,:,0]        
        bboxs = find_bbox(mask)
        for j in bboxs: 
            cv2.rectangle(img_pre, (j[0], j[1]), (j[0] + j[2], j[1] + j[3]), (255, 0, 0), 4) # -1->fill; 2->draw_rec

    img_pre = cv2.cvtColor(img_pre, cv2.COLOR_RGB2BGR)  
    
    if size is not None:
        img_pre = cv2.resize(img_pre, dsize=(size, size), interpolation=cv2.INTER_LINEAR)

    return img_pre

Originally posted by @chunbolang in #13 (comment)

@vangjin
Copy link
Author

vangjin commented Dec 7, 2022

i wanna know where is the definition of function ScribblesRobot() when anns mode is 'scribble'

@chunbolang
Copy link
Owner

Sorry for the late reply.

This function is not provided as it is not very relevant to our work, and you can refer to this link for the function ScribblesRobot().

Best,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants