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 crop and save segmented images #442

Open
ki580 opened this issue Jun 16, 2023 · 5 comments
Open

How to crop and save segmented images #442

ki580 opened this issue Jun 16, 2023 · 5 comments

Comments

@ki580
Copy link

ki580 commented Jun 16, 2023

Hi, I am trying to get semantic segmentation working in practice and would like to cut out a color coded segmented area and save it individually.
How can I do this after getting the masks information

@cajdotxa71262
Copy link

that is what I want to ask

@Bruce337f
Copy link

me too,that is what I want to ask!

@ki580
Copy link
Author

ki580 commented Jun 21, 2023

I can save crop image this code

output_directory = 'your output file'

for i in range(len(mask)):
x, y, width, height = mask[i]['bbox']
cropped_image = image[int(y):int(y+height), int(x):int(x+width)]
filename = os.path.join(output_directory, str(i) + '.png')
cv2.imwrite(filename, cropped_image)

@skycitywing
Copy link

我可以保存裁剪图像此代码

output_directory =“您的输出文件”

对于 i in range(len(mask)): x, y, width, height = mask[i]['bbox'] cropped_image = image[int(y):int(y+height), int(x):int(x+width)] 文件名 = os.path.join(output_directory, str(i) + '.png') cv2.imwrite(文件名, cropped_image)

I hope someone can provide an example on colab.
After getting the mask file and the original image, but don't know how to use the information about the mask boundaries for cropping.

@Github-Yilei
Copy link

this might be useful: #221

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