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

How to generate and save color image result #13

Open
wwjd1234 opened this issue Apr 12, 2020 · 2 comments
Open

How to generate and save color image result #13

wwjd1234 opened this issue Apr 12, 2020 · 2 comments

Comments

@wwjd1234
Copy link

The README does not include code example of how to generate and save the color result with the superpixles overlayed on the fish image. How can this be done?

@oconnor127
Copy link

to show the image with the overlayed regions, try something like:

from skimage.segmentation import mark_boundaries from PIL import Image import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(1, 1, 1) ax.set_title("Superpixels -- %d segments" % (160)) ax.imshow(mark_boundaries(image, assignment)) plt.axis("off") plt.show()

You can save it right there via the opened window

@ramchandracheke
Copy link

Hi,

Thanks for this superfast library. Its really fast. I have implemented it and I am trying to save this image. Therefore, I have converted image into RGB space using color.label2rgb. However, its very slow. Can you please guide how to save this super pixel image. Thanks in advance!

Kind regards,
Ram

import time
start_time = time.time()
with Image.open("C:\Users\003.bmp") as f:
image = np.array(f)
print("--- %s Time to read image ---" % (time.time() - start_time))

slic = SlicAvx2(num_components=500, compactness=10)
assignment = slic.iterate(image) # Cluster Map
print("--- %s Time to SuperPixel ---" % (time.time() - start_time))

Save Image

sample123 =color.label2rgb(assignment, image, kind='avg',bg_label = -1)
print("--- %s Time to Convert ---" % (time.time() - start_time))

io.imsave('test_16bit.png', sample123)
print("--- %s Time to Save Image ---" % (time.time() - start_time))

0.029166 | Time | to | read image |
0.141835 | Time | to | SuperPixel |
5.759102 | Time | to | Convert |  
6.418611 | Time | to | Save Image |

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

3 participants