Create image from an Image

2 ビュー (過去 30 日間)
sasad games
sasad games 2019 年 10 月 16 日
コメント済み: sasad games 2019 年 10 月 16 日
Hi, I got this image using segmentation with CNN. Is there a way I can obtain multiple images "cutting" everytime image is black? I need the blue part but separately. Thanks very much
sample

採用された回答

Image Analyst
Image Analyst 2019 年 10 月 16 日
Sum the image horizontally. Untested code:
verticalProfile = sum(rgbImage(:,:,3), 2); % Collapse across columns.
% Then find out where it's not black
nonBlackRows = verticalProfile ~= 0;
% Now find the starting and stopping points
props = regionprops(nonBlackRows, 'PixelIdxList');
% Now crop
for k = 1 : length(props)
row1 = props(k).PixelIdxList(1);
row2 = props(k).PixelIdxList(end);
imageList{k} = rgbImage(row1:row2, :, :);
end
Each image is in a cell of the cell array. They might all have different sizes.
  1 件のコメント
sasad games
sasad games 2019 年 10 月 16 日
Thanks a lot! It works

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by