how can i remove white spaces around this image ?
2 ビュー (過去 30 日間)
古いコメントを表示
採用された回答
Gopichandh Danala
2017 年 6 月 26 日
img = imread('whiteBG.jpg');
img = rgb2gray(img);
figure, imshow(img)
% count the pixels of each bin
[counts, bins] = imhist(img);
[M, I] = max(counts);
tempImg = img;
% we know that max pixels in image are white so change all pxiels in that
% bin and above to zero
tempImg(img >= bins(I)-1) = 0;
figure, imshow(tempImg)
% clear some traces or blobs having area less than 30 pixels ...
% (can change according to requirement)
BW = bwareaopen(tempImg,30);
figure, imshow(BW)
5 件のコメント
その他の回答 (1 件)
Image Analyst
2017 年 6 月 27 日
It looks reasonably well cropped right now. Why do you need to chop off a few pixels more? What's the need? I think you can do what you need to do without cropping to the bounding box, so why bother?
5 件のコメント
Image Analyst
2017 年 6 月 27 日
I already told you what to do next if that didn't work: "If that doesn't work you can......". See my above comment.
参考
カテゴリ
Help Center および File Exchange で Image Segmentation and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!