フィルターのクリア

extract multiple images from white background individually

4 ビュー (過去 30 日間)
Fateme Jalali
Fateme Jalali 2016 年 7 月 29 日
編集済み: Image Analyst 2016 年 7 月 29 日
Hello,I want to extract images from white background. In order to analyze each image individually, I should have matrix of each image. My code works well when there is just one image on the white background. Can any one help me to extract more than 1 image from white background? This image is an example:
and my codes are:
rgbImage=imread('D:/2ta.jpg');
grayImage = min(rgbImage, [], 3);
binaryImage = grayImage < 200;
figure(1)
imshow(binaryImage)
%binaryImage1 = bwareafilt2(binaryImage,[10 50],1,1);
binaryImage1=(binaryImage==1)
figure(2)
imshow(binaryImage1)
[rows, columns] = find(binaryImage);
row1 = min(rows);
row2 = max(rows);
col1 = min(columns);
col2 = max(columns);
% Crop
croppedImage = rgbImage(row1:row2, col1:col2, :);
figure(3)
imshow(croppedImage)

採用された回答

Image Analyst
Image Analyst 2016 年 7 月 29 日
編集済み: Image Analyst 2016 年 7 月 29 日
You need to label your binary image and then get the bounding box of all blobs in it, then crop them out using the bounding box and the imcrop() function.
[labeledImage, numBlobs] = bwlabel(binaryImage);
props = regionprops(labeledImage, 'BoundingBox');
for k = 1 : numBlobs
thisBB = props(k).BoundingBox;
thisImage{k} = imcrop(rgbImage, thisBB);
imshow(thisImage{k});
drawnow;
imwrite(...... % If you want to save the cropped image to disk.
end
  1 件のコメント
Fateme Jalali
Fateme Jalali 2016 年 7 月 29 日
Thank you so much.This code is exactly what I need.

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

その他の回答 (1 件)

Selva Karna
Selva Karna 2016 年 7 月 29 日
you can use color based image segmentation process...........
  1 件のコメント
Fateme Jalali
Fateme Jalali 2016 年 7 月 29 日
thanks.would you plz explain more?

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

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by