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

Question #9

Closed
Johncheng1 opened this issue Jan 2, 2019 · 4 comments
Closed

Question #9

Johncheng1 opened this issue Jan 2, 2019 · 4 comments

Comments

@Johncheng1
Copy link

How to show segmentation result(different colours) on Original image like in your Readme?I tried findcontours, but it not work,thank you!

@Issam28
Copy link
Owner

Issam28 commented Jan 6, 2019

you can use the following function :

import numpy as np
from skimage import color, img_as_float
from skimage.exposure import adjust_gamma

def show_segmented_image(orig_img, pred_img):
    '''
    Show the prediction over the original image
    INPUT:
        1)orig_img: the test image, which was used as input
        2)pred_img: the prediction output
    OUTPUT:
        segmented image rendering
    '''
    orig_img/=np.max(orig_img)
    #img_mask = np.pad(pred_img, (16,16), mode='edge')
    ones = np.argwhere(pred_img == 1)
    twos = np.argwhere(pred_img == 2)
    threes = np.argwhere(pred_img == 3)
    fours = np.argwhere(pred_img == 4)
    gray_img = img_as_float(orig_img)

    image = adjust_gamma(color.gray2rgb(gray_img), 1)
    sliced_image = image.copy()
    red_multiplier = [1, 0.2, 0.2]
    yellow_multiplier = [1,1,0.25]
    green_multiplier = [0.35,0.75,0.25]
    blue_multiplier = [0,0.25,0.9]

        # change colors of segmented classes
    for i in range(len(ones)):
        sliced_image[ones[i][0]][ones[i][1]] = red_multiplier
    for i in range(len(twos)):
        sliced_image[twos[i][0]][twos[i][1]] = green_multiplier
    for i in range(len(threes)):
        sliced_image[threes[i][0]][threes[i][1]] = blue_multiplier
    for i in range(len(fours)):
        sliced_image[fours[i][0]][fours[i][1]] = yellow_multiplier

    return sliced_image

@shaktichetan
Copy link

What should i pass for predicted images

@JiangZongKang
Copy link

How to show segmentation result(different colours) on Original image like in your Readme?I tried findcontours, but it not work,thank you!

hello,I use Issam28‘ above code, but can not show segmentation result(different colours) on Original image, please you work it?
thank you.

@akashshingha850
Copy link

@Issam28 if you kindly demonstrate how to generate those image from the trained model, that would be really helpful. Most of the people are facing such problem. In your read.me file, you only explain how to run the codes but for some reason, most of the people fail to understand how to generate such a colorful image. @Johncheng1 if you understand properly, please demonstrate it. Thank you.

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

5 participants