extract multiple images from white background individually
Show older comments
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)
Accepted Answer
More Answers (1)
Selva Karna
on 29 Jul 2016
0 votes
you can use color based image segmentation process...........
1 Comment
Fateme Jalali
on 29 Jul 2016
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!