How can I select the gray patches

조회 수: 4 (최근 30일)
Masood Salik
Masood Salik 2020년 11월 8일
댓글: Masood Salik 2020년 11월 8일
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.

답변 (1개)

Image Analyst
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
Masood Salik
Masood Salik 2020년 11월 8일
One of the patch colour is same as bacground, so if I use
mask = grayImage ~= backgroundGrayLevel;
Then that particular patch get removed. I think hard code coorinates method can work, but I don't know how to do that with varing image size.
Masood Salik
Masood Salik 2020년 11월 8일
I have seen some MATLAB GUI that do such type of work that I wanted to do. How can I achive this ?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by