how to save the segmented region as a separate image?
2 ビュー (過去 30 日間)
古いコメントを表示
I have used the code which I have found in online and divided an image into several segments. I want to extract green parts from the image and store them. I am able to display the segmented image separately with black mask. but I want to display and save the green small segmented region only as a separate image (like 9 separate .jpg images ) without black regions.
This is the code I have found in online
segmented_images = cell(1,3);
rgb_label = repmat(pixel_labels,[1 1 3]);
for k = 1:nColors
color = img;
color(rgb_label ~= k) = 0;
segmented_images{k} = color;
end
Thank you in advance.
2 件のコメント
採用された回答
Image Analyst
2017 年 11 月 5 日
First get the outline, then the bounding box and use imcrop(). Then use imwrite(). Let me know if you can't figure it out.
7 件のコメント
Image Analyst
2022 年 1 月 31 日
You should click on the "Show older comments" link. Then you'd see
props = regionprops(mask, 'BoundingBox');
croppedImage = imcrop(rgbImage, props.BoundingBox);
save(croppedImage, filename);
If you need more help with your image, post a new question after reading this:
その他の回答 (1 件)
r r
2018 年 8 月 4 日
I have a gray set of 20 images I want to convert gray to color and every time I work on the conversion colors vary I want to install the color for all images for example, The area in red color is still red in image1 but change blue in image 2 The problem: the changed the color with repeated 20 images
1 件のコメント
Image Analyst
2018 年 8 月 4 日
I have no idea what you're asking. Please try to rephrase, and attach some screenshots, in a new question (not back here). Basically I think you want to use ind2rgb() and somehow want to change the colormap with each image, though I'm not sure how you're going to decide how to change the colormap each time.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!