How can I select the gray patches
4 ビュー (過去 30 日間)
古いコメントを表示
I have this picture and I tried to wrote a code to select these 12 grey patches. The problem I am facing is that some patches are not detected properly. How can I correctly select these 12 ROI.
Fig 1: Input Image Fig 2: It miss the 2 ROIs and have false detection.
CropImg=imread('patchc.jpg');
img=rgb2gray(CropImg);
rangefiltv= rangefilt(img);
imshow(rangefiltv)
mask = rangefiltv >10;
mask=~mask;
mask = bwareafilt(mask, 12);
stat = regionprops(mask,'boundingbox');
imshow(CropImg); hold on;
for cnt = 1 : numel(stat)
bb = stat(cnt).BoundingBox;
rectangle('position',bb,'edgecolor','r','linewidth',2);
end
*Update
The Cropped image is from this image. The size of the picture may varry.
0 件のコメント
回答 (1 件)
Image Analyst
2020 年 11 月 8 日
This looks like a computer graphics image where the gray patches will be in exactly the same location for any similar image, so you can just hard code in the coordinates of the corners. If that's not true, then post an actual image, not a perfect computer graphics one, so we can write segmentation code for it. Something like
mask = grayImage ~= backgroundGrayLevel;
3 件のコメント
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!